Repository navigation
[precompile] Test that a custom op captures where an aliased autograd.Function cannot - #194455
Closed
bobrenjc93 wants to merge 3 commits into
Closed
bobrenjc93 wants to merge 3 commits into
bobrenjc93 wants to merge 3 commits into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/194455
Note: Links to docs will display an error until the docs builds have been completed. ❌ 23 New FailuresAs of commit 5462f2a with merge base 1b4e490 ( NEW FAILURES - The following jobs have failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This was referenced Aug 22, 2026
Closed
Closed
bobrenjc93
added a commit
that referenced
this pull request
Aug 22, 2026
….Function cannot A hand-fused kernel is usually reached as a module-level alias of `SomeFunction.apply`, chosen among several implementations by config. Capturing a model that calls one fails the default gates, and not for a reason the caller would guess from the error: the guards are CLASS_MATCH on the Function and CLOSURE_MATCH on its two staticmethods, which are unserializable by construction -- there is no portable spelling of "this exact object" -- so they are dropped, and an alias is exactly the config-selected slot `_is_risky_drop` exists to flag. The classification is right; the capture needs `require_no_risky_drops=False` and an audit. Registering the same math with `torch.library` instead replaces all three guards with an operator looked up by qualified name, which serializes, so the capture passes with the gates left on. That is the migration worth recommending to anyone hitting this, and nothing pinned it, so a later relaxation of `_is_risky_drop` could quietly make the two cases indistinguishable and remove the reason to migrate. No behaviour change; this documents what already happens. Test Plan: ``` python test/test_precompile.py ``` The new test captures the same math both ways: the aliased `.apply` form is asserted to fail on the dropped-guard gate, and the custom-op form is asserted to capture with the default gates and to serve equal to eager. Authored with an AI assistant. ghstack-source-id: 16885b9 Pull-Request: #194455
bobrenjc93
added a commit
that referenced
this pull request
Aug 22, 2026
….Function cannot A hand-fused kernel is usually reached as a module-level alias of `SomeFunction.apply`, chosen among several implementations by config. Capturing a model that calls one fails the default gates, and not for a reason the caller would guess from the error: the guards are CLASS_MATCH on the Function and CLOSURE_MATCH on its two staticmethods, which are unserializable by construction -- there is no portable spelling of "this exact object" -- so they are dropped, and an alias is exactly the config-selected slot `_is_risky_drop` exists to flag. The classification is right; the capture needs `require_no_risky_drops=False` and an audit. Registering the same math with `torch.library` instead replaces all three guards with an operator looked up by qualified name, which serializes, so the capture passes with the gates left on. That is the migration worth recommending to anyone hitting this, and nothing pinned it, so a later relaxation of `_is_risky_drop` could quietly make the two cases indistinguishable and remove the reason to migrate. No behaviour change; this documents what already happens. Test Plan: ``` python test/test_precompile.py ``` The new test captures the same math both ways: the aliased `.apply` form is asserted to fail on the dropped-guard gate, and the custom-op form is asserted to capture with the default gates and to serve equal to eager. Authored with an AI assistant. ghstack-source-id: 16885b9 Pull-Request: #194455
Contributor
Author
|
@bobrenjc93 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
This was referenced Aug 23, 2026
This was referenced Aug 28, 2026
Contributor
Author
|
@bobrenjc93 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
1 similar comment
Contributor
Author
|
@bobrenjc93 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Contributor
Author
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.
Stack from ghstack (oldest at bottom):
A hand-fused kernel is usually reached as a module-level alias of
SomeFunction.apply, chosen among several implementations by config. Capturinga model that calls one fails the default gates, and not for a reason the caller
would guess from the error: the guards are CLASS_MATCH on the Function and
CLOSURE_MATCH on its two staticmethods, which are unserializable by
construction -- there is no portable spelling of "this exact object" -- so they
are dropped, and an alias is exactly the config-selected slot
_is_risky_dropexists to flag. The classification is right; the capture needs
require_no_risky_drops=Falseand an audit.Registering the same math with
torch.libraryinstead replaces all threeguards with an operator looked up by qualified name, which serializes, so the
capture passes with the gates left on. That is the migration worth recommending
to anyone hitting this, and nothing pinned it, so a later relaxation of
_is_risky_dropcould quietly make the two cases indistinguishable and removethe reason to migrate.
No behaviour change; this documents what already happens.
Test Plan:
The new test captures the same math both ways: the aliased
.applyform isasserted to fail on the dropped-guard gate, and the custom-op form is asserted
to capture with the default gates and to serve equal to eager.
Authored with an AI assistant.
Differential Revision: D117073079