vllm.benchmarks.forward.batch
¶
Build a SchedulerOutput for an exact batch, without the scheduler.
Classes:
Functions:
-
build_batch–Allocate disjoint blocks and build
NewRequestDatafor 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.
Source code in vllm/benchmarks/forward/batch.py
finish()
¶
_num_blocks(spec, computed, kv_len, dcp_size)
¶
Return (leading null blocks, live blocks) for one request.
Source code in vllm/benchmarks/forward/batch.py
build_batch(case, kv_cache_groups, num_kv_blocks, vocab_size, rng, dcp_size=1)
¶
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.
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.
Source code in vllm/benchmarks/forward/batch.py
kv_block_size(spec, dcp_size)
¶
Tokens per block as the scheduler counts them: DCP spreads each block's tokens over the DCP ranks.