Repository navigation
[precompile] Drop a guard that cannot be rebuilt instead of refusing the artifact - #194383
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/194383
Note: Links to docs will display an error until the docs builds have been completed. ❌ 23 New Failures, 1 Unrelated FailureAs of commit 2162c1a with merge base 1b4e490 ( NEW FAILURES - The following jobs have failed:
BROKEN TRUNK - The following job failed but were present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This was referenced Aug 21, 2026
Closed
Closed
This was referenced Aug 22, 2026
Closed
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):
Whether a guard can be rebuilt from its serialized form and whether it is worth
keeping are different questions, and the check added a few commits ago let the
first one answer the second: any frame with one unrebuildable guard cost the
whole artifact. On the model this came from, that is 48 other frames refused
over a CONSTANT_MATCH on a weakref's
__callback__-- a value that is almostcertainly None and pins nothing anyone will vary.
Whether a guard rebuilds is now decided per guard rather than per frame. That
needed a way to ask, so
build_guardsgrows an opt-in collect mode: with alist supplied, a guard whose
createraises is recorded and skipped insteadof aborting the build, and the remaining builds in that CheckFunctionManager
skip it too. Guard.create's own traceback logging is silenced while collecting,
since the caller is going to report the guard itself.
The drop is recorded as RISKY, not as an ordinary drop, and that is the whole
safety argument. Dropping a guard is not free: a guard whose source is an
attribute leaves its companion HASATTR behind, and that one is rebuilt by
re-reading the reconstructed value, so it comes back INVERTED and routes calls
into the graph traced for the other branch -- measured at exactly 7x wrong on a
two-variant model. Recording these as risky means the default
require_no_risky_dropsstill refuses the artifact, and only a caller who hasalready said it accepts unchecked slots gets one. The policy is the caller's,
where it was already.
The check also moves out of
__exit__and intoartifact()/save().Every other artifact-quality gate -- require_complete, require_no_risky_drops,
require_no_dropped_guards -- raises from there, where a caller can catch it and
decide. Raising out of the
withblock instead meant a caller who had set itsown "a bad capture must not kill my job" flag lost the job anyway, and could not
tell a refused capture from a failed training step.
On the
torch.compiler.precompilepath nothing new is paid: the collect ridesalong on the rebuild
_apply_guard_policyalready does. Only a directprecompile_captureuser pays for a pass, and only where the policy did not.Test Plan:
The reworked test asserts the shape this commit is about: the artifact is
refused by DEFAULT because the drop is risky, and produced under
require_no_risky_drops=Falsewith the offending guard named inRISKY_DROPPED_GUARDS -- for both entry points, since covering only one was the
original defect.
Two failure classes reach this without injection and are worth knowing about:
a DDP module (
_unpickle_ddp_modulerebuilds throughDDP.__getstate__,which deletes process_group/reducer/logger) and any capture of a function
calling
torch._C._is_cow_tensor(COW_TENSOR_MATCH reads storage state nosource can name). Neither is fixed here; both now cost a recorded guard instead
of the artifact.
Authored with an AI assistant.
Differential Revision: D116962604