Repository navigation
[no-ci] [dynamo] Register the sources of aotautograd guards on a package's saved guards - #198125
Closed
bobrenjc93 wants to merge 1 commit into
Closed
bobrenjc93 wants to merge 1 commit into
bobrenjc93 wants to merge 1 commit into
Conversation
[ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/198125
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below: ❌ 11 New Failures, 1 Unclassified FailureAs of commit e9afcd3 with merge base 618de55 ( 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:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This was referenced Sep 22, 2026
Closed
Closed
Closed
Closed
Contributor
Author
|
Abandoning this stack for now; it may be reopened later. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stack from ghstack (oldest at bottom):
Problem. Since the commit below, the saved copy of a package's guards is built by its own
GuardBuilder, over the serialization-filtered guard list, and value pruning keys off that builder'sguard_tree_values. The aotautograd guards,DuplicateInputsandStorageOverlap, are subject to neither filter:compile_check_fninstalls them on the runtime build unconditionally and load rebuilds them unconditionally fromoutput_graph._aotautograd_guards. But the tensors they name reachguard_tree_valuesonly throughget_guard_manager_from_sourcecalls thatcompile_check_fnmakes on the runtime builder (and underuse_lamba_guard_for_object_aliasing,DUPLICATE_INPUTnames its second input throughadditional_used_local_varswithout registering it at all). When the saved copy holds no other guard on an aliased input, because itsTENSOR_MATCHwas dropped by the serialization filter,pickle_guards_stateprunes that tensor to_Missingwhile the loaded build reinstalls an aliasing guard rooted at its source.Fix. Right after the save build,
CheckFunctionManager.__init__walksoutput_graph.aotautograd_guardsand callsserialization_builder.get_guard_manager_from_sourcefor eachDuplicateInputsinput source and eachStorageOverlapoverlapping and non-overlapping source, which registers those tensors on the saved copy's guard tree.test_duplicate_input_survives_separate_save_buildpins it through a_post_tracehook in the test helper that injects aDuplicateInputsafter tracing.Summary. Registering the sources directly is the shape that names exactly what the saved copy must carry: the aotautograd guards are the unfilterable part of the guard set, so what they reach is guarded in the artifact by construction. Two alternatives were rejected. Inheriting the runtime builder's whole
guard_tree_valueswould keep every value the live guards reach, including values whose guards the filter dropped on purpose, and since membership in that dict is the prune gate inpickle_guards_stateandreducer_override, a non-portable value would be pickled instead of pruned; the commit below pins the pruning withtest_value_reached_only_by_a_dropped_guard_is_pruned. Inheriting only the entriescompile_check_fnadded would depend on whether an unrelated runtime guard had already registered the same tensor during the runtime build, which excludes it from the delta, so the artifact would keep or lose an aliased input depending on which other guards happened to exist. Nothing changes for the ambient caching-precompile path, whose single build already runscompile_check_fnon the builder it serializes from. Carved out of #195913.The aliased input stays in the artifact even when nothing else in the saved copy reaches it
Pinned by
test_duplicate_input_survives_separate_save_build, which fails on the parent with_Missing(missing values) is not an instance of <class 'torch.Tensor'>.Test Plan:
The new test fails on the parent, where the aliased input is pruned from the saved copy, and passes here.
Authored with an AI assistant.
Co-Authored-By: Claude Fable 5.1 [email protected]
cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @kadeng @chauhang @amjames @jataylo @azahed98