Repository navigation
Fix: Prevent premature eviction of CUDA graphs about to be used - #30660
Closed
frank-2077 wants to merge 1 commit into
Closed
frank-2077 wants to merge 1 commit into
frank-2077 wants to merge 1 commit into
Conversation
|
Hi @frank-2077, thanks for your contribution! Per our contribution guidelines, the automated PR checker found the following issue(s) that need your attention:
Please note that maintainers reserve the right to make final decisions on PRs. If you believe there is a mistake, please comment below. |
Exclude the currently requested graph from cleanup sweep to avoid forcing unnecessary re-capture when the same graph is reused after a 10+ second idle period.
frank-2077
force-pushed
the
fix-cuda-graph-premature-eviction
branch
from
October 16, 2026 09:22
bbc32b5 to
db3ca2c
Compare
Contributor
|
Seems like an okay fix, but does it really fix the issues you outlined? If not then please create an issue with a reproduction and someone will look into it. |
Author
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.
Problem
The current CUDA graph cleanup mechanism in PR #21611 introduces a timing issue that causes unnecessary performance degradation in high-concurrency scenarios.
Current behavior in
ggml-cuda/common.cuh:1467-1488:The issue:
If a graph's
last_used_timeis >10s ago, it gets deleted even when we're about to use it in the same function call. This forces expensive re-capture operations (warmup → capture → instantiate).Solution
Exclude the currently requested graph from the cleanup sweep:
This simple check prevents deleting the graph we're actively requesting. The graph's
last_used_timegets updated later in the function, so subsequent cleanups will preserve it correctly.Code Change
File:
ggml/src/ggml-cuda/common.cuh1 line changed - adds a check to skip the currently requested graph during cleanup.
Impact on Production Deployments
Our deployment characteristics make this fix critical:
Profiling Data - Capture & Instantiate Latency Growth (High Concurrency)
Under concurrent load (1→8 concurrent requests), re-capture costs become prohibitive:
1→8 concurrent
1→8 concurrent
(p50: 0.95 → 1.18)
(p50: 3.1)
(p95: 549ms)
Key observation: Some modules see 10-27× latency increase under concurrency, likely due to CUDA driver contention. Avoiding unnecessary re-captures is essential for maintaining throughput.
Benefits
Testing
This fix applies to any high-concurrency deployment where graph access patterns have occasional >10s gaps. We observed this in production serving multimodal workloads with bursty request patterns.
Note: Our workload uses a custom model architecture (Omni multimodal model) on a forked llama.cpp, but this fix applies to any high-concurrency deployment where graph access patterns have occasional >10s gaps.