-
Notifications
You must be signed in to change notification settings - Fork 476
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
pjrt_c_api_cpu_plugin - MacOS amd and arm64 compilation #19152
Comments
Same error occurs with |
But aside from these broken tests issues, a (XLA at To factor out the Go bindings ( The C++ test compiles runs and fails without an error in Mac -- but succeeds as expected in Linux. Here is the code:
namespace xla {
namespace {
using std::cout;
using std::endl;
const std::string kPjrtPluginPath = "/usr/local/lib/gomlx/pjrt/pjrt_c_api_cpu_plugin.so";
static void SetUpCpuPjRtApi() {
std::string device_type = "cpu";
auto status = ::pjrt::PjrtApi(device_type);
if (!status.ok()) {
TF_ASSERT_OK_AND_ASSIGN(
const PJRT_Api* api,
pjrt::LoadPjrtPlugin(device_type, kPjrtPluginPath)
);
cout << "Loaded PJRT from " << kPjrtPluginPath << endl;
}
}
TEST(PjRtCApiClientTest, EndToEnd) {
SetUpCpuPjRtApi();
TF_ASSERT_OK_AND_ASSIGN(std::unique_ptr<PjRtClient> client,
GetCApiClient("cpu"));
cout << "\tplatform_name=" << client->platform_name()
<< ", platform_id=" << client->platform_id()
<< endl;
// Create f(x) = x^2
cout << "Create f(x) = x^2:" << endl;
XlaBuilder builder("x*x+1");
Shape x_shape = ShapeUtil::MakeShape(F32, {});
auto x = Parameter(&builder, 0, x_shape, "x");
auto f = Mul(x, x);
auto computation = builder.Build(f).value();
cout << "\tComputation built." << endl;
std::unique_ptr<PjRtLoadedExecutable> executable =
client->Compile(computation, CompileOptions()).value();
cout << "\tCompiled to executable." << endl;
// Transfer concrete x value.
std::vector<float> data{3};
TF_ASSERT_OK_AND_ASSIGN(
auto x_value,
client->BufferFromHostBuffer(
data.data(), x_shape.element_type(), x_shape.dimensions(),
/*byte_strides=*/std::nullopt,
PjRtClient::HostBufferSemantics::kImmutableOnlyDuringCall, nullptr,
client->addressable_devices()[0]));
cout << "Tranferred value of x=" << data[0] << " to device." << endl;
// Execute function.
ExecuteOptions execute_options;
execute_options.non_donatable_input_indices = {0};
std::vector<std::vector<std::unique_ptr<PjRtBuffer>>> results =
executable->Execute({{x_value.get()}}, execute_options)
.value();
ASSERT_EQ(results[0].size(), 1);
auto& result_buffer = results[0][0];
// How do we print the actual result !?
cout << "Success" << endl;
}
} // namespace
} // namespace xla When running with
Yes, it fails without an error of any type before finishing to compile the HLO program.
|
I'm trying to debug it, and building it with
Again, notice this is something that only happens on DARWIN platform. |
Also if one changes static void SetUpCpuPjRtApi() {
std::string device_type = "cpu";
auto status = ::pjrt::PjrtApi(device_type);
if (!status.ok()) {
TF_ASSERT_OK(
pjrt::SetPjrtApi(device_type, ::pjrt::cpu_plugin::GetCpuPjrtApi()));
}
} With (adjust const std::string kPjrtPluginPath = "/usr/local/lib/gomlx/pjrt/pjrt_c_api_cpu_plugin.so";
static void SetUpCpuPjRtApi() {
std::string device_type = "cpu";
auto status = ::pjrt::PjrtApi(device_type);
if (!status.ok()) {
TF_ASSERT_OK_AND_ASSIGN(
const PJRT_Api* api,
pjrt::LoadPjrtPlugin(device_type, kPjrtPluginPath));
}
} |
Hi,
I'm trying to compile on macOS amd and arm64 the plugin pjrt_c_api_cpu_plugin.so.
The build succeeds but when I try to use it in gopjrt I'm getting a segmentation violation error.
What I've done:
On the xla project :
./configure.py --backend CPU --os DARWIN
bazel build //xla/pjrt/c:pjrt_c_api_cpu_plugin.so
Then I've just tried to run the gopjrt tests and they are showing me the error.
If I use the JAX metal plugin -> pjrt_plugin_metal_14.dylib the project is working fine.
Someone has already compiled and used the plugin on macOS?
Thanks
The text was updated successfully, but these errors were encountered: