vllm.benchmarks.forward.capture
¶
Capture the forward of one exact batch as a one-shot CUDA graph and time it.
The graph is captured for a single batch and only replays that batch, so the host-side decisions baked in at capture (attention plans, kernel choices by query length, chunk splits) are correct by construction. This deliberately bypasses vLLM's CUDA graph manager: no capture sizes, padding or dummy metadata. Each replay first restores the KV blocks the step writes, so state the forward mutates in place (e.g. compressor state) is the same on every replay.
Classes:
-
ForwardBench–Runs one batch through the runner's
execute_model, timing its forward.
Functions:
-
write_input_ids–Decode/verify inputs otherwise come from sampler state.
ForwardBench
¶
Runs one batch through the runner's execute_model, timing its forward.
execute_model prepares the inputs, attention metadata and forward context
as in serving; the bench takes over the eager model call. Two steps: the
first ("warmup") runs the model eagerly, which triggers JIT, autotuning and
lazy init. The second ("capture") captures, validates and times the graph.
_check_batch(input_batch)
¶
Fail unless the runner built exactly the requested batch.
_sample(output)
¶
Sample, or rejection-sample verify rows, as sample_tokens does.
The drafter keeps its fixed fully-accepted inputs, so the sampled tokens feed nothing.
_time(graph)
¶
Per-replay forward time between in-graph events, MAX across ranks.
_warmup(graph, seconds=1.0)
¶
Replay until clocks and caches reach a steady state.
write_input_ids(batch, input_batch, input_ids)
¶
Decode/verify inputs otherwise come from sampler state.