vllm.v1.worker.gpu.pp_utils
¶
Pipeline Parallelism utils for V2 Model Runner.
Classes:
-
PPHandler–Runs the PP sampled-token broadcast/recv on a side stream so the
-
PendingRecv–Per-step slot data for a deferred postprocess on the main stream.
Functions:
-
compute_need_sampled_mask–Return a bool array of shape
[input_batch.num_reqs]marking requests
PPHandler
¶
Runs the PP sampled-token broadcast/recv on a side stream so the
default stream isn't gated by the matching peer call. Step T's recv is
consumed at step T+pp_size via get_prev_sampled_outputs.
Uses a dedicated NCCL communicator (sibling of the PP device_group)
for the broadcast so it does not serialize on the wire with the
inter-stage hidden-state p2p send/recv ops.
Methods:
-
add_positions_buffer–Add the relayed positions to the persistent intermediate tensors,
-
add_upstream_aux_hidden_states–Turn the last stage's model output, which carries only the aux hidden
-
broadcast_drafts–Broadcast draft proposals so non-last ranks can embed real token ids.
-
get_prev_sampled_outputs–Consume the entry from pp_size steps ago and wait for its recv event,
-
receive–Returns True iff sampled tokens need to be gathered from all
-
receive_positions–Overwrite the locally prepared positions with the first stage's.
-
relay_aux_hidden_states–Forward earlier stages' aux hidden states next to this stage's.
-
send_positions–Add this step's positions to the tensors sent to the next stage.
add_positions_buffer(intermediate_tensors, max_num_tokens, num_dims)
¶
Add the relayed positions to the persistent intermediate tensors, which every PP transport checks received tensors against.
add_upstream_aux_hidden_states(intermediate_tensors, model_output)
¶
Turn the last stage's model output, which carries only the aux hidden states this stage took, into the full list the speculator reads. Call it once per forward.
broadcast_drafts(draft_tokens)
¶
Broadcast draft proposals so non-last ranks can embed real token ids.
get_prev_sampled_outputs()
¶
Consume the entry from pp_size steps ago and wait for its recv event,
then filter out entries whose request was freed since receive.
receive(input_batch, recv_drafts)
¶
Returns True iff sampled tokens need to be gathered from all
requests in the batch. recv_drafts must match whether the last rank
calls broadcast_drafts for this step.
receive_positions(intermediate_tensors, positions, num_tokens)
¶
Overwrite the locally prepared positions with the first stage's.
relay_aux_hidden_states(intermediate_tensors, output_intermediate_tensors)
¶
Forward earlier stages' aux hidden states next to this stage's.
send_positions(output_intermediate_tensors, positions)
¶
Add this step's positions to the tensors sent to the next stage.
PendingRecv
dataclass
¶
Per-step slot data for a deferred postprocess on the main stream.
compute_need_sampled_mask(input_batch)
¶
Return a bool array of shape [input_batch.num_reqs] marking requests
with outputs that might be needed in a subsequent (decode) step.
Returns None if no sampled outputs are needed in the requests' next step.