Skip to content

[precompile] Never drop a guard that pins a Python value - #194286

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

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

Conversation

@bobrenjc93

@bobrenjc93 bobrenjc93 commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

Invariant-guard dropping already exempts guards that pin a SHAPE, on the grounds
that with one example nothing can discriminate and what silently disappears is
the check that the runtime input looks like the captured one at all. Value
guards are the same argument and the worse half.

CONSTANT_MATCH, EQUALS_MATCH and DUPLICATE_INPUT pin a Python value the graph
specialized on: an int or bool argument that selects a branch, module.training,
an .item() result, mask=None, the same tensor passed twice. Dropped, the
artifact answers every other value from the captured branch. Measured before
this change, all with correct-LOOKING numerics and no error:

captured k=5, served k=1 -> the k=5 graph
captured eval, served train -> dropout stays off

Shapes at least crash inside a kernel on the inductor backend. These do not,
which is why they are the more dangerous half and why the exemption should have
covered them from the start.

Also stops the artifact reporting zero drops while dropping. Policy drops were
recorded in a set that was written and never read, so DROPPED_GUARDS printed []
and require_no_dropped_guards=True passed on captures that had silently
discarded a precondition -- the one place a reviewer would look was empty by
construction. They are now a field on PrecompileSummary and a POLICY_DROPPED_GUARDS
literal in the header, kept apart from DROPPED_GUARDS because "could not be
serialized" and "could, and was judged redundant" have different remedies.

Cost is small: +2.6% on a two-variant artifact (27,010 -> 27,709 chars).

Test Plan:

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

Two existing tests documented the old trade and now assert its inverse: an
uncovered value is refused rather than answered, on the standalone path, and
recompiled on the installed one.

Authored with an AI assistant.

Differential Revision: D116840945

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Aug 20, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❌ 22 New Failures, 1 Unrelated Failure

As of commit 9709e44 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 20, 2026
@bobrenjc93 bobrenjc93 added ciflow/trunk Trigger trunk jobs on your pull request topic: not user facing topic category labels Aug 20, 2026
@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.

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.

[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 #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/1008/head branch November 12, 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