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

Added support for declaring PyTree structures. #135

Merged
merged 15 commits into from
Nov 27, 2023
Merged

Conversation

patrick-kidger
Copy link
Owner

No description provided.

@patrick-kidger patrick-kidger force-pushed the structure-matching branch 2 times, most recently from 50d4a0c to 6b35a7f Compare October 22, 2023 00:35
@patrick-kidger patrick-kidger force-pushed the structure-matching branch 2 times, most recently from 14ffdac to d84bd95 Compare October 24, 2023 18:23
Base automatically changed from fixed-variadic-broadcast to main November 7, 2023 19:35
Phew, this ended up being a pretty complicated change!
The basic summary is that we now support the syntax
```
@jaxtyped(typechecker=typechecker)
def f(...): ...
```
and when using this, we now get pretty error messages about what went
wrong.

(
The old syntax, i.e.
```
@jaxtyped
@typechecker
def f(...): ...
```
is still supported, but doesn't give much information.
)

The internals of this do quite a lot of magic! In particular we
dynamically create quite a lot of functions and test the provided
arguments against their signatures. The overhead should still be
minimal under `jax.jit`, though.
(TODO: what's the overhead like in non-jit situations, e.g. PyTorch?
I've tried to minimise the overhead throughout just to be sure, but
perhaps PyTorch users should stick to the old syntax?)
…his avoids edge-case crash when using pytree-path dependent sizes
@patrick-kidger patrick-kidger merged commit 8e47c90 into main Nov 27, 2023
4 checks passed
@patrick-kidger patrick-kidger deleted the structure-matching branch November 27, 2023 17:50
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.

None yet

1 participant