Support SM80 (Ampere) with dual-arch build - #33
Open
Leslie360 wants to merge 1 commit into
Open
Conversation
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.
FlashKDA SM80 (Ampere) Support
Summary
Add SM80 (Ampere/A800) support to FlashKDA via a dual-architecture build. The existing SM90+ TMA path is preserved unchanged; a new cooperative-copy path is added under
csrc/sm80/.chunk_kda: ~6.13 msDesign
csrc/sm80/: new SM80 cooperative-copy implementation (no TMA, no cluster barriers)csrc/smxx/: existing SM90+ TMA implementation (unchanged)setup.py: buildsflash_kda_C_sm80andflash_kda_C_sm90as separate extensions based onFLASH_KDA_CUDA_ARCHSflash_kda/__init__.py: runtime dispatch bytorch.cuda.get_device_capability()csrc/flash_kda.cpp:dispatch_fwdselectsflash_kda::sm80::launch_fwdorflash_kda::sm90::launch_fwd; each extension is compiled withFLASH_KDA_SM80_ONLY/FLASH_KDA_SM90_ONLYSM80-Specific Optimizations
cp.asyncpipeline in K2 to hide gmem latencycoop_copy_2d_vec8/coop_copy_1d_vec4, 16B per thread-op)SharedStorageK2specialized onStateFP32: the 64 KB fp32 conversion scratch is only reserved when the state dtype is actually fp32; the bf16 path uses 71.2 KB smem (→ 2 CTA/SM on A800) instead of ~96 KBkK2InputStages = 2,kK2OutputStages = 1)__launch_bounds__adjusted from(256, 8)to(256, 4); ptxas reports 0 spillsBenchmark
See
BENCHMARK_A800.mdfor full data.Kernel breakdown (PyTorch Profiler): K2 recurrence 2.35 ms (58.8%), K1 prepare 1.63 ms (40.8%).
chunk_gated_delta_ruleis included as a reference only; it implements Gated DeltaNet (scalar per-head gate), not KDA.Correctness
tests/test_fwd.py: 4 passed (test_fwd,test_fwd_varlen,test_fwd_vs_fla,test_fwd_varlen_vs_fla)torch_reffor tested shapes.chunk_kda: err_ratio ≈ 3–5e-3 (bf16 noise level).Build Notes
FLASH_KDA_CUDA_ARCHS=auto/80/80,90averified on A800 (CUDA 12.2).FLASH_KDA_CUDA_ARCHS=allrequires CUDA 12.9+ forcompute_100a; not verified in the current environment.Files Changed
setup.pyREADME.mdcsrc/flash_kda.cppcsrc/fwd.hflash_kda/__init__.pycsrc/sm80/(new)BENCHMARK_A800.md(new)