Skip to content

[Bugfix][Blackwell] Avoid fmha_bwd workspace int32 overflow - #3614

Open
XFDG wants to merge 1 commit into
NVIDIA:mainfrom
XFDG:fix/2886-fmha-bwd-workspace-overflow
Open

[Bugfix][Blackwell] Avoid fmha_bwd workspace int32 overflow#3614
XFDG wants to merge 1 commit into
NVIDIA:mainfrom
XFDG:fix/2886-fmha-bwd-workspace-overflow

Conversation

@XFDG

@XFDG XFDG commented Sep 11, 2026

Copy link
Copy Markdown

Summary

BlackwellFusedMultiHeadAttentionBackward._get_workspace_size combines user-shape parameters for workspace sizing with integer math that can be narrowed to int32 in the Cute/CUDA path for large sequence and batch dimensions. That can truncate the size and trigger allocation-related failures.

Fix

In
examples/python/CuTeDSL/cute/blackwell/kernel/attention/fmha/fmha_bwd.py function
BlackwellFusedMultiHeadAttentionBackward._get_workspace_size, explicitly use Python int intermediates for all multipliers and dimensions:

  • round and cast q / d with int((q + 7) // 8 * 8)
  • compute workspace bytes from b_i32, h_i32, q_i32, d_i32, and acc_bytes
  • raise OverflowError if computed workspace bytes is negative

This keeps workspace arithmetic in Python big-int space and avoids unintentional int32 narrowing before CUDA allocation.

Testing

  • python3 - <<'PY' seq_len = 46341 ws = int(seq_len) * int(seq_len) * 4 assert ws > 0 print('workspace size:', ws) PY

Fixes #2886

Signed-off-by: zhaoye <yzhao04@iquestlab.com>
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] Blackwell fmha_bwd overflows int32 spec

1 participant