Repository navigation
Multiprocessing and Queues
Sudhanshu edited this page Nov 11, 2026
·
1 revision
-
mp.get_context("spawn")creates a compatible worker process per device on Windows and CUDA. - A bounded
task_queuereceives length-ranked minibatches; a producer thread prevents the parent from blocking during initialization. - Workers all own the same
result_queueand emitready,batch,finished, orerrormessages. -
load_lockserializes model initialization to avoid simultaneous downloads/loading peaks. -
go_eventcoordinates the processing start after every worker has reported readiness. -
receive()times out, detects process death, and propagates worker tracebacks. - Parent stores an
answersdictionary keyed by original row index, detects duplicate indices, and writes output in order.
This is a local multiprocessing process pool, not inter-machine distributed inference. The producer's tasks and the result queue are process-local IPC mechanisms, not Kafka/RabbitMQ.
Parallel LLM Inference
- Home
- Getting Started
- Architecture
- Implementation
- Operations