Skip to content

[guards] Share a guard's user_stack, and re-reduce a _Missing compactly - #194386

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

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

Conversation

@bobrenjc93

@bobrenjc93 bobrenjc93 commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

Two independent size fixes in the same function.

Guard.user_stack is pure provenance -- it is what a guard-failure message
prints -- and most guards from one frame carry the same one. They carry it as
EQUAL StackSummary objects rather than as the same object, so the pickle memo
cannot fold them and each one is written in full. Canonicalizing by rendered
text before pickling lets the memo do its job, with no loss: a guard now
references a stack that was textually identical to its own, so every message is
the message it would have printed. Measured on a resnet18 capture at three
batch sizes: 1,005,922 bytes to 869,238, -13.6%.

Separately, a _Missing sentinel that came back from a previous
serialization was re-serialized by the default protocol --
NEWOBJ+EMPTY_TUPLE+EMPTY_DICT+SETITEM+BUILD -- rather than by the compact
REDUCE that wrote it. Fifty of them: 720 bytes against 462. That is most of
what re-serializing a guard state costs over serializing it once, which the
invariant-guard policy does for every frame.

Test Plan:

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

Authored with an AI assistant.

Differential Revision: D116962601

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

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

❌ 24 New Failures, 1 Unrelated Failure

As of commit 4227b11 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]
[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/1023/head branch November 12, 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