diff --git a/async/async.zig b/async/async.zig index 8e8cf742..19166532 100644 --- a/async/async.zig +++ b/async/async.zig @@ -102,7 +102,8 @@ pub fn callGeneric(comptime func: anytype, args: anytype) FnSignature(func, @Typ .notif = Notification.init() catch @panic("Notification.init failed"), .args = &args, }; - defer newtask.notif.deinit(); + // NOTE(Corentin): Disable this to avoid crash with epoll backend + //defer newtask.notif.deinit(); AsyncThread.current.thread_pool.schedule(xev.ThreadPool.Batch.from(&newtask._task)); newtask.notif.wait() catch @panic("Unable to wait for notification"); diff --git a/third_party/modules/libxev/20240910.0-a2d9b31/patches/0001-Change-Backend-Linux.patch b/third_party/modules/libxev/20240910.0-a2d9b31/patches/0001-Change-Backend-Linux.patch new file mode 100644 index 00000000..ed524e67 --- /dev/null +++ b/third_party/modules/libxev/20240910.0-a2d9b31/patches/0001-Change-Backend-Linux.patch @@ -0,0 +1,22 @@ +From 4db5de34f70d991fedbe28915c8239b97ba7a064 Mon Sep 17 00:00:00 2001 +From: Steeve Morin +Date: Mon, 18 Mar 2024 17:17:34 +0100 +Subject: [PATCH 3/3] [PJRT C API] Ensure C compliance for Profiler Extension + +--- + xla/pjrt/c/pjrt_c_api_profiler_extension.h | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/src/main.zig b/src/main.zig +index 74f451a..1cfb61c 100644 +--- a/src/main.zig ++++ b/src/main.zig +@@ -36,7 +36,7 @@ pub const Backend = enum { + /// Returns a recommend default backend from inspecting the system. + pub fn default() Backend { + return @as(?Backend, switch (builtin.os.tag) { +- .linux => .io_uring, ++ .linux => .epoll, + .ios, .macos => .kqueue, + .wasi => .wasi_poll, + .windows => .iocp, diff --git a/third_party/modules/libxev/20240910.0-a2d9b31/source.json b/third_party/modules/libxev/20240910.0-a2d9b31/source.json index c56bc6a8..c38d9c27 100644 --- a/third_party/modules/libxev/20240910.0-a2d9b31/source.json +++ b/third_party/modules/libxev/20240910.0-a2d9b31/source.json @@ -5,5 +5,9 @@ "overlay": { "MODULE.bazel": "", "BUILD.bazel": "" + }, + "patch_strip": 1, + "patches": { + "0001-Change-Backend-Linux.patch": "" } } diff --git a/zml/module.zig b/zml/module.zig index 69f2c952..f87ad8d6 100644 --- a/zml/module.zig +++ b/zml/module.zig @@ -849,18 +849,23 @@ pub fn ExeWithWeights(comptime func: anytype) type { pub fn call(self: Self, args: Bufferized(Signature.ArgsT)) Bufferized(Signature.ReturnT) { fillBuffers(&args, self.input_per_device, self.inner.model_buffer_count, self.inner.args_buffer_count); - var event: [1]*pjrt.Event = undefined; + var events: [Platform.MAX_NUM_DEVICES]*pjrt.Event = undefined; + const sharding = self.platform().sharding(); self.inner.exe.execute(self.inner.platform.pjrt_api, .{ .arguments = self.input_per_device, .num_args = self.inner.args_buffer_count + self.inner.model_buffer_count, .results = self.output_per_device, - .events = &event, + .events = events[0..sharding.num_partitions], // TODO: this allows to tell a specific buffer shouldn't be donated, // even if it has been marked as "can be donated" during compilation. .non_donatable_input_indices = &.{}, }) catch unreachable; + for (events[0..sharding.num_partitions]) |e| { + e.await_(self.inner.platform.pjrt_api) catch unreachable; + } + var result: Bufferized(Signature.ReturnT) = undefined; assignRawBuffers(&result, self.inner.platform, self.output_per_device, self.inner.result_buffer_shapes, self.inner.result_buffer_count); return result; diff --git a/zml/platform.zig b/zml/platform.zig index a8ec82f4..f1844e15 100644 --- a/zml/platform.zig +++ b/zml/platform.zig @@ -113,7 +113,8 @@ pub const Platform = struct { }{ .notif = try asynk.Notification.init(), }; - defer ctx.notif.deinit(); + // NOTE(Corentin): Disable this to avoid crash with epoll backend + //defer ctx.notif.deinit(); try event.onReady(self.pjrt_api, &(struct { fn call(err: ?*pjrt.Error, user_arg: ?*anyopaque) callconv(.C) void {