Repository navigation
fix(qwen3-vl): bound CUDA graph caches - #125
Merged
LiangSu8899 merged 4 commits intoJul 1, 2026
Merged
LiangSu8899 merged 4 commits into
LiangSu8899 merged 4 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds bounded (LRU) CUDA Graph cache management to the Qwen3-VL Torch frontends to prevent unbounded graph growth in long-running processes, aligning Qwen3-VL behavior with existing bounded-cache patterns elsewhere in FlashRT.
Changes:
- Replace unbounded decode/prefill graph dictionaries with
OrderedDict-backed LRU caches, with configurable caps via env vars / constructor params. - Add public
clear_graphs()andgraph_cache_stats()APIs to aid operational control and debugging. - Add CI-friendly regression tests that validate LRU eviction and buffer/graph cache synchronization.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/test_qwen3_vl_graph_cache.py | New regression tests covering LRU eviction, buffer eviction coupling, stats, and clear behavior. |
| tests/test_qwen3_vl_fp8_sm89.py | Extends import/signature smoke checks to cover new graph-cache parameters and APIs. |
| flash_rt/frontends/torch/qwen3_vl_rtx.py | Implements bounded prefill/decode graph caches, adds clear_graphs() and graph_cache_stats(), and keeps staged buffers in sync on eviction. |
| flash_rt/frontends/torch/qwen3_vl_fp8_sm89.py | Adds bounded decode graph cache + stats/clear APIs and a new max_decode_graphs constructor parameter. |
| flash_rt/frontends/torch/qwen3_vl_fp8_sm89_multimodal.py | Adds bounded prefill/decode graph caches for the multimodal wrapper, plus clear/stats APIs (including delegating to text frontend). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+156
to
+158
| import torch | ||
| monkeypatch.setattr(torch.cuda, "current_stream", | ||
| lambda: _FakeStream(), raising=False) |
Contributor
Author
There was a problem hiding this comment.
Fixed in the latest push by monkeypatching torch.cuda.synchronize to a no-op in this CI-friendly test, matching the other mocked CUDA surface.
heiheiha798
force-pushed
the
fix/qwen3-vl-graph-cache-management
branch
from
July 1, 2026 15:49
f8d0403 to
94a16b2
Compare
LiangSu8899
approved these changes
Jul 1, 2026
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
Fixes #122.
This PR adds bounded CUDA Graph cache management for all current Qwen3-VL frontends in the repo:
Qwen3VlTorchFrontendRtx(SM120/NVFP4 multimodal path)Qwen3VlTorchFrontendRtxBF16(Orin SM87 BF16 multimodal path)Qwen3VlFp8Sm89TextFrontend(SM89 FP8 text path)Qwen3VlFp8Sm89Frontend(SM89 FP8 multimodal wrapper)The change replaces unbounded process-local graph dictionaries with LRU-bounded
OrderedDictcaches, adds publicclear_graphs()APIs, and exposes lightweightgraph_cache_stats()bucket diagnostics. Prefill graph eviction also drops the corresponding staged/static input buffers so graph entries and buffer residency stay in sync.Decode graph caches that bake a prompt-dependent RoPE position now key by
(cache_pos, rope_pos), avoiding reuse of a graph captured for a different MRoPE continuation position.The default cap is 256 entries per cache. It can be overridden with:
FLASHRT_QWEN3_VL_PREFILL_GRAPH_CACHE_MAXFLASHRT_QWEN3_VL_DECODE_GRAPH_CACHE_MAXValues <= 0 preserve legacy unbounded behavior for callers that intentionally want it.
Scope
Runtime graph-cache bookkeeping only. This does not change model numerics, kernels, dtype policy, dispatch policy, graph-capture bodies, launch parameters, CMake, or pybind bindings.
Validation
Environment:
Commands:
Results:
compileall: passedgit diff --check: passedNot Run
Those are useful integration checks for CUDA Graph capture/replay on hardware, but the regression tests in this PR intentionally isolate the cache-management bug without requiring checkpoints or real CUDA Graph capture.