Skip to content

Commit

Permalink
patch-ception: fix compute_library within xla within jax
Browse files Browse the repository at this point in the history
  • Loading branch information
h-vetinari committed Feb 21, 2025
1 parent bb6a5bf commit 3100ff7
Showing 1 changed file with 155 additions and 17 deletions.
172 changes: 155 additions & 17 deletions recipe/patches/0002-Consolidated-build-fixes-for-XLA.patch
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From 3fc0f7bad5d185004ba50abf6b7d0af81fa147bb Mon Sep 17 00:00:00 2001
From b1c1955f80774f6590ad72fef42221ff720c8bf5 Mon Sep 17 00:00:00 2001
From: "Uwe L. Korn" <[email protected]>
Date: Thu, 14 Dec 2023 17:06:15 +0100
Subject: [PATCH 2/2] Consolidated build fixes for XLA
Expand All @@ -20,25 +20,27 @@ Co-Authored-By: H. Vetinari <[email protected]>
...0004-Add-missing-bits-absl-systemlib.patch | 245 ++++++++++++++++++
...ther-absl-log-is-already-initialized.patch | 58 +++++
.../xla/0006-Add-conda-cuda-path.patch | 31 +++
third_party/xla/workspace.bzl | 8 +
7 files changed, 491 insertions(+)
...07-xla-cpu-Fix-build-errors-from-ACL.patch | 128 +++++++++
third_party/xla/workspace.bzl | 10 +
8 files changed, 621 insertions(+)
create mode 100644 third_party/xla/0001-Support-third-party-build-of-boringssl.patch
create mode 100644 third_party/xla/0002-Fix-abseil-headers.patch
create mode 100644 third_party/xla/0003-Omit-usage-of-StrFormat.patch
create mode 100644 third_party/xla/0004-Add-missing-bits-absl-systemlib.patch
create mode 100644 third_party/xla/0005-Check-whether-absl-log-is-already-initialized.patch
create mode 100644 third_party/xla/0006-Add-conda-cuda-path.patch
create mode 100644 third_party/xla/0007-xla-cpu-Fix-build-errors-from-ACL.patch

diff --git a/third_party/xla/0001-Support-third-party-build-of-boringssl.patch b/third_party/xla/0001-Support-third-party-build-of-boringssl.patch
new file mode 100644
index 000000000..0d6fd60cf
index 000000000..6337bd8ee
--- /dev/null
+++ b/third_party/xla/0001-Support-third-party-build-of-boringssl.patch
@@ -0,0 +1,51 @@
+From 49a684836e4cde37d326aaac66fd7ed74e396f3b Mon Sep 17 00:00:00 2001
+From: "Uwe L. Korn" <[email protected]>
+Date: Thu, 14 Dec 2023 15:04:51 +0100
+Subject: [PATCH 1/6] Support third-party build of boringssl
+Subject: [PATCH 1/7] Support third-party build of boringssl
+
+---
+ third_party/boringssl.BUILD | 21 +++++++++++++++++++++
Expand Down Expand Up @@ -88,14 +90,14 @@ index 000000000..0d6fd60cf
+
diff --git a/third_party/xla/0002-Fix-abseil-headers.patch b/third_party/xla/0002-Fix-abseil-headers.patch
new file mode 100644
index 000000000..f2e4b1ab9
index 000000000..dc4d73303
--- /dev/null
+++ b/third_party/xla/0002-Fix-abseil-headers.patch
@@ -0,0 +1,73 @@
+From bd9bdaf6ef5d57905620b167de2bba35d54ea930 Mon Sep 17 00:00:00 2001
+From: "Uwe L. Korn" <[email protected]>
+Date: Thu, 23 May 2024 15:45:52 +0200
+Subject: [PATCH 2/6] Fix abseil headers
+Subject: [PATCH 2/7] Fix abseil headers
+
+---
+ xla/python/ifrt_proxy/common/BUILD | 3 +++
Expand Down Expand Up @@ -167,14 +169,14 @@ index 000000000..f2e4b1ab9
+ "@com_google_absl//absl/time",
diff --git a/third_party/xla/0003-Omit-usage-of-StrFormat.patch b/third_party/xla/0003-Omit-usage-of-StrFormat.patch
new file mode 100644
index 000000000..29326c54b
index 000000000..293211c8e
--- /dev/null
+++ b/third_party/xla/0003-Omit-usage-of-StrFormat.patch
@@ -0,0 +1,25 @@
+From e4c2b38053744f0ce7a7cd734f0415504a514bc1 Mon Sep 17 00:00:00 2001
+From: "Uwe L. Korn" <[email protected]>
+Date: Thu, 4 Jul 2024 10:36:03 +0200
+Subject: [PATCH 3/6] Omit usage of StrFormat
+Subject: [PATCH 3/7] Omit usage of StrFormat
+
+---
+ xla/stream_executor/gpu/gpu_executor.h | 5 +++++
Expand All @@ -198,14 +200,14 @@ index 000000000..29326c54b
+ #include <vector>
diff --git a/third_party/xla/0004-Add-missing-bits-absl-systemlib.patch b/third_party/xla/0004-Add-missing-bits-absl-systemlib.patch
new file mode 100644
index 000000000..6e2c94274
index 000000000..f63bf15d5
--- /dev/null
+++ b/third_party/xla/0004-Add-missing-bits-absl-systemlib.patch
@@ -0,0 +1,245 @@
+From 0ab5601817af80651b62decc237f01d461dc768b Mon Sep 17 00:00:00 2001
+From: "Uwe L. Korn" <[email protected]>
+Date: Thu, 4 Jul 2024 15:58:32 +0200
+Subject: [PATCH 4/6] Add missing bits absl systemlib
+Subject: [PATCH 4/7] Add missing bits absl systemlib
+
+---
+ .../third_party/absl/system.absl.base.BUILD | 16 +++++
Expand Down Expand Up @@ -449,14 +451,14 @@ index 000000000..6e2c94274
+ "numeric",
diff --git a/third_party/xla/0005-Check-whether-absl-log-is-already-initialized.patch b/third_party/xla/0005-Check-whether-absl-log-is-already-initialized.patch
new file mode 100644
index 000000000..d7a92b704
index 000000000..94007c0a6
--- /dev/null
+++ b/third_party/xla/0005-Check-whether-absl-log-is-already-initialized.patch
@@ -0,0 +1,58 @@
+From e95ed3a620df2ba0513ee44b50eacef391b50088 Mon Sep 17 00:00:00 2001
+From: "Uwe L. Korn" <[email protected]>
+Date: Fri, 22 Nov 2024 10:51:18 +0100
+Subject: [PATCH 5/6] Check whether absl log is already initialized
+Subject: [PATCH 5/7] Check whether absl log is already initialized
+
+---
+ xla/pjrt/c/pjrt_c_api_gpu.cc | 7 ++++++-
Expand Down Expand Up @@ -513,14 +515,14 @@ index 000000000..d7a92b704
+ } // namespace xla
diff --git a/third_party/xla/0006-Add-conda-cuda-path.patch b/third_party/xla/0006-Add-conda-cuda-path.patch
new file mode 100644
index 000000000..164119e51
index 000000000..93999484f
--- /dev/null
+++ b/third_party/xla/0006-Add-conda-cuda-path.patch
@@ -0,0 +1,31 @@
+From 25667f2b9448fff8cc462dd386c85c96740c64af Mon Sep 17 00:00:00 2001
+From: Silvio Traversaro <[email protected]>
+Date: Tue, 10 Dec 2024 09:42:51 +0100
+Subject: [PATCH 6/6] Add conda cuda path
+Subject: [PATCH 6/7] Add conda cuda path
+
+---
+ xla/tsl/platform/default/cuda_root_path.cc | 11 +++++++++++
Expand Down Expand Up @@ -548,11 +550,145 @@ index 000000000..164119e51
+ }
+ #endif // defined(PLATFORM_POSIX) && !defined(__APPLE__)
+
diff --git a/third_party/xla/0007-xla-cpu-Fix-build-errors-from-ACL.patch b/third_party/xla/0007-xla-cpu-Fix-build-errors-from-ACL.patch
new file mode 100644
index 000000000..40256f16f
--- /dev/null
+++ b/third_party/xla/0007-xla-cpu-Fix-build-errors-from-ACL.patch
@@ -0,0 +1,128 @@
+From 2b81e35e9e89a13aac3bb08a21b91c76740fd74c Mon Sep 17 00:00:00 2001
+From: Penporn Koanantakool <[email protected]>
+Date: Fri, 24 Jan 2025 13:33:38 -0800
+Subject: [PATCH 7/7] [xla:cpu] Fix build errors from ACL
+
+Reported in:
+https://github.com/jax-ml/jax/issues/26062
+
+PiperOrigin-RevId: 719416696
+---
+ .../exclude_omp_scheduler.patch | 23 +++++++++++++++++++
+ .../compute_library/include_string.patch | 12 ++++++++++
+ .../exclude_omp_scheduler.patch | 23 +++++++++++++++++++
+ .../compute_library/include_string.patch | 12 ++++++++++
+ third_party/tsl/workspace2.bzl | 2 ++
+ 5 files changed, 72 insertions(+)
+ create mode 100644 third_party/compute_library/exclude_omp_scheduler.patch
+ create mode 100644 third_party/compute_library/include_string.patch
+ create mode 100644 third_party/tsl/third_party/compute_library/exclude_omp_scheduler.patch
+ create mode 100644 third_party/tsl/third_party/compute_library/include_string.patch
+
+diff --git a/third_party/compute_library/exclude_omp_scheduler.patch b/third_party/compute_library/exclude_omp_scheduler.patch
+new file mode 100644
+index 0000000000..7ccfebbd36
+--- /dev/null
++++ b/third_party/compute_library/exclude_omp_scheduler.patch
+@@ -0,0 +1,23 @@
++diff --git a/src/BUILD.bazel b/src/BUILD.bazel
++index bf71e534e2..22377f1a32 100644
++--- a/src/BUILD.bazel
+++++ b/src/BUILD.bazel
++@@ -971,7 +971,6 @@ filegroup(
++ "runtime/NEON/functions/NETranspose.cpp",
++ "runtime/NEON/functions/NEUnstack.cpp",
++ "runtime/NEON/functions/NEWinogradConvolutionLayer.cpp",
++- "runtime/OMP/OMPScheduler.cpp",
++ "runtime/OffsetLifetimeManager.cpp",
++ "runtime/OffsetMemoryPool.cpp",
++ "runtime/OperatorTensor.cpp",
++@@ -984,6 +983,10 @@ filegroup(
++ "runtime/Tensor.cpp",
++ "runtime/TensorAllocator.cpp",
++ "runtime/Utils.cpp"] +
+++ select({
+++ "//:openmp_flag": ["runtime/OMP/OMPScheduler.cpp"],
+++ "//conditions:default": [],
+++ }) +
++ glob(["**/*.h",
++ "**/*.hpp",
++ "**/*.inl"]),
+diff --git a/third_party/compute_library/include_string.patch b/third_party/compute_library/include_string.patch
+new file mode 100644
+index 0000000000..709aeea621
+--- /dev/null
++++ b/third_party/compute_library/include_string.patch
+@@ -0,0 +1,12 @@
++diff --git a/arm_compute/core/utils/logging/IPrinter.h b/arm_compute/core/utils/logging/IPrinter.h
++index 42dca58ea1..9c8b1598e8 100644
++--- a/arm_compute/core/utils/logging/IPrinter.h
+++++ b/arm_compute/core/utils/logging/IPrinter.h
++@@ -25,6 +25,7 @@
++ #define ARM_COMPUTE_LOGGING_PRINTER_H
++
++ #include "support/Mutex.h"
+++#include <string>
++
++ namespace arm_compute
++ {
+diff --git a/third_party/tsl/third_party/compute_library/exclude_omp_scheduler.patch b/third_party/tsl/third_party/compute_library/exclude_omp_scheduler.patch
+new file mode 100644
+index 0000000000..7ccfebbd36
+--- /dev/null
++++ b/third_party/tsl/third_party/compute_library/exclude_omp_scheduler.patch
+@@ -0,0 +1,23 @@
++diff --git a/src/BUILD.bazel b/src/BUILD.bazel
++index bf71e534e2..22377f1a32 100644
++--- a/src/BUILD.bazel
+++++ b/src/BUILD.bazel
++@@ -971,7 +971,6 @@ filegroup(
++ "runtime/NEON/functions/NETranspose.cpp",
++ "runtime/NEON/functions/NEUnstack.cpp",
++ "runtime/NEON/functions/NEWinogradConvolutionLayer.cpp",
++- "runtime/OMP/OMPScheduler.cpp",
++ "runtime/OffsetLifetimeManager.cpp",
++ "runtime/OffsetMemoryPool.cpp",
++ "runtime/OperatorTensor.cpp",
++@@ -984,6 +983,10 @@ filegroup(
++ "runtime/Tensor.cpp",
++ "runtime/TensorAllocator.cpp",
++ "runtime/Utils.cpp"] +
+++ select({
+++ "//:openmp_flag": ["runtime/OMP/OMPScheduler.cpp"],
+++ "//conditions:default": [],
+++ }) +
++ glob(["**/*.h",
++ "**/*.hpp",
++ "**/*.inl"]),
+diff --git a/third_party/tsl/third_party/compute_library/include_string.patch b/third_party/tsl/third_party/compute_library/include_string.patch
+new file mode 100644
+index 0000000000..709aeea621
+--- /dev/null
++++ b/third_party/tsl/third_party/compute_library/include_string.patch
+@@ -0,0 +1,12 @@
++diff --git a/arm_compute/core/utils/logging/IPrinter.h b/arm_compute/core/utils/logging/IPrinter.h
++index 42dca58ea1..9c8b1598e8 100644
++--- a/arm_compute/core/utils/logging/IPrinter.h
+++++ b/arm_compute/core/utils/logging/IPrinter.h
++@@ -25,6 +25,7 @@
++ #define ARM_COMPUTE_LOGGING_PRINTER_H
++
++ #include "support/Mutex.h"
+++#include <string>
++
++ namespace arm_compute
++ {
+diff --git a/third_party/tsl/workspace2.bzl b/third_party/tsl/workspace2.bzl
+index 0b1bd5ee69..68d965f560 100644
+--- a/third_party/tsl/workspace2.bzl
++++ b/third_party/tsl/workspace2.bzl
+@@ -179,6 +179,8 @@ def _tf_repositories():
+ patch_file = [
+ "//third_party/compute_library:compute_library.patch",
+ "//third_party/compute_library:acl_thread_local_scheduler.patch",
++ "//third_party/compute_library:exclude_omp_scheduler.patch",
++ "//third_party/compute_library:include_string.patch",
+ ],
+ sha256 = "c4ca329a78da380163b2d86e91ba728349b6f0ee97d66e260a694ef37f0b0d93",
+ strip_prefix = "ComputeLibrary-23.05.1",
diff --git a/third_party/xla/workspace.bzl b/third_party/xla/workspace.bzl
index d08d9bba9..f3ad6a5a6 100644
index d08d9bba9..4db026b92 100644
--- a/third_party/xla/workspace.bzl
+++ b/third_party/xla/workspace.bzl
@@ -30,6 +30,14 @@ def repo():
@@ -30,6 +30,16 @@ def repo():
sha256 = XLA_SHA256,
strip_prefix = "xla-{commit}".format(commit = XLA_COMMIT),
urls = tf_mirror_urls("https://github.com/openxla/xla/archive/{commit}.tar.gz".format(commit = XLA_COMMIT)),
Expand All @@ -563,6 +699,8 @@ index d08d9bba9..f3ad6a5a6 100644
+ "//third_party/xla:0004-Add-missing-bits-absl-systemlib.patch",
+ "//third_party/xla:0005-Check-whether-absl-log-is-already-initialized.patch",
+ "//third_party/xla:0006-Add-conda-cuda-path.patch",
+ # backport https://github.com/openxla/xla/commit/14ba309d98db689ba5c185287483d555e3307b7f
+ "//third_party/xla:0007-xla-cpu-Fix-build-errors-from-ACL.patch",
+ ],
)

Expand Down

0 comments on commit 3100ff7

Please sign in to comment.