Skip to content

add more detail about aux_data in pytree docs #8739

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mattjj
Copy link
Collaborator

@mattjj mattjj commented Nov 30, 2021

fixes #8726

@mattjj mattjj requested a review from hawkinsp November 30, 2021 19:44
@google-cla google-cla bot added the cla: yes label Nov 30, 2021
@mattjj mattjj requested review from jakevdp and removed request for hawkinsp November 30, 2021 19:45
to specify how to flatten and unflatten instances of the new type. That is, you
register two functions: the first function accepts instances of the new type and
returns a pair where the first element is an iterable of children (for example,
the values of a dictionary) and the second element is auxiliary metadata needed
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we add some words about how you might decide what parts of an object are "children" and what are "aux_data"? My understanding is that children should contain all the traceable/dynamic/JAX-array components (not sure the best language to use there), and aux_data should be all the static components (and must be hashable, I believe)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good idea. Though I don't like the word "static", I'll figure out a way to express that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

(The reason I don't like the word "static" here is that I think of that as jit- or staging-specific jargon, which doesn't cover all cases here, e.g. in how pytree metadata interacts with vmap or AD. It's hard to think of a better term though...)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe something like "generally all array components should go into children, and all non-array metadata should go into aux_data"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nice! That seems like a good rule of thumb.

@jakevdp
Copy link
Collaborator

jakevdp commented Jun 29, 2022

Ping on this - it would be a nice addition to the docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Doc for register_pytree_node_class doesn't explain aux_data
2 participants