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

XLA_TARGET for Apple Metal Silicon? #74

Closed
shaqq opened this issue Feb 10, 2024 · 11 comments · Fixed by #75
Closed

XLA_TARGET for Apple Metal Silicon? #74

shaqq opened this issue Feb 10, 2024 · 11 comments · Fixed by #75

Comments

@shaqq
Copy link

shaqq commented Feb 10, 2024

Apologies for the n00b question

If I want BumbleBee/Axon/EXLA to use GPUs on Apple M1 Silicon via Metal, what should I set the XLA_TARGET to?

@josevalim
Copy link
Contributor

XLA has no official support afaik. Apple release some plugin for old versions but afaik that is already outdated.

@josevalim josevalim closed this as not planned Won't fix, can't repro, duplicate, stale Feb 11, 2024
@shaqq
Copy link
Author

shaqq commented Feb 11, 2024

I see - I think #51 is the reference issue, and maybe jax-ml/jax#8074.

I can send up a PR to the README here to clarify this (if you'd like, @josevalim). I'm sure others are looking to use Bumblebee on their Macs and want to know if it works on Apple Metal.

josevalim added a commit that referenced this issue Feb 11, 2024
@joelberkeley
Copy link

joelberkeley commented Nov 29, 2024

Any progress with this? I'm trying to build the PJRT plugin myself but don't know where to start. It's far more opaque than building for aarch64 CPUs, which isn't particularly easy either

@polvalente
Copy link

We've released elixir-nx/emlx for Metal support!

There's still some work needed for compiler acceleration, but I was already able to see some improvements on workflows that don't make use of the EXLA compiler, just the backend.

@josevalim
Copy link
Contributor

The plugins are out of scope for this repository but the good news is that you should be able to just import existing precompiled ones. Here is a PR where we add support for Metal plugins in Nx: elixir-nx/nx#1504 - but it wasn't merged yet because several operations are missing on Apple's plugins and unfortunately the plugin is closed source.

@joelberkeley
Copy link

OK so the jax metal plugin packaged in the python wheel isn't python-specific (as many jax things are, I think)? And it can be used as a normal PjRt plugin?

@jonatanklosko
Copy link
Member

@joelberkeley correct, it's just a PjRt plugin!

@joelberkeley
Copy link

joelberkeley commented Nov 30, 2024

Do you know if it's an XLA plugin? The website says

The Metal plugin uses the OpenXLA compiler

but OpenXLA is an ecosystem not a compiler. It's not important but I am curious.

@jonatanklosko
Copy link
Member

I'm not sure what you mean by XLA plugin :D There are many parts, so I may be missing the right wording, but the Jax Metal provides a PjRt plugin API implementation, in the sense that you load a dynamic library via pjrt::LoadPjrtPlugin.

@joelberkeley
Copy link

joelberkeley commented Nov 30, 2024

I'm not sure what you mean by XLA plugin

A PjRt plugin that uses the XLA compiler.

in the sense that you load a dynamic library via pjrt::LoadPjrtPlugin

ah, so this plugin doesn't have a C API, for use with the PjRt C API? I'm assuming the presence of an extern "C" function GetPjrtApi like in the CPU plugin

@joelberkeley
Copy link

joelberkeley commented Nov 30, 2024

ah, ok so that function calls GetPjrtApi anyway, so we're on the same page (assuming an extern "C")

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 a pull request may close this issue.

5 participants