(
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,
)
| 175 | |
| 176 | @error_propogation_decorator |
| 177 | def 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 | |
| 230 | def start_fanout_worker( |
nothing calls this directly
no test coverage detected