Skip to content

Export compact GatedDeltaNet state updates for Qwen3.5/3.8 - #2453

Merged
Tianlei Wu (tianleiwu) merged 10 commits into
mainfrom
tlwu/qwen_gdn_production_export
Aug 28, 2026
Merged

Export compact GatedDeltaNet state updates for Qwen3.5/3.8#2453
Tianlei Wu (tianleiwu) merged 10 commits into
mainfrom
tlwu/qwen_gdn_production_export

Conversation

@tianleiwu

@tianleiwu Tianlei Wu (tianleiwu) commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

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

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)

@tianleiwu
Tianlei Wu (tianleiwu) force-pushed the tlwu/qwen_gdn_production_export branch from 0ffd128 to a9a4300 Compare August 27, 2026 07:42
@tianleiwu Tianlei Wu (tianleiwu) changed the title Add production GatedDeltaNet export for Qwen3.5/3.8 Export compact GatedDeltaNet state updates for Qwen3.5/3.8 Aug 27, 2026
Comment thread src/python/py/models/builders/base.py Fixed
@tianleiwu
Tianlei Wu (tianleiwu) marked this pull request as ready for review August 27, 2026 08:49
@tianleiwu
Tianlei Wu (tianleiwu) requested a review from a team as a code owner August 27, 2026 08:49
Copilot AI lite review requested due to automatic review settings August 27, 2026 08:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Python model builder to export Qwen3.5/3.8 hybrid linear-attention layers using packed varlen contrib ops and to optionally emit compact state-transition updates (conv values + GatedDeltaNet capsules) for speculative tokens, while keeping the existing state_groups schema unchanged.

Changes:

  • Add builder support for VarlenCausalConvWithState and packed GatedDeltaNet with optional compact state-update outputs.
  • Introduce Qwen3.5/3.8 extra options linear_attn_op and state_update_capacity, including validation and I/O shape/type rewiring for paged exports.
  • Extend docs and tests to cover compact state-update behavior and the removal of legacy checkpoint outputs.

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
test/python/builder/test_decoder_state_groups.py Adds targeted unit tests validating packed varlen op wiring, compact-update enable/disable behavior, and option validation.
src/python/py/models/README.md Documents compact state updates for Qwen3.5/3.8 and how to enable them via --extra_options.
src/python/py/models/builders/qwen.py Implements Qwen builder option parsing/validation, configures compact-update I/O, and routes linear-attention layers to packed/dense GatedDeltaNet paths.
src/python/py/models/builders/base.py Adds builder emission helpers for VarlenCausalConvWithState, dense GatedDeltaNet, and packed GatedDeltaNet with compact capsule outputs.
src/python/py/models/builder.py Updates CLI --extra_options help text to describe linear_attn_op, state_update_capacity, and updated state_window semantics.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/python/py/models/builders/base.py Outdated
@tianleiwu

Copy link
Copy Markdown
Contributor Author

/azp run Integration Tests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@tianleiwu

Copy link
Copy Markdown
Contributor Author

/azp run Integration Tests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@tianleiwu
Tianlei Wu (tianleiwu) force-pushed the tlwu/qwen_gdn_production_export branch from f3f59d9 to ebbfd4c Compare August 28, 2026 01:40
Comment thread src/python/py/models/builders/qwen.py
Comment thread src/python/py/models/builders/qwen.py
Comment thread src/python/py/models/builders/qwen.py
Comment thread src/python/py/models/builders/qwen.py Outdated
Comment thread src/python/py/models/builders/qwen.py
Comment thread src/python/py/models/builders/base.py Outdated
Comment thread src/python/py/models/builders/base.py Outdated
Comment thread src/python/py/models/builders/base.py
Comment thread src/python/py/models/builder.py Outdated
Comment thread src/config.h Outdated
Separate Qwen layer construction from the generic GatedDeltaNet emitter, document compact state options, and cover the disabled ABI.
@tianleiwu
Tianlei Wu (tianleiwu) force-pushed the tlwu/qwen_gdn_production_export branch 2 times, most recently from e8a70d1 to 14d9c2c Compare August 28, 2026 18:44
@tianleiwu
Tianlei Wu (tianleiwu) force-pushed the tlwu/qwen_gdn_production_export branch from 14d9c2c to adc6898 Compare August 28, 2026 18:45
@tianleiwu
Tianlei Wu (tianleiwu) enabled auto-merge (squash) August 28, 2026 19:44
@tianleiwu
Tianlei Wu (tianleiwu) merged commit 3feedff into main Aug 28, 2026
62 of 64 checks passed
Tianlei Wu (tianleiwu) added a commit 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants