Repository navigation
[CUDA] Add compact GatedDeltaNet operator - #32282
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds CUDA GatedDeltaNet and compact state updates, extends paged attention and quantized GEMV paths for speculative decoding, and adds supporting tests and documentation.
Changes:
- Adds GatedDeltaNet and packed variable-length causal convolution.
- Extends paged attention with non-causal FlashAttention support.
- Expands small-M and quantized GEMV kernels to 64 rows.
Reviewed changes
Copilot reviewed 42 out of 42 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
onnxruntime/core/graph/contrib_ops/bert_defs.cc |
Adds schemas and causality attribute. |
onnxruntime/core/graph/contrib_ops/ms_opset.h |
Registers new schemas. |
onnxruntime/contrib_ops/cuda/cuda_contrib_kernels.cc |
Registers CUDA kernels. |
onnxruntime/contrib_ops/cuda/bert/gated_delta_net.h |
Declares GDN kernel. |
onnxruntime/contrib_ops/cuda/bert/gated_delta_net.cc |
Validates and dispatches GDN. |
onnxruntime/contrib_ops/cuda/bert/gated_delta_net_impl.h |
Defines GDN launch interface. |
onnxruntime/contrib_ops/cuda/bert/gated_delta_net_impl.cu |
Implements recurrent/chunked GDN. |
onnxruntime/contrib_ops/cuda/bert/gated_delta_net_mma.cuh |
Adds tensor-core primitives. |
onnxruntime/contrib_ops/cuda/bert/gated_delta_net_plan.h |
Defines planning heuristics. |
onnxruntime/contrib_ops/cuda/bert/gated_delta_net_plan.cc |
Implements plan caching. |
onnxruntime/contrib_ops/cuda/bert/gated_delta_net_split_impl.cu |
Adds split chunked engine. |
onnxruntime/contrib_ops/cuda/bert/varlen_causal_conv_with_state.h |
Declares packed convolution. |
onnxruntime/contrib_ops/cuda/bert/varlen_causal_conv_with_state.cc |
Validates packed convolution inputs. |
onnxruntime/contrib_ops/cuda/bert/varlen_causal_conv_with_state_impl.cu |
Implements packed convolution. |
onnxruntime/contrib_ops/cuda/bert/paged_attention.h |
Stores causality configuration. |
onnxruntime/contrib_ops/cuda/bert/paged_attention.cc |
Routes non-causal attention. |
onnxruntime/contrib_ops/cuda/bert/paged_attention_impl.cu |
Passes causality to FlashAttention. |
onnxruntime/contrib_ops/cuda/bert/group_query_attention.cc |
Allows batched subsequent prompts. |
onnxruntime/contrib_ops/cuda/bert/causal_conv_with_state.cc |
Improves validation context. |
onnxruntime/contrib_ops/cpu/bert/group_query_attention_helper.h |
Adds prompt-validation override. |
onnxruntime/contrib_ops/cpu/bert/causal_conv_with_state.cc |
Supplies operator name to validation. |
onnxruntime/contrib_ops/cpu/bert/causal_conv_with_state_helper.h |
Generalizes validation messages. |
onnxruntime/contrib_ops/cpu/bert/attention_parameters.h |
Adds paged-attention causality state. |
onnxruntime/core/providers/cuda/math/matmul.cc |
Moves counter initialization into launcher. |
onnxruntime/core/providers/cuda/math/matmul_small_n_gemv.h |
Documents 64-row support. |
onnxruntime/core/providers/cuda/math/matmul_small_n_gemv.cu |
Adds chunked row launches. |
onnxruntime/contrib_ops/cuda/math/matmul_block_scaled_fp8.h |
Exposes FP8 GEMV limit. |
onnxruntime/contrib_ops/cuda/math/matmul_block_scaled_fp8.cc |
Uses dynamic FP8 GEMV limit. |
onnxruntime/contrib_ops/cuda/math/matmul_block_scaled_fp8.cu |
Adds multi-row FP8 MMA. |
onnxruntime/contrib_ops/cuda/math/matmul_block_scaled_fp4.h |
Exposes FP4 GEMV limit. |
onnxruntime/contrib_ops/cuda/math/matmul_block_scaled_fp4.cc |
Uses dynamic FP4 GEMV limit. |
onnxruntime/contrib_ops/cuda/math/matmul_block_scaled_fp4.cu |
Adds multi-row FP4 MMA. |
onnxruntime/python/tools/microbench/gdn.py |
Adds GDN microbenchmark. |
onnxruntime/test/python/transformers/test_paged_attention.py |
Tests non-causal paged attention. |
onnxruntime/test/providers/cuda/test_cases/matmul_small_n_gemv_op_test.cc |
Tests expanded GEMV shapes. |
onnxruntime/test/contrib_ops/matmul_block_scaled_fp8_test.cc |
Tests FP8 row tiling. |
onnxruntime/test/contrib_ops/matmul_block_scaled_fp4_test.cc |
Tests FP4 row tiling. |
onnxruntime/test/contrib_ops/gated_delta_net_op_test.cc |
Covers GDN behavior and planning. |
onnxruntime/test/contrib_ops/causal_conv_with_state_op_test.cc |
Covers packed convolution. |
docs/contrib_ops/cuda/gdn.md |
Documents GDN contracts and results. |
docs/ContribOperators.md |
Updates generated schemas. |
docs/OperatorKernels.md |
Updates generated kernel inventory. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Tianlei Wu (tianleiwu)
marked this pull request as draft
August 26, 2026 18:50
Tianlei Wu (tianleiwu)
force-pushed
the
tlwu/qwen_gdn_paged_v2
branch
from
August 26, 2026 23:22
497e1b9 to
593476a
Compare
Tianlei Wu (tianleiwu)
force-pushed
the
tlwu/qwen_gdn_paged_v2
branch
from
August 27, 2026 00:12
593476a to
047b5c4
Compare
Tianlei Wu (tianleiwu)
force-pushed
the
tlwu/qwen_gdn_paged_v2
branch
from
August 27, 2026 00:37
047b5c4 to
bcdc015
Compare
Tianlei Wu (tianleiwu)
marked this pull request as ready for review
August 27, 2026 04:13
4 tasks done
Tianlei Wu (tianleiwu)
added a commit
that referenced
this pull request
Aug 28, 2026
### Description - Replace dense `VarlenCausalConvWithState` checkpoint output with the compact three-output ABI `[output, final_state, state_update]`. - Add optional per-request `capture_count` input and bounded `state_update_capacity` attribute. - Return only the appended activation values required to replay accepted speculative prefixes, shaped `[batch_size, state_update_capacity, channels]`. - Remove the retired `max_checkpoints` attribute and `prefix_states` output. - Add schema validation, CUDA shape/runtime checks, and focused compact-capture tests. ### Motivation and Context Dense checkpoint output scales the full convolution state with speculative width. The convolution transition only needs the newly appended value at each accepted position, so compact capture avoids duplicating the full `[channels, kernel_size - 1]` state while preserving exact replay from committed state. This change is coordinated with the compact GatedDeltaNet operator and ONNX Runtime GenAI replay integration: - #32282 - microsoft/onnxruntime-genai#2472 ### Validation - `ContribOpVarlenCausalConvWithStateTest.*`: 39/39 passed on H200 with CUDA 13.0 and cuDNN 9.23. - Coverage includes sequential-prefix equivalence, all-ones decode, adjacent requests, omitted output at zero capacity, capture-count requirements and shape validation, and capacity bounds. - File-scoped lintrunner and `git diff --check` passed for all five changed files. - Generated `docs/ContribOperators.md` is intentionally excluded and left to CI generation.
Baiju Meswani (baijumeswani)
approved these changes
Aug 28, 2026
Baiju Meswani (baijumeswani)
left a comment
Contributor
There was a problem hiding this comment.
Looks good.
Tianlei Wu (tianleiwu)
added a commit
to microsoft/onnxruntime-genai
that referenced
this pull request
Aug 28, 2026
## Summary - export packed Qwen3.5/3.8 linear-attention layers with `VarlenCausalConvWithState` and `GatedDeltaNet` - replace dense recurrent checkpoints with compact convolution values and GDN transition capsules - export raw `A_log`/`dt_bias` for native Qwen gate arithmetic, without `arithmetic_mode` - keep committed paged recurrent state unwindowed, FP32, and V-major while preserving the dense `LinearAttention` default The existing `state_groups` schema is unchanged in this PR. Parsing compact update metadata and replaying these transitions is handled by the stacked runtime PR #2454. ## Dependencies - microsoft/onnxruntime#32282 - microsoft/onnxruntime#32290 - microsoft/onnxruntime#32307 ## Testing - `python3 -m pytest test/python/builder/test_decoder_state_groups.py test/python/builder/test_qwen_vl.py -q` (50 passed) - `python3 -m pytest test/python/builder -q` (493 passed, 3 skipped)
Tianlei Wu (tianleiwu)
added a commit
to microsoft/onnxruntime-genai
that referenced
this pull request
Aug 30, 2026
## Summary Replace dense recurrent checkpoint tensors with compact state-update replay for dynamically batched hybrid models. The engine now owns fixed convolution and GatedDeltaNet state beside paged KV cache, captures packed per-token updates, and replays only an accepted prefix into inactive state banks before atomically publishing both cache types. ## Stack - Stacked on #2453, which exports compact Qwen3.5/3.8 `value` and `capsule` outputs. - Depends on microsoft/onnxruntime#32282 and microsoft/onnxruntime#32290. - MTP scheduling and drafter orchestration remain outside this PR. ## Key Changes - Parse explicit `paged_kv` and `fixed` decoder state groups, including compact convolution `value` and GDN `capsule` update bindings. - Add a fixed-state pool with per-request ownership, double-buffered publication, compact prefix replay, and CPU/CUDA provider implementations. - Add composite paged/fixed reservations with validation and preparation before the allocation-free publication boundary. - Bind packed variable-length inputs and fixed state together through `HybridDecoderIO`, including optional packed `position_ids`. - Resolve paged cache tensor names from explicit manifest bindings while retaining legacy name-template synthesis for models without `state_groups`. - Add synthetic hybrid/composite fixtures and focused manifest, reservation, replay, transaction, and end-to-end Engine coverage. ## Memory Impact The runtime no longer requires dense per-token recurrent checkpoint outputs. Speculative rollback data is bounded by `state_update_capacity` and represented as compact convolution values or packed GDN transition capsules. ## Testing - `test/python/builder/test_decoder_state_groups.py`: 24 passed - CPU Debug `engine_unit_tests`: 256 passed - CUDA Debug `engine_unit_tests` on H200: 261 passed - Paged and hybrid Engine Python tests across CPU/CUDA: 32 passed - CUDA compact convolution/GDN partial-prefix replay: passed ## Checklist - [x] Tests added and updated - [x] CPU and CUDA replay paths validated - [x] No MTP/drafter scheduling included - [x] Existing paged-only Engine behavior preserved --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.
Description
GatedDeltaNetcontrib operator with recurrent decode and tensor-core chunked prefill paths.A_log.[output, final_state, state_update]. The FP32state_updatecapsule packs decay, shared-key, and delta transitions needed to replay accepted speculative prefixes without materializing dense recurrent checkpoints.Motivation and Context
Dense recurrent checkpoints scale the full FP32 state with draft width. At the Qwen3.8 geometry, a four-slot window across 48 GDN layers consumes 576 MiB. Compact transition capture keeps one committed state and records only the information needed to reconstruct an accepted prefix.
The schema intentionally exposes only native arithmetic and does not include the experimental
arithmetic_modeattribute. Models exported with the retired experimental ABI must be re-exported.Companion ONNX Runtime GenAI integration: microsoft/onnxruntime-genai#2472
Validation
./build/cu130/Debug/onnxruntime_provider_test --gtest_filter='*GatedDeltaNet*'Performance and Quality
On H200, context 2048, generation 256, with five paired fresh-process repetitions per batch: