GPUWorker¶
GPUWorker
¶
The one place nnsight gets into a vLLM worker process.
vLLM's worker builds its model runner in init_device; once it has, the
runner's class is swapped for nnsight's subclass, which adds behaviour and no
constructor state. _load names this class as vLLM's worker_cls, a supported
engine argument, so no part of vLLM's own startup is patched — and a runner
nnsight does not instrument is refused here, in the worker, rather than coming up
silently uninstrumented.
NNsightGPUWorker
¶
Bases: Worker
A vLLM GPU worker whose model runner interleaves interventions.
collect_nnsight
¶
collect_nnsight(request_ids: list[str], finished_request_ids: Optional[list[str]] = None, outputs: Optional[Any] = None) -> Optional[bytes]
Return this worker's saved values, as collective_rpc reaches it here.
outputs arrives pickled (see NNsightLLMEngine.step): the RPC is
msgpack-encoded on the way in, and bytes are what it carries natively.
nnsight_request_count
¶
How many requests this worker's runner still tracks, via collective_rpc.
nnsight_register
¶
Install a block this worker runs for every request (collective_rpc).
name is what requests may address it by (edits=[...]).
nnsight_clear_registered
¶
Remove a registration from this worker (collective_rpc).