Skip to content

[precompile] Resolve code defined under a property or cached_property - #194619

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

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

Conversation

@bobrenjc93

@bobrenjc93 bobrenjc93 commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

A frame whose code object lives inside a descriptor has no resolvable name, so
capture drops it:

PackageError: Cannot resolve a fully qualified name for
<code object slim_comp_expose_outputs>. Lookup scope: <property object>

convert_frame catches that and runs the frame eager, so the capture reports
success while quietly covering less. On a large production model one property
cost four frames this way.

getattr on a CLASS returns the descriptor, never the function inside it, and
every place that walks a code object to a name filters for
function/method/class. A property passes none of those tests, so the walk
either stops on an object it cannot descend into (3.11+, where the qualname is
walked directly) or skips the attribute entirely (3.10 and below, where the
class dict is scanned). Both arms needed the same unwrapping, which is now one
helper naming the attribute -- fget, fset, fdel, or func -- rather than
the function, because that is what makes the path round-trip: the loader
replays it with plain getattr, and property.fget is an ordinary attribute.
C.prop resolves to ("C.prop", "fget.__code__").

The name check in the class scan needed the same treatment: a descriptor has no
__name__, so it compares the wrapped function's, which carries the
attribute's name.

Not fixed here, from the same report: two other resolution failures on that
model are code objects built by exec of generated source -- a dataclass-style
__init__ and a dynamic_func, both at <string> -- which have no module to
resolve by construction. Whether those should be resolvable at all or a quiet
documented skip is a different question from this one, which is a plain miss.

Test Plan:

python test/dynamo/test_package.py
python test/test_precompile.py
python test/dynamo/test_aot_autograd_cache.py

One new test covers a getter, a nested function inside a getter, a
cached_property and a setter, and for each replays exactly what the loader
does -- including the co_consts[i] index step -- so the assertion is that the
path round-trips rather than merely that a name was produced. All four raise
without this change.

Authored with an AI assistant.

Differential Revision: D117283890

[ghstack-poisoned]
@bobrenjc93 bobrenjc93 added ciflow/trunk Trigger trunk jobs on your pull request topic: not user facing topic category labels Aug 24, 2026
@pytorch-bot

pytorch-bot Bot commented Aug 24, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❌ 13 New Failures, 1 Unrelated Failure

As of commit 1ac85b4 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 24, 2026
This was referenced Aug 24, 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.

[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/1065/head branch November 11, 2026 01:46
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