Skip to content

[guards] Stop pickling a Guard's export bookkeeping - #194301

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

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

Conversation

@bobrenjc93

@bobrenjc93 bobrenjc93 commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

Guard.code_list and Guard.guard_types exist for export's benefit and are
repopulated by create_fn when a serialized guard state is loaded, so nothing
reads the shipped copy. Shipping it is not merely redundant:
Guard.set_export_info EXTENDS both lists rather than assigning them, and
CheckFunctionManager runs up to three guard builds per compilation, so every
code part appears in the artifact three or four times over.

Clearing them in the dataclasses.replace that serialize_guards already
performs cannot affect the live guards, since that replace produces fresh
objects, and nothing between it and pickle_guards_state reads either field.

Measured on artifact size, resnet18 at three batch sizes with the eager backend:
2,310,113 bytes to 984,729, a 57% reduction. A 32-wide two-layer net through
inductor with a graph break goes 281,801 to 211,405, and a small training
capture 202,790 to 183,466. The win scales with guard count, which is why the
resnet is the dramatic one.

Test Plan:

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

The new test asserts the contract directly -- every guard in every variant of a
shipped artifact has code_list is None and guard_types is None -- and
then loads and serves that same artifact, since the claim being made is that
create_fn puts them back.

Authored with an AI assistant.

Differential Revision: D116865485

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

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

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

As of commit c4ee9b4 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 20, 2026
This was referenced 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]
[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/1013/head branch November 12, 2026 01:45
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