Skip to content

Use @jtu.register_static as decorator on _Missing#1193

Draft
nstarman wants to merge 3 commits into
patrick-kidger:mainfrom
nstarman:copilot/simplify-pytree-registration
Draft

Use @jtu.register_static as decorator on _Missing#1193
nstarman wants to merge 3 commits into
patrick-kidger:mainfrom
nstarman:copilot/simplify-pytree-registration

Conversation

@nstarman

@nstarman nstarman commented Mar 4, 2026

Copy link
Copy Markdown
Contributor

Applies jax.tree_util.register_static as a class decorator on _Missing instead of a separate post-definition call, co-locating the registration with the class.

# Before
class _Missing:
    ...

MISSING = _Missing()
jtu.register_static(_Missing)

# After
@jtu.register_static
class _Missing:
    ...

MISSING = _Missing()

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits March 4, 2026 16:26
Co-authored-by: nstarman <8949649+nstarman@users.noreply.github.com>
Co-authored-by: nstarman <8949649+nstarman@users.noreply.github.com>
@nstarman nstarman changed the title simplify pytree registration Use @jtu.register_static as decorator on _Missing Mar 4, 2026
@nstarman

nstarman commented Mar 4, 2026

Copy link
Copy Markdown
Contributor Author

Copilot made this PR on nstarman#3 and I transferred it here.

@nstarman nstarman marked this pull request as ready for review March 4, 2026 16:55
Copilot AI review requested due to automatic review settings March 4, 2026 16:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors how the internal _Missing sentinel type is registered with JAX pytrees by co-locating the registration directly on the class definition.

Changes:

  • Apply @jtu.register_static as a class decorator to _Missing.
  • Remove the separate post-definition pytree registration call for _Missing.

Comment thread equinox/_module/_flatten.py
@patrick-kidger

Copy link
Copy Markdown
Owner

So I'm inclined to leave this as-is, e.g. because the older registration will work on older JAX versions.

@nstarman

nstarman commented Mar 6, 2026

Copy link
Copy Markdown
Contributor Author

Or wait to merge until the minimum supported JAX version has register_static ?

@nstarman

nstarman commented Mar 6, 2026

Copy link
Copy Markdown
Contributor Author

I can convert back to draft.

@nstarman nstarman marked this pull request as draft April 21, 2026 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants