From b016c8adcbde4bf6d9f73197836302826c470dc7 Mon Sep 17 00:00:00 2001 From: Dragan Mladjenovic Date: Wed, 22 Apr 2026 23:29:03 -0700 Subject: [PATCH 1/4] PR #40385: [ROCm] Streamline bazel targets for rocm libraries MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Imported from GitHub PR https://github.com/openxla/xla/pull/40385 📝 Summary of Changes Move from linking to rocm libraries trough DsoLoader to direct linking. Make sure we only link to specified rocm library, not to any other library said library may use. This change leaves enough wrapper (namespace wrap) headers needed for TF. 🎯 Justification Makes our build targets not tainted by transitive dependencies of rocm libraries. DsoLoader use has little benefit for rocm since the libraries get loaded ahead of time by jax plugin anyways. 🚀 Kind of Contribution ♻️ Cleanup Copybara import of the project: -- 38470a3e7e6113bab1ea3f2c9a5e30eb087da0f7 by Dragan Mladjenovic : [ROCm] Streamline bazel targets for rocm libraries -- 7f2ec3413faf0f9fcdbca005eaf1bb04414cadd3 by Dragan Mladjenovic : [ROCm] Remove rocm_solver_context -- 1e34f26de297e5a5d6fc6ad845ab2e6916f1273a by Dragan Mladjenovic : [ROCm] Remove hipblaslt_wrapper.h -- 2a35a534c1de76c90051b3db07233c57db565c5d by Dragan Mladjenovic : [ROCm] Remove hipsparse_wrapper.h -- 37338f22c47a4f57e514b32d2a9058c5c21c96e0 by Dragan Mladjenovic : Remove rocsolver_wrapper.h -- 545039f97aec9c96cc0ef3eb21df714c3f41c2be by Dragan Mladjenovic : Remove rocblas_wrapper.h -- c7e959ea1c8053231c1ee8155e28a653e6ac974a by Dragan Mladjenovic : Remove rocm_driver_wrapper.h -- e41363dfd9b0b82f5f6789ba56480f7ba5cd6a76 by Dragan Mladjenovic : Remove wrap namespace usage from rocm_fft -- 94dc13e75523e61424116edb051bf35815c0f438 by Dragan Mladjenovic : Remove wrap namespace usage from rocm_dnn -- 0885e4018ed701815a4ff0388780f180ede29e0f by Dragan Mladjenovic : Remove TryDlopenROCmLibraries -- 983cc3f0cfa4cc616dfbca172fbb7530e8678049 by Dragan Mladjenovic : Remove :all_files -- aa5b6c313b8153d77351ceadcd319bb11b09314d by Dragan Mladjenovic : Partialy restore *wrapper.h files needed by ROCm TF -- d2e89c2861024092a361b723f68255157e581f70 by Dragan Mladjenovic : Use more filegroups -- 3abd2376d1d688524348f2cd6c9fcc633eeb0957 by Dragan Mladjenovic : Remove DsoLoader ROCm support -- 474acd27c9c6e3050fc63cf4b63dac4c85ceffa7 by Dragan Mladjenovic : Unblock X86 build CI -- 57e11008fdb0afe46e3ba25f582360d6365f1099 by Dragan Mladjenovic : Fix RBE build -- 8a55bfb69b092827c96237faf30c65305686c473 by Dragan Mladjenovic : Move to rocm_lib_import macro Merging this change closes #40385 COPYBARA_INTEGRATE_REVIEW=https://github.com/openxla/xla/pull/40385 from ROCm:draganm/rocm_libs 8a55bfb69b092827c96237faf30c65305686c473 PiperOrigin-RevId: 904252712 (cherry picked from commit 4f993de7ae1ca4932bc9389ef56e4c2ac06213e2) (cherry picked from commit 16f1d8dd3f71f16715fbf15c7f585275f9f68866) --- third_party/gpus/rocm/build_defs.bzl.tpl | 3 ++- xla/tsl/platform/default/dso_loader.cc | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/third_party/gpus/rocm/build_defs.bzl.tpl b/third_party/gpus/rocm/build_defs.bzl.tpl index 76a5c04c130de..4c4aca36404e2 100644 --- a/third_party/gpus/rocm/build_defs.bzl.tpl +++ b/third_party/gpus/rocm/build_defs.bzl.tpl @@ -1,5 +1,6 @@ load("@rules_cc//cc:cc_import.bzl", "cc_import") load("@rules_cc//cc:cc_library.bzl", "cc_library") +load("@rules_cc//cc:cc_import.bzl", "cc_import") # Macros for building ROCm code. def if_rocm(if_true, if_false = []): @@ -83,7 +84,7 @@ def rocm_library(copts = [], deps = [], **kwargs): def get_rbe_amdgpu_pool(is_single_gpu = False): return "%{single_gpu_rbe_pool}" if is_single_gpu else "%{multi_gpu_rbe_pool}" -def rocm_lib_import(name, interface_library, data, deps): +def rocm_lib_import(name, interface_library, data, deps=[]): cc_import( name = name + "_interface", shared_library = interface_library, diff --git a/xla/tsl/platform/default/dso_loader.cc b/xla/tsl/platform/default/dso_loader.cc index e79365fd562c6..6fa691439f999 100644 --- a/xla/tsl/platform/default/dso_loader.cc +++ b/xla/tsl/platform/default/dso_loader.cc @@ -50,7 +50,6 @@ absl::string_view GetCusparseVersion() { return TF_CUSPARSE_VERSION; } absl::string_view GetNcclVersion() { return TF_NCCL_VERSION; } absl::string_view GetTensorRTVersion() { return TF_TENSORRT_VERSION; } absl::string_view GetNvshmemVersion() { return XLA_NVSHMEM_VERSION; } - absl::StatusOr GetDsoHandle(const std::string& name, absl::string_view version) { auto filename = From fcfddb9b7de50cdded95bcde361cd48d57cb8f6f Mon Sep 17 00:00:00 2001 From: Dragan Mladjenovic Date: Mon, 4 May 2026 05:13:15 -0700 Subject: [PATCH 2/4] PR #41591: [ROCm] Unblock CI after PR #40385 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Imported from GitHub PR https://github.com/openxla/xla/pull/41591 📝 Summary of Changes Default for hermetic paths in non-hermetic build too 🎯 Justification Makes CI pick up rocm libs when doing local build + remote testing 🚀 Kind of Contribution 🐛 Bug Fix Copybara import of the project: -- 2ab9eadd430de3a17924f17bf53b9270b67a5acd by Dragan Mladjenovic : [ROCm] Unblock CI after PR #40385 Merging this change closes #41591 COPYBARA_INTEGRATE_REVIEW=https://github.com/openxla/xla/pull/41591 from ROCm:draganm/rocm_libs_followup 2ab9eadd430de3a17924f17bf53b9270b67a5acd PiperOrigin-RevId: 909965137 (cherry picked from commit d9922e7bfb72f055d4d852360f782aa3a0b2a8f6) (cherry picked from commit 83380a5a9759581a6e285e427a71af8097be8be0) --- third_party/gpus/rocm/build_defs.bzl.tpl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/third_party/gpus/rocm/build_defs.bzl.tpl b/third_party/gpus/rocm/build_defs.bzl.tpl index 4c4aca36404e2..76a5c04c130de 100644 --- a/third_party/gpus/rocm/build_defs.bzl.tpl +++ b/third_party/gpus/rocm/build_defs.bzl.tpl @@ -1,6 +1,5 @@ load("@rules_cc//cc:cc_import.bzl", "cc_import") load("@rules_cc//cc:cc_library.bzl", "cc_library") -load("@rules_cc//cc:cc_import.bzl", "cc_import") # Macros for building ROCm code. def if_rocm(if_true, if_false = []): @@ -84,7 +83,7 @@ def rocm_library(copts = [], deps = [], **kwargs): def get_rbe_amdgpu_pool(is_single_gpu = False): return "%{single_gpu_rbe_pool}" if is_single_gpu else "%{multi_gpu_rbe_pool}" -def rocm_lib_import(name, interface_library, data, deps=[]): +def rocm_lib_import(name, interface_library, data, deps): cc_import( name = name + "_interface", shared_library = interface_library, From a2eb9c32e0e7ab5cd3e56cd6709731447ef01aec Mon Sep 17 00:00:00 2001 From: Aleksei Nurmukhametov Date: Tue, 26 May 2026 15:36:57 +0000 Subject: [PATCH 3/4] [ROCm] Add librocm_kpack and libclang-cpp to runfiles globs Two new DT_NEEDED entries appeared in ROCm 7.13 that BUILD.tpl's data globs weren't mirroring into runfiles, causing dlopen failures at runtime: - libamdhip64.so.7 -> librocm_kpack.so.0 - libamd_comgr.so.3 -> libclang-cpp.so (cherry picked from commit 9fb3e7d9b7e7d69d8e50d0b2cc8423798375516e) (cherry picked from commit 802fe8adcbc12ff31315dee495458cbe6cb9659a) --- third_party/gpus/rocm/BUILD.tpl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/third_party/gpus/rocm/BUILD.tpl b/third_party/gpus/rocm/BUILD.tpl index 51ab379ed21e4..f225ec82baae3 100644 --- a/third_party/gpus/rocm/BUILD.tpl +++ b/third_party/gpus/rocm/BUILD.tpl @@ -148,6 +148,7 @@ rocm_lib_import( data = glob( [ "%{rocm_root}/lib/libamdhip64.so*", + "%{rocm_root}/lib/librocm_kpack.so*", ], ), interface_library = "%{rocm_root}/lib/libamdhip64.so", @@ -195,6 +196,7 @@ cc_library( "%{rocm_root}/lib/libamd_comgr_loader.so*", "%{rocm_root}/lib/libamd_comgr.so*", "%{rocm_root}/lib/llvm/lib/libLLVM.so*", + "%{rocm_root}/lib/llvm/lib/libclang-cpp.so*", ], ), deps = [ From f2ef57efccf83f0e365f31e42333dfd804ac1dbf Mon Sep 17 00:00:00 2001 From: tsrw2048 <239799652+tsrw2048@users.noreply.github.com> Date: Tue, 9 Jun 2026 17:29:04 +0000 Subject: [PATCH 4/4] Fix formatting error in rocm_blas.cc (cherry picked from commit 8ef3bb4953b489196d0188cbabf8c1abfcbc4633) --- xla/stream_executor/rocm/rocm_blas.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xla/stream_executor/rocm/rocm_blas.cc b/xla/stream_executor/rocm/rocm_blas.cc index 0fabd1dc387fc..297327c97e465 100644 --- a/xla/stream_executor/rocm/rocm_blas.cc +++ b/xla/stream_executor/rocm/rocm_blas.cc @@ -69,7 +69,7 @@ namespace { #define ROCBLAS_API_WRAPPER(__name) \ struct WrapperShim__##__name { \ - constexpr static const char* kName = #__name; \ + constexpr static const char *kName = #__name; \ template \ rocblas_status operator()(Args... args) { \ return (::__name)(args...); \