MCPcopy Create free account
hub / github.com/ScalingIntelligence/tokasaurus / start_basic_model_worker

Function start_basic_model_worker

tokasaurus/model/basic_worker.py:177–227  ·  view source on GitHub ↗
(
    config: ServerConfig,
    input_q: mp.Queue,
    q_model_to_manager: mp.Queue,
    dp_rank: int,
    tp_rank: int,
    master_port: int,
    process_name: str,
    barrier: TimedBarrier,
)

Source from the content-addressed store, hash-verified

175
176@error_propogation_decorator
177def start_basic_model_worker(
178 config: ServerConfig,
179 input_q: mp.Queue,
180 q_model_to_manager: mp.Queue,
181 dp_rank: int,
182 tp_rank: int,
183 master_port: int,
184 process_name: str,
185 barrier: TimedBarrier,
186):
187 setup_logging(config)
188
189 device_mesh, device = setup_distributed(
190 config,
191 dp_rank=dp_rank,
192 pp_rank=0,
193 tp_rank=tp_rank,
194 master_port=master_port,
195 )
196 dtype = get_dtype(config.dtype)
197
198 batch_index_to_last_token = torch.zeros(
199 config.max_batch_index(), dtype=torch.long, device=device
200 )
201
202 state = BasicWorkerState(
203 config=config,
204 batch_index_to_last_token=batch_index_to_last_token,
205 input_q=input_q,
206 q_model_to_manager=q_model_to_manager,
207 device=device,
208 dtype=dtype,
209 process_name=process_name,
210 tp_rank=tp_rank,
211 barrier=barrier,
212 )
213
214 state.logger.info("Model worker started!")
215 state.logger.info(f"Creating model on device {device} with dtype {dtype}")
216
217 model = make_model(
218 config,
219 device,
220 dtype,
221 tp_rank=tp_rank,
222 tp_group=device_mesh["tp"].get_group() if device_mesh is not None else None,
223 )
224
225 state.logger.info("Created model")
226
227 basic_model_loop(state, model)
228
229
230def start_fanout_worker(

Callers

nothing calls this directly

Calls 7

setup_loggingFunction · 0.90
setup_distributedFunction · 0.90
get_dtypeFunction · 0.90
BasicWorkerStateClass · 0.90
make_modelFunction · 0.90
basic_model_loopFunction · 0.85
max_batch_indexMethod · 0.80

Tested by

no test coverage detected