Repository navigation
lint_duplicate_definitions: a decorated def _ binds nothing - #18360
Merged
Merged
Conversation
#18285 registers two torch.library fake kernels in dequant_cache.py with the documented @torch.library.register_fake(...) def _(...) idiom. The whole-tree duplicate-definitions gate in Lint CI reads that as merge damage and fails on main. The decorator keeps the function and the name _ is never read back, so neither copy is dead code; exempt a decorated def _, keep an undecorated duplicate _ a finding, and add both as self-test cases.
Member
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Codex Review Summary: ❌ FailedThis 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. |
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.
Summary
The whole-tree "Duplicate definitions" step in Lint CI fails on main:
Every PR's source lint job inherits this (for example the staging runs for #17742 and #18108, both on current main).
Cause
#18285 registers fake (meta) kernels for its two custom ops with the idiom the torch.library docs use:
That code is correct. The decorator keeps a reference to each function, and the name
_is never read back, so neither copy is dead.lint_duplicate_definitions.pyexists to catch a second copy that silently replaces the first, which is not what happens here. The lint is too broad for this case.Fix
In
scripts/lint_duplicate_definitions.py, adef _that has at least one decorator binds nothing. This coversregister_fake,singledispatch's@f.register def _, and similar registration hooks. The exemption is deliberately narrow:def _defined twice is still a finding.Two self-test cases pin both sides. The docstring's list of carve-outs documents it.
Verification
--self-test: 65 cases pass. With the exemption removed, the new decorated_case fails (self-test FAILED (1 case(s))).unsloth unsloth_cli studio scripts tests cli.py unsloth-cli.py):clean: 6105 file(s) checked. On main the only finding was the one above, so the exemption hides nothing else.tests/test_lint_duplicate_definitions.py: 12 passed. ruff is clean.