NSA compression: suppress aliased O1 store for static short queries - #599
Draft
mgoldfarb-nvidia wants to merge 1 commit into
Draft
NSA compression: suppress aliased O1 store for static short queries#599mgoldfarb-nvidia wants to merge 1 commit into
mgoldfarb-nvidia wants to merge 1 commit into
Conversation
Contributor
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
When the query extent is statically at most one 128-row MMA tile, flat_divide folds the residual tile stride to zero. The unconditional O1 TMA store then aliases O0 and overwrites valid output. Compile out only that aliased store while always consuming and releasing both correction pipeline stages. Dynamic and multi-tile extents retain the original store and wait sequence. Add JAX regression coverage at 127, 128, 129, and 300 rows.
mgoldfarb-nvidia
force-pushed
the
mgoldfarb/fix-nsa-compression-short-q
branch
from
August 14, 2026 20:42
6e63b5d to
376f7de
Compare
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.
Before submitting
pre-commit runand committed any formatting changes.cat-*, one or moremod-*, and oneorig-*. Maintainer action requested:cat-bug,mod-cutedsl, andorig-nv-eng; the contributor token cannot add upstream labels.Affected area
FE OSS kernels or CuTeDSL
Summary
Why
Each compression CTA processes two 128-row query tiles. When a statically specialized query extent contains only one tile,
flat_dividecanonicalizes the singleton residual tile mode to stride zero. The unconditional O1 TMA store therefore aliases O0 and overwrites valid output instead of remaining out of bounds.The guard checks the layout extent with
cute.is_staticand evaluates the tile-count condition withcutlass.const_expr. Dynamic extents and static multi-tile extents retain the original O1 store/wait path; only the static singleton specialization prunes the aliased store. Both correction pipeline handles are still consumed and released unconditionally.Related issues
None.
API and compatibility impact
None. This is a correctness fix for the SM100 NSA compression kernel and does not change its public API. The guard folds during tracing, so the dynamic path adds no runtime comparison or branch. The short static specialization removes one invalid TMA store and commit.
Testing
seqlen_q=128failed against the FP32 reference with max absolute error 0.27612305;seqlen_q=129passed.cd test/python && pytest -q fe_api/nsa/test_NSA_compression_attention_jax.py -m L0: 4 passed (127, 128, 129, 300).uvx pre-commit run --files python/cudnn/native_sparse_attention/compression/fmha.py test/python/fe_api/nsa/test_NSA_compression_attention_jax.py: passed.python3 -m py_compile python/cudnn/native_sparse_attention/compression/fmha.py test/python/fe_api/nsa/test_NSA_compression_attention_jax.py: passed.git diff --check: passed.