Repository navigation
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a compact K/V/decay replay cache (--enable-linear-compact-spec-cache) for KDA and GDN hybrid linear attention models during speculative target verification, optimizing memory usage by caching per-token states instead of full SSM states. The code review identified several critical issues: Triton compilation errors and correctness bugs in the state replay kernels (using Python's range instead of tl.range and incorrect request slot indexing), an AttributeError in model_runner_kv_cache_mixin.py due to a misspelled ServerArgs attribute, and a missing import of TritonGDNKernel in gdn_backend.py that would cause a runtime NameError.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
/tag-and-rerun-ci |
|
/rerun-failed-ci |
|
@strgrb Please add unit tests to cover the new functions for GDN. |
|
This is a novel and valuable feature. LGTM in general. |
Extra option is added to GDN test suite, and new cases are added to registered case. |
|
Could you add Qwen3-Next-80B-A3B-Instruct GSM8K full 1319 q result? |
|
@yizhang2077 @hanming-lu @kaixih Could you help to review this PR? |
|
/tag-and-rerun-ci |
Scores in description is 1319 result |
|
/rerun-failed-ci |
|
@strgrb please resolve conflict. |
resolved |
|
/rerun-failed-ci |
Motivation
For KDA and GDN, we can use delta cache instead of full ssm state:

In equation above,$k_t$ and $v_t^T - k_t^T Diag(\alpha_t)S_{t-1}$ are vectors, so we can store them and $\alpha_t$ as delta of ssm state.
Currently, KDA, GDN, Lightning Attn can use this method, and only GDN is implemented in this pr, because KDA verify is not implemented yet, and Lightning Attn is not formatted with RadixLinearAttention and may be modified when refactored.
In this pr, I store these 3 vectors to replace intermediate ssm states to decrease memory usage with large concurrency. To restore full ssm state, a replay kernel is organized.
For each head in each layer, full ssm state is [128, 128], and is reduced to [3, 128]. With 70 layers, 64 heads, 4 draft tokens, each req needs 4B * 128 * 128 * 64 * 70 * 4 = 560MB, which is quite significant for 32 or 64 concurrency.
This feature can also be used with radix cache, a full ssm state and some deltas are stored in 1 page, and we can replay to cache hit of any single token with it. This may be hard, and may be implemented in the future.
For performance, verify kernel speeds up by decreasing writing to global memory, and relay kernel slows down by increasing calculation, and total performance is the same or a little higher since both kernels are memory bound. I think with better GPUs, more performance gain can be found.
Following tests are done with H20.
starting command:
memory usage before:
memory usage after:
Modifications
Accuracy Tests
before:
after:
Speed Tests and Profiling
With 8k input and 1k output: opt vs origin
Checklist
Review and Merge Process
/tag-and-rerun-ci,/tag-run-ci-label,/rerun-failed-ciCI States
Latest PR Test (Base): ❌ Run #27732324898
Latest PR Test (Extra): ❌ Run #27732324795