Conversation
The meta backend (-sm tensor) dispatches one subgraph per AllReduce split point to every simple backend. For qwen4exp that is ~128 subgraphs per device, each getting its own entry in the per-device cuda_graphs map. With max_cuda_graphs = 64 the LRU cap evicted entries on every decode token, so graph->uid never matched and warmup never completed: zero CUDA graph captures, fully eager decode (~14.6k kernel launches per token per device). Measured on 8x V100-SXM2 (NVLink), qwen4exp Q4_K_XL: TP4 tg64: 6.77 -> 44.41 ± 6.26 t/s (tg512: 47.93) TP8 tg64: 5.50 -> 30.37 ± 5.86 t/s nsys tg64: cudaGraphLaunch 0 -> 48888, cudaLaunchKernel 2.96M -> 118k Layer-split mode only needs one entry per device and was unaffected. 512 covers large TP graphs; the existing 10s idle sweep still bounds the map size in steady state. Co-Authored-By: Claude Code <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
-sm tensor(meta backend) never captures CUDA graphs in decode when a model produces more than 64 subgraphs per device, becausemax_cuda_graphs = 64makes the LRU eviction run on every token, permanently resetting graph warmup.cuda_graphs.graph->uidnever matches → warmup never completes → zerocudaGraphLaunch, fully eager decode (~14.6kcudaLaunchKernelper token per device ≈ 70 ms of CPU launch overhead).Measurements
8× V100-SXM2-32GB (NVLink), Qwen3.8-Flash-Next UD-Q4_K_XL,
llama-bench -sm tensor -ngl 999 -p 0 -n 64 -r 3:nsys (TP4, one tg64 run):
cudaGraphLaunch0 → 48,888,cudaLaunchKernel2.96M → 118k, 1552 graph captures. Layer-split mode needs only one entry per device and is unaffected. Output correctness verified (greedy, temp 0: arithmetic, counting, generation all correct).The capture storm also disappears: with 128 keys cycling through a 64-entry map, each token re-instantiated 64+ graphs; after the fix, captures happen once and
cudaGraphExecUpdatereplays them.Notes
node_propertiesper graph node (ggml_tensor+ src ptr/ne/nb), so 512 entries × ~1000-node subgraphs is tens of MB — negligible next to the captured graphs themselves.🤖 Generated with Claude Code