Skip to content

[precompile] Report a guard that rebuilds into a different check - #194393

Closed
bobrenjc93 wants to merge 3 commits into
gh/bobrenjc93/1028/basefrom
gh/bobrenjc93/1028/head
Closed

bobrenjc93 wants to merge 3 commits into
gh/bobrenjc93/1028/basefrom
gh/bobrenjc93/1028/head

Conversation

@bobrenjc93

@bobrenjc93 bobrenjc93 commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

A guard whose source cannot be re-evaluated against the reconstructed values
raises, and the commit that added the rebuild pass drops it. The quieter half of
the same failure has no symptom at all: a guard that rebuilds SUCCESSFULLY into
a different check, because reconstruction lost a value the guard reads rather
than a value its source traverses. That artifact serializes, loads, and then
never matches -- which looks like a cold cache, not like a bug.

Both fixes in this stack are of that shape. A dropped dimension marking turns
getattr(x, '_dynamo_unbacked_indices', set()).issubset({0}) into
hasattr(x, '_dynamo_unbacked_indices') == False; a dropped tensor attribute
leaves a HASATTR that comes back as its own inverse. Neither raises.

Record the leaf guards every LIVE build produces during a capture, and compare
the rebuild against them. A leaf the live build never made means reconstruction
lost something. Recorded only from live builds -- the flag is off for a state
loaded from a pickle -- or a reconstruction bug would whitelist itself.

One-directional, on purpose: the invariant-guard policy legitimately drops
guards, so a leaf present live and absent at load is expected and must not fire.

Four things are excluded from the comparison, each because it differs on a
CORRECT artifact. Node lines, which carry the guarded value's type (Tensor live,
FakeTensor rebuilt). Depth, since the same guard at a different depth means
nothing different. Relational guards, installed by compile_check_fn for the
runtime builder only. And LAMBDA_GUARD, whose identity is a generated name: a
tensor subclass installs a metadata lambda on one side and not the other, which
this cannot tell from real drift. Raw id()s are masked for the same reason.

A warning, not a refusal. The exclusion list was arrived at empirically and a
false positive would refuse a working artifact, which is worse than the drift it
would catch. Enough evidence to warn, not enough to fail closed.

Test Plan:

python test/test_precompile.py
python test/dynamo/test_package.py
python test/dynamo/test_guard_serialization.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).

Swept for false positives across all three precompile suites: zero, against
three TRUE positives -- the artifacts the drop-not-refuse tests deliberately
break, each caught as the inverted NO_HASATTR. The new test asserts both
directions on one model: no drift reported normally, and the attribute named
when the carrier is disabled.

Authored with an AI assistant.

Differential Revision: D116962609

[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/194393

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

❌ 11 New Failures, 1 Unrelated Failure, 1 Unclassified Failure

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

NEW FAILURES - The following jobs have failed:

UNCLASSIFIED FAILURE - DrCI could not classify the following job because the workflow did not run on the merge base. The failure may be pre-existing on trunk or introduced by this PR:

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]
[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/1028/head branch November 12, 2026 01:47
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