Skip to content

vllm.benchmarks.forward.batch

Build a SchedulerOutput for an exact batch, without the scheduler.

Classes:

Functions:

  • build_batch –

    Allocate disjoint blocks and build NewRequestData for every request.

  • kv_block_size –

    Tokens per block as the scheduler counts them: DCP spreads each

BenchBatch dataclass

Methods:

  • finish –

    A step that only removes this batch's requests.

finish()

A step that only removes this batch's requests.

_num_blocks(group, computed, kv_len, dcp_size)

Return (leading null blocks, live blocks) for one request.

build_batch(case, kv_cache_groups, num_kv_blocks, vocab_size, rng, dcp_size=1, lookahead=0, sampling_params=None)

Allocate disjoint blocks and build NewRequestData for every request.

Groups share one block pool, so block IDs are unique across groups. Block 0 is the null block. Lookahead reserves space for the drafter's KV writes. Every request uses sampling_params (default: SamplingParams()).

With prefix P = K - Q (KV length K, query length Q):

Kind prompt tokens num_computed_tokens spec tokens
Prefill K P -
Decode P P -
Verify (D drafts) P P D

Unless chunked, a prefill's prefix is a prefix hit, which replays its last R = min(window, P) tokens on models with SWA bounded replay (window 0 otherwise), like the scheduler: it schedules R + Q tokens from replay_start = num_computed_tokens = P - R.

kv_block_size(spec, dcp_size)

Tokens per block as the scheduler counts them: DCP spreads each block's tokens over the DCP ranks.