Skip to content

[5/9] Add request-local NVFP4 recurrent-state QAT - #2805

Draft
kaix-nv wants to merge 1 commit into
kaix/linear-attention-qat-examplefrom
kaix/linear-attention-state-nvfp4
Draft

kaix-nv wants to merge 1 commit into
kaix/linear-attention-qat-examplefrom
kaix/linear-attention-state-nvfp4

Conversation

@kaix-nv

@kaix-nv kaix-nv commented Oct 14, 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.

Add dynamic NVFP4 state fake QDQ through TensorQuantizer: E2M1 values, 16-value blocks and E4M3 block scales. The outer amax is computed separately for each request and head, so unrelated scheduled requests cannot alter a sequence's quantized state. Training and ordinary serving share this boundary.

The recipe leaves model weights and other activations unchanged and uses identity STE. It requires no calibration pass. Storage remains floating point; this is not packed-state compression or a serving-speed claim.

Usage

from modelopt.recipe import load_recipe
recipe = load_recipe("general/ptq/linear_attention_state_nvfp4_dynamic")
# Apply recipe.quantize to a supported model and use linear_attention_training_phase.

Testing

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

  • 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 Oct 14, 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 Oct 14, 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 Oct 14, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 57.14286% with 3 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (kaix/linear-attention-qat-example@6a2f0f6). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...elopt/torch/quantization/linear_attention/utils.py 57.14% 3 Missing ⚠️
Additional details and impacted files
@@                         Coverage Diff                          @@
##             kaix/linear-attention-qat-example    #2805   +/-   ##
====================================================================
  Coverage                                     ?   73.12%           
====================================================================
  Files                                        ?      674           
  Lines                                        ?    76627           
  Branches                                     ?        0           
====================================================================
  Hits                                         ?    56032           
  Misses                                       ?    20595           
  Partials                                     ?        0           
Flag Coverage Δ
unit 61.21% <57.14%> (?)

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.

@github-actions

github-actions Bot commented Oct 14, 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-2805/

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

@kaix-nv kaix-nv changed the title [4/8] Add dynamic NVFP4 recurrent-state QAT [4/9] Add dynamic NVFP4 recurrent-state QAT Oct 19, 2026
@kaix-nv
kaix-nv removed this pull request from stack #2806 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 [4/9] Add dynamic NVFP4 recurrent-state QAT [4/10] Add dynamic NVFP4 recurrent-state QAT Oct 19, 2026
@kaix-nv
kaix-nv force-pushed the kaix/linear-attention-state-nvfp4 branch from fa97dd3 to f78b7a9 Compare October 28, 2026 05:56
@kaix-nv
kaix-nv removed this pull request from stack #2879 October 28, 2026 05:58
@kaix-nv kaix-nv changed the title [4/10] Add dynamic NVFP4 recurrent-state QAT [5/9] Add request-local NVFP4 recurrent-state QAT Oct 28, 2026
@kaix-nv
kaix-nv added this pull request to stack #3079 October 28, 2026 06:01
@kaix-nv
kaix-nv force-pushed the kaix/linear-attention-state-nvfp4 branch from f78b7a9 to e2a9923 Compare November 17, 2026 01:08

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.

1 participant