Repository navigation
Conversation
yooooo00
requested review from
kisnwangg,
liuchongming74,
suteng,
yangzhenzhang02 and
yaoyifanx
as code owners
November 20, 2026 09:08
…chemes in CSA2 family
yooooo00
force-pushed
the
feat/csa2-quant-primitives
branch
from
November 25, 2026 08:59
b61d6f7 to
2bac04f
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.
Paired: GitHub #1641 ↔ GitCode !2010
Summary
Following the merge of PR #1606 (
CompressedSparseAttention2Module Family), this PR unifies the CSA2 quantization primitives and theCompressedSparseAttention2Module Family low-precision integration into a single clean feature commit for single-card (TP=CP=PP=1,EP>=1) training:LowPrecisionCompressedSparseAttention2Module(CompressedSparseAttention2Module)and registers"precision": SelectorSpec(str, "inherit")with explicitlow_precision_reference/low_precision_fusedrules inCompressedSparseAttention2'sModuleFamilyallowlist (variant_rules), keeping baselineCompressedSparseAttention2Modulepure floating-point math and leavingCPCompressedSparseAttention2untouched for follow-up CP expansion.DEFAULT_LINEAR_ALLOWLIST(q_a_proj,q_b_proj,kv_proj,o_b_proj,compressor.wkv,compressor.wgate,indexer.q_b_proj,indexer.wk) and delegates internal 2D projection replacement to theLinearModule Family (MXFP8andHiFloat8vialinear_dtype_scheme), while explicitly preservingo_a_proj(3D groupedtorch.bmm) andindexer.weights_proj(small head-merge gate) inBF16.CSA2IndexerQKFormat,CSA2MainKVFormat, andCSA2SWAKVFormattoLowPrecisionConfig(indexer_qk,main_kv,swa_kv).CSA2CacheTensor(QuantizedTensorphysicaluint8packed storage without floating shadow copies) with full-bankdequantize(), sparse row-selecteddequantize_selected(indices)for reference Indexer KL teacher reads, and straight-through estimator (STE) gradients.MainKVCacheQATStrategy(FP4 E2M1+ group-16E4M3/E8M7scales),SWAKVQATStrategy(FP8 E4M3+ group-32E8M0/E8M7scales), andMXFP4FakeQuantPolicy(OCP MXFP4query QDQ + single-encode Full-layerIndexer Kpacked cache)."hif8"(replace_hif8_linear) inLinearModule Family and adds0-Tokenempty-slice short-circuit protection inLinearStrategyforward/backward.sparse_flash_mla_grad_metadataand pure-SWAcmp_mask_mode=0handling insparse_flash_mla.py.Verification
pytestacrosstests/ut/components/quantization/,test_shared_compressed_dsa_attention.py,test_csa2_recompute_contract.py,test_sparse_lightning_indexer_kl_loss_grad.py,test_linear_family.py,test_family_import_compatibility.py,test_module_build.py,test_replacement_initialization.py, andtest_import_boundaries.py: all passed.scripts/pre-commit/run_pylint.py, incrementalscripts/pre-commit/run_lizard.py, and.agent/scripts/check_agents_catalog.py: 0 findings.tests/ut/components/quantization/test_width_matrix.py(TestWidthMatrixNPU): 6 passed (13 subtests passed).tests/torch/expert_parallel/test_linear_family.py: 1 passed.DeepseekV41ForCausalLM(SWA-only,Full,Reindex,Reuseroles) end-to-end training smoke acrossMXFP8/HiFloat8×use_fused_ops=False/True+e8m7scales: all 5 configurations passed with finite decreasing losses and verified allowlistedLowPrecisionLinearreplacements.