Skip to content

Map top-left map to bottom-right for self-attn - #3939

Closed
Micky774 wants to merge 1 commit into
mainfrom
zain/tl-br-sym
Closed

Micky774 wants to merge 1 commit into
mainfrom
zain/tl-br-sym

Conversation

@Micky774

@Micky774 Micky774 commented Jun 25, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

gfx1250 only has kernels which support bottom-right masking. In the case of s_q=s_kv we have that bottom-right = top-left masking. This mirrors a similar symmetry already in place for gfx942.

Technical Details

Test Plan

Tested by building w/ TE and applying to E2E models.

Test Result

The E2E model succeeds.

Submission Checklist

@Micky774
Micky774 requested review from a team and Copilot June 25, 2026 21:23
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter op tests (gfx942 + gfx950)
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
ci:triton-300x Run an additional Triton test job on MI300X in PRs; main branch always runs both MI35X and MI300X
ci:sglang SGLang integration tests: DeepSeek-R1-MXFP4 accuracy, Qwen 3.5 accuracy
ci:atom ATOM benchmark: DeepSeek-R1-0528, GPT-OSS-120B
ci:atom_full ATOM accuracy suite for PR and main models from ATOM models_accuracy.json
ci:vllm vLLM benchmark: GPT-OSS-120B, DeepSeek-R1-0528, Kimi-K2.5
ci:all All standard extended tests (excludes ci:atom_full)

Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 3939 --add-label <label>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the FMHA v3 backward ASM kernel selection to handle gfx1250’s limited causal-mask kernel availability by remapping an equivalent causal mask in the self-attention (square) case, aligning with an existing symmetry already used for gfx942.

Changes:

  • For arch_id == "gfx1250", remap mask_type from top-left (1) to bottom-right (2) when seqlen_q == seqlen_k so existing gfx1250 causal BWD kernels can be selected.
  • Keep the existing gfx942 square-seqlen remap logic (2 → 1) and apply the analogous inverse remap for gfx1250.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Micky774

Copy link
Copy Markdown
Contributor Author

@yzhou103 gentle ping to see if this PR could get a review -- thanks!

@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

No activity for 15 days, so this is now labelled stale. A push or a comment clears it; keep-open exempts it.

@github-actions github-actions Bot added the stale The PR hasn't been updated in 2 weeks label Oct 7, 2026
@Micky774

Micky774 commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

@yzhou103 @zufayu ping for review, thanks

@github-actions github-actions Bot removed the stale The PR hasn't been updated in 2 weeks label Oct 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

No activity for 15 days, so this is now labelled stale. A push or a comment clears it; keep-open exempts it. Nothing is closed automatically.

@github-actions github-actions Bot added the stale The PR hasn't been updated in 2 weeks label Oct 27, 2026
@zufayu
zufayu requested review from shay-li77 and removed request for yzhou103 October 27, 2026 06:36
@github-actions github-actions Bot removed the stale The PR hasn't been updated in 2 weeks label Oct 28, 2026
@shay-li77

Copy link
Copy Markdown
Contributor

@Micky774 Sorry this sat for so long. main now has the same remap: #6454 (Oct 16) added the gfx1250 mt == 1 → 2 conversion in csrc/cpp_itfs/mha_bwd.cu when seqlen_q == seqlen_k, and #6767 extended it to gfx1250-strict. The main version also skips group mode, where a batch's own seqlen_q and seqlen_k can differ even when the call-level values match. Since this PR is superseded and now conflicts with main, I plan to close it. If your TE case still hits something main doesn't cover, please let me know; otherwise I'll close this in a few days. Thanks for the fix.

@shay-li77 shay-li77 closed this Nov 29, 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.

3 participants