Skip to content

[guards] Name the attribute path when a guard value cannot be pickled - #194283

Closed
bobrenjc93 wants to merge 3 commits into
gh/bobrenjc93/1005/basefrom
gh/bobrenjc93/1005/head
Closed

bobrenjc93 wants to merge 3 commits into
gh/bobrenjc93/1005/basefrom
gh/bobrenjc93/1005/head

Conversation

@bobrenjc93

@bobrenjc93 bobrenjc93 commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

"PackageError: TypeError: cannot pickle 'generator' object" names a type and
nothing else. In a model with a thousand-frame guard tree that is not
actionable: finding which of them holds the generator means instrumenting the
pickler by hand and re-running a capture that takes minutes. One user did that
twice at 13 minutes a cycle.

Everything needed is already at the raise site, so the error now walks the
scopes the guard state carries and appends the first path whose value has the
failing type:

TypeError: cannot pickle 'generator' object
  reached via: local_scope['p'].deep.it

Best-effort by construction, and every line of it is inside the guard --
including the regex that reads the type out of the message. This runs while an
exception is already being raised, so a failure here must stay silent rather
than replace the real error with its own; an early version got that wrong and
turned the report into a bare NameError.

Test Plan:

python test/test_precompile.py
python test/dynamo/test_guard_serialization.py

Two tests: one asserts the path is reported for a nested unpicklable attribute,
and one asserts a walker that raises still returns "" rather than masking the
error it was describing.

Authored with an AI assistant.

Differential Revision: D116840944

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Aug 20, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/194283

Note: Links to docs will display an error until the docs builds have been completed.

❌ 12 New Failures, 1 Unrelated Failure

As of commit 23a5c60 with merge base 1b4e490 (image):

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.

@pytorch-bot pytorch-bot Bot added ciflow/inductor ciflow/torchtitan Run TorchTitan integration tests module: dynamo labels Aug 20, 2026
@bobrenjc93 bobrenjc93 added ciflow/trunk Trigger trunk jobs on your pull request topic: not user facing topic category labels Aug 20, 2026
@bobrenjc93

Copy link
Copy Markdown
Contributor Author

@bobrenjc93 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

This was referenced Aug 22, 2026
[ghstack-poisoned]
@bobrenjc93

Copy link
Copy Markdown
Contributor Author

@bobrenjc93 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

[ghstack-poisoned]
@bobrenjc93

Copy link
Copy Markdown
Contributor Author

@bobrenjc93 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

1 similar comment
@bobrenjc93

Copy link
Copy Markdown
Contributor Author

@bobrenjc93 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@bobrenjc93

Copy link
Copy Markdown
Contributor Author

Superseded by the canonical precompile stack #195353-#195362; this change lives in #195362 (with the guard-drop policy half in #195360). Closing to consolidate review there. The branch is kept on GitHub.

@bobrenjc93 bobrenjc93 closed this Sep 3, 2026
@github-actions
github-actions Bot deleted the gh/bobrenjc93/1005/head branch November 11, 2026 01:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/inductor ciflow/torchtitan Run TorchTitan integration tests ciflow/trunk Trigger trunk jobs on your pull request module: dynamo topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant