Skip to content

[8/9] Add experimental GDN prefill operand QAT - #2503

Draft
kaix-nv wants to merge 1 commit into
kaix/linear-attention-replayssm-servingfrom
kaix/linear-attention-qat-m2
Draft

kaix-nv wants to merge 1 commit into
kaix/linear-attention-replayssm-servingfrom
kaix/linear-attention-qat-m2

Conversation

@kaix-nv

@kaix-nv kaix-nv commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Merge order: 9 draft PRs

#3077 → #2519 → #3078 → #2657 → #2805 → #2788 → #2878 → #2503 → #2507

#2497 is already on main. Each PR is based on the preceding branch; #3077 is based on main.

What does this PR do?

Type of change: New feature.

Port the prefill study onto the current state-QAT interfaces. Expose left/right operand quantizers at the eight actual GDN chunk-64 algorithmic GEMMs. Provide per-row FP8 and block16 NVFP4 recipes; NVFP4 outer scales are isolated by chunk and head. The solve is exact FP32, and working arithmetic is FP32 with BF16 Q/K/V.

This profile runs full GDN prefill; it cannot compose with state or ReplaySSM QDQ in the same layer. KDA operand QAT is rejected because the previous pairwise gate-adjusted operand is not a native GEMM operand. Obsolete W-quantizer glue and study-specific training machinery are not ported.

This is training-time fake-QDQ emulation, with dynamic scales and no calibration pass. It supplies neither a native low-precision prefill kernel nor a speed or accuracy-recovery claim.

Usage

from modelopt.recipe import load_recipe
recipe = load_recipe("general/ptq/gdn_prefill_fp8_dynamic")
# NVFP4 alternative: general/ptq/gdn_prefill_nvfp4_dynamic

Use the Bridge example with the selected recipe. It retains the prompt label mask while the profile runs each sequence's full valid length through prefill. See the operand guide.

Testing

Restacked on main 580ffff1cddb9b20a38b7434e6290654ebf96a8f on 2026-10-27; this PR head is 6d10361e803565893019933b60f1a880e140c2d3.

  • Combined stack at 9f913d907c298efeb99daf84a7c32246cf38208a: 226 tests passed in 108.95 seconds, covering TensorQuantizer defaults/calibration/folding/restore, state policies, independent recurrence and gradient references, replay cache lifecycle, CUDA graphs, packed two-precision gradients, GDN operand QDQ and guarded inverse behavior. These are stack-tip results; intermediate heads were not all rerun separately.
  • Changed-file pre-commit checks passed (including Ruff, mypy and Bandit). The recipe checker was run separately with the installed Python environment; all eight changed complete recipes loaded successfully.
  • All nine parent links, signed commits, Python syntax and diff checks verified. Every rebuilt branch is free of the removed biased mode; released changelog entries are preserved.
  • Local environment: RTX A6000/SM86, PyTorch 2.9.1+cu128, Triton 3.5.1. The regular GPU tests use independent reference prefixes where native vLLM is unavailable. The vLLM 0.30 engine, supported Megatron/Bridge environment, FLA 0.5.2 on Hopper/Blackwell, and full-model accuracy were not rerun. These results are not new model-quality or throughput evidence.

Before your PR is "Ready for review"

  • Backward compatibility: opt-in; existing default behavior is retained.
  • Necessary tests: existing focused suites extended or retained; validation and environment limits listed above.
  • Dependencies: optional versions and setup are documented with the example; this restack adds no dependency.
  • Changelog: updated under 0.49; released 0.48 entries preserved.
  • Owner review and CI for the new head remain required. Keep draft.

@copy-pr-bot

copy-pr-bot Bot commented Sep 22, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@coderabbitai

coderabbitai Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@codecov

codecov Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 40.58824% with 101 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (kaix/linear-attention-replayssm-serving@f3826c0). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...opt/torch/quantization/linear_attention/prefill.py 10.22% 79 Missing ⚠️
...lopt/torch/quantization/linear_attention/matmul.py 65.95% 16 Missing ⚠️
...odelopt/torch/quantization/linear_attention/gdn.py 16.66% 5 Missing ⚠️
...opt/torch/quantization/plugins/linear_attention.py 87.50% 1 Missing ⚠️
Additional details and impacted files
@@                            Coverage Diff                             @@
##             kaix/linear-attention-replayssm-serving    #2503   +/-   ##
==========================================================================
  Coverage                                           ?   72.61%           
==========================================================================
  Files                                              ?      681           
  Lines                                              ?    77317           
  Branches                                           ?        0           
==========================================================================
  Hits                                               ?    56140           
  Misses                                             ?    21177           
  Partials                                           ?        0           
Flag Coverage Δ
unit 60.79% <40.58%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kaix-nv
kaix-nv removed this pull request from stack #2510 September 23, 2026 01:07
@kaix-nv
kaix-nv added this pull request to stack #2520 September 23, 2026 01:07
@kaix-nv
kaix-nv removed this pull request from stack #2520 September 23, 2026 01:08
@kaix-nv
kaix-nv force-pushed the kaix/linear-attention-qat-m2 branch from 86c4600 to bd1f350 Compare September 23, 2026 01:16
@kaix-nv kaix-nv changed the title [QAT] Add GDN prefill operand and arithmetic emulation [3/4] GDN/KDA prefill operand and arithmetic QAT Sep 23, 2026
@kaix-nv
kaix-nv changed the base branch from kaix/linear-attention-qat-m1 to kaix/linear-attention-decode-first September 23, 2026 01:16
@kaix-nv
kaix-nv added this pull request to stack #2521 September 23, 2026 01:22
@kaix-nv kaix-nv changed the title [3/4] GDN/KDA prefill operand and arithmetic QAT [4/5] GDN/KDA prefill operand and arithmetic QAT Sep 24, 2026
@kaix-nv
kaix-nv removed this pull request from stack #2521 September 24, 2026 06:17
@kaix-nv
kaix-nv added this pull request to stack #2542 September 24, 2026 06:18
@kaix-nv
kaix-nv force-pushed the kaix/linear-attention-qat-m2 branch from bd1f350 to 580c3dc Compare September 24, 2026 06:30
@kaix-nv
kaix-nv removed this pull request from stack #2542 September 24, 2026 06:31
@kaix-nv
kaix-nv changed the base branch from kaix/linear-attention-decode-first to kaix/linear-attention-vllm September 24, 2026 06:31
@kaix-nv
kaix-nv added this pull request to stack #2543 September 24, 2026 06:31
@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://NVIDIA.github.io/Model-Optimizer/pr-preview/pr-2503/

Built to branch gh-pages at 2026-10-28 06:02 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@kaix-nv
kaix-nv force-pushed the kaix/linear-attention-qat-m2 branch 2 times, most recently from 207e918 to 2dd8c1d Compare September 25, 2026 01:54
@kaix-nv
kaix-nv force-pushed the kaix/linear-attention-qat-m2 branch from 2dd8c1d to 3f42ee9 Compare September 25, 2026 04:26
@kaix-nv
kaix-nv removed this pull request from stack #2658 October 8, 2026 18:41
@kaix-nv
kaix-nv added this pull request to stack #2714 October 8, 2026 18:41
@kaix-nv kaix-nv changed the title [6/7] GDN/KDA prefill operand and arithmetic QAT [5/6] GDN/KDA prefill operand and arithmetic QAT Oct 8, 2026
@kaix-nv
kaix-nv removed this pull request from stack #2714 October 14, 2026 06:28
@kaix-nv
kaix-nv added this pull request to stack #2789 October 14, 2026 06:29
@kaix-nv kaix-nv changed the title [5/6] GDN/KDA prefill operand and arithmetic QAT [6/7] GDN/KDA prefill operand and arithmetic QAT Oct 14, 2026
@kaix-nv
kaix-nv removed this pull request from stack #2789 October 14, 2026 20:18
@kaix-nv
kaix-nv added this pull request to stack #2806 October 14, 2026 20:19
@kaix-nv kaix-nv changed the title [6/7] GDN/KDA prefill operand and arithmetic QAT [7/8] GDN/KDA prefill operand and arithmetic QAT Oct 14, 2026
@kaix-nv kaix-nv changed the title [7/8] GDN/KDA prefill operand and arithmetic QAT [7/9] GDN/KDA prefill operand and arithmetic QAT Oct 19, 2026
@kaix-nv
kaix-nv removed this pull request from stack #2806 October 19, 2026 22:19
@kaix-nv
kaix-nv changed the base branch from kaix/linear-attention-vllm to kaix/linear-attention-replayssm-serving October 19, 2026 22:19
@kaix-nv
kaix-nv added this pull request to stack #2879 October 19, 2026 22:19
@kaix-nv kaix-nv changed the title [7/9] GDN/KDA prefill operand and arithmetic QAT [9/10] GDN/KDA prefill operand and arithmetic QAT Oct 19, 2026
@kaix-nv
kaix-nv force-pushed the kaix/linear-attention-qat-m2 branch from bd2be2b to 6d10361 Compare October 28, 2026 05:56

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants