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
Framework Agnostic API: Introduces a new low-level API, removes the dependency between Model and Module, adds support for Flax and Haiku, simplifies hooks. #139
Conversation
Care to explain? Will this break the existing API? |
Hey @alexander-g, I was going to tag you here with some info once I got an MVP but here is what is happening: I've been thinking a lot about both #138 and #128, and more generally on how to make Elegy more appealing to the research-oriented Jax ecosystem. Current proposal:
Pros:
Cons:
Pointers:
Open Questions:
|
What do you think about this? Very opened to suggestions. |
It sounds promising and I support this direction. |
@alexander-g I believe we can maintain the functionality needed for |
I suppose you could go a little further and centralise imports to one part of the codebase, say an if environ["ELEGY_ENGINE"] == "np":
# use `numpy`
elif environ["ELEGY_ENGINE"] == "jax":
# use `JAX`
elif environ["ELEGY_ENGINE"] == "arrow":
# use apache arrow
elif environ["ELEGY_ENGINE"] == "tensorflow":
# use `tf.experimental.numpy`, and maybe other tf stuff also Most formula are equivalent, so easily work (à la, the |
Hey @SamuelMarks, right now by "framework agnostic" I mean that it should be able to work with any / most of the other Jax-based Module framework such as Flax, Haiku, ect. |
Just because other frameworks make it harder for their users doesn't mean Elegy has to copy it. It's not like it's mutually exclusive, the user could still call |
For now I think there is still one advantage of init + apply: safety. If we have a single type-dependent apply for GeneralizedModule then That said, I am very intrigued by the idea, maybe we can explore it in the future. |
@charlielito Examples are now being tested. |
It been a very intense PR and some tasks are missing but I think I am merging this to |
As noted below, this PR contains the following features:
GeneralizedModule
API and implements it for Flax, Haiku, Elegy Module types, and regular python functions.Tasks: