Repository navigation
[precompile] Don't lose a frame to a served artifact installed on a guarded object - #194677
Closed
bobrenjc93 wants to merge 3 commits into
Closed
bobrenjc93 wants to merge 3 commits into
bobrenjc93 wants to merge 3 commits into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/194677
Note: Links to docs will display an error until the docs builds have been completed. ❌ 14 New Failures, 1 Unrelated FailureAs of commit 6e923eb with merge base 1b4e490 ( NEW FAILURES - The following jobs have failed:
BROKEN TRUNK - The following job failed but were present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This was referenced Aug 24, 2026
Closed
Closed
This was referenced Aug 24, 2026
Closed
bobrenjc93
added a commit
that referenced
this pull request
Aug 25, 2026
…uarded object
Install a loaded artifact onto a live object, then capture again with that
object in scope, and the frame dies:
torch_dynamo_resume_in_fwd_loss_bwd_at_208
TypeError: cannot pickle '_thread.RLock' object
reached via: local_scope['pipeline']._precompiled_fwd_loss_bwd
._compiled._inner._state._lock
The lock is ours. `_precompiled_fwd_loss_bwd` is the handle a previous load
installed, `._inner._state` is the session's condition variable, and the guard
tree walks from the guarded pipeline straight into it. `convert_frame` catches
the PackageError and runs the frame eager, so the capture reports success while
covering less -- and the frame that trips is a resume function of the capture
entry region, so it is on the hot path rather than a corner.
The structural reason it is reachable at all: the pruning in
`pickle_guards_state` walks the top-level leaves of `local_scope`, and the
pickler walks everything under them. Anything nested inside an object a guard
DOES read is therefore never pruned and needs a reducer of its own.
Give precompile's own handles one. Nothing can guard on a served artifact, so
it drops the way a pruned value does.
Deliberately narrow. The first version keyed on locks generally, which broke
two existing tests -- and they were right to break: a lock in the CALLER's
model still fails the frame with its path named, because that is something they
can act on. This one is ours, installed by us, and a caller cannot remove it.
Test Plan:
```
python test/test_precompile.py
python test/dynamo/test_guard_serialization.py
python test/dynamo/test_package.py
```
The new test pickles a handle nested inside a guarded object and asserts it
comes back as the missing sentinel with its siblings intact, and asserts a bare
lock is NOT treated this way -- the property the two
`test_unpicklable_guard_value_names_where_it_lives` cases depend on.
Not reproduced end to end: reaching it needs a guard set that walks into an
installed handle, and every synthetic shape I built pruned the handle before
the pickler got there. The path above is from a real capture and names every
step, so the reducer is written against that rather than against a guess.
Authored with an AI assistant.
ghstack-source-id: 78994dc
Pull-Request: #194677
bobrenjc93
added a commit
that referenced
this pull request
Aug 25, 2026
…uarded object
Install a loaded artifact onto a live object, then capture again with that
object in scope, and the frame dies:
torch_dynamo_resume_in_fwd_loss_bwd_at_208
TypeError: cannot pickle '_thread.RLock' object
reached via: local_scope['pipeline']._precompiled_fwd_loss_bwd
._compiled._inner._state._lock
The lock is ours. `_precompiled_fwd_loss_bwd` is the handle a previous load
installed, `._inner._state` is the session's condition variable, and the guard
tree walks from the guarded pipeline straight into it. `convert_frame` catches
the PackageError and runs the frame eager, so the capture reports success while
covering less -- and the frame that trips is a resume function of the capture
entry region, so it is on the hot path rather than a corner.
The structural reason it is reachable at all: the pruning in
`pickle_guards_state` walks the top-level leaves of `local_scope`, and the
pickler walks everything under them. Anything nested inside an object a guard
DOES read is therefore never pruned and needs a reducer of its own.
Give precompile's own handles one. Nothing can guard on a served artifact, so
it drops the way a pruned value does.
Deliberately narrow. The first version keyed on locks generally, which broke
two existing tests -- and they were right to break: a lock in the CALLER's
model still fails the frame with its path named, because that is something they
can act on. This one is ours, installed by us, and a caller cannot remove it.
Test Plan:
```
python test/test_precompile.py
python test/dynamo/test_guard_serialization.py
python test/dynamo/test_package.py
```
The new test pickles a handle nested inside a guarded object and asserts it
comes back as the missing sentinel with its siblings intact, and asserts a bare
lock is NOT treated this way -- the property the two
`test_unpicklable_guard_value_names_where_it_lives` cases depend on.
Not reproduced end to end: reaching it needs a guard set that walks into an
installed handle, and every synthetic shape I built pruned the handle before
the pickler got there. The path above is from a real capture and names every
step, so the reducer is written against that rather than against a guess.
Authored with an AI assistant.
ghstack-source-id: 78994dc
Pull-Request: #194677
bobrenjc93
added a commit
that referenced
this pull request
Aug 25, 2026
…uarded object
Install a loaded artifact onto a live object, then capture again with that
object in scope, and the frame dies:
torch_dynamo_resume_in_fwd_loss_bwd_at_208
TypeError: cannot pickle '_thread.RLock' object
reached via: local_scope['pipeline']._precompiled_fwd_loss_bwd
._compiled._inner._state._lock
The lock is ours. `_precompiled_fwd_loss_bwd` is the handle a previous load
installed, `._inner._state` is the session's condition variable, and the guard
tree walks from the guarded pipeline straight into it. `convert_frame` catches
the PackageError and runs the frame eager, so the capture reports success while
covering less -- and the frame that trips is a resume function of the capture
entry region, so it is on the hot path rather than a corner.
The structural reason it is reachable at all: the pruning in
`pickle_guards_state` walks the top-level leaves of `local_scope`, and the
pickler walks everything under them. Anything nested inside an object a guard
DOES read is therefore never pruned and needs a reducer of its own.
Give precompile's own handles one. Nothing can guard on a served artifact, so
it drops the way a pruned value does.
Deliberately narrow. The first version keyed on locks generally, which broke
two existing tests -- and they were right to break: a lock in the CALLER's
model still fails the frame with its path named, because that is something they
can act on. This one is ours, installed by us, and a caller cannot remove it.
Test Plan:
```
python test/test_precompile.py
python test/dynamo/test_guard_serialization.py
python test/dynamo/test_package.py
```
The new test pickles a handle nested inside a guarded object and asserts it
comes back as the missing sentinel with its siblings intact, and asserts a bare
lock is NOT treated this way -- the property the two
`test_unpicklable_guard_value_names_where_it_lives` cases depend on.
Not reproduced end to end: reaching it needs a guard set that walks into an
installed handle, and every synthetic shape I built pruned the handle before
the pickler got there. The path above is from a real capture and names every
step, so the reducer is written against that rather than against a guess.
Authored with an AI assistant.
ghstack-source-id: 78994dc
Pull-Request: #194677
This was referenced Aug 26, 2026
This was referenced Aug 28, 2026
Contributor
Author
|
@bobrenjc93 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Contributor
Author
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):
Install a loaded artifact onto a live object, then capture again with that
object in scope, and the frame dies:
The lock is ours.
_precompiled_fwd_loss_bwdis the handle a previous loadinstalled,
._inner._stateis the session's condition variable, and the guardtree walks from the guarded pipeline straight into it.
convert_framecatchesthe PackageError and runs the frame eager, so the capture reports success while
covering less -- and the frame that trips is a resume function of the capture
entry region, so it is on the hot path rather than a corner.
The structural reason it is reachable at all: the pruning in
pickle_guards_statewalks the top-level leaves oflocal_scope, and thepickler walks everything under them. Anything nested inside an object a guard
DOES read is therefore never pruned and needs a reducer of its own.
Give precompile's own handles one. Nothing can guard on a served artifact, so
it drops the way a pruned value does.
Deliberately narrow. The first version keyed on locks generally, which broke
two existing tests -- and they were right to break: a lock in the CALLER's
model still fails the frame with its path named, because that is something they
can act on. This one is ours, installed by us, and a caller cannot remove it.
Test Plan:
The new test pickles a handle nested inside a guarded object and asserts it
comes back as the missing sentinel with its siblings intact, and asserts a bare
lock is NOT treated this way -- the property the two
test_unpicklable_guard_value_names_where_it_livescases depend on.Not reproduced end to end: reaching it needs a guard set that walks into an
installed handle, and every synthetic shape I built pruned the handle before
the pickler got there. The path above is from a real capture and names every
step, so the reducer is written against that rather than against a guess.
Authored with an AI assistant.