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

Load PjRT Plugin API for Custom PjRT Backend #5046

Open
aws-kingrj opened this issue May 22, 2023 · 5 comments
Open

Load PjRT Plugin API for Custom PjRT Backend #5046

aws-kingrj opened this issue May 22, 2023 · 5 comments
Labels
nostale Do not consider for staleness runtime

Comments

@aws-kingrj
Copy link
Collaborator

aws-kingrj commented May 22, 2023

❓ Questions and Help

We are currently trying to use the load_pjrt_plugin() API for loading custom C-API pjrt plugins but the function is not exposed in torch_xla. I can see it defined here in the xla.cc file of the tensorflow xla commit used for torch_xla 2.0: https://github.com/tensorflow/tensorflow/blob/f7759359f8420d3ca7b9fd19493f2a01bd47b4ef/tensorflow/compiler/xla/python/xla.cc#L325 as a part of the xla_extension.so file as a pybind11 module but that xla_extensions.so file isn't exposed in torch_xla.

Is there another way we can used this API in python to load our C-API pjrt plugin with the current torch_xla 2.0 or is there some other API exposed for us to load pjrt plugins?

@JackCaoG
Copy link
Collaborator

@will-cromar Can you take a look?

@will-cromar
Copy link
Collaborator

We don't support the xla_extensions pybind module in PyTorch/XLA. You have to load the module in C++ during the ComputationClient creation. For now, you can add a branch like this one here:

} else if (device_type == "XPU") {
TF_VLOG(1) << "Initializing PjRt XPU client...";
XLA_CHECK_OK(pjrt::LoadPjrtPlugin(
"xpu", sys_util::GetEnvString(env::kEnvXpuLibraryPath, "libxpu.so")));
client_ = std::move(xla::GetCApiClient("XPU").value());

You can use the XPU PR as a reference to add a new plugin: #4891

I'm planning on updating this logic to allow dynamic plugin loading and remove all of those device type enums/lists, but that may have to wait until after we remove XRT.

@amithrm
Copy link
Collaborator

amithrm commented May 23, 2023

Thanks @will-cromar ! We will try doing this and update you

@JackCaoG JackCaoG added nostale Do not consider for staleness runtime labels Jun 5, 2023
@aws-kingrj
Copy link
Collaborator Author

Neuron PR for this #5428

@aws-kingrj
Copy link
Collaborator Author

Neuron PR for import hook to be added: #5429

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
nostale Do not consider for staleness runtime
Projects
None yet
Development

No branches or pull requests

4 participants