Repository navigation
[precompile] Render POLICY_DROPPED_GUARDS beside the other dropped-guard lists - #198920
bobrenjc93 wants to merge 6 commits into
Conversation
[ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/198920
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 8a266ce with merge base be4d660 ( 🟢 GREEN LIGHT - PR approved to be merged without human review:
reason: This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
Claude finished @bobrenjc93's task in 46s —— View job The render change is correct and the test covers it. The one problem: the comment above the dropped-guard lists says they are guards that "could NOT be serialized", which is wrong for the new policy list. DetailsPR Review: #198920SummaryThe multi-graph artifact renderer now writes Code Quality
RecommendationApprove once the comment is fixed. It's a one-line change. |
[ghstack-poisoned]
|
@claude review |
|
Claude finished @bobrenjc93's task in 41s —— View job The render change and its test are correct, but one problem from the last review is still open: the comment above the dropped-guard lists says they "could NOT be serialized", and that's wrong for DetailsPR Review: #198920SummaryThe multi-graph artifact renderer now writes Code Quality
RecommendationApprove once the comment is fixed. It's a one-line change. |
[ghstack-poisoned]
|
Claude finished @bobrenjc93's task in 29s —— View job The render change and its test are correct. One problem is still open after two earlier reviews: the generated comment above the dropped-guard lists says they "could NOT be serialized", and that is wrong for DetailsSummaryThe multi-graph artifact renderer now writes Code Quality
RecommendationRequest Changes: the fix is one generated comment line. |
[ghstack-poisoned]
|
@claude review |
|
Claude finished @bobrenjc93's task in 24s —— View job No issues found. HEAD DetailsPR Review: #198920SummaryThe multi-graph artifact renderer now writes The new line has its own comment ( RecommendationApprove |
…ard lists Addresses aorenste's review of #198136, which is approved and so is left untouched. A multi-graph artifact rendered `DROPPED_GUARDS` and `RISKY_DROPPED_GUARDS` but not `PrecompileSummary.policy_dropped_guards`, while `DROPPED_GUARD_CODE` draws its slots from both `dropped_guards` and `policy_dropped_guards`. So the artifact could list the check for a slot that no list above it names, and a capture that discarded a precondition by policy would read like one that had none. `_parse_artifact_metadata` already accepts `POLICY_DROPPED_GUARDS`, so the renderer now writes it next to the other two. Nothing fills the field yet (`PrecompileSession` passes an empty policy set), so this is latent until the invariance policy is wired in, and today's artifacts gain an empty list. Test Plan: `test_multigraph_artifact_round_trips_a_hand_built_package` now builds its summary with a policy drop and that drop's guard code. It checks that the rendered `POLICY_DROPPED_GUARDS` round-trips, and that every slot in `DROPPED_GUARD_CODE` is named by `DROPPED_GUARDS` or `POLICY_DROPPED_GUARDS`. With the render line removed, the test fails with `KeyError: 'POLICY_DROPPED_GUARDS'`. ``` python test/test_precompile.py -k round_trips_a_hand_built python test/test_precompile.py lintrunner test/test_precompile.py torch/_precompile.py ``` This PR was authored with the help of an AI assistant (Claude). Co-Authored-By: Claude Opus 5.5 <[email protected]> ghstack-source-id: 706ef66 Pull-Request: #198920
…ard lists Addresses aorenste's review of #198136, which is approved and so is left untouched. A multi-graph artifact rendered `DROPPED_GUARDS` and `RISKY_DROPPED_GUARDS` but not `PrecompileSummary.policy_dropped_guards`, while `DROPPED_GUARD_CODE` draws its slots from both `dropped_guards` and `policy_dropped_guards`. So the artifact could list the check for a slot that no list above it names, and a capture that discarded a precondition by policy would read like one that had none. `_parse_artifact_metadata` already accepts `POLICY_DROPPED_GUARDS`, so the renderer now writes it next to the other two. Nothing fills the field yet (`PrecompileSession` passes an empty policy set), so this is latent until the invariance policy is wired in, and today's artifacts gain an empty list. Test Plan: `test_multigraph_artifact_round_trips_a_hand_built_package` now builds its summary with a policy drop and that drop's guard code. It checks that the rendered `POLICY_DROPPED_GUARDS` round-trips, and that every slot in `DROPPED_GUARD_CODE` is named by `DROPPED_GUARDS` or `POLICY_DROPPED_GUARDS`. With the render line removed, the test fails with `KeyError: 'POLICY_DROPPED_GUARDS'`. ``` python test/test_precompile.py -k round_trips_a_hand_built python test/test_precompile.py lintrunner test/test_precompile.py torch/_precompile.py ``` This PR was authored with the help of an AI assistant (Claude). Co-Authored-By: Claude Opus 5.5 <[email protected]> ghstack-source-id: 706ef66 Pull-Request: #198920
…ard lists Addresses aorenste's review of #198136, which is approved and so is left untouched. A multi-graph artifact rendered `DROPPED_GUARDS` and `RISKY_DROPPED_GUARDS` but not `PrecompileSummary.policy_dropped_guards`, while `DROPPED_GUARD_CODE` draws its slots from both `dropped_guards` and `policy_dropped_guards`. So the artifact could list the check for a slot that no list above it names, and a capture that discarded a precondition by policy would read like one that had none. `_parse_artifact_metadata` already accepts `POLICY_DROPPED_GUARDS`, so the renderer now writes it next to the other two. Nothing fills the field yet (`PrecompileSession` passes an empty policy set), so this is latent until the invariance policy is wired in, and today's artifacts gain an empty list. Test Plan: `test_multigraph_artifact_round_trips_a_hand_built_package` now builds its summary with a policy drop and that drop's guard code. It checks that the rendered `POLICY_DROPPED_GUARDS` round-trips, and that every slot in `DROPPED_GUARD_CODE` is named by `DROPPED_GUARDS` or `POLICY_DROPPED_GUARDS`. With the render line removed, the test fails with `KeyError: 'POLICY_DROPPED_GUARDS'`. ``` python test/test_precompile.py -k round_trips_a_hand_built python test/test_precompile.py lintrunner test/test_precompile.py torch/_precompile.py ``` This PR was authored with the help of an AI assistant (Claude). Co-Authored-By: Claude Opus 5.5 <[email protected]> ghstack-source-id: 706ef66 Pull-Request: #198920
…ard lists Addresses aorenste's review of #198136, which is approved and so is left untouched. A multi-graph artifact rendered `DROPPED_GUARDS` and `RISKY_DROPPED_GUARDS` but not `PrecompileSummary.policy_dropped_guards`, while `DROPPED_GUARD_CODE` draws its slots from both `dropped_guards` and `policy_dropped_guards`. So the artifact could list the check for a slot that no list above it names, and a capture that discarded a precondition by policy would read like one that had none. `_parse_artifact_metadata` already accepts `POLICY_DROPPED_GUARDS`, so the renderer now writes it next to the other two. Nothing fills the field yet (`PrecompileSession` passes an empty policy set), so this is latent until the invariance policy is wired in, and today's artifacts gain an empty list. Test Plan: `test_multigraph_artifact_round_trips_a_hand_built_package` now builds its summary with a policy drop and that drop's guard code. It checks that the rendered `POLICY_DROPPED_GUARDS` round-trips, and that every slot in `DROPPED_GUARD_CODE` is named by `DROPPED_GUARDS` or `POLICY_DROPPED_GUARDS`. With the render line removed, the test fails with `KeyError: 'POLICY_DROPPED_GUARDS'`. ``` python test/test_precompile.py -k round_trips_a_hand_built python test/test_precompile.py lintrunner test/test_precompile.py torch/_precompile.py ``` This PR was authored with the help of an AI assistant (Claude). Co-Authored-By: Claude Opus 5.5 <[email protected]> ghstack-source-id: 706ef66 Pull-Request: #198920
…ard lists Addresses aorenste's review of #198136, which is approved and so is left untouched. A multi-graph artifact rendered `DROPPED_GUARDS` and `RISKY_DROPPED_GUARDS` but not `PrecompileSummary.policy_dropped_guards`, while `DROPPED_GUARD_CODE` draws its slots from both `dropped_guards` and `policy_dropped_guards`. So the artifact could list the check for a slot that no list above it names, and a capture that discarded a precondition by policy would read like one that had none. `_parse_artifact_metadata` already accepts `POLICY_DROPPED_GUARDS`, so the renderer now writes it next to the other two. Nothing fills the field yet (`PrecompileSession` passes an empty policy set), so this is latent until the invariance policy is wired in, and today's artifacts gain an empty list. Test Plan: `test_multigraph_artifact_round_trips_a_hand_built_package` now builds its summary with a policy drop and that drop's guard code. It checks that the rendered `POLICY_DROPPED_GUARDS` round-trips, and that every slot in `DROPPED_GUARD_CODE` is named by `DROPPED_GUARDS` or `POLICY_DROPPED_GUARDS`. With the render line removed, the test fails with `KeyError: 'POLICY_DROPPED_GUARDS'`. ``` python test/test_precompile.py -k round_trips_a_hand_built python test/test_precompile.py lintrunner test/test_precompile.py torch/_precompile.py ``` This PR was authored with the help of an AI assistant (Claude). Co-Authored-By: Claude Opus 5.5 <[email protected]> ghstack-source-id: 706ef66 Pull-Request: #198920
…ard lists Addresses aorenste's review of #198136, which is approved and so is left untouched. A multi-graph artifact rendered `DROPPED_GUARDS` and `RISKY_DROPPED_GUARDS` but not `PrecompileSummary.policy_dropped_guards`, while `DROPPED_GUARD_CODE` draws its slots from both `dropped_guards` and `policy_dropped_guards`. So the artifact could list the check for a slot that no list above it names, and a capture that discarded a precondition by policy would read like one that had none. `_parse_artifact_metadata` already accepts `POLICY_DROPPED_GUARDS`, so the renderer now writes it next to the other two. Nothing fills the field yet (`PrecompileSession` passes an empty policy set), so this is latent until the invariance policy is wired in, and today's artifacts gain an empty list. Test Plan: `test_multigraph_artifact_round_trips_a_hand_built_package` now builds its summary with a policy drop and that drop's guard code. It checks that the rendered `POLICY_DROPPED_GUARDS` round-trips, and that every slot in `DROPPED_GUARD_CODE` is named by `DROPPED_GUARDS` or `POLICY_DROPPED_GUARDS`. With the render line removed, the test fails with `KeyError: 'POLICY_DROPPED_GUARDS'`. ``` python test/test_precompile.py -k round_trips_a_hand_built python test/test_precompile.py lintrunner test/test_precompile.py torch/_precompile.py ``` This PR was authored with the help of an AI assistant (Claude). Co-Authored-By: Claude Opus 5.5 <[email protected]> ghstack-source-id: 706ef66 Pull-Request: #198920
[ghstack-poisoned]
|
@claude review |
|
Claude finished @bobrenjc93's task in 23s —— View job I found no issues at HEAD DetailsPR Review: #198920SummaryThe multi-graph artifact renderer now writes I found no issues:
RecommendationApprove |
|
/easycla |
Superseded by a newer greenlight verdict.
[ghstack-poisoned]
|
@pytorchbot merge -i |
Merge startedYour change will be merged while ignoring the following 0 checks: Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Follow-up to the review of #198137, which has landed; this does not amend it. The precompile_capture docstring claimed runtime guards stay intact during capture and that guard_filter_fn only shapes the serialized guard state. That is backwards: CheckFunctionManager applies the filter to sorted_guards before it builds the runtime guard manager, so a dropped guard never triggers a recompile during capture, just as it cannot pick a graph at serve time. The docstring now says so, and the summary() comment gains the matching caveat: the varied-value rule only compares variants some kept guard split apart, so a dropped slot that is the sole difference between two calls is never reported. The nn.Module and bound-method PackageError messages ended with "calling cap(model, x)", but nothing in this module is named cap (the session hands back its _call). The clause is dropped. PrecompileSession is now Generic[_P, _R]: __init__ takes Callable[_P, _R], __enter__ returns Callable[_P, _R], and _call is typed with _P.args/_P.kwargs, so the callable from the with block keeps fn's signature instead of returning object. precompile_capture returns PrecompileSession[_P, _R], and _DynamoCapture, already Capture[_P, _R], now takes a PrecompileSession[_P, _R]. Test Plan: ``` lintrunner -a torch/_dynamo/precompile_package.py torch/_precompile.py python test/dynamo/test_precompile_package.py python test/test_precompile.py ``` Both suites pass (99 and 297 tests); no test asserts on the dropped message clause. This PR was authored with the help of an AI assistant (Claude Code). Co-Authored-By: Claude Opus 5.5 <[email protected]> Pull Request resolved: #199065 Approved by: https://github.com/MengjiaoZhou ghstack dependencies: #198558, #198920
…roperty (#198777) Part of the set of changes the two-phase precompile workflow needs at pytorch tip, on top of the open precompile stack that ends in #198558. In that workflow, one GPU captures the model against a fake process group of the serving world size, and then every rank replays the saved artifact with recompilation refused. The set was found by running the workflow end to end at tip on a large production FSDP2 recommendation model. Each change here was the first blocker at its step: the run got past that step once the change was applied. Each was then confirmed by removing it alone from the full set, which made the run fail again at the same point. With the full set, the replay completed on all 16 ranks for 100 batches with zero serve-time compilation. Its losses matched an uncompiled run of the same build: the first step was bit-identical, and after 100 steps the differences were within run-to-run noise. **Why precompile needs this.** A precompile artifact is loaded by a different process from the one that captured it. So each compiled frame's code object is recorded as a location, a module plus a qualname, that the loading process can look up and match against the frame Dynamo sees. Plain `torch.compile` never needs this, because it keys its cache on the live code object. A code object that cannot be located cannot be packaged, so the whole capture fails. Getters defined with `@property` are ordinary model code (a `forward` that reads `self.scale`, for example), so precompile has to locate them. In the end-to-end run: The model compiles a frame whose code is defined under a `@property`. At tip, capture failed at package save with exactly the error above. With this change, capture got past package save. **What.** `_get_code_source` records a code object's location by walking its `co_qualname` from the module with `getattr`. On a class, `getattr` returns the `property` or `functools.cached_property` descriptor, not the function inside it. So a code object that is a property getter, or a function nested in one (`C.prop.<locals>.inner`), could not be resolved. Packaging then aborted with: PackageError: Cannot resolve a fully qualified name for <code object ...>. Lookup scope: <property object ...> This change: - stops the qualname walk at a descriptor; - descends through `fget`, `fset`, `fdel` or `func`, emitting a path the loader replays with plain `getattr` (for example `.fget`); - lets the class search in `_find_code_source` look inside descriptors too. Python 3.10 has no `co_qualname`, so there this search is the only path, and before this change it skipped descriptors entirely. **Example.** ```python # owner.py import functools class Owner: @Property def prop(self): def inner(): return 1 return inner @functools.cached_property def cached(self): return 2 ``` ```python from torch._dynamo.package import CompilePackage from owner import Owner getter = vars(Owner)["prop"].fget.__code__ package = CompilePackage(None) with package.code_context(getter): pass # before: PackageError: Cannot resolve a fully qualified name for <code object prop ...>. # Lookup scope: <property object ...> # after: recorded under Owner.prop and found again through .fget; the same holds # for the nested `inner` and for Owner.cached through .func ``` Pull Request resolved: #198777 Approved by: https://github.com/pytorchgreenlight, https://github.com/MengjiaoZhou ghstack dependencies: #198558, #198920, #199065
Stack from ghstack (oldest at bottom):
Addresses aorenste's review of #198136, which is approved and so is left
untouched.
A multi-graph artifact rendered
DROPPED_GUARDSandRISKY_DROPPED_GUARDSbutnot
PrecompileSummary.policy_dropped_guards, whileDROPPED_GUARD_CODEdrawsits slots from both
dropped_guardsandpolicy_dropped_guards. So theartifact could list the check for a slot that no list above it names, and a
capture that discarded a precondition by policy would read like one that had
none.
_parse_artifact_metadataalready acceptsPOLICY_DROPPED_GUARDS, so therenderer now writes it next to the other two. Nothing fills the field yet
(
PrecompileSessionpasses an empty policy set), so this is latent until theinvariance policy is wired in, and today's artifacts gain an empty list.
Test Plan:
test_multigraph_artifact_round_trips_a_hand_built_packagenow builds itssummary with a policy drop and that drop's guard code. It checks that the
rendered
POLICY_DROPPED_GUARDSround-trips, and that every slot inDROPPED_GUARD_CODEis named byDROPPED_GUARDSorPOLICY_DROPPED_GUARDS.With the render line removed, the test fails with
KeyError: 'POLICY_DROPPED_GUARDS'.This PR was authored with the help of an AI assistant (Claude).
Co-Authored-By: Claude Opus 5.5 [email protected]