Repository navigation
[dynamo] Record why a compile was bypassed on the package entry - #198084
bobrenjc93 wants to merge 2 commits into
Conversation
[ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/198084
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: ⏳ 6 Pending, 2 Unrelated FailuresAs of commit bb26af8 with merge base 618de55 ( 🟡 GREEN LIGHT - PR requires human review:
reason: UNSTABLE - The following jobs are marked as unstable, possibly due to flakiness on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
Claude finished @bobrenjc93's task in 19m 55s —— View job This PR cleanly threads the existing bypass reason onto the package entry, but the new tests never exercise the save/load round trip that is the whole point of storing it, and the save-time bypass path is left without a reason on the same argument ("it's in the trace") that the PR rejects for the compile-time path. Full reviewPR Review: #198084SummaryAdds Testing
API Design
Code Quality
RecommendationRequest Changes — only the round-trip test is a genuine blocker: the field's whole purpose is to be readable off a loaded artifact, and no test covers that path while the one line preserving it through |
[ghstack-poisoned]
|
Thanks; all four folded (the fix is in bb26af8). Note this PR now sits at position 3 of the stack, above the CheckFunctionManager refactor #198085; its diff did not change by that move.
Fixed in bb26af8:
Fixed in bb26af8:
Fixed in bb26af8: the slice is
Fixed in bb26af8: |
|
Claude finished @bobrenjc93's task in 15m 33s —— View job All four items from the previous round are genuinely fixed in bb26af8; what's left is one stale artifact (the PR description still documents the pre-fix behavior) and two small accuracy nits, none of which block. Full re-review of bb26af8Re-review: #198084
Verification of the four items1. Round-trip coverage — fixed. 2. Save-time bypass reason — fixed, and the state space is genuinely smaller. 3. Constant naming — fixed. 4. Empty-string state — fixed. Remaining
RecommendationApprove. The blocker is closed and the field is now well-covered on both bypass paths. Please refresh the PR description before landing, since the numbers and the scope in it no longer match the code. |
|
Abandoning this stack for now; it may be reopened later. |
Stack from ghstack (oldest at bottom):
Problem. When a compile cannot be saved into its
CompilePackage(most often because a guard's value cannot be pickled),OutputGraph.bypass_packagelogs a warning, emits aprecompile_cache_bypassstructured-trace artifact and marks the entry bypassed. The reason string exists only at that site: the package entry records a barebypassed = Trueand nothing else. Anyone holding the package afterwards, in particular a writer that wants to name why a frame has nothing installable, can only say "bypassed" and send the user to tlparse, which a production job may not have. The reason is a fact about the entry and belongs on it.Fix.
_DynamoCodeCacheEntrygainsbypass_reason: str | None = None, documented as item 11 of the class docstring.CompilePackage.bypass_current_compiletakes an optionalreason, truncates anything longer than_BYPASS_REASON_MAX_CHARS(2048) to that prefix plus" ... (truncated)", and stores it only when the entry ends up bypassed, storing None otherwise.add_guarded_coderesets the reason alongside the flag it already resets.OutputGraph.bypass_packagepasses itsreasonargument through, so both existing bypass sites (guard serialization inCheckFunctionManager, and a graph with named parameters incompile_and_call_fx_graph) populate it with no further change.Summary. The reason follows the flag exactly, because main's model is that an entry is bypassed only while it has no installable variant: a bypass on a code object that already recorded a guarded code leaves that variant installable and the entry not bypassed, so recording a reason there would describe a compile that did not cost the entry anything, and a later recorded compile clears the flag, so it clears the reason too. Storing the reason unconditionally was rejected for that mismatch, and a separate per-compile log was rejected because the artifact is what a later consumer has in hand. The cap exists because a reason can embed a repr of a user object (the guard-serialization message does) and the entry is pickled into the on-disk artifact, so an unbounded repr would bloat the file; 2048 characters keeps the exception text and drops the tail. The field has a default, so entries pickled before this commit load unchanged, and the artifact bytes of an entry that was never bypassed only gain a None. Nothing in
torch/reads the field yet; it is the ingredient a later stack's artifact builder needs to explain a refusal, and it sits above commit 1 (which fixed the bypass flag being set on a live entry) so that a copy carries its reason with it. Carved out of #195913.The reason lives and dies with the bypassed flag
Pinned by
test_bypass_reason_is_recorded_only_while_the_entry_is_bypassed.The guard-serialization bypass names its cause on the entry
Pinned by
test_bypass_reason_names_the_guard_that_could_not_serialize. The existingtest_bypassed_guards_keep_the_frames_earlier_variantkeeps pinning that a bypass next to an installable variant does not bypass the entry.Test Plan:
The two new tests fail on the parent (the reason argument and the field do not exist) 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