Repository navigation
[no-ci] [dynamo] Let a serving package recompile an uncovered frame without recording it - #198090
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/198090
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: ❌ 10 New Failures, 1 Unclassified FailureAs of commit 383c6b7 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.
_compiletreats every package it is handed as one being captured. The guard build serializes its guards whenever the compile still has a package, and the guard bytes, the inlined source and the device type are then appended to the package's entry for the frame. A package that serves a loaded artifact, which is what theservingflag introduced three commits below means, gets nothing from this: nothing will ever save it, so the serialized guards are dead weight. Worse, the pickling can still fail on a frame the caller never asked to capture, bypassing the entry or, for a strict capture, raisingPackageErrorout of an ordinary recompile. Refusing to compile such a frame is not an option either: the artifact simply does not cover it, and the program has to keep running.Fix.
_compile_innercomputesrecord = package is not None and not package.servingnext to the existing capture flag and gates three things on it. Thesave=argument to the guard build is now on only when the compile records, so a serving package never runs the serialization build. Thestrict_error=argument is likewise on only for a recording explicit capture, since raise-versus-bypass only means something when a save build can fail. The block that callsadd_guarded_code, then adds the inlined source and updates the device type, is entered only when the compile records; its assertion that the guard bytes are present stays sound because the save that would have produced them was skipped under the same condition.Summary. The three gates are one decision, not three: the save build produces the guard bytes the recording block consumes, and strictness is a property of that save build, so a single
recordflag keeps them from drifting apart and makes the None assertion in the block a real invariant rather than a coincidence. Two alternatives were rejected: letting a serving package record anyway (wasted serialization on every recompile, plus a pickling failure that would bypass or raise for a frame nobody intends to persist) and making it refuse uncovered frames (the frame must run; withsaveoff the compile is exactly a plaintorch.compile, a single strict runtime guard build with the backend installed as usual). Everything else about the frame is unchanged: it still goes throughcode_context, so its entry exists and hashas_compile_idset, it still counts toward the recompile limit throughcache_entries, and a non-serving package still records every variant as before. The entry this leaves behind, compiled but with no guarded codes and not bypassed, is precisely the shape the top of the stack reads back as an uncovered frame, so the two commits are a pair. Carved out of #195913.A serving package compiles the frame twice and records neither variant
Dropping
serving=Truefrom the constructor gives two guarded codes, one inlined source and acpudevice type on the same run, which is what the parent produced for the serving package too. Pinned bytest_serving_package_records_nothing_and_still_recompiles.Strictness is moot when nothing is saved
The raise on the capturing side is pinned by
test_explicit_capture_raises_where_the_ambient_cache_bypassesfrom the commit below; the serving side is pinned bytest_serving_package_is_not_strict_about_unserializable_guards, which runs withstrict_precompileon and still compiles.Test Plan:
The new tests fail on the parent, where the serving package records both variants and the strict one raises, and pass 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