-
Notifications
You must be signed in to change notification settings - Fork 193
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
feat(EXLA): Add support for MLIR compilation #1247
Conversation
exla/lib/exla/client.ex
Outdated
@@ -170,6 +170,11 @@ defmodule EXLA.Client do | |||
:tpu -> | |||
EXLA.NIF.get_tpu_client() | |||
|
|||
:metal -> | |||
# TODO: Is this really where/how we want to do this? | |||
:ok = EXLA.NIF.load_pjrt_plugin("METAL", "/opt/homebrew/lib/python3.10/site-packages/jax_plugins/metal_plugin/pjrt_plugin_metal_14.dylib") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this should be linked in the respective release for elixir-nx/xla directly, and then you can have something like this coming from there:
Lines 347 to 355 in 219c23e
NIF(mps_is_available) | |
{ | |
#ifdef MAC_ARM64 | |
bool has_mps = at::hasMPS(); | |
#else | |
bool has_mps = false; | |
#endif | |
return nx::nif::make(env, has_mps); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For Torchx, this flag is defined here:
Lines 46 to 48 in 219c23e
if(ARM64_SUPPORTED) | |
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMAC_ARM64") | |
endif() |
I assume you'd do something similar for :xla
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we want to keep doing it on Elixir land: we can load the plugin on EXLA.Application. I also agree that ideally we would bundle the plugin with the precompiled XLA binary for macOS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that's going to work here because the only way to register the plugin as far as I can tell is dynamically through PjRt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I mean is that we ship the plugin with XLA and in here we point to XLA priv dir to load it. Would that work?
Requires elixir-nx/xla#45
There's a lot of other changes that need to be made as well. Metal requires MLIR and not XLA Op output, so I need to figure out how to bridge those