vllm.v1.worker.gpu.dp_utils
¶
Classes:
-
DPSyncState–What a
dispatch_cg_and_sync_dpcall agreed across DP ranks.
Functions:
-
dispatch_cg_and_sync_dp–Pick a cudagraph descriptor for this batch, agreeing it across DP ranks.
-
sync_cudagraph_and_dp_padding–Coordinates the batch descriptor and DP padding across all ranks.
DPSyncState
dataclass
¶
What a dispatch_cg_and_sync_dp call agreed across DP ranks.
Every field is identical on every rank, so callers can branch on them without disagreeing about whether to run a collective. Never add a per-rank value here.
dispatch_cg_and_sync_dp(cudagraph_manager, num_reqs, num_tokens, uniform_token_count, dp_size, dp_rank, max_query_len=None, need_eager=False, num_active_loras=0, parallel_config=None, allow_ubatching=False, uniform_decode=False, allow_skip_drafts=False, dp_sync_state=None)
¶
Pick a cudagraph descriptor for this batch, agreeing it across DP ranks.
Runs a collective when dp_size > 1 so every rank dispatches to the same
shape. Pass dp_sync_state from a dispatch already made over this same batch (a
drafter's prefill runs the target's batch shape) to reuse that agreement
instead, with no collective.
Parameters:
-
(cudagraph_manager¶CudaGraphManager | None) –Manager to dispatch against. May be None only when
need_eageris True (profile run). -
(num_reqs¶int) –Requests in this rank's batch.
-
(num_tokens¶int) –Tokens in this rank's batch, already padded by the caller.
-
(uniform_token_count¶int | None) –Per-request token count if this rank's batch is a uniform decode, else None.
dp_sync_state.uniform_token_counttakes its place when a sync is reused, since that one is agreed across ranks. -
(dp_size¶int) –Data-parallel world size. 1 skips all cross-rank work.
-
(dp_rank¶int) –This rank's index in the DP group.
-
(max_query_len¶int | None, default:None) –Upper bound on per-request query length, for selecting varlen decode graphs. None, as for a batch that is not decode-graph eligible, keeps the batch out of graphs that constrain it. Reusing a sync replaces this with
dp_sync_state.max_query_len, including when it is None. -
(need_eager¶bool, default:False) –Force
CUDAGraphMode.NONEinstead of dispatching. -
(num_active_loras¶int, default:0) –Active LoRA count for this rank. Does not need cross-rank agreement; it never changes a bucket's token count.
-
(parallel_config¶ParallelConfig | None, default:None) –Only needed for FT coordination and to decide whether to microbatch, so callers that do neither can leave it out.
-
(allow_ubatching¶bool, default:False) –Whether this rank's batch may be split into microbatches. Agreed across ranks before it takes effect.
-
(uniform_decode¶bool, default:False) –Whether this rank's batch is a uniform decode, used to pick the microbatching split.
-
(allow_skip_drafts¶bool, default:False) –Whether this rank allows skipping drafts, because none of its requests can use this step's drafts. Agreed across ranks (all must allow it) into
DPSyncState.skip_drafts. -
(dp_sync_state¶DPSyncState | None, default:None) –Agreement from a prior dispatch over this same batch, to reuse. Must come from a batch with this same padded
num_tokensand the sameuniform_token_count;num_reqsmay differ, as neither depends on it. Passing a sync from a different batch is a caller error and trips an assert.
Returns:
-
BatchExecutionDescriptor–(batch_desc, sync), where
syncis this batch's agreement for a later -
DPSyncState | None–dispatch to reuse. It is None when
dp_sizeis 1 or no rank has work.
sync_cudagraph_and_dp_padding(cudagraph_manager, desired_batch_desc, num_tokens, num_reqs, uniform_token_count, dp_size, dp_rank, max_query_len=None, num_active_loras=0, parallel_config=None, allow_ubatching=False, uniform_decode=False, allow_skip_drafts=False)
¶
Coordinates the batch descriptor and DP padding across all ranks.
Returns (synced_batch_desc, sync). sync is None when no rank has work.