MCPcopy Create free account
hub / github.com/Sphere-AI-Lab/FormalMATH-Bench / init_worker

Function init_worker

generate_answers.py:14–27  ·  view source on GitHub ↗

Initialize worker process, set GPU environment, and initialize the model

(model_path, gpu_id)

Source from the content-addressed store, hash-verified

12from pathlib import Path
13import jsonlines
14def init_worker(model_path, gpu_id):
15 """Initialize worker process, set GPU environment, and initialize the model"""
16 os.environ["CUDA_VISIBLE_DEVICES"] = str(gpu_id)
17 print(f"Process {os.getpid()} using GPU {gpu_id}")
18
19 global model
20 model = LLM(
21 model=model_path,
22 max_num_batched_tokens=8192,
23 max_model_len=8192,
24 seed=1,
25 trust_remote_code=True,
26 tensor_parallel_size=1
27 )
28
29def process_single_item(item, sampling_params, num_batches):
30 """Process a single data item"""

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected