Repository navigation
[no-ci] [dynamo] Build a package's guards under its serialization filter and capture mode - #198088
Closed
bobrenjc93 wants to merge 4 commits into
Closed
bobrenjc93 wants to merge 4 commits into
bobrenjc93 wants to merge 4 commits into
Conversation
[ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/198088
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 67d3e8a 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
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
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. The commit below gives
CompilePackagea serialization guard filter and an explicit-capture flag, and the commit two below teachesCheckFunctionManagerto honour both, but nothing connects them:_compilenever reads either attribute off the package, andDynamoOutput.build_guardshas no way to hand them on. So a package constructed with a filter still serializes exactly the guards its runtime cache checks, and an explicit capture still gets its live guards out of a save build, with the caching-precompile filter rewrite applied to them as if it were the ambient cache.Fix.
DynamoOutput.build_guardsandDynamoOutput._build_guardsin convert_frame.py grow two keyword arguments,serialization_guard_filter_fnandexplicit_capture, and pass them straight through to theCheckFunctionManagerconstructor (both paths, with and without translation validation). The guard-building block in_compilereads them off the package it was handed: the filter is the package'sserialization_guard_filter_fnwhen a package exists and None otherwise, andexplicit_captureis true only when a package exists and says so. A test in test_package.py pins the observable split between live and saved guards.Summary. This is the wiring step of the stack: the two commits below each add one half of the mechanism as pure data or pure guard-manager logic, and this commit is the only place the two meet, so a reviewer can check the threading here without re-reading the guard builder. The kwargs are read from the package rather than from
Hooksbecause they describe the artifact being recorded, not the caller's compile, and a package survives across many frames while hooks are per-call. Passing them as keyword arguments through bothbuild_guardslayers, instead of lettingCheckFunctionManagerlook at the package itself, keeps the guard builder free of any knowledge ofCompilePackage, as it is today. Nothing else changes:saveis stilloutput.package is not None,strict_erroris still the default (the commit above ties it to the capture mode), andGraphCaptureOutput.build_guards, which never has a package, is untouched. A package with neither flag set builds exactly the single save build it built before, so the ambient caching-precompile path is unaffected. Carved out of #195913.The filter applies to the saved copy only
The live cache still recompiles on a dtype change, because the runtime guards keep
TENSOR_MATCH; only the pickled guards state drops it. Verified from the top of the stack (nothing here depends on the commits above).The same holds with
explicit_capture=Trueon that package.test_serialization_filter_applies_to_the_saved_guards_onlyin test/dynamo/test_package.py pins both the recompile and the missingTENSOR_MATCH, for the explicit and the ambient package.An explicit capture without a filter saves its guards unfiltered
The capture mode alone changes how the guards are built (a strict runtime build plus a separate save build), not which guards are saved.
The same test's final block pins this; a plain
CompilePackage(fn)savesTENSOR_MATCHtoo.Test Plan:
The new test fails on the parent (the saved copy still carries
TENSOR_MATCH) 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