Skip to content

Revert "[WIP][Megatron-LM] feat: reduce extra qkv transpose in attn"#641

Merged
Xiaoming-AMD merged 1 commit into
mainfrom
revert-625-dev/zhangrb/refine_turbo_attn
Apr 1, 2026
Merged

Revert "[WIP][Megatron-LM] feat: reduce extra qkv transpose in attn"#641
Xiaoming-AMD merged 1 commit into
mainfrom
revert-625-dev/zhangrb/refine_turbo_attn

Conversation

@Xiaoming-AMD
Copy link
Copy Markdown
Collaborator

Reverts #625

@Xiaoming-AMD Xiaoming-AMD requested a review from wenxie-amd as a code owner April 1, 2026 08:26
Copilot AI review requested due to automatic review settings April 1, 2026 08:26
@Xiaoming-AMD Xiaoming-AMD requested a review from limou102 as a code owner April 1, 2026 08:26
@Xiaoming-AMD Xiaoming-AMD merged commit b61cddc into main Apr 1, 2026
5 of 7 checks passed
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Reverts prior work in Megatron-LM Primus-Turbo attention intended to reduce extra QKV transposes, restoring earlier QKV layout handling and output layout conversion behavior.

Changes:

  • Updates PrimusTurboAttention.forward() QKV layout validation and conditional transpose behavior based on qkv_format.
  • Adjusts attention output reshaping/transposition back to expected (S, B, ...) layout.

), f"qkv_format only support {SUPPORTED_QKV_FORMATS}, but got {qkv_format}"
# NOTE(ruibin): The layout of q, k and v is (S, B, H, D). But attn accept the shape of qkv is (B, S, H, D).
query, key, value = [x.permute(1, 0, 2, 3) for x in (query, key, value)]
assert qkv_format in ("sbhd", "bhsd"), "qkv_format only support bshd, but got {qkv_format}"
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

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

The qkv_format validation looks inconsistent: it allows ("sbhd", "bhsd") but the error text says "bshd", and {qkv_format} won’t be interpolated because this isn’t an f-string. If the intended formats are SBHD and BSHD (matching the comment removed in this revert), update the allowed tuple and make the message an f-string (or use ValueError) so the reported format is correct.

Suggested change
assert qkv_format in ("sbhd", "bhsd"), "qkv_format only support bshd, but got {qkv_format}"
assert qkv_format in ("sbhd", "bshd"), f"qkv_format only supports 'sbhd' and 'bshd', but got {qkv_format}"

Copilot uses AI. Check for mistakes.
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.

2 participants