Repository navigation
[ROCm][Perf] Extend default CUDA graph sizes for speculative decoding with breakable graphs on CDNA4 - #66563
[ROCm][Perf] Extend default CUDA graph sizes for speculative decoding with breakable graphs on CDNA4#66563tuukkjs wants to merge 5 commits into
Conversation
|
Documentation preview: https://vllm--66563.org.readthedocs.build/en/66563/ |
b7aaf79 to
be6fc40
Compare
jhartika-amd
left a comment
There was a problem hiding this comment.
Thanks @tuukkjs! This seems like well evidenced change. One change request in inline comment.
| max_num_tokens, | ||
| ) | ||
| extend = extended_max_tokens > shared_max | ||
| if extend and compilation_config.max_decode_cudagraph_capture_tokens is None: |
There was a problem hiding this comment.
This sets the decode budget even when the user set max_decode_cudagraph_capture_requests or decode_cudagraph_capture_request_sizes. E.g. K=5 with max_decode_cudagraph_capture_requests: 1024: main captures decode graphs up to 1024 requests (6144 tokens); this PR stops at 682 (4092 tokens), and adaptive verification's verify graphs at 4096 instead of 6144. That contradicts "capture sizes set in --compilation-config resolve as before". Either set the budget only when both decode fields are unset (decode_sizes is None and max_decode_requests is None), or state it in the description and docs (SM100's 8192 budget behaves the same way). A test case with max_decode_cudagraph_capture_requests: 1024 would pin it down.
There was a problem hiding this comment.
Agreed. Fixed it. The budget is now set only when neither decode_cudagraph_capture_request_sizes nor max_decode_cudagraph_capture_requests is set, so max_decode_cudagraph_capture_requests: 1024 captures decode graphs up to 1024 requests (6144 tokens) as on main. The test case now uses 1024 and expects no budget. SM100's 8192 budget has the same interaction on main. I left that out of scope here.
… with breakable graphs on CDNA4 Breakable CUDA graphs run without torch.compile, so a batch wider than every captured graph runs eagerly. On ROCm the default sizes stop at 512 tokens, which a K=5 speculative decode batch exceeds at 84 requests. With speculative decoding on breakable CUDA graphs on CDNA4 (gfx950), the default prefill and decode CUDA graph sizes now reach twice the widest decode batch, at most 4096 tokens. Sizes set explicitly in --compilation-config are kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tuukka Sarvi <tuukka.sarvi@amd.com>
Set the extended decode token budget only when neither decode_cudagraph_capture_request_sizes nor max_decode_cudagraph_capture_requests is set. With max_decode_cudagraph_capture_requests=1024 and K=5, decode graphs now reach 1024 requests (6144 tokens) as on main instead of stopping at 682. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tuukka Sarvi <tuukka.sarvi@amd.com>
be6fc40 to
a71a983
Compare
At 2048 tokens the extended graphs keep the measured throughput gains of 4096 (within 2.5 points on SPEED-Bench at TP2 and TP4), while the extra graph memory, and with it the KV cache cost, halves. K=5 decode stays graphed up to 341 requests; only mixed steps of 2048-4096 tokens run eagerly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tuukka Sarvi <tuukka.sarvi@amd.com>
|
Lowered the default bound from 4096 to 2048 tokens. On SPEED-Bench, 2048 measured the same gains as 4096 at C64-C256 (within 3 points at TP2 and TP4) with less than half the extra graph memory. |
|
cc @Pb314314 |
There was a problem hiding this comment.
Thanks for the detailed benchmarks and the explicit-override fix. The goal of the questions below is to help justify the new default across the configurations it affects: understand where the gains come from, whether the token grid and number of graphs are appropriate, and what accounts for the extra memory use and whether it could be reduced.
- Scope / Validation: these defaults also affect HY4 and forced-breakable models on gfx950, while reported end-to-end results cover DeepSeek-V4.1-Flash + DSpark. Graph coverage and memory costs can differ across models/drafters. Could we add representative end-to-end validation beyond that pair, or narrow enablement until validated?
- Details: prefill/PW and FULL decode settings apply differently across target/drafter paths. Could we document how the prefill token grids, decode request counts and token budgets apply to each, following #63406, §3?
- Performance: the shared-cap comparison changes both PW and decode coverage. Could we hold decode settings fixed and compare PW=2K/4K/8K on larger prefill/mixed batches, reporting the capture grids and graph counts, throughput, graph memory and remaining KV capacity? #63406, Appendix A offers GB200 workload examples beyond 4K, not an AMD cap recommendation. If memory drives the limit, could we break down target PW/FULL versus drafter allocations and check whether buffer/workspace reuse helps?
Two smaller description/docs points: CPU sizing with gfx950 mocked (9fbe012b → fbc0dc0e) changes the prefill cap from 248 to 252 at max_num_seqs=21, K=5, despite Claims saying small configurations are unchanged. Could we preserve that behavior or qualify the claim and cover this case? Could we also update “no budget elsewhere” in docs/design/torch_compile.md to reflect the CDNA4 budget?
The two inline comments cover scope and budget behavior. Our checks used model-free configs and simulated capture completion for dispatch lookup; no real GPU capture, model execution or AMD performance/memory measurement was run.
| and current_platform.is_rocm() | ||
| and current_platform.is_device_capability(95) | ||
| and compilation_config.use_breakable_cudagraph | ||
| and self.uniform_decode_query_len > 1 |
There was a problem hiding this comment.
The CPU sizing check shows prefill max changing from 512 to 2048 (9fbe012b → fbc0dc0e) with simulated gfx950/breakable graphs, no speculative config, diffusion canvas 256 and eight requests. One scope concern is that uniform_decode_query_len also includes the diffusion canvas length, so the default extension in this PR reaches beyond the intended speculative-decoding scope. Could we explicitly require speculation and add a regression test, leaving diffusion tuning to separate work? The check used a mocked platform and model-free config; it did not run a diffusion model, GPU capture or AMD benchmark.
| # One-token draft decodes keep their graphs up to max_num_seqs. | ||
| compilation_config.max_decode_cudagraph_capture_tokens = max( | ||
| extended_max_tokens, min(max_num_seqs, max_num_tokens) | ||
| ) |
There was a problem hiding this comment.
CPU checks (9fbe012b → fbc0dc0e, gfx950 mocked) showed two budget concerns.
One concern is lost coverage: with max_num_seqs=1024, dynamic K=5 for batches 1–512 and K=0 for 513–1024, the 512-request/3072-token batch changes from FULL to NONE. Could we preserve existing coverage and add a regression test?
Another concern is that n-gram with K=5, max_num_seqs=8192, and max_num_batched_tokens=16384 expands planned target graphs to 8190 tokens, despite having no draft-model graphs to preserve. Could we bound new target expansion separately from draft coverage and add a regression test?
These model-free CPU checks simulated capture completion for real dispatch-table lookup; no GPU capture, model execution, or AMD performance/memory measurement was run.
…uests Require a speculative config, so a diffusion canvas no longer triggers the extension, and extend only where 2 * max_num_seqs * (1 + K) exceeds the 512-token ceiling, so smaller configurations keep main's sizes. Bound the new target decode request sizes by the extended token bound instead of setting a decode token budget. The budget also capped the graphs that the shared sizes give at other query lengths (dynamic speculative decoding's 512-request graphs), and its one-token-draft floor widened n-gram target graphs up to max_num_seqs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tuukka Sarvi <tuukka.sarvi@amd.com>
|
This pull request has merge conflicts that must be resolved before it can be |
|
Thanks for working on this! #68552 just merged and adds |
simondanielsson
left a comment
There was a problem hiding this comment.
Thanks for the work! Agree let's use the platform hook
Question: whats the extra memory consumption from this? Would be good to have numbers for a few different models
| not legacy_sizes | ||
| and not wide_defaults | ||
| and current_platform.is_rocm() | ||
| and current_platform.is_device_capability(95) |
There was a problem hiding this comment.
Question: what's the reason for why we only update CDNA4? I'd imagine it makes sense to update on cdna 3 and above
Suggestion: When we move this to a platform hook we should use get_cdna_version() if we want to keep this
| _ROCM_BREAKABLE_MAX_CAPTURE_TOKENS, | ||
| max_num_tokens, | ||
| ) | ||
| extend = extended_max_tokens > 512 |
There was a problem hiding this comment.
Question: How did we determine this value 512?
| GPUs, otherwise the platform's default `max_cudagraph_capture_size`; at most | ||
| `max_num_batched_tokens`. More and wider graphs take memory from the KV | ||
| cache and lengthen startup.""" | ||
| GPUs; with speculative decoding on breakable CUDA graphs on CDNA4 (gfx950), |
There was a problem hiding this comment.
Question: was it intentional to update the prefill cudagraph capture sizes if we're mainly concerned with decodes operating outside CGs?
|
|
||
| With adaptive verification, the target model's decode batches mix query lengths, so they take token-keyed graphs. Those graphs reach `max_decode_cudagraph_capture_requests * (1 + num_speculative_tokens)` tokens, within `max_decode_cudagraph_capture_tokens`; the decode request sizes then set only the draft decode graphs. | ||
|
|
||
| Breakable CUDA graphs run without torch.compile, so a batch wider than every graph runs eagerly. On ROCm CDNA4 (gfx950) with breakable CUDA graphs and speculative decoding, unset kinds therefore extend past the platform default where `2 * max_num_seqs * (1 + num_speculative_tokens)` exceeds its 512 tokens: prefill graphs reach that many tokens, at most 2048, and decode graphs reach as many requests of `1 + num_speculative_tokens` tokens as fit in them. |
There was a problem hiding this comment.
Minor question: Isn't the first sentence true independent of if torch.compile is enabled or not? I'm thinking if we should even remove the breakable cudagraphs checks from the PR if this holds independent of we're using torch.compile.
| `max_num_batched_tokens`. More and wider graphs take memory from the KV | ||
| cache and lengthen startup.""" | ||
| GPUs; with speculative decoding on breakable CUDA graphs on CDNA4 (gfx950), | ||
| `2 * max_num_seqs * (1 + num_speculative_tokens)` up to 2048 where that |
There was a problem hiding this comment.
Question: What's the rationale for stopping at 2048? Considering SM100 goes up to 8k :)
Overview
With breakable CUDA graphs, vLLM runs without torch.compile, so a batch wider than every captured graph runs eagerly. On ROCm the default graphs stop at 512 tokens, which K=5 speculative decoding exceeds at 84 requests: DeepSeek-V4.1-Flash, which uses breakable graphs by default on ROCm, then runs DSpark slower than no speculation at high concurrency on MI355X. On CDNA4/gfx950 with breakable graphs and speculative decoding, this PR raises the default prefill and decode CUDA graph sizes to twice the widest decode batch, at most 2048 tokens.
Scope. Only models that run breakable CUDA graphs with speculative decoding on gfx950 change: DeepSeek-V4.1 and HY4 by default, and any model with
VLLM_USE_BREAKABLE_CUDAGRAPH=1(for example the Kimi-K3.1-Pro recipe's MI355X command). Other GPUs, runs without speculation and capture sizes set in--compilation-configresolve as before.Why change the default. The same graphs can be requested with
--compilation-config, and tuned recipes set them by hand, but the default command, which most users run, falls off this cliff. This PR makes the default cover the speculative decode batch, as #49390 (1024-token shared default) and #63406 (prefill graphs and decode token budget at 8192 tokens) did on data-center Blackwell.Claims
DeepSeek-V4.1-Flash on MI355X with DSpark, main → this PR:
max_num_seqs256): K=5 +23% at 128 (1.22x → 1.50x) and +7% at 256; adaptive verification +1% and +5%.max_num_seqs * (1 + K) <= 256) are unchanged.Validation
MI355X x4,
deepseek-ai/DeepSeek-V4.1-Flash-1017, DSpark with fixed verification (K=5) or adaptive verification (AV). One server per arm: "main" is an unmodified nightly image, "this PR" mounts itsvllm/config/{vllm,compilation}.pywith this diff applied. Setup and commands are in the fold below.Accuracy
niah_single_2, 64K (32)No statistically detectable difference. Per GSM8K question, over three runs per arm, this PR minus main is -0.10 ± 0.41 points (K=5) and +0.08 ± 0.38 (AV), and the two disagree on as many questions as two runs of one server (batched serving is not bit-deterministic). GPQA's standard error is about 0.02.
Performance
Results are single runs; this PR's TP4 SPEED-Bench cells at C64-C256 were repeated and agree within 3 points. Bold marks changes beyond the run-to-run spread (about ±5%, up to 10% for the smallest runs) at concurrency 128-256, where main runs most target steps eagerly.
SPEED-Bench (qualitative, output length 512), TP4, output throughput (tok/s), main → this PR:
At C128 / C256, the share of target steps that run eagerly (
--cudagraph-metricslogsNONE) falls from 80% / 85% to 2% / 14% for K=5 and from 9% / 18% to 1% / 5% for AV (no spec: 1%). AV's acceptance length at C256 rises from 2.03 to 2.49 (K=5: 2.90 → 2.89). Up to C64, decode steps use the same graphs; only mixed steps above 512 tokens move from eager to graphs (K=5 at C64: 7% → 0% of steps).TP2 with Engram offloaded, K=5, output throughput (tok/s), main → this PR; eager steps at C128 / C256 fall from 83% / 84% to 3% / 14%:
Long-input sweep with SGLang's serving benchmark against the vLLM server (
python3 -m sglang.bench_serving,randomdataset: ShareGPT text resized to 80-100% of the target input and output lengths),max_num_seqs256, imagenightly-083fbac0(see the fold below). Output throughput (tok/s), main → this PR:Below C128 and at 60K-128K inputs, decode stays within 512 tokens and long prompts prefill in chunks above 2048 tokens, so both arms run largely the same graphs.
Startup cost (rank 0), main → this PR:
Setup and commands
vllm/vllm-openai-rocm:nightly-a2bcb5657a881a002e79d0adab3c6b5e39436121; this revision of the change gated on the equivalentget_cdna_version() == 4. Long-input sweep, GPQA and NIAH:nightly-083fbac021348c2c7af8a7bc71ba18199d0dd7a4, withquick_all_reduce.pyfrom [Bugfix][ROCm] Support AITER's preload() in FlyDSL INT4 QuickReduce init #65995 mounted in every arm (INT4 QuickReduce with aiter 0.1.28).1bae0e10; main's GSM8K repeats (except K=5), TP2 main and every arm of this PR loaded08c8657f, the same weights pluschat_template.jinja.max_num_seqsup to 2048) and keeping explicitly set decode request sizes without the budget.Server (recipe MI355X command; TP2 adds
--tensor-parallel-size 2 --engram-config '{"cpu_offload":true}'; the long-input sweep drops--cudagraph-metricsand addsAITER_USE_FLYDSL_MOE_SORTING=1 --max-num-seqs 256 --no-enable-prefix-caching --enable-auto-tool-choice --tool-call-parser deepseek_v41 --reasoning-parser deepseek_v41):Clients:
Unit tests
tests/compile/test_config.pybuilds a realVllmConfig(facebook/opt-125mwith n-gram or draft-model speculation); onlyis_device_capabilitystands in for the GPU. The cases cover the gfx950 defaults and each term of the bound; no speculation, no breakable graphs, gfx942 and the deprecated fields (unchanged sizes); an explicit setting; sizes up to 512 tokens unchanged; and one-token draft decodes up tomax_num_seqs. On MI355X,pytest -v tests/compile/test_config.py -k "rocm_breakable or one_token_draft":The whole file passes (150 passed). In CI the tests run in the MI300 mirror of PyTorch Compilation and skip off ROCm.
Details
Root cause. The 512-token ceiling assumes torch.compile covers wider batches, but breakable CUDA graphs set
CompilationMode.NONE, so a wider batch launches every op from Python. DSpark verifies K+1 = 6 tokens per request, so K=5 decode graphs stop at 83 requests. Adaptive verification prices the eager step as a cost cliff and mostly stays within 512 tokens, which holds acceptance length at 2.03. Variable acceptance also spreads prefills across most steps, so mixed steps of about 1500 decode tokens plus a short prefill are frequent.Change. In
_split_cudagraph_capture_sizes, on ROCm gfx950 (is_device_capability(95)) with breakable CUDA graphs, speculative decoding and none of the deprecated shared fields set, unset kinds extend tomin(2 * max_num_seqs * (1 + K), 2048, max_num_batched_tokens)tokens, the shared ceiling's2 * max_num_seqs * query_lenrule:max_num_seqsmax_num_seqs, so one-token draft decodes (EAGLE, MTP, draft models) keep their graphs as on main.Sizes up to 512 tokens and explicit settings are unchanged. It reuses the grids of #63406's SM100 defaults (a prefill grid, and a decode request grid within a token budget), but where SM100 applies a fixed 8192 tokens to every model, this applies only with breakable graphs (no compiled fallback) and speculative decoding (1 + K tokens per decode request), scales with the decode batch and stops at 2048, since graph memory comes out of the KV cache. 2048 covers K=5 decode up to 341 requests; a 4096 cap measured the same SPEED-Bench gains at C64-C256 (within 3 points at TP2 and TP4) at more than twice the extra graph memory.
Tradeoffs and limitations.
--compilation-config '{"max_prefill_cudagraph_capture_tokens":2048,"max_decode_cudagraph_capture_requests":1024,"max_decode_cudagraph_capture_tokens":2048}'gives the same coverage today; this PR makes it the default. Those caps also switch to the coarser default grids from 1 token (less graph memory), while this PR keeps main's sizes up to 512 tokens.Duplicate check. No open or recent PR extends capture sizes for speculative decoding on ROCm. #64825 (open) extends the split prefill sizes for Qwen3.5 on NVIDIA in the same function; whichever lands second rebases. #60265 (open) edits the deprecated shared sizes. #63070 (draft, GLM-5.3-Flash) and #66320 (Qwen3.5) would move more models to breakable graphs on gfx950, which then get these sizes when speculating. Recipes set such sizes by hand today, e.g. MiniMax-M3.1-Flash on MI355X (#66188).
Pull Request Checklist
I used vLLM's
/pr-checklistskill. (Mandatory for agents, optional for humans).AI assistance was used during the creation of this PR.
Design Fit: Minimizes impact on core components, reuses existing functionality, and justifies added complexity.
Testing and Validation: Validates the change and ensures any added tests are meaningful and reliable, with CI coverage or documented CI resource constraints and validation performed outside CI.
Code Quality and Style: Keeps code and comments clear and concise, and updates relevant documentation and examples.
Pull Request Contents: Includes a brief summary and relevant links, supports claims with evidence, explains root causes and implementation trade-offs, and follows the contributing guide.
AI assistance was used for this PR.