Skip to content

Large-head attention: comment every constexpr, check fp fusion at the _launch helper - #17891

Merged
danielhanchen merged 1 commit into
mainfrom
fix-large-head-lints
Nov 16, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
fix-large-head-lints

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

Two kernel lint tests in Repo tests (CPU, rest) have failed on main since #17817 added unsloth/kernels/large_head_attention.py (Gemma-4 large-head attention kernels):

tests/test_triton_constexpr_comments.py::test_every_constexpr_line_has_a_comment
E   tl.constexpr parameters without a comment:
E     unsloth/kernels/large_head_attention.py:158 _lh_bwd_pre.HEAD_DIM  ... (23 parameters)

tests/test_triton_fp_fusion.py::test_every_launch_requests_fp_fusion
E   Triton launches without enable_fp_fusion: ['large_head_attention.py:702:kernel', 'large_head_attention.py:696:kernel.fn']

The forward kernel follows the constexpr convention, but the backward, TMA and _tma_tile signatures do not. On fp fusion the kernels are fine. Every launch goes through a _launch(kernel, grid, tile, *args, **kwargs) helper, and all three callers pass enable_fp_fusion = True. The lint only sees the kernel[...] / kernel.fn[...] subscripts inside the helper. That is the same shape as layernorm.py's and rms_layernorm.py's helpers, which the test already handles.

Changes

  • unsloth/kernels/large_head_attention.py: a short comment on each of the 23 constexpr parameters (head dim, rows per program or step, which gradient a pass stores). _tma_tile gets one parameter per line, so ROWS and HALF carry their own comments. Comments only, no code change.
  • tests/test_triton_fp_fusion.py: register large_head_attention.py's _launch in _LAUNCH_HELPERS, and its kernel / kernel.fn subscripts in _NOT_LAUNCHES, as for the two layernorm files. Each _launch(...) call is now checked for enable_fp_fusion directly.

Verification

  • tests/test_triton_constexpr_comments.py tests/test_triton_fp_fusion.py tests/test_large_head_attention.py tests/test_block_compile.py: 94 passed, 102 skipped (CUDA-only). On main, the two lint tests fail.
  • The fp fusion lint still catches a missing flag. Deleting enable_fp_fusion = True from the forward _launch call gives Triton launches without enable_fp_fusion: ['large_head_attention.py:787:_launch'].

… _launch helper

#17817 added unsloth/kernels/large_head_attention.py. Its backward and TMA kernels left 23 tl.constexpr
parameters uncommented, and its launches go through a _launch helper whose callers pass
enable_fp_fusion = True, which test_every_launch_requests_fp_fusion could not see. Both lint tests failed
on main. Add the comments, and register _launch as a launch helper (its kernel / kernel.fn subscripts as
forwarding sites) so each _launch call is checked for enable_fp_fusion instead.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-16T03:36:55.113796Z 6537177 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 6537177e42

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen
danielhanchen merged commit 640cfb9 into main Nov 16, 2026
@danielhanchen
danielhanchen deleted the fix-large-head-lints branch November 16, 2026 03:57
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.

1 participant