Skip to content

[Example 77] FMHA bwd: free Tensor Memory only after the Mma and Reduce warps are done - #3939

Open
yunweili3 wants to merge 1 commit into
NVIDIA:mainfrom
yunweili3:fix-3935-fmha-bwd-tmem-free
Open

yunweili3 wants to merge 1 commit into
NVIDIA:mainfrom
yunweili3:fix-3935-fmha-bwd-tmem-free

Conversation

@yunweili3

Copy link
Copy Markdown
Contributor

Fixes #3935

In sm100_fmha_bwd_kernel_tma_warpspecialized.hpp the Compute warps meet at EpilogueBarrier among themselves and then free all of Tensor Memory. The Mma warp still issues the dQ MMAs of the last tile after that point, and the Reduce warps still load that dQ from Tensor Memory, so the free can come before the last use.

With this change the Mma warp and the Reduce warps arrive at EpilogueBarrier when they are done, and the Compute warps wait there for all 13 warps before the free.

Tested on B200 (CUDA 13.1), 77_blackwell_fmha_bwd_fp16 --verify, default problem, GPU shared with one other process, 10 runs per cell, with the issue's delay (Reduce warps held back before their last load of dQ):

main this fix
no delay 10/10 pass 10/10 pass
200 µs 10/10 failed dQ 10/10 pass
1 ms 10/10 failed dQ 10/10 pass
20 ms 10/10 pass
  • The example's bwd test set (basic, causal, varlen 00–14, MLA basic/varlen) passes for fp16 and fp8: 20/20 each.
  • Speed is unchanged: 685–695 TFLOPS/s on main, 687–691 with the fix (default problem, 5 alternating runs).

…ce warps are done

The Compute warps met at EpilogueBarrier among themselves and then freed all
of Tensor Memory. The Mma warp still issues the dQ MMAs of the last tile
after the commit the Compute warps wait for, and the Reduce warps still load
that dQ from Tensor Memory, so the free could come before the last use.

Now the Mma warp and the Reduce warps arrive at EpilogueBarrier when they
are done, and the Compute warps wait there for all 13 warps before the free.

Fixes NVIDIA#3935

This branch has not been deployed

No deployments
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.

[BUG] Example 77 FMHA backward (sm100): the Compute warps free Tensor Memory while the Mma and Reduce warps still use it

1 participant