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

Optional autodiff support? #518

Open
alxmrs opened this issue Jul 23, 2024 · 4 comments
Open

Optional autodiff support? #518

alxmrs opened this issue Jul 23, 2024 · 4 comments

Comments

@alxmrs
Copy link
Contributor

alxmrs commented Jul 23, 2024

It would be awesome if the backing array implementation supported auto differentiation, that we could access some grad method from Cubed.

It looks like a bunch of stakeholder libraries have this functionality:

https://data-apis.org/array-api/latest/purpose_and_scope.html#stakeholders

Though, differentiable programming may be out of scope for Cubed. @TomNicholas @tomwhite @rbavery any thoughts here?

I have a pipe dream of turning Cubed into an ML framework, and I think this would play an important part.

I haven’t thought of all the implications, but a potential sharp edge that @shoyer once pointed out to me: there will probably be significant memory differences between an op graph and its gradient. Can Cubed’s spec model be extended here?

@tomwhite
Copy link
Member

Can Cubed’s spec model be extended here?

Cubed has a simple model of upper bounds for memory usage, derived from knowledge about the different operations in the array API. So if there's a way of modelling the memory usage of gradient operations, then this should be possible.

@alxmrs
Copy link
Contributor Author

alxmrs commented Jul 26, 2024 via email

@shoyer
Copy link

shoyer commented Jul 26, 2024

If you want to do this on top of JAX, I think the easiest approach is probably to build a custom interpreter that implements the array API on top of JAXprs:
https://jax.readthedocs.io/en/latest/notebooks/Writing_custom_interpreters_in_Jax.html

JAX primitives are typically thin wrappers around a minimal set of XLA operations, so hopefully this would be relatively straightforward. JAXprs are quite explicit about array shapes, so memory usage should be fairly transparent.

@tomwhite
Copy link
Member

Thanks @shoyer! That's very useful.

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

No branches or pull requests

3 participants