Conversation
Signed-off-by: Kai Xu <kaix@nvidia.com>
|
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. |
This was referenced Sep 22, 2026
kaix-nv
added this pull request to stack #2510
September 22, 2026 21:27
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueComment |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## kaix/linear-attention-qat-m2 #2506 +/- ##
================================================================
+ Coverage 70.49% 70.51% +0.01%
================================================================
Files 612 615 +3
Lines 67875 68025 +150
================================================================
+ Hits 47850 47969 +119
- Misses 20025 20056 +31
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
kaix-nv
removed this pull request from stack #2510
September 23, 2026 01:07
Contributor
|
This was referenced Sep 23, 2026
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.
Superseded: KDA prefill is now included in #2503, after the shared GDN/KDA decode infrastructure in #2519. This closed PR and its branch retain the original review and qualification history.
What does this PR do?
Type of change: New feature, new example, new tests, documentation.
Adds experimental training-time numerical emulation to FLA 0.5.1 KimiDeltaAttention. ModelOpt conversion creates disabled-by-default KDA state/W and eight prefill operand-site controls. Enabling a policy routes the existing layer through differentiable FP32 materialized prefill with dynamic FP8 or NVFP4 QDQ; disabling all controls preserves the original FLA forward. This is stacked on #2503.
KDA uses per-key-channel retention. Causal pairwise exponentials are computed from prefix differences, avoiding an overflowing inverse-decay factorization. The adapter retains the model's projections, short convolution, gate formulas, and normalization, and preserves gradients and saved numerical policies. Invocation-local dispatch also works for copied modules without changing global FLA functions.
A pinned public checkpoint/WikiText runner records matched pre/post-training NLL, token hashes, source hashes, optimizer updates, and time/memory. The exact solve remains the default. Approximate inverse and decode/replay training are subsequent milestones.
Usage
Install the example's pinned FLA dependencies only when using this adapter. Core ModelOpt imports do not require FLA.
Testing
Revision:
e3987d01bb2b54188bb18165b478972a101ac54e(signed). Remote staged source hashes matched the implementation.arcee-ai/AFM-4.5B-Base-KDA-Onlyat01ad2e06ee4f1214193c17b69e09105a9b257e80, WikiText-2 raw revisionb08601e04326c79dfdd32d625aee71d232d685c3. All checkpoint keys loaded, all trainable attention gradients were finite, and an optimizer update changed query weights. Runs used identical token hashes/seed, one 128-token training step and four validation blocks (512 predicted tokens), attention-only FP32 AdamW under BF16 autocast with activation checkpointing.These are one-step integration results, not evidence of quality recovery. The model payload has 36 KDA layers; configuration and weight index were checked rather than relying on the model-card layer count. Original FP32 gate parameters are preserved during loading.
H100 environment: NeMo 26.08, Torch 2.13.0a0+8145d630e8.nv26.06, CUDA 13.3, Triton 3.7, FLA/core 0.5.1, Transformers 4.57.1, TileLang 0.1.8, TVM-FFI 0.1.9, Megatron-Core 0.19.1, Transformer Engine 2.18.0. Numerical qualification excludes TF32.
Measured KDA training overhead
One H100, shape
[1,1024,4,64], BF16 Q/K/V, FP32 working math, TF32 off. Three warmups and 20 interleaved trials; median times and paired wall ratios. Extra memory is peak tensor allocation above the pre-forward baseline. Compilation is excluded; samples and source hashes retained.The per-channel interaction tensors account for substantial materialization cost. This is an explicit numerical research path, with no speed claim.
The model-study command and pinned dependencies are in
examples/llm_qat/linear_attention/README.md; run once with no quant config, once withkda_exact_matmul.json, and once withkda_prefill_fp8.json.Before your PR is "Ready for review"
CONTRIBUTING.md: ✅ Uses existing optional FLA APIs; example dependencies are permissively licensed and pinned where needed. No new mandatory core dependency.Additional Information
The materialized path is a numerical research implementation. It does not claim native low-precision execution, serving acceleration, or model-quality recovery. Qualification uses FLA's general gate path; the optional safe_gate TensorCore rounding is not emulated. CP, recurrent inference, and FLA intermediate/recompute flags are rejected. FLA selects recurrent inference for evaluation sequences of at most 64 tokens; these QAT prefill studies use longer sequences.