Skip to content

[precompile] Lead the risky-drop report with the guards that can change a shape - #194542

Closed
bobrenjc93 wants to merge 4 commits into
gh/bobrenjc93/1061/basefrom
gh/bobrenjc93/1061/head
Closed

bobrenjc93 wants to merge 4 commits into
gh/bobrenjc93/1061/basefrom
gh/bobrenjc93/1061/head

Conversation

@bobrenjc93

@bobrenjc93 bobrenjc93 commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

A capture of a large sharded model reported 652 accepted risky drops. Four of
them mattered -- one SEQUENCE_LENGTH and three CONSTANT_MATCHes on a default
argument the traced graph had specialised on -- and finding them took a
hand-written filter over the summary, weeks after the artifact was first built.
The other 648 are CLOSURE_MATCH, CLASS_MATCH, ID_MATCH and friends on function
and class identities: slots to audit against a deployment, but none of them can
change what shape the graph computes.

The warning made that hard on purpose without meaning to. It flattened every
drop into one list, cut it at 8 in guard-type order, and admitted in a comment
that the cut said nothing about severity. At 33 drops -- Qwen2, the largest
model measured when it was written -- that is survivable. At 652 the entire
visible window is CLOSURE_MATCH.

Group by guard type and cap per type instead, with the shape-bearing types
first and labelled as the ones that can make a served call run a graph traced
for a different shape without missing a guard. On that same 652 the first
clause now names all four, because a type with one member can no longer be
crowded out by a type with 392.

Both copies of the paragraph -- save() and artifact() -- had already drifted
apart, so they now share one helper.

The ordering is by guard TYPE, and the report now says so rather than
promising more. Type is as far as this can go: the question a reader has is
whether the guarded VALUE can differ at serve time, and on the model above all
four candidates this surfaced turned out to be reached through a class or
function definition -- mro walks to defaults and code -- so they
were compile-time constants that no batch could change. Ranking them properly
needs the structured source rather than the name, so instead the report names
that tell, which is what a reader needs to dismiss one in a second rather than
a round trip.

This changes reporting only. Whether an unrebuildable shape-bearing guard
should be droppable at all under require_no_risky_drops=False is a separate
question: the policy path exempts those types and this path does not, and
closing that gap means refusing artifacts that build today, which wants
evidence about how often it fires before it is worth doing.

Test Plan:

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

One new test reproduces the distribution that hid the lead -- 392
CLOSURE_MATCH, 81 ID_MATCH, three shape-bearing -- and asserts each
shape-bearing name survives truncation and is named ahead of the bulk.

Authored with an AI assistant.

Differential Revision: D117281204

[ghstack-poisoned]
@bobrenjc93 bobrenjc93 added ciflow/trunk Trigger trunk jobs on your pull request topic: not user facing topic category labels Aug 23, 2026
@pytorch-bot

pytorch-bot Bot commented Aug 23, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❌ 13 New Failures, 1 Unrelated Failure

As of commit b28761f 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 23, 2026
This was referenced Aug 23, 2026
[ghstack-poisoned]
bobrenjc93 added a commit that referenced this pull request Aug 23, 2026
…ge a shape

A capture of a large sharded model reported 652 accepted risky drops. Four of
them mattered -- one SEQUENCE_LENGTH and three CONSTANT_MATCHes on a default
argument the traced graph had specialised on -- and finding them took a
hand-written filter over the summary, weeks after the artifact was first built.
The other 648 are CLOSURE_MATCH, CLASS_MATCH, ID_MATCH and friends on function
and class identities: slots to audit against a deployment, but none of them can
change what shape the graph computes.

The warning made that hard on purpose without meaning to. It flattened every
drop into one list, cut it at 8 in guard-type order, and admitted in a comment
that the cut said nothing about severity. At 33 drops -- Qwen2, the largest
model measured when it was written -- that is survivable. At 652 the entire
visible window is CLOSURE_MATCH.

Group by guard type and cap per type instead, with the shape-bearing types
first and labelled as the ones that can make a served call run a graph traced
for a different shape without missing a guard. On that same 652 the first
clause now names all four, because a type with one member can no longer be
crowded out by a type with 392.

Both copies of the paragraph -- save() and artifact() -- had already drifted
apart, so they now share one helper.

The ordering is by guard TYPE, and the report now says so rather than
promising more. Type is as far as this can go: the question a reader has is
whether the guarded VALUE can differ at serve time, and on the model above all
four candidates this surfaced turned out to be reached through a class or
function definition -- __mro__ walks to __defaults__ and __code__ -- so they
were compile-time constants that no batch could change. Ranking them properly
needs the structured source rather than the name, so instead the report names
that tell, which is what a reader needs to dismiss one in a second rather than
a round trip.

This changes reporting only. Whether an unrebuildable shape-bearing guard
should be droppable at all under require_no_risky_drops=False is a separate
question: the policy path exempts those types and this path does not, and
closing that gap means refusing artifacts that build today, which wants
evidence about how often it fires before it is worth doing.

Test Plan:

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

One new test reproduces the distribution that hid the lead -- 392
CLOSURE_MATCH, 81 ID_MATCH, three shape-bearing -- and asserts each
shape-bearing name survives truncation and is named ahead of the bulk.

Authored with an AI assistant.

ghstack-source-id: dea4c64
Pull-Request: #194542
@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

@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.

[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/1061/head branch November 11, 2026 01:46
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