Skip to content

[NVIDIA][CuTe,Fwd,sm120] Fix use_tma_O crash on SM120 (issue #2649) - #2655

Closed
johnnynunez wants to merge 2 commits into
Dao-AILab:mainfrom
johnnynunez:fix/sm120-use-tma-o-2649
Closed

johnnynunez wants to merge 2 commits into
Dao-AILab:mainfrom
johnnynunez:fix/sm120-use-tma-o-2649

Conversation

@johnnynunez

Copy link
Copy Markdown
Contributor

Summary

Fixes #2649. On SM120 (Blackwell GeForce / RTX PRO 6000 / DGX Spark) the CuTe-DSL forward kernel is currently unusable — every call crashes with:

AttributeError: 'NoneType' object has no attribute '_trait'
  in cpasync.tma_partition (flash_fwd.py epilogue O-store)

Root cause

FlashAttentionForwardSm120 inherits the forward __call__, which sets:

self.use_tma_O = self.arch >= Arch.sm_90

This enables the TMA-based O-store epilogue for SM120. But SM120 does not build the TMA store atom (tma_atom_O is None), because it lacks the WGMMA-era TMA-store epilogue path. The first tma_partition on the null atom raises the AttributeError.

Fix

Restrict the TMA O-store to sm_90 .. sm_119:

self.use_tma_O = Arch.sm_90 <= self.arch < Arch.sm_120

SM120 then falls back to the register→gmem O store already used by the SM80 path, which is what the CpAsync SM120 kernel expects.

Testing

Verified on RTX PRO 6000 Blackwell (sm_120, cc 12.0), torch 2.12.0+cu130, nvidia-cutlass-dsl 4.5.2:

  • Before: every SM120 forward call raises the AttributeError above.
  • After: forward runs and matches PyTorch SDPA reference (bf16), max abs error:
    • hdim=64 non-causal: 1.3e-3
    • hdim=96 non-causal: 1.1e-3
    • hdim=128 causal: 8.1e-3

One-line behavioral change; no effect on sm80/sm90/sm100 paths.

@johnnynunez johnnynunez changed the title [CuTe,Fwd,sm120] Fix use_tma_O crash on SM120 (issue #2649) [NVIDIA][CuTe,Fwd,sm120] Fix use_tma_O crash on SM120 (issue #2649) Jun 15, 2026
@thad0ctor

Copy link
Copy Markdown
Contributor

#2634 disables the broken SM80-base TMA-O path for SM120, though with a broader self.use_tma_O = False approach in the SM80-base path.

On SM120 (Blackwell GeForce / RTX PRO 6000 / DGX Spark) the forward kernel set
`use_tma_O = self.arch >= Arch.sm_90`, enabling the TMA-based O-store epilogue.
But SM120 does not build the TMA store atom (tma_atom_O is None), so any forward
call crashes in cpasync.tma_partition with:

    AttributeError: 'NoneType' object has no attribute '_trait'

This makes the CuTe-DSL forward unusable on every SM120 GPU.

Restrict the TMA O-store to sm_90..sm_119, which is where the WGMMA-era epilogue
path is actually available:

    self.use_tma_O = Arch.sm_90 <= self.arch < Arch.sm_120

SM120 falls back to the non-TMA register->gmem O store (already used for the
SM80 path), which is correct and what the CpAsync SM120 kernel expects.

Verified on RTX PRO 6000 Blackwell (sm_120, cc 12.0), torch 2.12.0+cu130,
nvidia-cutlass-dsl 4.5.2: forward now runs and matches PyTorch SDPA reference
for hdim 64/96/128, causal and non-causal (max abs err <= 8e-3 in bf16). Before
this fix every SM120 forward call raised the AttributeError above.
@johnnynunez
johnnynunez force-pushed the fix/sm120-use-tma-o-2649 branch from 61fa553 to e1e9ed0 Compare June 28, 2026 18:08
The functional use_tma_O guard already landed via Dao-AILab#2656; this branch now
carries only the explanatory comment for the sm_120 TMA-O restriction
(issue Dao-AILab#2649).
@johnnynunez
johnnynunez requested a review from v0i0 July 7, 2026 09:57
@johnnynunez johnnynunez closed this Jul 7, 2026
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.

FlashAttentionForwardSm120: use_tma_O incorrectly True on SM_121 → AttributeError on tma_atom_O=None

3 participants