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, 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.
Source code in vllm/benchmarks/forward/batch.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | |
kv_block_size(spec, dcp_size)
¶
Tokens per block as the scheduler counts them: DCP spreads each block's tokens over the DCP ranks.