Skip to content

Block compile: import large_head_attention by its written-out name (Source lint red on main) - #17838

Merged
danielhanchen merged 1 commit into
mainfrom
fix-block-compile-lh-import
Nov 15, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
fix-block-compile-lh-import

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

Source lint has been red on main since #17817 merged (also seen on the staging run of #17835):

No new risky loader call sites: Failed
1 risky loader call site(s) not in the baseline:
  unsloth/models/_block_compile.py:1364  [dynamic-import] import_module

_band_kernel_check loads the band-attention kernel module through importlib.import_module(_LH_MODULE). The risky-loader lint flags a dynamic import whose module name is not written at the call site. Here the name is the constant "unsloth.kernels.large_head_attention", so nothing is actually dynamic.

Change

from unsloth.kernels import large_head_attention as lh replaces the importlib call. It stays in the same place, so the module is still loaded lazily, only for a layer whose sliding-window head dim qualifies, and still inside the try/except that falls back to the stock attention path. No baseline entry is needed. sys.modules[_LH_MODULE] lookups elsewhere are unchanged.

Verification

On a clean export of the tree:

scripts/lint_risky_loaders.py
main 1 call site not in the baseline (_block_compile.py:1364)
this branch ok: 117 risky loader call sites, all recorded

tests/test_block_compile.py tests/test_large_head_attention.py tests/security/test_lint_risky_loaders.py: 120 passed, 68 skipped (CUDA-only cases).

#17817 loaded the band-attention kernel module through importlib.import_module(_LH_MODULE). The
risky-loader lint flags a dynamic import whose name is not written at the call site, so Source lint has
been red on main since it merged. The module name is a constant, so a plain from-import is equivalent and
keeps the lazy, exception-guarded load inside _band_kernel_check.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 15, 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-15T14:24:03.221248Z 6128b4e 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. 🚀

Reviewed commit: 6128b4ea3b

ℹ️ 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 a6b475e into main Nov 15, 2026
@danielhanchen
danielhanchen deleted the fix-block-compile-lh-import branch November 15, 2026 14:25
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