Skip to content

[6/9] Add ReplaySSM QAT and its in-repo serving backend - #2788

Draft
kaix-nv wants to merge 2 commits into
kaix/linear-attention-state-nvfp4from
kaix/linear-attention-replayssm
Draft

kaix-nv wants to merge 2 commits into
kaix/linear-attention-state-nvfp4from
kaix/linear-attention-replayssm

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 two-precision GDN ReplaySSM training and serving with an FP32 recurrence anchor, FP8 or NVFP4 read values, and a fixed 16-token replay window. Read QDQ is independent of recurrence updates; backward uses the window adjoint and STE through the sampled read values.

The in-repository Triton backend, cache lifecycle and worker land together here, so this PR runs without the undeclared external emulation package. NVFP4 outer scales are local to each request and head, partial value tiles are covered, and cache offsets widen to int64 before page-stride multiplication. Nearest and unbiased stochastic NVFP4 reads are supported; the biased mode is removed.

The worker requires an explicit recipe and checks saved policies. The ordinary FakeQuantWorker rejects this profile. Two-precision tests use an independent Torch oracle and do not skip when vLLM is absent. The separate legacy INT8/Hadamard profile still has its own optional fork dependency.

This is floating-storage numerical emulation, not packed low-bit cache compression. K=128 is required. Engine qualification beyond one active request and full-model quality remain follow-up work.

Usage

from modelopt.recipe import load_recipe
recipe = load_recipe("general/ptq/gdn_replayssm_nvfp4_read")
# Use recipe.quantize with the state-QAT training phase; FP8 uses gdn_replayssm_fp8_read.

For serving, use examples/vllm_serve/replayssm_worker.py with the same explicit recipe. Complete launch settings are in REPLAYSSM.md.

Testing

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

  • 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 7.47863% with 433 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.72%. Comparing base (f78b7a9) to head (2effab8).

Files with missing lines Patch % Lines
...elopt/torch/quantization/plugins/vllm_replayssm.py 0.00% 116 Missing ⚠️
...kernels/quantization/linear_attention/replayssm.py 0.00% 107 Missing ⚠️
...ch/quantization/linear_attention/_two_precision.py 21.00% 79 Missing ⚠️
...s/quantization/linear_attention/replayssm_cache.py 0.00% 67 Missing ⚠️
...ls/quantization/linear_attention/replayssm_read.py 0.00% 44 Missing ⚠️
...pt/torch/quantization/linear_attention/training.py 9.09% 10 Missing ⚠️
...opt/torch/kernels/quantization/common/fp8_quant.py 0.00% 6 Missing ⚠️
...lopt/torch/quantization/linear_attention/decode.py 33.33% 2 Missing ⚠️
...ls/quantization/linear_attention/serving/replay.py 0.00% 1 Missing ⚠️
...odelopt/torch/quantization/linear_attention/gdn.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@                          Coverage Diff                          @@
##           kaix/linear-attention-state-nvfp4    #2788      +/-   ##
=====================================================================
- Coverage                              73.12%   72.72%   -0.40%     
=====================================================================
  Files                                    674      679       +5     
  Lines                                  76627    77088     +461     
=====================================================================
+ Hits                                   56032    56064      +32     
- Misses                                 20595    21024     +429     
Flag Coverage Δ
unit 60.87% <7.47%> (-0.34%) ⬇️

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 force-pushed the kaix/linear-attention-replayssm branch from 291b2c1 to bd91f22 Compare October 14, 2026 20:17
@kaix-nv
kaix-nv removed this pull request from stack #2789 October 14, 2026 20:18
@kaix-nv
kaix-nv changed the base branch from kaix/linear-attention-qat-example to kaix/linear-attention-state-nvfp4 October 14, 2026 20:19
@kaix-nv
kaix-nv added this pull request to stack #2806 October 14, 2026 20:19
@kaix-nv kaix-nv changed the title [4/7] ReplaySSM state QAT and two-precision design [5/8] ReplaySSM state QAT and two-precision design Oct 14, 2026
@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-2788/

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

@kaix-nv kaix-nv changed the title [5/8] ReplaySSM state QAT and two-precision design [5/8] ReplaySSM state QAT and two-precision GDN Oct 15, 2026
@kaix-nv kaix-nv changed the title [5/8] ReplaySSM state QAT and two-precision GDN [5/9] ReplaySSM state QAT and two-precision GDN Oct 19, 2026
@kaix-nv
kaix-nv force-pushed the kaix/linear-attention-replayssm branch from be18a1f to 4fc6028 Compare October 19, 2026 22:19
@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-state-nvfp4 to kaix/tensor-quantizer-rounding 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 [5/9] ReplaySSM state QAT and two-precision GDN [6/10] ReplaySSM state QAT and two-precision GDN Oct 19, 2026
@kaix-nv
kaix-nv force-pushed the kaix/linear-attention-replayssm branch from 4fc6028 to 6c0a9f2 Compare October 23, 2026 21:50
@kaix-nv
kaix-nv force-pushed the kaix/linear-attention-replayssm branch from 6c0a9f2 to 2effab8 Compare October 28, 2026 05:56
Base automatically changed from kaix/tensor-quantizer-rounding to main 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 [6/10] ReplaySSM state QAT and two-precision GDN [6/9] Add ReplaySSM QAT and its in-repo serving backend Oct 28, 2026
@kaix-nv
kaix-nv changed the base branch from main to kaix/linear-attention-state-nvfp4 October 28, 2026 06:01
@kaix-nv
kaix-nv added this pull request to stack #3079 October 28, 2026 06:01
Record forward BF16 operands and FP16 read updates for the STE adjoint. Strengthen native forward, recurrence-anchor and independent triangular-solve gradient regression coverage.

Signed-off-by: Kai Xu <[email protected]>
@kaix-nv
kaix-nv force-pushed the kaix/linear-attention-replayssm branch from 2effab8 to 846521e 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