Repository navigation
MoE grouped GEMM: skip kernel-info logging work unless debug logging is on - #14787
Merged
Merged
Conversation
…nless debug logging is on log_kernel_info ran after every forward / dX / dW launch and built its debug f-strings (the compiled kernel's full metadata) even with logging off: ~12 us of host time per launch (57 -> 45 us for a small forward). It now returns early unless the logger is enabled for DEBUG.
Member
Author
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
danielhanchen
added a commit
that referenced
this pull request
Oct 22, 2026
pre-commit.ci fails `ruff-format-with-kwargs` on every open PR (#14806, #14805, #14803, #14790, #14785, #14781, #14780, #14777, #14776, #14775, #14774, #14773, #14772, #14770, #14769, #14768, and others): "files were modified by this hook". pre-commit.ci runs the hooks on all files, and 20 files on main (26 by the time this lands) are not in the formatter's output, so every PR is reformatted outside its own diff. Where pre-commit.ci can push, its autofix commit drags those unrelated files into the PR (for example #14790's touches `tests/test_block_compile.py`, `tests/test_bnb_integration_compile.py` and `unsloth/models/_utils.py`). The drift came in with PRs merged today, among them #14702, #14751, #14759, #14784, #14786, #14787, #14788, #14791 and the FP8 block decode, GRPO routing replay, 4-bit decode, compiled blocks and MoE LoRA target changes. ### Change `python scripts/run_ruff_format.py` (the hook's own entry point, `ruff==0.6.9` as pinned in `.pre-commit-config.yaml`) applied to those 20 files, plus 6 more from #14739, #14779 and #14806, which merged while this was open. Formatting only. ### Verification - Every changed file parses to an identical AST before and after. - A second run of the hook over the same files changes nothing (fixed point), and over all tracked Python files on this branch it changes nothing. - `ruff check` passes on the changed files; `tests/test_formatter_fixed_point.py` passes (16). Open PRs pick this up on their next pre-commit.ci run after merging main.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was wrong
log_kernel_infoinunsloth/kernels/moe/grouped_gemm/interface.pyruns after every grouped GEMM launch (forward, dX and dW, so three times per MoE layer per training step). It readname,n_regs,n_spillsandmetadatafrom the compiled kernel and built two f-strings before callinglogger.debug. The logger is at the default level (WARNING), so the messages were dropped, but the formatting of theKernelMetadatanamedtuple still ran on every call.Change
Return early unless
logger.isEnabledFor(logging.DEBUG). With debug logging on, the output is unchanged.Validation
B200, torch 2.14 + Triton 3.8, real
CompiledKernelfrom an autotuned Triton kernel, 5 x 20000 calls:log_kernel_info(ck)log_kernel_info(ck, best_config)That is about 20 us of host time per MoE layer per step on the
unsloth_tritonbackend.logger.setLevel(logging.DEBUG)both arms print the same two lines (k: n_regs=... metadata=KernelMetadata(...)andk autotuned best_config: ...).tests/test_grouped_gemm_log_kernel_info.py: the no-debug test fails on base (it reads the compiled kernel's attributes) and passes here; the debug test passes on both.Not covered