Skip to content

[precompile] Actually remove a dropped guard from the artifact - #194409

Closed
bobrenjc93 wants to merge 2 commits into
gh/bobrenjc93/1031/basefrom
gh/bobrenjc93/1031/head
Closed

bobrenjc93 wants to merge 2 commits into
gh/bobrenjc93/1031/basefrom
gh/bobrenjc93/1031/head

Conversation

@bobrenjc93

@bobrenjc93 bobrenjc93 commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

Dropping an unrebuildable guard did not, in two separate ways, produce an
artifact that could be served.

FIRST: the drop was recorded but not applied. Capture logged ten drops and
listed them in DROPPED_GUARDS; the pickle still contained all ten, so load
refused the artifact with the same AttributeError the capture had already
reported handling. A reviewer reading the header would believe the guard was
gone.

That is a regression from further down this stack. The pruning lives inside
build_filter_entries, which used to run for every CheckFunctionManager.
"Build a precompiled frame's guard tree twice, not three times" then stopped
calling it when there is no RUNTIME filter -- exactly the configuration
_apply_guard_policy uses -- and derived the filter entries from the runtime
builder instead. The failures were still collected, so the log and the header
were right; nothing pruned all_guards, so the serialized set was not. The
pruning is now its own step, run after EVERY build that can collect.

SECOND, and this one was never right: a guard on base.attr does not travel
alone. Dynamo also emits a HASATTR on base for attr, and that guard's
truth value is RECOMPUTED at rebuild by reading the reconstructed object. Drop
only the first and the second comes back as its own inverse --
not hasattr(base, attr) -- so the artifact loads and then rejects the very
call it was captured on:

load OK
serve: no captured variant   miss: ["not hasattr(L['x'], '_cpu_copy')"]

So the companions go with it: anything keyed on the same (base, attribute) link,
recorded as risky alongside the guard that failed. With both fixes the minimal
case -- exactly one guard dropped, everything else intact -- captures, loads and
serves, matching eager.

Both messages now name the frame. Several frames can guard the same source
string -- the model this came from captured ten variants each of two frames
guarding the same weakref -- so without it there is no telling "recorded but not
applied" from "one frame swept and another missed", and those need different
fixes.

Test Plan:

python test/test_precompile.py
python test/dynamo/test_package.py
python test/dynamo/test_guard_serialization.py
python test/dynamo/test_precompile_context.py
python test/dynamo/test_aot_compile.py

test_aot_compile.py has 3 pre-existing failures in this environment
(test_aot_compile_with_aoti*, fatal error: cuda.h).

The existing drop test asserted only that the drop was RECORDED, which is what
let both of these through. It now injects the fault NARROWLY -- one attribute
stops being carried, the rest of the artifact is untouched, so a dropped guard
is distinguishable from a wrecked artifact -- then decodes the shipped artifact,
asserts the dropped source is absent from every variant's guard state, loads it,
and SERVES it against eager. Each half fails on its own without its fix.

Authored with an AI assistant.

Differential Revision: D116983946

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Aug 21, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/194409

Note: Links to docs will display an error until the docs builds have been completed.

❌ 11 New Failures, 1 Unrelated Failure

As of commit 55a3976 with merge base 1b4e490 (image):

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.

@pytorch-bot pytorch-bot Bot added ciflow/inductor ciflow/torchtitan Run TorchTitan integration tests module: dynamo labels Aug 21, 2026
This was referenced Aug 21, 2026
This was referenced Aug 22, 2026
[ghstack-poisoned]
@bobrenjc93

Copy link
Copy Markdown
Contributor Author

@bobrenjc93 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

1 similar comment
@bobrenjc93

Copy link
Copy Markdown
Contributor Author

@bobrenjc93 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@bobrenjc93

Copy link
Copy Markdown
Contributor Author

Superseded by the canonical precompile stack #195353-#195362; this change lives in #195362 (with the guard-drop policy half in #195360). Closing to consolidate review there. The branch is kept on GitHub.

@bobrenjc93 bobrenjc93 closed this Sep 3, 2026
@github-actions
github-actions Bot deleted the gh/bobrenjc93/1031/head branch November 11, 2026 01:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/inductor ciflow/torchtitan Run TorchTitan integration tests ciflow/trunk Trigger trunk jobs on your pull request module: dynamo topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant