From 9909a26a633787db2eef83e9043459900f11e4d2 Mon Sep 17 00:00:00 2001 From: Corentin Godeau Date: Wed, 15 Jan 2025 12:46:13 +0000 Subject: [PATCH 1/3] runtimes/rocm: fix --- runtimes/rocm/libpjrt_rocm.BUILD.bazel | 4 ++++ runtimes/rocm/zmlxrocm.cc | 1 + 2 files changed, 5 insertions(+) diff --git a/runtimes/rocm/libpjrt_rocm.BUILD.bazel b/runtimes/rocm/libpjrt_rocm.BUILD.bazel index d28bfd2c..2d4790da 100644 --- a/runtimes/rocm/libpjrt_rocm.BUILD.bazel +++ b/runtimes/rocm/libpjrt_rocm.BUILD.bazel @@ -62,6 +62,10 @@ cc_import( "//conditions:default": [], }), shared_library = "libpjrt_rocm.so", + add_needed = ["libzmlxrocm.so.0"], + rename_dynamic_symbols = { + "dlopen": "zmlxrocm_dlopen", + }, visibility = ["//visibility:public"], deps = [ ":zmlxrocm", diff --git a/runtimes/rocm/zmlxrocm.cc b/runtimes/rocm/zmlxrocm.cc index e69f75b4..ff7c8da3 100644 --- a/runtimes/rocm/zmlxrocm.cc +++ b/runtimes/rocm/zmlxrocm.cc @@ -10,6 +10,7 @@ static void setup_runfiles(int argc, char **argv) __attribute__((constructor)) { + std::ifstream f{argv[0]}; using bazel::tools::cpp::runfiles::Runfiles; auto runfiles = std::unique_ptr(Runfiles::Create(argv[0], BAZEL_CURRENT_REPOSITORY)); From 3bd91c95d8491cb0ed5a87bc507d187a08945803 Mon Sep 17 00:00:00 2001 From: Corentin Godeau Date: Wed, 15 Jan 2025 12:46:55 +0000 Subject: [PATCH 2/3] zml/module.zig: disable PJRT caching --- zml/module.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zml/module.zig b/zml/module.zig index 3bcdc9ec..83af1629 100644 --- a/zml/module.zig +++ b/zml/module.zig @@ -211,7 +211,7 @@ pub const CompilationContext = struct { const module_hash = computeModuleHash(self._platform, module); var module_dir: ?[]const u8 = null; - var pjrt_location: ?[:0]const u8 = null; + const pjrt_location: ?[:0]const u8 = null; if (self._platform.compilation_options.xla_dump_to) |xla_dump_to| { const sep = std.fs.path.sep_str; @@ -229,7 +229,7 @@ pub const CompilationContext = struct { log.warn("Failed to open {s}", .{mlir_name}); } - pjrt_location = try std.fs.path.joinZ(arena, &.{ module_dir.?, "module.pjrt" }); + //pjrt_location = try std.fs.path.joinZ(arena, &.{ module_dir.?, "module.pjrt" }); } const loaded_executable: *pjrt.LoadedExecutable = blk: { From 8ae1b741b8c5e6085ff4bd5344cf4424ceab5c37 Mon Sep 17 00:00:00 2001 From: Corentin Godeau Date: Wed, 15 Jan 2025 12:47:12 +0000 Subject: [PATCH 3/3] examples/llama: enable profiling --- examples/llama/main.zig | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/examples/llama/main.zig b/examples/llama/main.zig index d7f82736..84800908 100644 --- a/examples/llama/main.zig +++ b/examples/llama/main.zig @@ -39,6 +39,15 @@ pub fn generateText( seed: u128, prompt: []const u8, ) ![]const u8 { + var profiler = mod.platform().getProfiler(null); + defer profiler.deinit(); + + profiler.start(); + defer { + profiler.stop(); + profiler.dumpAsJsonTo(allocator, std.fs.cwd(), "trace.json") catch unreachable; + } + const prompt_tok = tokenizer.encode(allocator, prompt, .{}) catch unreachable; log.debug("Tokenized Prompt {d}", .{prompt_tok}); const dims = llama.model.shape();