Repository navigation
cuda: grow the CUDA graph cache cap while it evicts graphs still in use - #238
Open
LeoBorcherding wants to merge 2 commits into
Open
LeoBorcherding wants to merge 2 commits into
LeoBorcherding wants to merge 2 commits into
Conversation
Tensor split needs ~2*n_layers+1 graphs per device per shape, so the fixed cap of 64 evicted every graph before its next use and decode ran without graph reuse. Start at 64 and double, up to 2048, whenever the LRU victim was used within the last second. Patch by floewe (unslothai/unsloth#12468).
This was referenced Oct 8, 2026
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.
Fixes the tensor split decode regression in unslothai/unsloth#12468 (2.4x to 4.3x slower since
b10715-mix-86bd2d3).max_cuda_graphs = 64from #144 is below the working set in--split-mode tensor. That mode needs about2 x n_layers + 1graphs per device per shape, so any model past ~31 layers evicts every graph before its next use and decode runs with no graph reuse. Single GPU and layer split need 2 to 4 graphs and are unaffected.Instead of a new fixed number, the cap starts at 64 and doubles, up to 2048, whenever the LRU victim was used within the last second. That only happens when the cap is below the working set. The existing 10 s sweep still drops stale entries, and the hard limit keeps the many-shapes case #144 added the cap for bounded.
The patch and every number below are floewe's, from unslothai/unsloth#12468. The only change from their diff is
static constexpron the limit, becausestd::mintakes it by reference and astatic constmember without an out-of-class definition can fail to link at-O0.Measured by floewe on this head (
5df4722)2x RTX 5070 Ti 16 GB, WSL2 Ubuntu 24.04, driver 616.92, CUDA 13.3, built from this branch. Baseline is the
b10715-mix-86bd2d3prebuilt. Three 600-token requests per row (full log in unslothai/unsloth#12468).With a counter build: the cap grew to 512 for Qwen and 1024 for Gemma (727 live graphs at the prompt-to-decode transition), and stayed at 64 for layer split and single GPU. No graph used within the last second was ever evicted. The 2048 limit was never reached, so the warning didn't fire.
Relation to #232
#232 raises the fixed cap to 512. That covers steady-state decode for the three models above, but not Gemma's 727 live graphs at the prompt-to-decode transition, and a deeper model with MTP will outgrow it the same way 64 was outgrown.
Not verified
scripts/unsloth/pr-set.jsonafter MTP for Qwen3.8-Flash-Next #144.