Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use qualified Python names in metadata if available #18794

Merged
merged 1 commit into from
Dec 4, 2023

Conversation

olupton
Copy link
Contributor

@olupton olupton commented Dec 4, 2023

co_qualname is the equivalent of __qualname__ in Python code.
For a member function

class A:
  def b(self):
    pass

then the co_name of b was b, and the co_qualname of it is A.b.
These locations are propagated to XLA and the metadata of the compiled graph.
Depending on the coding style, b can be a very generic name (run, or whatever) with the useful information contained in the class name, A. In that case, having both in the metadata is more informative.

Unfortunately before Python 3.11 then the qualified name was not available through the code object.

See #18764 for an example of the co_name-based metadata.

cc: @nouiz

@hawkinsp hawkinsp self-assigned this Dec 4, 2023
Copy link
Collaborator

@hawkinsp hawkinsp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Thanks for the PR.

(The only thing I'm wondering is: do we have a test for this? If so, it might need updating. Let's see what CI says.)

@google-ml-butler google-ml-butler bot added kokoro:force-run pull ready Ready for copybara import and testing labels Dec 4, 2023
@copybara-service copybara-service bot merged commit 5e0993c into jax-ml:main Dec 4, 2023
@olupton olupton deleted the qualname branch December 4, 2023 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pull ready Ready for copybara import and testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants