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

Array API: remove array mutation from functions/write JAX version of each array mutating function #432

Open
Saransh-cpp opened this issue Nov 17, 2024 · 0 comments
Assignees
Labels
api An (incompatible) API change array-api Work is related to the Array API

Comments

@Saransh-cpp
Copy link
Member

Saransh-cpp commented Nov 17, 2024

Add your issue here

Conversation from Slack -

2 quick things from my initial experiments -

We will need custom JAX implementations for most of the functions as JAX arrays are immutable. See how -

Given that the project's first half is more focussed on GPUs and less on AD, I experimented with CuPy, but their Array API support is still experimental (and I might have also stumbled on a bug - cupy/cupy#8747).

I thought the only place in the code where we cannot trivially get around the mutation was in iternorm() but I haven't actually gone through and checked

Oh yes, or remove all the lines of code that are mutating arrays. Maybe I should check for all such lines using ruff.

So the mutation in iternorm would be quite organically fixed by the "deep dive" project outside the GPU work that I was mentioning. We definitely have a path forward there.

My inclination would be that we change all functions to not mutate arrays and then we can use jax and everything else in one go. Is there any disadvantage of this approach?

Only in the way iternorm currently works, since it always needs to discard a large array and reallocate a fresh large array that's exactly the same. But probably negligible in the grand scheme of things, within GLASS at least (the code predates use in GLASS).

@Saransh-cpp Saransh-cpp added array-api Work is related to the Array API api An (incompatible) API change labels Nov 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api An (incompatible) API change array-api Work is related to the Array API
Projects
None yet
Development

No branches or pull requests

3 participants