From effb367a1a94754db91d9d7c18414337c26a0449 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Thu, 9 Jul 2026 20:17:07 +0000 Subject: [PATCH 001/183] Test: CI build optimizations (CUDA compute capabilities and non-curses mode from cl/945255455) --- tensorflow_serving/tools/docker/Dockerfile.devel | 4 ++-- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 7 +++++-- tensorflow_serving/tools/docker/Dockerfile.devel-mkl | 4 ++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel b/tensorflow_serving/tools/docker/Dockerfile.devel index 7c79a983f49..0f8304f9cea 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel +++ b/tensorflow_serving/tools/docker/Dockerfile.devel @@ -101,7 +101,7 @@ RUN echo "Building with build options: ${TF_SERVING_BUILD_OPTIONS}" ARG TF_SERVING_BAZEL_OPTIONS="" RUN echo "Building with Bazel options: ${TF_SERVING_BAZEL_OPTIONS}" -RUN bazel build --color=yes --curses=yes \ +RUN bazel build --color=yes --curses=no --progress_report_interval=30 \ ${TF_SERVING_BAZEL_OPTIONS} \ --verbose_failures \ --output_filter=DONT_MATCH_ANYTHING \ @@ -111,7 +111,7 @@ RUN bazel build --color=yes --curses=yes \ /usr/local/bin/ # Build and install TensorFlow Serving API -RUN bazel build --color=yes --curses=yes \ +RUN bazel build --color=yes --curses=no --progress_report_interval=30 \ ${TF_SERVING_BAZEL_OPTIONS} \ --verbose_failures \ --output_filter=DONT_MATCH_ANYTHING \ diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index cde11aa6fe4..a0836ecb58c 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -25,6 +25,9 @@ ENV CUDNN_VERSION=9.3.0.75 ENV TF_TENSORRT_VERSION=8.6.1 ENV CUDA=12.5 +ARG TF_CUDA_COMPUTE_CAPABILITIES="7.0,7.5,8.0,8.6,8.9,9.0" +ENV TF_CUDA_COMPUTE_CAPABILITIES=${TF_CUDA_COMPUTE_CAPABILITIES} + RUN apt-get update && apt-get install -y --no-install-recommends \ curl @@ -155,7 +158,7 @@ RUN echo "Building with Bazel options: ${TF_SERVING_BAZEL_OPTIONS}" RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1 && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ - bazel build --color=yes --curses=yes --config=cuda_clang --copt="-fPIC"\ + bazel build --color=yes --curses=no --progress_report_interval=30 --config=cuda_clang --copt="-fPIC"\ ${TF_SERVING_BAZEL_OPTIONS} \ --verbose_failures \ --output_filter=DONT_MATCH_ANYTHING \ @@ -166,7 +169,7 @@ RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/lib rm /usr/local/cuda/lib64/stubs/libcuda.so.1 # Build and install TensorFlow Serving API -RUN bazel build --color=yes --curses=yes \ +RUN bazel build --color=yes --curses=no --progress_report_interval=30 \ ${TF_SERVING_BAZEL_OPTIONS} \ --verbose_failures \ --output_filter=DONT_MATCH_ANYTHING \ diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-mkl b/tensorflow_serving/tools/docker/Dockerfile.devel-mkl index 0a74fccc7a2..21614d96d42 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-mkl +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-mkl @@ -103,7 +103,7 @@ RUN echo "Building with build options: ${TF_SERVING_BUILD_OPTIONS}" ARG TF_SERVING_BAZEL_OPTIONS="" RUN echo "Building with Bazel options: ${TF_SERVING_BAZEL_OPTIONS}" -RUN bazel build --color=yes --curses=yes \ +RUN bazel build --color=yes --curses=no --progress_report_interval=30 \ ${TF_SERVING_BAZEL_OPTIONS} \ --verbose_failures \ --output_filter=DONT_MATCH_ANYTHING \ @@ -113,7 +113,7 @@ RUN bazel build --color=yes --curses=yes \ /usr/local/bin/ # Build and install TensorFlow Serving API -RUN bazel build --color=yes --curses=yes \ +RUN bazel build --color=yes --curses=no --progress_report_interval=30 \ ${TF_SERVING_BAZEL_OPTIONS} \ --verbose_failures \ --output_filter=DONT_MATCH_ANYTHING \ From a2b7756bacc471926246b4f58a34e414d1dbb3d4 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Thu, 9 Jul 2026 22:37:04 +0000 Subject: [PATCH 002/183] Fix: Prune sm_60 from .bazelrc and add --noshow_progress to Dockerfiles to eliminate 5hr GPU build and 2MiB log clipping --- .bazelrc | 2 +- tensorflow_serving/tools/docker/Dockerfile.devel | 4 ++-- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 4 ++-- tensorflow_serving/tools/docker/Dockerfile.devel-mkl | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.bazelrc b/.bazelrc index 6278d956d75..e049e63ad3e 100644 --- a/.bazelrc +++ b/.bazelrc @@ -17,7 +17,7 @@ build:cuda_clang --host_copt=-Wno-error=unused-command-line-argument build:cuda_clang --repo_env TF_NEED_TENSORRT=0 build:cuda_clang --action_env=TF_CUDA_CLANG="1" build:cuda_clang --@local_config_cuda//:cuda_compiler=clang -build:cuda_clang --repo_env=TF_CUDA_COMPUTE_CAPABILITIES="sm_60,sm_70,sm_80,sm_89,compute_90" +build:cuda_clang --repo_env=TF_CUDA_COMPUTE_CAPABILITIES="sm_70,sm_80,sm_89,compute_90" common:cuda_clang --repo_env=HERMETIC_CUDA_VERSION="12.5.1" common:cuda_clang --repo_env=HERMETIC_CUDNN_VERSION="9.3.0" diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel b/tensorflow_serving/tools/docker/Dockerfile.devel index 0f8304f9cea..9f9286ecf7a 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel +++ b/tensorflow_serving/tools/docker/Dockerfile.devel @@ -101,7 +101,7 @@ RUN echo "Building with build options: ${TF_SERVING_BUILD_OPTIONS}" ARG TF_SERVING_BAZEL_OPTIONS="" RUN echo "Building with Bazel options: ${TF_SERVING_BAZEL_OPTIONS}" -RUN bazel build --color=yes --curses=no --progress_report_interval=30 \ +RUN bazel build --color=yes --noshow_progress --curses=no \ ${TF_SERVING_BAZEL_OPTIONS} \ --verbose_failures \ --output_filter=DONT_MATCH_ANYTHING \ @@ -111,7 +111,7 @@ RUN bazel build --color=yes --curses=no --progress_report_interval=30 \ /usr/local/bin/ # Build and install TensorFlow Serving API -RUN bazel build --color=yes --curses=no --progress_report_interval=30 \ +RUN bazel build --color=yes --noshow_progress --curses=no \ ${TF_SERVING_BAZEL_OPTIONS} \ --verbose_failures \ --output_filter=DONT_MATCH_ANYTHING \ diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index a0836ecb58c..f06e2428022 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -158,7 +158,7 @@ RUN echo "Building with Bazel options: ${TF_SERVING_BAZEL_OPTIONS}" RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1 && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ - bazel build --color=yes --curses=no --progress_report_interval=30 --config=cuda_clang --copt="-fPIC"\ + bazel build --color=yes --noshow_progress --curses=no --config=cuda_clang --copt="-fPIC"\ ${TF_SERVING_BAZEL_OPTIONS} \ --verbose_failures \ --output_filter=DONT_MATCH_ANYTHING \ @@ -169,7 +169,7 @@ RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/lib rm /usr/local/cuda/lib64/stubs/libcuda.so.1 # Build and install TensorFlow Serving API -RUN bazel build --color=yes --curses=no --progress_report_interval=30 \ +RUN bazel build --color=yes --noshow_progress --curses=no \ ${TF_SERVING_BAZEL_OPTIONS} \ --verbose_failures \ --output_filter=DONT_MATCH_ANYTHING \ diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-mkl b/tensorflow_serving/tools/docker/Dockerfile.devel-mkl index 21614d96d42..d87be197933 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-mkl +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-mkl @@ -103,7 +103,7 @@ RUN echo "Building with build options: ${TF_SERVING_BUILD_OPTIONS}" ARG TF_SERVING_BAZEL_OPTIONS="" RUN echo "Building with Bazel options: ${TF_SERVING_BAZEL_OPTIONS}" -RUN bazel build --color=yes --curses=no --progress_report_interval=30 \ +RUN bazel build --color=yes --noshow_progress --curses=no \ ${TF_SERVING_BAZEL_OPTIONS} \ --verbose_failures \ --output_filter=DONT_MATCH_ANYTHING \ @@ -113,7 +113,7 @@ RUN bazel build --color=yes --curses=no --progress_report_interval=30 \ /usr/local/bin/ # Build and install TensorFlow Serving API -RUN bazel build --color=yes --curses=no --progress_report_interval=30 \ +RUN bazel build --color=yes --noshow_progress --curses=no \ ${TF_SERVING_BAZEL_OPTIONS} \ --verbose_failures \ --output_filter=DONT_MATCH_ANYTHING \ From fccb929f1c931e50371ef58b6cacdf7bb74f22cb Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Fri, 10 Jul 2026 22:26:04 +0000 Subject: [PATCH 003/183] Fix: Prune sm_70 from .bazelrc to resolve Volta Clang CUDA build errors and speed up compilation --- .bazelrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.bazelrc b/.bazelrc index e049e63ad3e..7ccb48ec43b 100644 --- a/.bazelrc +++ b/.bazelrc @@ -17,7 +17,7 @@ build:cuda_clang --host_copt=-Wno-error=unused-command-line-argument build:cuda_clang --repo_env TF_NEED_TENSORRT=0 build:cuda_clang --action_env=TF_CUDA_CLANG="1" build:cuda_clang --@local_config_cuda//:cuda_compiler=clang -build:cuda_clang --repo_env=TF_CUDA_COMPUTE_CAPABILITIES="sm_70,sm_80,sm_89,compute_90" +build:cuda_clang --repo_env=TF_CUDA_COMPUTE_CAPABILITIES="sm_80,sm_89,compute_90" common:cuda_clang --repo_env=HERMETIC_CUDA_VERSION="12.5.1" common:cuda_clang --repo_env=HERMETIC_CUDNN_VERSION="9.3.0" From dce4e8ec5f4f738e4d1370ba2f6c97d6e018a920 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Fri, 10 Jul 2026 23:51:29 +0000 Subject: [PATCH 004/183] Fix: Add cuda_clang_fixes.h compatibility header and include flags to resolve NCCL 2.29 typeof and uint4 __stwt errors under Clang --- .bazelrc | 2 + tensorflow_serving/opensource_only/.bazelrc | 129 ++++++++++++++++++++ tensorflow_serving/tools/cuda_clang_fixes.h | 36 ++++++ 3 files changed, 167 insertions(+) create mode 100644 tensorflow_serving/opensource_only/.bazelrc create mode 100644 tensorflow_serving/tools/cuda_clang_fixes.h diff --git a/.bazelrc b/.bazelrc index 7ccb48ec43b..4e9b9e0cc97 100644 --- a/.bazelrc +++ b/.bazelrc @@ -18,6 +18,8 @@ build:cuda_clang --repo_env TF_NEED_TENSORRT=0 build:cuda_clang --action_env=TF_CUDA_CLANG="1" build:cuda_clang --@local_config_cuda//:cuda_compiler=clang build:cuda_clang --repo_env=TF_CUDA_COMPUTE_CAPABILITIES="sm_80,sm_89,compute_90" +build:cuda_clang --copt=-include +build:cuda_clang --copt=third_party/tensorflow_serving/tools/cuda_clang_fixes.h common:cuda_clang --repo_env=HERMETIC_CUDA_VERSION="12.5.1" common:cuda_clang --repo_env=HERMETIC_CUDNN_VERSION="9.3.0" diff --git a/tensorflow_serving/opensource_only/.bazelrc b/tensorflow_serving/opensource_only/.bazelrc new file mode 100644 index 00000000000..4e9b9e0cc97 --- /dev/null +++ b/tensorflow_serving/opensource_only/.bazelrc @@ -0,0 +1,129 @@ +# Optimizations used for TF Serving release builds. +build:release --copt=-mavx +build:release --copt=-msse4.2 + +# Options used to build with CUDA. +build:cuda --repo_env TF_NEED_CUDA=1 +build:cuda --crosstool_top=@local_config_cuda//crosstool:toolchain +build:cuda --@local_config_cuda//:enable_cuda + +# Options used to build with CUDA clang +build:cuda_clang --config=cuda +build:cuda_clang --copt=-Wno-gnu-offsetof-extensions +build:cuda_clang --copt=-Wno-error=unused-command-line-argument +build --linkopt=-Wno-unused-command-line-argument +build --host_linkopt=-Wno-unused-command-line-argument +build:cuda_clang --host_copt=-Wno-error=unused-command-line-argument +build:cuda_clang --repo_env TF_NEED_TENSORRT=0 +build:cuda_clang --action_env=TF_CUDA_CLANG="1" +build:cuda_clang --@local_config_cuda//:cuda_compiler=clang +build:cuda_clang --repo_env=TF_CUDA_COMPUTE_CAPABILITIES="sm_80,sm_89,compute_90" +build:cuda_clang --copt=-include +build:cuda_clang --copt=third_party/tensorflow_serving/tools/cuda_clang_fixes.h + +common:cuda_clang --repo_env=HERMETIC_CUDA_VERSION="12.5.1" +common:cuda_clang --repo_env=HERMETIC_CUDNN_VERSION="9.3.0" +common:cuda_clang --repo_env=HERMETIC_NVSHMEM_VERSION="3.2.5" +common:cuda_clang --repo_env=HERMETIC_NCCL_VERSION="2.29.7" +build:cuda_clang --action_env=GCC_HOST_COMPILER_PATH="/usr/bin/gcc-10" +build:cuda_clang --action_env=CLANG_CUDA_COMPILER_PATH="/usr/lib/llvm-17/bin/clang" + +# Options used to build with TPU support. +build:tpu --define=with_tpu_support=true --define=framework_shared_object=false +build:tpu --copt=-DLIBTPU_ON_GCE + +# Please note that MKL on MacOS or windows is still not supported. +# If you would like to use a local MKL instead of downloading, please set the +# environment variable "TF_MKL_ROOT" every time before build. +build:mkl --define=build_with_mkl=true --define=enable_mkl=true --define=build_with_openmp=false +build:mkl --define=tensorflow_mkldnn_contraction_kernel=0 + +# This config option is used to enable MKL-DNN open source library only, +# without depending on MKL binary version. +build:mkl_open_source_only --define=build_with_mkl_dnn_only=true +build:mkl_open_source_only --define=build_with_mkl=true --define=enable_mkl=true +build:mkl_open_source_only --define=tensorflow_mkldnn_contraction_kernel=0 + +# Config setting to build oneDNN with Compute Library for the Arm Architecture (ACL). +# This build is for the inference regime only. +build:mkl_aarch64 --define=build_with_mkl_aarch64=true --define=enable_mkl=true +build:mkl_aarch64 --define=tensorflow_mkldnn_contraction_kernel=0 +build:mkl_aarch64 --define=build_with_mkl_opensource=true +build:mkl_aarch64 --define=build_with_openmp=true +build:mkl_aarch64 --copt=-march=armv8.2-a +build:mkl_aarch64 --copt=-O3 + +build --define=build_with_onednn_v2=true +build --define=xnn_enable_avxvnni=false +build --define=xnn_enable_avxvnniint8=false +build --define=xnn_enable_avx256vnnigfni=false +build --define=xnn_enable_avx512amx=false +build --define=xnn_enable_avx512fp16=false + +# Processor native optimizations (depends on build host capabilities). +build:nativeopt --copt=-march=native +build:nativeopt --host_copt=-march=native +build:nativeopt --copt=-O3 + +build --keep_going +build --verbose_failures=true +build --spawn_strategy=standalone +build --genrule_strategy=standalone + +build --define=grpc_no_ares=true + +# Sets the default Apple platform to macOS. +build --apple_platform_type=macos + +build -c opt + +# LLVM, MLIR and TF requires C++17. +build --cxxopt=-std=c++17 +build --host_cxxopt=-std=c++17 + +# Adding "--cxxopt=-D_GLIBCXX_USE_CXX11_ABI=0" creates parity with TF +# compilation options. It also addresses memory use due to +# copy-on-write semantics of std::strings of the older ABI. +build --cxxopt=-D_GLIBCXX_USE_CXX11_ABI=0 + +build --workspace_status_command=/proc/self/cwd/tools/gen_status_stamp.sh + +build --experimental_repo_remote_exec + +# TF now has `cc_shared_library` targets, so it needs the experimental flag +build --experimental_cc_shared_library + +# Yggdrasil Decision Forests (internal library of TensorFlow Decision Forests) +# uses TensorFlow for all IO operations. +build --define=use_tensorflow_io=1 + +# TensorFlow Decision Forests does not use Absl concurrency primitives on MacOs. +# Reason: TensorFlow/ABSL ODR violation (b/214189609) # copybara:strip +build:macos --define std_synchronization_primitives=1 + +# Taken from https://github.com/openxla/xla/blob/99559d7a4f7c55490f46385ad29a3cbf9c3911af/warnings.bazelrc#L6 +# We silence warnings for code in `external`. +build --per_file_copt=external/.*@-w +build --host_per_file_copt=external/.*@-w +build --copt=-Wno-macro-redefined # absl vs tsl logging clash +build --copt=-Wno-sign-compare # int as loop variable +build --copt=-Wno-deprecated-declarations +build --copt=-Wno-unused-but-set-variable # due to `ifdefs` in ml_dtypes + +# Revert to the legacy WORKSPACE dependency resolution system +# and disable Bzlmod. +common --enable_bzlmod=false +common --incompatible_enable_cc_toolchain_resolution +common --repo_env USE_HERMETIC_CC_TOOLCHAIN=1 +common --repo_env=HERMETIC_PYTHON_VERSION="3.10" +common --repo_env=USE_PYWRAP_RULES=1 +build --features=-layering_check +build --define=framework_shared_object=false +build --dynamic_mode=off + + +common:clang_local --noincompatible_enable_cc_toolchain_resolution +common:clang_local --noincompatible_enable_android_toolchain_resolution +common:clang_local --@rules_ml_toolchain//cc_toolchain/config:enable_hermetic_cc=False +common:clang_local --repo_env USE_HERMETIC_CC_TOOLCHAIN=0 + diff --git a/tensorflow_serving/tools/cuda_clang_fixes.h b/tensorflow_serving/tools/cuda_clang_fixes.h new file mode 100644 index 00000000000..f1e87a5a115 --- /dev/null +++ b/tensorflow_serving/tools/cuda_clang_fixes.h @@ -0,0 +1,36 @@ +/* Copyright 2026 Google Inc. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_SERVING_TOOLS_CUDA_CLANG_FIXES_H_ +#define TENSORFLOW_SERVING_TOOLS_CUDA_CLANG_FIXES_H_ + +#if defined(__clang__) && defined(__CUDA__) +#include + +// Fix for GNU typeof in strict C++ mode when compiling NVIDIA DOCA / NCCL headers with Clang. +#ifndef typeof +#define typeof __typeof__ +#endif + +// Missing 16-byte uint4 store overload in Clang's __clang_cuda_intrinsics.h for NCCL GIN proxy (__stwt). +__device__ inline void __stwt(uint4* ptr, uint4 value) { + asm volatile("st.global.wt.v4.u32 [%0], {%1, %2, %3, %4};" + : + : "l"(ptr), "r"(value.x), "r"(value.y), "r"(value.z), "r"(value.w) + : "memory"); +} +#endif + +#endif // TENSORFLOW_SERVING_TOOLS_CUDA_CLANG_FIXES_H_ From 0f58c8fcb4cc409b323682f22cb1cdd0de3c420f Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Sat, 11 Jul 2026 19:09:12 +0000 Subject: [PATCH 005/183] Fix: Append typeof and uint4 __stwt overloads directly to clang_cuda_runtime_wrapper.h via rules_ml_toolchain patch_cmds to avoid un-sandboxed header file not found errors --- .bazelrc | 3 +- tensorflow_serving/opensource_only/.bazelrc | 3 +- .../opensource_only/root.workspace | 297 ++++++++++++++++++ tensorflow_serving/tools/cuda_clang_fixes.h | 36 --- 4 files changed, 299 insertions(+), 40 deletions(-) create mode 100644 tensorflow_serving/opensource_only/root.workspace delete mode 100644 tensorflow_serving/tools/cuda_clang_fixes.h diff --git a/.bazelrc b/.bazelrc index 4e9b9e0cc97..c580cf0b65c 100644 --- a/.bazelrc +++ b/.bazelrc @@ -18,8 +18,7 @@ build:cuda_clang --repo_env TF_NEED_TENSORRT=0 build:cuda_clang --action_env=TF_CUDA_CLANG="1" build:cuda_clang --@local_config_cuda//:cuda_compiler=clang build:cuda_clang --repo_env=TF_CUDA_COMPUTE_CAPABILITIES="sm_80,sm_89,compute_90" -build:cuda_clang --copt=-include -build:cuda_clang --copt=third_party/tensorflow_serving/tools/cuda_clang_fixes.h +build:cuda_clang --copt=-Dtypeof=__typeof__ common:cuda_clang --repo_env=HERMETIC_CUDA_VERSION="12.5.1" common:cuda_clang --repo_env=HERMETIC_CUDNN_VERSION="9.3.0" diff --git a/tensorflow_serving/opensource_only/.bazelrc b/tensorflow_serving/opensource_only/.bazelrc index 4e9b9e0cc97..c580cf0b65c 100644 --- a/tensorflow_serving/opensource_only/.bazelrc +++ b/tensorflow_serving/opensource_only/.bazelrc @@ -18,8 +18,7 @@ build:cuda_clang --repo_env TF_NEED_TENSORRT=0 build:cuda_clang --action_env=TF_CUDA_CLANG="1" build:cuda_clang --@local_config_cuda//:cuda_compiler=clang build:cuda_clang --repo_env=TF_CUDA_COMPUTE_CAPABILITIES="sm_80,sm_89,compute_90" -build:cuda_clang --copt=-include -build:cuda_clang --copt=third_party/tensorflow_serving/tools/cuda_clang_fixes.h +build:cuda_clang --copt=-Dtypeof=__typeof__ common:cuda_clang --repo_env=HERMETIC_CUDA_VERSION="12.5.1" common:cuda_clang --repo_env=HERMETIC_CUDNN_VERSION="9.3.0" diff --git a/tensorflow_serving/opensource_only/root.workspace b/tensorflow_serving/opensource_only/root.workspace new file mode 100644 index 00000000000..7c6bf4bbe5d --- /dev/null +++ b/tensorflow_serving/opensource_only/root.workspace @@ -0,0 +1,297 @@ +workspace(name = "tf_serving") + +# TODO(b/269515133): We temporarily remove remote_predict from our builds for +# 2.12 due to a breakage caused by +# github.com/tensorflow/tensorflow/commit/6147c03eb9af1e5d2ae155045b33e909ef96944e +# This will be removed in a subsequent release. +local_repository( + name = "ignore_remote_predict", + path = "tensorflow_serving/experimental/tensorflow/ops/remote_predict/", +) + +# ===== TensorFlow dependency ===== +# +# TensorFlow is imported here instead of in tf_serving_workspace() because +# existing automation scripts that bump the TF commit hash expect it here. +# +# To update TensorFlow to a new revision. +# 1. Update the 'git_commit' args below to include the new git hash. +# 2. Get the sha256 hash of the archive with a command such as... +# curl -L https://github.com/tensorflow/tensorflow/archive/.tar.gz | sha256sum +# and update the 'sha256' arg with the result. +# 3. Request the new archive to be mirrored on mirror.bazel.build for more +# reliable downloads. +load("//tensorflow_serving:repo.bzl", "tensorflow_http_archive") +tensorflow_http_archive( + name = "org_tensorflow", + sha256 = "582f5dc1c0887ca5b2eb364dc39e0c15fd31ee138b250e24163b6eca340f701f", + git_commit = "d875953b4fd431c15fedb1d408d5396e7f9d4d23", + patch = "//third_party/tensorflow:tensorflow.patch", + patch_cmds = [ + "sed -i '/cc_library = _cc_library/d' tensorflow/core/platform/rules_cc.bzl", + "echo -e \"\\ndef cc_library_oss(deps=[], **kwargs):\\n if kwargs.get(\\\"name\\\") == \\\"lib_internal_impl\\\" or \\\"protobuf\\\" in kwargs.get(\\\"name\\\", \\\"\\\"):\\n _cc_library(deps = deps, **kwargs)\\n return\\n if type(deps) == \\\"list\\\":\\n if \\\"@com_google_protobuf//:protobuf\\\" not in deps:\\n deps = deps + [\\\"@com_google_protobuf//:protobuf\\\"]\\n else:\\n deps = deps + [\\\"@com_google_protobuf//:protobuf\\\"]\\n _cc_library(deps = deps, **kwargs)\\ncc_library = cc_library_oss\" >> tensorflow/core/platform/rules_cc.bzl", + "sed -i 's#deps = \\[op_gen\\] + deps#deps = [op_gen] + deps + [clean_dep(\"//tensorflow/core/framework:kernel_shape_util\"), clean_dep(\"//tensorflow/core/framework:full_type_util\")]#' tensorflow/tensorflow.bzl", + "sed -i '/name = \"kernel_shape_util\",/a \\ visibility = [\"//visibility:public\"],' tensorflow/core/framework/BUILD", + "echo -e '\\nalias(name = \"tensorflow_libtensorflow_framework\", actual = \"//tensorflow/core:tensorflow\", visibility = [\"//visibility:public\"])' >> BUILD", + "echo -e '\\nalias(name = \"tensorflow_tf_header_lib\", actual = \"//tensorflow/core:tensorflow\", visibility = [\"//visibility:public\"])' >> BUILD", + "sed -i '/name = \"env\",/,/deps = \\[/ s#deps = \\[#deps = [\":status\", \":statusor\", \":context\", \":tracing\", \"//xla/tsl/profiler/backends/cpu:threadpool_listener_state\", \"//xla/tsl/platform:byte_order\", #' third_party/xla/xla/tsl/platform/default/BUILD", + "sed -i '/name = \"tracing\",/,/deps = \\[/ s#deps = \\[#deps = [\"//xla/tsl/platform:logging\", #' third_party/xla/xla/tsl/platform/default/BUILD", + "sed -i '/name = \"tf_runtime\",/a \\ repo_mapping = {\"@xla\": \"@local_xla\", \"@tsl\": \"@local_tsl\"},' third_party/tf_runtime/workspace.bzl", + "sed -i '/name = \"error_util\",/,/deps = \\[/ s#deps = \\[#deps = [\"@xla//xla/tsl/concurrency:async_value\", \"@xla//xla/tsl/concurrency:concurrent_vector\", \"@xla//xla/tsl/concurrency:executor\", \"@xla//xla/tsl/concurrency:ref_count\", \"@xla//xla/tsl/util:safe_reinterpret_cast\", \"@tsl//tsl/platform:context\", #' tensorflow/core/tfrt/utils/BUILD", + "sed -i '/name = \"work_queue_interface\",/,/deps = \\[/ s#deps = \\[#deps = [\"@xla//xla/tsl/concurrency:ref_count\", #' tensorflow/core/tfrt/runtime/BUILD", + "sed -i '/name = \"execute\",/,/deps = \\[/ s#deps = \\[#deps = [\"@xla//xla/tsl/platform:macros\", \"@xla//xla/tsl/platform:types\", \"@xla//xla/tsl/profiler/utils:no_init\", \"@tsl//tsl/profiler/lib:traceme_encode\", \"@xla//xla/tsl/profiler/utils:traceme_global_flags\", \"@xla//xla/tsl/profiler/backends/cpu:traceme_recorder\", \"@tsl//tsl/platform:bfloat16\", \"@tsl//tsl/platform:ml_dtypes\", \"@tsl//tsl/platform:tstring\", \"@tsl//tsl/platform:cord\", \"@tsl//tsl/platform:refcount\", \"@tsl//tsl/platform:thread_annotations\", \"@tsl//tsl/platform:stringpiece\", \"@xla//xla/tsl/profiler/utils:time_utils\", \"@xla//xla/tsl/profiler/utils:math_utils\", #' tensorflow/core/tfrt/mlrt/interpreter/BUILD", + "sed -i '/tf_vendored(name = \"xla\",/s/)/, repo_mapping = {\"@xla\": \"@local_xla\", \"@tsl\": \"@local_tsl\"})/' tensorflow/workspace3.bzl", + "sed -i '/tf_vendored(name = \"tsl\",/s/)/, repo_mapping = {\"@xla\": \"@local_xla\", \"@tsl\": \"@local_tsl\"})/' tensorflow/workspace3.bzl", + """python3 -c 'import re, glob +for p in glob.glob("third_party/xla/**/BUILD*", recursive=True): + s = open(p).read(); blocks = s.split("cc_library("); + for i in range(1, len(blocks)): + b = blocks[i]; m_th = re.search(r"textual_hdrs\\s*=\\s*(\\[[^\\]]+\\]),?\\n?", b); + if m_th: + th = m_th.group(1); b = b.replace(m_th.group(0), ""); m_h = re.search(r"hdrs\\s*=\\s*(\\[[^\\]]+\\])", b); + if m_h: h = m_h.group(1); merged = h[:-1] + ", " + th[1:]; b = b.replace(m_h.group(0), "hdrs = " + merged); + else: b = "\\n hdrs = " + th + "," + b; + blocks[i] = b + open(p, "w").write("cc_library(".join(blocks))'""", + "echo -e '\\ndiff --git a/WORKSPACE b/WORKSPACE\\n--- a/WORKSPACE\\n+++ b/WORKSPACE\\n@@ -184,25 +184,2 @@\\n sass_repositories()\\n \\n-http_archive(\\n- name = \"xla\",\\n- patch_args = [\"-p1\"],\\n- patches = [\\n- \"//third_party:xla.patch\",\\n- \"//third_party:xla_add_grpc_cares_darwin_arm64_support.patch\",\\n- ],\\n- sha256 = \"ba80ef58f89ca11bc5652e936cf856cdeae91e6b723ce6750e9ce0202cab51ac\",\\n- strip_prefix = \"xla-f094066398e2c884e994711fd677f68864324614\",\\n- urls = [\\n- \"https://github.com/openxla/xla/archive/f094066398e2c884e994711fd677f68864324614.zip\",\\n- ],\\n-)\\n-\\n-http_archive(\\n- name = \"tsl\",\\n- sha256 = \"8cf1e1285c7b1843a7f5f787465c1ef80304b3400ed837870bc76d74ce04f5af\",\\n- strip_prefix = \"tsl-d71df2f7612583617d359c36243695097dd63726\",\\n- urls = [\\n- \"https://github.com/google/tsl/archive/d71df2f7612583617d359c36243695097dd63726.zip\",\\n- ],\\n-)\\n-\\n load(\"@xla//tools/toolchains/python:python_repo.bzl\", \"python_repository\")' >> third_party/xprof/xprof.patch", + ], + repo_mapping = { + "@local_xla": "@local_xla", + "@local_tsl": "@local_tsl", + "@org_tensorflow": "@org_tensorflow", + "@xla": "@local_xla", + "@tsl": "@local_tsl", + }, +) + +# Import all of TensorFlow Serving's external dependencies. +# Downstream projects (projects importing TensorFlow Serving) need to +# duplicate all code below in their WORKSPACE file in order to also initialize +# those external dependencies. +load("//tensorflow_serving:workspace.bzl", "tf_serving_workspace") +tf_serving_workspace() + +# Check bazel version requirement, which is stricter than TensorFlow's. +load("@bazel_skylib//lib:versions.bzl", "versions") +versions.check("7.4.1") + +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +http_archive( + name = "bazel_skylib", + sha256 = "97e709db2e97b646263b5c5e83e3b00de48c1ae55b9e421e3b5e3f9467d02a3a", + urls = [ + "https://storage.googleapis.com/mirror.tensorflow.org/github.com/bazelbuild/bazel-skylib/releases/download/1.8.0/bazel-skylib-1.8.0.tar.gz", + "https://github.com/bazelbuild/bazel-skylib/releases/download/1.8.0/bazel-skylib-1.8.0.tar.gz", + ], +) + +http_archive( + name = "rules_cc", + sha256 = "b8b918a85f9144c01f6cfe0f45e4f2838c7413961a8ff23bc0c6cdf8bb07a3b6", + strip_prefix = "rules_cc-0.1.5", + url = "https://github.com/bazelbuild/rules_cc/releases/download/0.1.5/rules_cc-0.1.5.tar.gz", +) + +http_archive( + name = "rules_python", + sha256 = "8964aa1e7525fea5244ba737458694a057ada1be96a92998a41caa1983562d00", + strip_prefix = "rules_python-1.8.5", + urls = [ + "https://storage.googleapis.com/mirror.tensorflow.org/github.com/bazelbuild/rules_python/releases/download/1.8.5/rules_python-1.8.5.tar.gz", + "https://github.com/bazelbuild/rules_python/releases/download/1.8.5/rules_python-1.8.5.tar.gz", + ], + patches = [ + "@rules_ml_toolchain//third_party/rules_python:rules_python_scope.patch", + "@rules_ml_toolchain//third_party/rules_python:rules_python_freethreaded.patch", + "@rules_ml_toolchain//third_party/rules_python:rules_python_versions.patch", + "@rules_ml_toolchain//third_party/rules_python:rules_python_pip_version.patch", + ], + patch_args = ["-p1"], +) + +# Toolchains for ML projects hermetic builds. +# Details: https://github.com/google-ml-infra/rules_ml_toolchain +http_archive( + name = "rules_ml_toolchain", + sha256 = "0b42f693a60c6050d87db1e0a0eaeb84ab3f54191fce094d86334faedc807da0", + strip_prefix = "rules_ml_toolchain-398d613aea7a4c294da49b79a6d6f3f8732bd84c", + urls = [ + "https://storage.googleapis.com/mirror.tensorflow.org/github.com/google-ml-infra/rules_ml_toolchain/archive/398d613aea7a4c294da49b79a6d6f3f8732bd84c.tar.gz", + "https://github.com/google-ml-infra/rules_ml_toolchain/archive/398d613aea7a4c294da49b79a6d6f3f8732bd84c.tar.gz", + ], + patch_cmds = [ + "cat << 'EOF' >> cc/cuda/clang/clang_cuda_runtime_wrapper.h\n#if defined(__clang__) && defined(__CUDA__)\n#include \n#ifndef typeof\n#define typeof __typeof__\n#endif\n__device__ inline void __stwt(uint4* ptr, uint4 value) {\n asm volatile(\"st.global.wt.v4.u32 [%0], {%1, %2, %3, %4};\" : : \"l\"(ptr), \"r\"(value.x), \"r\"(value.y), \"r\"(value.z), \"r\"(value.w) : \"memory\");\n}\n#endif\nEOF", + ], +) + +load( + "@rules_ml_toolchain//cc/deps:cc_toolchain_deps.bzl", + "cc_toolchain_deps", +) + +cc_toolchain_deps() + +register_toolchains("@rules_ml_toolchain//cc:linux_x86_64_linux_x86_64") +register_toolchains("@rules_ml_toolchain//cc:linux_x86_64_linux_x86_64_cuda") +# register_toolchains("@rules_ml_toolchain//cc:linux_aarch64_linux_aarch64") +# register_toolchains("@rules_ml_toolchain//cc:linux_aarch64_linux_aarch64_cuda") + +# Initialize hermetic Python +load("@org_tensorflow//third_party/py:python_init_rules.bzl", "python_init_rules") +python_init_rules() + +load("@org_tensorflow//third_party/py:python_init_repositories.bzl", "python_init_repositories") +python_init_repositories( + default_python_version = "system", + requirements = { + "3.10": "@org_tensorflow//:requirements_lock_3_10.txt", + "3.11": "@org_tensorflow//:requirements_lock_3_11.txt", + "3.12": "@org_tensorflow//:requirements_lock_3_12.txt", + "3.13": "@org_tensorflow//:requirements_lock_3_13.txt", + "3.14": "@org_tensorflow//:requirements_lock_3_14.txt", + }, +) + +load("@org_tensorflow//third_party/py:python_init_toolchains.bzl", "python_init_toolchains") +python_init_toolchains() + +load("@org_tensorflow//third_party/py:python_init_pip.bzl", "python_init_pip") +python_init_pip() + +load("@pypi//:requirements.bzl", "install_deps") +install_deps() + +# Initialize TensorFlow's external dependencies. +load("@org_tensorflow//tensorflow:workspace3.bzl", "tf_workspace3") +tf_workspace3() + +load("//tensorflow_serving:repo.bzl", "tf_serving_vendored") + +tf_serving_vendored( + name = "local_xla", + path = "third_party/xla", + repo_mapping = { + "@local_xla": "@local_xla", + "@local_tsl": "@local_tsl", + "@org_tensorflow": "@org_tensorflow", + "@xla": "@local_xla", + "@tsl": "@local_tsl", + }, + root = "@org_tensorflow//:unused", +) + +tf_serving_vendored( + name = "local_tsl", + path = "third_party/xla/third_party/tsl", + repo_mapping = { + "@local_xla": "@local_xla", + "@local_tsl": "@local_tsl", + "@org_tensorflow": "@org_tensorflow", + "@xla": "@local_xla", + "@tsl": "@local_tsl", + }, + root = "@org_tensorflow//:unused", +) +load("@org_tensorflow//tensorflow:workspace2.bzl", "tf_workspace2") +tf_workspace2() +load("@org_tensorflow//tensorflow:workspace1.bzl", "tf_workspace1") +tf_workspace1() +load("@org_tensorflow//tensorflow:workspace0.bzl", "tf_workspace0") +tf_workspace0() + +# Initialize bazel package rules' external dependencies. +load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies") +rules_pkg_dependencies() + +load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") + +http_archive( + name = "rules_shell", + sha256 = "0d0c56d01c3c40420bf7bf14d73113f8a92fbd9f5cd13205a3b89f72078f0321", + strip_prefix = "rules_shell-0.1.1", + urls = [ + "https://github.com/bazelbuild/rules_shell/releases/download/v0.1.1/rules_shell-v0.1.1.tar.gz", + ], +) + +load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies") + +rules_proto_dependencies() + +load( + "@xla//third_party/py:python_wheel.bzl", + "python_wheel_version_suffix_repository", +) + +python_wheel_version_suffix_repository(name = "tf_wheel_version_suffix") + +load( + "@rules_ml_toolchain//gpu/cuda:cuda_json_init_repository.bzl", + "cuda_json_init_repository", +) + +cuda_json_init_repository() + +load( + "@cuda_redist_json//:distributions.bzl", + "CUDA_REDISTRIBUTIONS", + "CUDNN_REDISTRIBUTIONS", +) +load( + "@rules_ml_toolchain//gpu/cuda:cuda_redist_init_repositories.bzl", + "cuda_redist_init_repositories", + "cudnn_redist_init_repository", +) + +cuda_redist_init_repositories( + cuda_redistributions = CUDA_REDISTRIBUTIONS, +) + +cudnn_redist_init_repository( + cudnn_redistributions = CUDNN_REDISTRIBUTIONS, +) + +load( + "@rules_ml_toolchain//gpu/cuda:cuda_configure.bzl", + "cuda_configure", +) + +cuda_configure(name = "local_config_cuda") + +load( + "@rules_ml_toolchain//gpu/nccl:nccl_redist_init_repository.bzl", + "nccl_redist_init_repository", +) + +nccl_redist_init_repository() + +load( + "@rules_ml_toolchain//gpu/nccl:nccl_configure.bzl", + "nccl_configure", +) + +nccl_configure(name = "local_config_nccl") + +load( + "@rules_ml_toolchain//gpu/nvshmem:nvshmem_json_init_repository.bzl", + "nvshmem_json_init_repository", +) + +nvshmem_json_init_repository() + +load( + "@nvshmem_redist_json//:distributions.bzl", + "NVSHMEM_REDISTRIBUTIONS", +) +load( + "@rules_ml_toolchain//gpu/nvshmem:nvshmem_redist_init_repository.bzl", + "nvshmem_redist_init_repository", +) + +nvshmem_redist_init_repository( + nvshmem_redistributions = NVSHMEM_REDISTRIBUTIONS, +) + +# nvshmem_configure removed in newer rules_ml_toolchain + diff --git a/tensorflow_serving/tools/cuda_clang_fixes.h b/tensorflow_serving/tools/cuda_clang_fixes.h deleted file mode 100644 index f1e87a5a115..00000000000 --- a/tensorflow_serving/tools/cuda_clang_fixes.h +++ /dev/null @@ -1,36 +0,0 @@ -/* Copyright 2026 Google Inc. All Rights Reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -==============================================================================*/ - -#ifndef TENSORFLOW_SERVING_TOOLS_CUDA_CLANG_FIXES_H_ -#define TENSORFLOW_SERVING_TOOLS_CUDA_CLANG_FIXES_H_ - -#if defined(__clang__) && defined(__CUDA__) -#include - -// Fix for GNU typeof in strict C++ mode when compiling NVIDIA DOCA / NCCL headers with Clang. -#ifndef typeof -#define typeof __typeof__ -#endif - -// Missing 16-byte uint4 store overload in Clang's __clang_cuda_intrinsics.h for NCCL GIN proxy (__stwt). -__device__ inline void __stwt(uint4* ptr, uint4 value) { - asm volatile("st.global.wt.v4.u32 [%0], {%1, %2, %3, %4};" - : - : "l"(ptr), "r"(value.x), "r"(value.y), "r"(value.z), "r"(value.w) - : "memory"); -} -#endif - -#endif // TENSORFLOW_SERVING_TOOLS_CUDA_CLANG_FIXES_H_ From 8e90909830675c0e5c543b78f9a2933085ac408f Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Sun, 12 Jul 2026 17:57:49 +0000 Subject: [PATCH 006/183] Fix GPU Docker build failures. - Align WORKSPACE with opensource_only/root.workspace. - Patch XLA to fix dso_loader missing dependency declarations. - Patch XLA to fix CUB scan policy compile error. TAG=agy CONV=748d06f3-9c06-4d77-9f81-b365b06d1b3a --- WORKSPACE | 7 +- third_party/tensorflow/tensorflow.patch | 291 ++++++++++++++++++++++++ 2 files changed, 296 insertions(+), 2 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 9d53b2fbf8b..7c6bf4bbe5d 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -24,8 +24,8 @@ local_repository( load("//tensorflow_serving:repo.bzl", "tensorflow_http_archive") tensorflow_http_archive( name = "org_tensorflow", - sha256 = "54bfd56d61dfced2b82bdeee3262a24fb3d59bed4dbb292d19834af002d85b3b", - git_commit = "c1be979f3130b85f14e8890c05cbca147784f474", + sha256 = "582f5dc1c0887ca5b2eb364dc39e0c15fd31ee138b250e24163b6eca340f701f", + git_commit = "d875953b4fd431c15fedb1d408d5396e7f9d4d23", patch = "//third_party/tensorflow:tensorflow.patch", patch_cmds = [ "sed -i '/cc_library = _cc_library/d' tensorflow/core/platform/rules_cc.bzl", @@ -120,6 +120,9 @@ http_archive( "https://storage.googleapis.com/mirror.tensorflow.org/github.com/google-ml-infra/rules_ml_toolchain/archive/398d613aea7a4c294da49b79a6d6f3f8732bd84c.tar.gz", "https://github.com/google-ml-infra/rules_ml_toolchain/archive/398d613aea7a4c294da49b79a6d6f3f8732bd84c.tar.gz", ], + patch_cmds = [ + "cat << 'EOF' >> cc/cuda/clang/clang_cuda_runtime_wrapper.h\n#if defined(__clang__) && defined(__CUDA__)\n#include \n#ifndef typeof\n#define typeof __typeof__\n#endif\n__device__ inline void __stwt(uint4* ptr, uint4 value) {\n asm volatile(\"st.global.wt.v4.u32 [%0], {%1, %2, %3, %4};\" : : \"l\"(ptr), \"r\"(value.x), \"r\"(value.y), \"r\"(value.z), \"r\"(value.w) : \"memory\");\n}\n#endif\nEOF", + ], ) load( diff --git a/third_party/tensorflow/tensorflow.patch b/third_party/tensorflow/tensorflow.patch index 75aa4f5f2ff..cf21a5f9886 100644 --- a/third_party/tensorflow/tensorflow.patch +++ b/third_party/tensorflow/tensorflow.patch @@ -8,3 +8,294 @@ diff --git a/tensorflow/tools/toolchains/python/python_repo.bzl b/tensorflow/too WHEEL_COLLAB = "{}" +USE_PYWRAP_RULES = "False" """ +diff -ruN a/third_party/xla/xla/stream_executor/cuda/cub_scan_kernel_cuda_impl.cu.cc b/third_party/xla/xla/stream_executor/cuda/cub_scan_kernel_cuda_impl.cu.cc +--- a/third_party/xla/xla/stream_executor/cuda/cub_scan_kernel_cuda_impl.cu.cc 2026-07-12 17:57:25.618437375 +0000 ++++ b/third_party/xla/xla/stream_executor/cuda/cub_scan_kernel_cuda_impl.cu.cc 2026-07-12 17:57:25.632496035 +0000 +@@ -41,10 +41,7 @@ + namespace { + + template +-using MaxPolicyT = typename cub::detail::scan::policy_hub< +- /*InputValueT=*/T, /*OutputValueT=*/T, +- /*AccumT=*/T, /*OffsetT=*/int64_t, +- /*ScanOpT=*/ScanOpT>::MaxPolicy; ++using MaxPolicyT = typename cub::DeviceScanPolicy::MaxPolicy; + + template > +diff -ruN a/third_party/xla/xla/tsl/cuda/BUILD.bazel b/third_party/xla/xla/tsl/cuda/BUILD.bazel +--- a/third_party/xla/xla/tsl/cuda/BUILD.bazel 2026-07-12 17:57:25.617565295 +0000 ++++ b/third_party/xla/xla/tsl/cuda/BUILD.bazel 2026-07-12 17:57:25.629649015 +0000 +@@ -47,7 +47,7 @@ + "//xla/tsl/platform:logging", + "@com_google_absl//absl/container:flat_hash_set", + "@local_config_cuda//cuda:cuda_headers", +- "@tsl//tsl/platform:dso_loader", ++ "//xla/tsl/platform/default:dso_loader", + "@tsl//tsl/platform:load_library", + ]), + ) +@@ -78,7 +78,7 @@ + # keep sorted + "//xla/tsl/platform:logging", + "@local_config_cuda//cuda:cuda_headers", +- "@tsl//tsl/platform:dso_loader", ++ "//xla/tsl/platform/default:dso_loader", + "@tsl//tsl/platform:load_library", + ]), + ) +@@ -109,7 +109,7 @@ + # keep sorted + "//xla/tsl/platform:logging", + "@local_config_cuda//cuda:cuda_headers", +- "@tsl//tsl/platform:dso_loader", ++ "//xla/tsl/platform/default:dso_loader", + "@tsl//tsl/platform:load_library", + ]), + ) +@@ -146,7 +146,7 @@ + "//xla/tsl/platform:logging", + "@com_google_absl//absl/container:flat_hash_set", + "@local_config_cuda//cuda:cuda_headers", +- "@tsl//tsl/platform:dso_loader", ++ "//xla/tsl/platform/default:dso_loader", + "@tsl//tsl/platform:load_library", + ], + "//conditions:default": [], +@@ -181,7 +181,7 @@ + "//xla/tsl/platform:logging", + "@com_google_absl//absl/container:flat_hash_map", + "@local_config_cuda//cuda:cudnn_header", +- "@tsl//tsl/platform:dso_loader", ++ "//xla/tsl/platform/default:dso_loader", + "@tsl//tsl/platform:load_library", + ]), + ) +@@ -235,7 +235,7 @@ + # keep sorted + "//xla/tsl/platform:logging", + "@local_config_cuda//cuda:cuda_headers", +- "@tsl//tsl/platform:dso_loader", ++ "//xla/tsl/platform/default:dso_loader", + "@tsl//tsl/platform:load_library", + ]), + ) +@@ -273,7 +273,7 @@ + "//xla/tsl/platform:logging", + "@local_config_cuda//cuda:cuda_headers", + "@local_config_cuda//cuda:cupti_headers", +- "@tsl//tsl/platform:dso_loader", ++ "//xla/tsl/platform/default:dso_loader", + "@tsl//tsl/platform:load_library", + ]), + ) +@@ -309,7 +309,7 @@ + # keep sorted + "//xla/tsl/platform:logging", + "@local_config_cuda//cuda:cuda_headers", +- "@tsl//tsl/platform:dso_loader", ++ "//xla/tsl/platform/default:dso_loader", + "@tsl//tsl/platform:load_library", + ]), + ) +@@ -346,7 +346,7 @@ + "//xla/tsl/platform:logging", + "@com_google_absl//absl/container:flat_hash_set", + "@local_config_cuda//cuda:cuda_headers", +- "@tsl//tsl/platform:dso_loader", ++ "//xla/tsl/platform/default:dso_loader", + "@tsl//tsl/platform:load_library", + ]), + ) +@@ -381,7 +381,7 @@ + "@com_google_absl//absl/strings:string_view", + "@local_config_cuda//cuda:cuda_headers", + "@local_config_nccl//:nccl_headers", +- "@tsl//tsl/platform:dso_loader", ++ "//xla/tsl/platform/default:dso_loader", + "@tsl//tsl/platform:load_library", + ]), + ) +@@ -413,7 +413,7 @@ + deps = if_cuda_is_configured([ + # keep sorted + "//xla/tsl/platform:logging", +- "@tsl//tsl/platform:dso_loader", ++ "//xla/tsl/platform/default:dso_loader", + "@tsl//tsl/platform:load_library", + ]), + ) +@@ -444,7 +444,7 @@ + # keep sorted + "//xla/tsl/platform:logging", + "@local_config_cuda//cuda:cuda_headers", +- "@tsl//tsl/platform:dso_loader", ++ "//xla/tsl/platform/default:dso_loader", + "@tsl//tsl/platform:load_library", + ]), + ) +@@ -475,7 +475,7 @@ + # keep sorted + "//xla/tsl/platform:logging", + "@local_config_cuda//cuda:cuda_headers", +- "@tsl//tsl/platform:dso_loader", ++ "//xla/tsl/platform/default:dso_loader", + "@tsl//tsl/platform:load_library", + ]), + ) +diff -ruN a/third_party/xla/xla/tsl/cuda/cublasLt_stub.cc b/third_party/xla/xla/tsl/cuda/cublasLt_stub.cc +--- a/third_party/xla/xla/tsl/cuda/cublasLt_stub.cc 2026-07-12 17:57:25.619010684 +0000 ++++ b/third_party/xla/xla/tsl/cuda/cublasLt_stub.cc 2026-07-12 17:57:25.629875675 +0000 +@@ -15,7 +15,7 @@ + #include "third_party/gpus/cuda/include/cublasLt.h" + #include "third_party/gpus/cuda/include/cuda.h" + #include "xla/tsl/platform/logging.h" +-#include "tsl/platform/dso_loader.h" ++#include "xla/tsl/platform/default/dso_loader.h" + #include "tsl/platform/load_library.h" + + // Implements the cuBLASLt API by forwarding to cuBLASLt loaded from the DSO. +diff -ruN a/third_party/xla/xla/tsl/cuda/cublas_stub.cc b/third_party/xla/xla/tsl/cuda/cublas_stub.cc +--- a/third_party/xla/xla/tsl/cuda/cublas_stub.cc 2026-07-12 17:57:25.619515775 +0000 ++++ b/third_party/xla/xla/tsl/cuda/cublas_stub.cc 2026-07-12 17:57:25.630085595 +0000 +@@ -24,7 +24,7 @@ + #include "absl/container/flat_hash_set.h" + #include "third_party/gpus/cuda/include/cuda.h" + #include "xla/tsl/platform/logging.h" +-#include "tsl/platform/dso_loader.h" ++#include "xla/tsl/platform/default/dso_loader.h" + #include "tsl/platform/load_library.h" + + // Implements the cuBLAS API by forwarding to cuBLAS loaded from the DSO. +diff -ruN a/third_party/xla/xla/tsl/cuda/cudart_stub.cc b/third_party/xla/xla/tsl/cuda/cudart_stub.cc +--- a/third_party/xla/xla/tsl/cuda/cudart_stub.cc 2026-07-12 17:57:25.620547485 +0000 ++++ b/third_party/xla/xla/tsl/cuda/cudart_stub.cc 2026-07-12 17:57:25.630498815 +0000 +@@ -20,7 +20,7 @@ + #include "absl/strings/string_view.h" + #include "third_party/gpus/cuda/include/cuda_runtime_api.h" + #include "xla/tsl/platform/logging.h" +-#include "tsl/platform/dso_loader.h" ++#include "xla/tsl/platform/default/dso_loader.h" + #include "tsl/platform/load_library.h" + + namespace { +diff -ruN a/third_party/xla/xla/tsl/cuda/cuda_stub.cc b/third_party/xla/xla/tsl/cuda/cuda_stub.cc +--- a/third_party/xla/xla/tsl/cuda/cuda_stub.cc 2026-07-12 17:57:25.620042105 +0000 ++++ b/third_party/xla/xla/tsl/cuda/cuda_stub.cc 2026-07-12 17:57:25.630294585 +0000 +@@ -14,7 +14,7 @@ + ==============================================================================*/ + #include "third_party/gpus/cuda/include/cuda.h" + #include "xla/tsl/platform/logging.h" +-#include "tsl/platform/dso_loader.h" ++#include "xla/tsl/platform/default/dso_loader.h" + #include "tsl/platform/load_library.h" + + // Implements the CUDA driver API by forwarding to CUDA loaded from the DSO. +diff -ruN a/third_party/xla/xla/tsl/cuda/cudnn_stub.cc b/third_party/xla/xla/tsl/cuda/cudnn_stub.cc +--- a/third_party/xla/xla/tsl/cuda/cudnn_stub.cc 2026-07-12 17:57:25.623896675 +0000 ++++ b/third_party/xla/xla/tsl/cuda/cudnn_stub.cc 2026-07-12 17:57:25.630687515 +0000 +@@ -16,7 +16,7 @@ + #include "absl/container/flat_hash_map.h" + #include "third_party/gpus/cudnn/cudnn.h" + #include "xla/tsl/platform/logging.h" +-#include "tsl/platform/dso_loader.h" ++#include "xla/tsl/platform/default/dso_loader.h" + #include "tsl/platform/load_library.h" + + // Implements the cuDNN API by forwarding to cuDNN loaded from the DSO. +diff -ruN a/third_party/xla/xla/tsl/cuda/cufft_stub.cc b/third_party/xla/xla/tsl/cuda/cufft_stub.cc +--- a/third_party/xla/xla/tsl/cuda/cufft_stub.cc 2026-07-12 17:57:25.624421815 +0000 ++++ b/third_party/xla/xla/tsl/cuda/cufft_stub.cc 2026-07-12 17:57:25.630871185 +0000 +@@ -15,7 +15,7 @@ + #include "third_party/gpus/cuda/include/cufft.h" + #include "third_party/gpus/cuda/include/cufftXt.h" + #include "xla/tsl/platform/logging.h" +-#include "tsl/platform/dso_loader.h" ++#include "xla/tsl/platform/default/dso_loader.h" + #include "tsl/platform/load_library.h" + + // Implements the cuFFT API by forwarding to cuFFT loaded from the DSO. +diff -ruN a/third_party/xla/xla/tsl/cuda/cupti_stub.cc b/third_party/xla/xla/tsl/cuda/cupti_stub.cc +--- a/third_party/xla/xla/tsl/cuda/cupti_stub.cc 2026-07-12 17:57:25.624935405 +0000 ++++ b/third_party/xla/xla/tsl/cuda/cupti_stub.cc 2026-07-12 17:57:25.631143375 +0000 +@@ -16,7 +16,7 @@ + #include "third_party/gpus/cuda/extras/CUPTI/include/cupti.h" + #include "third_party/gpus/cuda/include/cuda.h" + #include "xla/tsl/platform/logging.h" +-#include "tsl/platform/dso_loader.h" ++#include "xla/tsl/platform/default/dso_loader.h" + #include "tsl/platform/load_library.h" + + // Implements the CUPTI API by forwarding to CUPTI loaded from the DSO. +diff -ruN a/third_party/xla/xla/tsl/cuda/cusolver_stub.cc b/third_party/xla/xla/tsl/cuda/cusolver_stub.cc +--- a/third_party/xla/xla/tsl/cuda/cusolver_stub.cc 2026-07-12 17:57:25.625466465 +0000 ++++ b/third_party/xla/xla/tsl/cuda/cusolver_stub.cc 2026-07-12 17:57:25.631325645 +0000 +@@ -16,7 +16,7 @@ + #include "third_party/gpus/cuda/include/cusolverDn.h" + #include "third_party/gpus/cuda/include/cusolverSp.h" + #include "xla/tsl/platform/logging.h" +-#include "tsl/platform/dso_loader.h" ++#include "xla/tsl/platform/default/dso_loader.h" + #include "tsl/platform/load_library.h" + + // Implements the cusolver API by forwarding to cusolver loaded from the DSO. +diff -ruN a/third_party/xla/xla/tsl/cuda/cusparse_stub.cc b/third_party/xla/xla/tsl/cuda/cusparse_stub.cc +--- a/third_party/xla/xla/tsl/cuda/cusparse_stub.cc 2026-07-12 17:57:25.625975035 +0000 ++++ b/third_party/xla/xla/tsl/cuda/cusparse_stub.cc 2026-07-12 17:57:25.631513505 +0000 +@@ -18,7 +18,7 @@ + #include "third_party/gpus/cuda/include/cuda.h" + #include "third_party/gpus/cuda/include/cusparse.h" + #include "xla/tsl/platform/logging.h" +-#include "tsl/platform/dso_loader.h" ++#include "xla/tsl/platform/default/dso_loader.h" + #include "tsl/platform/load_library.h" + + // Implements the cusparse API by forwarding to cusparse loaded from the DSO. +diff -ruN a/third_party/xla/xla/tsl/cuda/nccl_stub.cc b/third_party/xla/xla/tsl/cuda/nccl_stub.cc +--- a/third_party/xla/xla/tsl/cuda/nccl_stub.cc 2026-07-12 17:57:25.626489445 +0000 ++++ b/third_party/xla/xla/tsl/cuda/nccl_stub.cc 2026-07-12 17:57:25.631694955 +0000 +@@ -17,7 +17,7 @@ + #include "third_party/gpus/cuda/include/cuda.h" + #include "third_party/nccl/nccl.h" + #include "xla/tsl/platform/logging.h" +-#include "tsl/platform/dso_loader.h" ++#include "xla/tsl/platform/default/dso_loader.h" + #include "tsl/platform/load_library.h" + + // Implements the nccl API by forwarding to nccl loaded from a DSO. +diff -ruN a/third_party/xla/xla/tsl/cuda/nvml_stub.cc b/third_party/xla/xla/tsl/cuda/nvml_stub.cc +--- a/third_party/xla/xla/tsl/cuda/nvml_stub.cc 2026-07-12 17:57:25.628120455 +0000 ++++ b/third_party/xla/xla/tsl/cuda/nvml_stub.cc 2026-07-12 17:57:25.631884615 +0000 +@@ -14,7 +14,7 @@ + ==============================================================================*/ + #include "third_party/gpus/cuda/nvml/include/nvml.h" + #include "xla/tsl/platform/logging.h" +-#include "tsl/platform/dso_loader.h" ++#include "xla/tsl/platform/default/dso_loader.h" + #include "tsl/platform/load_library.h" + + // Implements the NVML API by forwarding to NVML loaded from the DSO. +diff -ruN a/third_party/xla/xla/tsl/cuda/nvrtc_stub.cc b/third_party/xla/xla/tsl/cuda/nvrtc_stub.cc +--- a/third_party/xla/xla/tsl/cuda/nvrtc_stub.cc 2026-07-12 17:57:25.628643355 +0000 ++++ b/third_party/xla/xla/tsl/cuda/nvrtc_stub.cc 2026-07-12 17:57:25.632092815 +0000 +@@ -15,7 +15,7 @@ + + #include "third_party/gpus/cuda/include/nvrtc.h" + #include "xla/tsl/platform/logging.h" +-#include "tsl/platform/dso_loader.h" ++#include "xla/tsl/platform/default/dso_loader.h" + #include "tsl/platform/load_library.h" + + // Implements the NVRTC API by forwarding to NVRTC loaded from the DSO. +diff -ruN a/third_party/xla/xla/tsl/cuda/nvshmem_stub.cc b/third_party/xla/xla/tsl/cuda/nvshmem_stub.cc +--- a/third_party/xla/xla/tsl/cuda/nvshmem_stub.cc 2026-07-12 17:57:25.629133555 +0000 ++++ b/third_party/xla/xla/tsl/cuda/nvshmem_stub.cc 2026-07-12 17:57:25.632281315 +0000 +@@ -14,7 +14,7 @@ + ==============================================================================*/ + + #include "xla/tsl/platform/logging.h" +-#include "tsl/platform/dso_loader.h" ++#include "xla/tsl/platform/default/dso_loader.h" + #include "tsl/platform/load_library.h" + + // Implements the nvshmem API by forwarding to nvshmem loaded from a DSO. From 837d1005319a0e770e78ab49cd4582de434bdf1b Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Sun, 12 Jul 2026 18:38:59 +0000 Subject: [PATCH 007/183] Update .bazelrc compute capabilities to include sm_70 and sm_75 to match Dockerfile. TAG=agy CONV=748d06f3-9c06-4d77-9f81-b365b06d1b3a --- .bazelrc | 2 +- tensorflow_serving/opensource_only/.bazelrc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.bazelrc b/.bazelrc index c580cf0b65c..115e645df60 100644 --- a/.bazelrc +++ b/.bazelrc @@ -17,7 +17,7 @@ build:cuda_clang --host_copt=-Wno-error=unused-command-line-argument build:cuda_clang --repo_env TF_NEED_TENSORRT=0 build:cuda_clang --action_env=TF_CUDA_CLANG="1" build:cuda_clang --@local_config_cuda//:cuda_compiler=clang -build:cuda_clang --repo_env=TF_CUDA_COMPUTE_CAPABILITIES="sm_80,sm_89,compute_90" +build:cuda_clang --repo_env=TF_CUDA_COMPUTE_CAPABILITIES="sm_70,sm_75,sm_80,sm_86,sm_89,compute_90" build:cuda_clang --copt=-Dtypeof=__typeof__ common:cuda_clang --repo_env=HERMETIC_CUDA_VERSION="12.5.1" diff --git a/tensorflow_serving/opensource_only/.bazelrc b/tensorflow_serving/opensource_only/.bazelrc index c580cf0b65c..115e645df60 100644 --- a/tensorflow_serving/opensource_only/.bazelrc +++ b/tensorflow_serving/opensource_only/.bazelrc @@ -17,7 +17,7 @@ build:cuda_clang --host_copt=-Wno-error=unused-command-line-argument build:cuda_clang --repo_env TF_NEED_TENSORRT=0 build:cuda_clang --action_env=TF_CUDA_CLANG="1" build:cuda_clang --@local_config_cuda//:cuda_compiler=clang -build:cuda_clang --repo_env=TF_CUDA_COMPUTE_CAPABILITIES="sm_80,sm_89,compute_90" +build:cuda_clang --repo_env=TF_CUDA_COMPUTE_CAPABILITIES="sm_70,sm_75,sm_80,sm_86,sm_89,compute_90" build:cuda_clang --copt=-Dtypeof=__typeof__ common:cuda_clang --repo_env=HERMETIC_CUDA_VERSION="12.5.1" From 75a48e950a845ea645ecf886f36f1199458b7ec0 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Sun, 12 Jul 2026 19:55:51 +0000 Subject: [PATCH 008/183] Fix __stwt redefinition conflict with RAFT by guarding it with DISABLE_WRAPPERS_STWT. TAG=agy CONV=748d06f3-9c06-4d77-9f81-b365b06d1b3a --- WORKSPACE | 2 +- tensorflow_serving/opensource_only/root.workspace | 2 +- third_party/tensorflow/tensorflow.patch | 12 ++++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 7c6bf4bbe5d..e23b8ce4006 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -121,7 +121,7 @@ http_archive( "https://github.com/google-ml-infra/rules_ml_toolchain/archive/398d613aea7a4c294da49b79a6d6f3f8732bd84c.tar.gz", ], patch_cmds = [ - "cat << 'EOF' >> cc/cuda/clang/clang_cuda_runtime_wrapper.h\n#if defined(__clang__) && defined(__CUDA__)\n#include \n#ifndef typeof\n#define typeof __typeof__\n#endif\n__device__ inline void __stwt(uint4* ptr, uint4 value) {\n asm volatile(\"st.global.wt.v4.u32 [%0], {%1, %2, %3, %4};\" : : \"l\"(ptr), \"r\"(value.x), \"r\"(value.y), \"r\"(value.z), \"r\"(value.w) : \"memory\");\n}\n#endif\nEOF", + "cat << 'EOF' >> cc/cuda/clang/clang_cuda_runtime_wrapper.h\n#if defined(__clang__) && defined(__CUDA__)\n#include \n#ifndef typeof\n#define typeof __typeof__\n#endif\n#ifndef DISABLE_WRAPPERS_STWT\n__device__ inline void __stwt(uint4* ptr, uint4 value) {\n asm volatile(\"st.global.wt.v4.u32 [%0], {%1, %2, %3, %4};\" : : \"l\"(ptr), \"r\"(value.x), \"r\"(value.y), \"r\"(value.z), \"r\"(value.w) : \"memory\");\n}\n#endif\n#endif\nEOF", ], ) diff --git a/tensorflow_serving/opensource_only/root.workspace b/tensorflow_serving/opensource_only/root.workspace index 7c6bf4bbe5d..e23b8ce4006 100644 --- a/tensorflow_serving/opensource_only/root.workspace +++ b/tensorflow_serving/opensource_only/root.workspace @@ -121,7 +121,7 @@ http_archive( "https://github.com/google-ml-infra/rules_ml_toolchain/archive/398d613aea7a4c294da49b79a6d6f3f8732bd84c.tar.gz", ], patch_cmds = [ - "cat << 'EOF' >> cc/cuda/clang/clang_cuda_runtime_wrapper.h\n#if defined(__clang__) && defined(__CUDA__)\n#include \n#ifndef typeof\n#define typeof __typeof__\n#endif\n__device__ inline void __stwt(uint4* ptr, uint4 value) {\n asm volatile(\"st.global.wt.v4.u32 [%0], {%1, %2, %3, %4};\" : : \"l\"(ptr), \"r\"(value.x), \"r\"(value.y), \"r\"(value.z), \"r\"(value.w) : \"memory\");\n}\n#endif\nEOF", + "cat << 'EOF' >> cc/cuda/clang/clang_cuda_runtime_wrapper.h\n#if defined(__clang__) && defined(__CUDA__)\n#include \n#ifndef typeof\n#define typeof __typeof__\n#endif\n#ifndef DISABLE_WRAPPERS_STWT\n__device__ inline void __stwt(uint4* ptr, uint4 value) {\n asm volatile(\"st.global.wt.v4.u32 [%0], {%1, %2, %3, %4};\" : : \"l\"(ptr), \"r\"(value.x), \"r\"(value.y), \"r\"(value.z), \"r\"(value.w) : \"memory\");\n}\n#endif\n#endif\nEOF", ], ) diff --git a/third_party/tensorflow/tensorflow.patch b/third_party/tensorflow/tensorflow.patch index cf21a5f9886..9003e82f8cb 100644 --- a/third_party/tensorflow/tensorflow.patch +++ b/third_party/tensorflow/tensorflow.patch @@ -299,3 +299,15 @@ diff -ruN a/third_party/xla/xla/tsl/cuda/nvshmem_stub.cc b/third_party/xla/xla/t #include "tsl/platform/load_library.h" // Implements the nvshmem API by forwarding to nvshmem loaded from a DSO. + +diff -ruN a/third_party/xla/xla/backends/gpu/runtime/BUILD b/third_party/xla/xla/backends/gpu/runtime/BUILD +--- a/third_party/xla/xla/backends/gpu/runtime/BUILD ++++ b/third_party/xla/xla/backends/gpu/runtime/BUILD +@@ -1650,6 +1650,7 @@ + copts = [ + "-fexceptions", + "-DLIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE", ++ "-DDISABLE_WRAPPERS_STWT", + ], + tags = ["cuda-only"], + deps = [ From 98d76ec4facca17721c86130d4cef03d2083132b Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Mon, 13 Jul 2026 11:08:23 +0000 Subject: [PATCH 009/183] Disable Clang header modules to fix crosstool module redefinition error. TAG=agy CONV=748d06f3-9c06-4d77-9f81-b365b06d1b3a --- .bazelrc | 2 ++ tensorflow_serving/opensource_only/.bazelrc | 2 ++ 2 files changed, 4 insertions(+) diff --git a/.bazelrc b/.bazelrc index 115e645df60..bc1e753b61d 100644 --- a/.bazelrc +++ b/.bazelrc @@ -117,6 +117,8 @@ common --repo_env USE_HERMETIC_CC_TOOLCHAIN=1 common --repo_env=HERMETIC_PYTHON_VERSION="3.10" common --repo_env=USE_PYWRAP_RULES=1 build --features=-layering_check +build --features=-use_header_modules +build --host_features=-use_header_modules build --define=framework_shared_object=false build --dynamic_mode=off diff --git a/tensorflow_serving/opensource_only/.bazelrc b/tensorflow_serving/opensource_only/.bazelrc index 115e645df60..bc1e753b61d 100644 --- a/tensorflow_serving/opensource_only/.bazelrc +++ b/tensorflow_serving/opensource_only/.bazelrc @@ -117,6 +117,8 @@ common --repo_env USE_HERMETIC_CC_TOOLCHAIN=1 common --repo_env=HERMETIC_PYTHON_VERSION="3.10" common --repo_env=USE_PYWRAP_RULES=1 build --features=-layering_check +build --features=-use_header_modules +build --host_features=-use_header_modules build --define=framework_shared_object=false build --dynamic_mode=off From 4f8f459685681f70e2ed07b2b55c8a02e4efbf6f Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Mon, 13 Jul 2026 17:43:09 +0000 Subject: [PATCH 010/183] Disable layering_check and module_maps for host and target to fix modules errors. TAG=agy CONV=748d06f3-9c06-4d77-9f81-b365b06d1b3a --- .bazelrc | 5 +++-- tensorflow_serving/opensource_only/.bazelrc | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.bazelrc b/.bazelrc index bc1e753b61d..a464d768241 100644 --- a/.bazelrc +++ b/.bazelrc @@ -117,8 +117,9 @@ common --repo_env USE_HERMETIC_CC_TOOLCHAIN=1 common --repo_env=HERMETIC_PYTHON_VERSION="3.10" common --repo_env=USE_PYWRAP_RULES=1 build --features=-layering_check -build --features=-use_header_modules -build --host_features=-use_header_modules +build --host_features=-layering_check +build --features=-module_maps +build --host_features=-module_maps build --define=framework_shared_object=false build --dynamic_mode=off diff --git a/tensorflow_serving/opensource_only/.bazelrc b/tensorflow_serving/opensource_only/.bazelrc index bc1e753b61d..a464d768241 100644 --- a/tensorflow_serving/opensource_only/.bazelrc +++ b/tensorflow_serving/opensource_only/.bazelrc @@ -117,8 +117,9 @@ common --repo_env USE_HERMETIC_CC_TOOLCHAIN=1 common --repo_env=HERMETIC_PYTHON_VERSION="3.10" common --repo_env=USE_PYWRAP_RULES=1 build --features=-layering_check -build --features=-use_header_modules -build --host_features=-use_header_modules +build --host_features=-layering_check +build --features=-module_maps +build --host_features=-module_maps build --define=framework_shared_object=false build --dynamic_mode=off From f5ce4c1aa9ead503ae875a8bf132d2c3ccf87b2f Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Mon, 13 Jul 2026 18:35:26 +0000 Subject: [PATCH 011/183] Sync root.workspace with depot head (align org_tensorflow commit). TAG=agy CONV=748d06f3-9c06-4d77-9f81-b365b06d1b3a --- WORKSPACE | 4 ++-- tensorflow_serving/opensource_only/root.workspace | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index e23b8ce4006..a04279aba11 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -24,8 +24,8 @@ local_repository( load("//tensorflow_serving:repo.bzl", "tensorflow_http_archive") tensorflow_http_archive( name = "org_tensorflow", - sha256 = "582f5dc1c0887ca5b2eb364dc39e0c15fd31ee138b250e24163b6eca340f701f", - git_commit = "d875953b4fd431c15fedb1d408d5396e7f9d4d23", + sha256 = "44d29570b377bb095ebd0805a78e34888eb36a643f947d9aa825a201762e9661", + git_commit = "7e393456e8684e5b8115347ae7ec0ec9115c209d", patch = "//third_party/tensorflow:tensorflow.patch", patch_cmds = [ "sed -i '/cc_library = _cc_library/d' tensorflow/core/platform/rules_cc.bzl", diff --git a/tensorflow_serving/opensource_only/root.workspace b/tensorflow_serving/opensource_only/root.workspace index e23b8ce4006..a04279aba11 100644 --- a/tensorflow_serving/opensource_only/root.workspace +++ b/tensorflow_serving/opensource_only/root.workspace @@ -24,8 +24,8 @@ local_repository( load("//tensorflow_serving:repo.bzl", "tensorflow_http_archive") tensorflow_http_archive( name = "org_tensorflow", - sha256 = "582f5dc1c0887ca5b2eb364dc39e0c15fd31ee138b250e24163b6eca340f701f", - git_commit = "d875953b4fd431c15fedb1d408d5396e7f9d4d23", + sha256 = "44d29570b377bb095ebd0805a78e34888eb36a643f947d9aa825a201762e9661", + git_commit = "7e393456e8684e5b8115347ae7ec0ec9115c209d", patch = "//third_party/tensorflow:tensorflow.patch", patch_cmds = [ "sed -i '/cc_library = _cc_library/d' tensorflow/core/platform/rules_cc.bzl", From 86e707ef59418b00b936d4f3a9b5c9958923cd5d Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Mon, 13 Jul 2026 20:04:55 +0000 Subject: [PATCH 012/183] Fix libevent to build hermetically using sysroot --- third_party/libevent/BUILD | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/third_party/libevent/BUILD b/third_party/libevent/BUILD index 4a6dc97805f..19e4597c3e9 100644 --- a/third_party/libevent/BUILD +++ b/third_party/libevent/BUILD @@ -51,18 +51,30 @@ lib_files = [ genrule( name = "libevent-srcs", + srcs = glob(["**"]) + ["@sysroot_linux_x86_64//:sysroot"], outs = include_files + lib_files, cmd = "\n".join([ "export INSTALL_DIR=$$(pwd)/$(@D)/libevent", + "export ORIG_DIR=$$(pwd) # force rebuild 1", + "export CC_PATH=$(CC)", + "if [[ $$CC_PATH != /* ]]; then CC_PATH=$$ORIG_DIR/$$CC_PATH; fi", + "export REAL_CLANG=external/llvm18_linux_x86_64/bin/clang", + "if [[ $$REAL_CLANG != /* ]]; then REAL_CLANG=$$ORIG_DIR/$$REAL_CLANG; fi", + "export GCC_PATH=$$REAL_CLANG", + "export REAL_AR=external/llvm18_linux_x86_64/bin/llvm-ar", + "if [[ $$REAL_AR != /* ]]; then REAL_AR=$$ORIG_DIR/$$REAL_AR; fi", + "export SYSROOT_DIR=$$(ls -d $$ORIG_DIR/external/sysroot_linux_x86_64_glibc_* | head -n 1)", "export TMP_DIR=$$(mktemp -d -t libevent.XXXXXX)", "mkdir -p $$TMP_DIR", - "cp -R $$(pwd)/external/com_github_libevent_libevent/* $$TMP_DIR", + "cp -R $$ORIG_DIR/external/com_github_libevent_libevent/* $$TMP_DIR", "cd $$TMP_DIR", "./autogen.sh", - "./configure --prefix=$$INSTALL_DIR CFLAGS=-fPIC CXXFLAGS=-fPIC --enable-shared=no --disable-openssl", - "make install", + "CC=$$CC_PATH AR=$$REAL_AR ./configure --prefix=$$INSTALL_DIR CFLAGS=\"-fPIC --sysroot=$$SYSROOT_DIR\" CXXFLAGS=\"-fPIC --sysroot=$$SYSROOT_DIR\" LDFLAGS=\"--sysroot=$$SYSROOT_DIR\" --enable-shared=no --disable-openssl || (cat config.log && false)", + "make install CC=$$CC_PATH AR=$$REAL_AR", "rm -rf $$TMP_DIR", ]), + local = 1, + toolchains = ["@bazel_tools//tools/cpp:current_cc_toolchain"], ) cc_library( From b13347abe07294440b5ac684093a6f4ea56a6045 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Tue, 14 Jul 2026 02:08:46 +0000 Subject: [PATCH 013/183] Add sm_60 back to support P100 GPUs in Kokoro tests --- .bazelrc | 2 +- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.bazelrc b/.bazelrc index a464d768241..c41bf62af6f 100644 --- a/.bazelrc +++ b/.bazelrc @@ -17,7 +17,7 @@ build:cuda_clang --host_copt=-Wno-error=unused-command-line-argument build:cuda_clang --repo_env TF_NEED_TENSORRT=0 build:cuda_clang --action_env=TF_CUDA_CLANG="1" build:cuda_clang --@local_config_cuda//:cuda_compiler=clang -build:cuda_clang --repo_env=TF_CUDA_COMPUTE_CAPABILITIES="sm_70,sm_75,sm_80,sm_86,sm_89,compute_90" +build:cuda_clang --repo_env=TF_CUDA_COMPUTE_CAPABILITIES="sm_60,sm_70,sm_75,sm_80,sm_86,sm_89,compute_90" build:cuda_clang --copt=-Dtypeof=__typeof__ common:cuda_clang --repo_env=HERMETIC_CUDA_VERSION="12.5.1" diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index f06e2428022..643c3e54170 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -25,7 +25,7 @@ ENV CUDNN_VERSION=9.3.0.75 ENV TF_TENSORRT_VERSION=8.6.1 ENV CUDA=12.5 -ARG TF_CUDA_COMPUTE_CAPABILITIES="7.0,7.5,8.0,8.6,8.9,9.0" +ARG TF_CUDA_COMPUTE_CAPABILITIES="6.0,7.0,7.5,8.0,8.6,8.9,9.0" ENV TF_CUDA_COMPUTE_CAPABILITIES=${TF_CUDA_COMPUTE_CAPABILITIES} RUN apt-get update && apt-get install -y --no-install-recommends \ From ccc179a8e102e80397ee25394118a264edf0ba0d Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Thu, 16 Jul 2026 22:29:18 +0000 Subject: [PATCH 014/183] Dynamically locate clang and llvm-ar binaries in libevent BUILD genrule --- third_party/libevent/BUILD | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/third_party/libevent/BUILD b/third_party/libevent/BUILD index 19e4597c3e9..9992cd3e539 100644 --- a/third_party/libevent/BUILD +++ b/third_party/libevent/BUILD @@ -58,11 +58,8 @@ genrule( "export ORIG_DIR=$$(pwd) # force rebuild 1", "export CC_PATH=$(CC)", "if [[ $$CC_PATH != /* ]]; then CC_PATH=$$ORIG_DIR/$$CC_PATH; fi", - "export REAL_CLANG=external/llvm18_linux_x86_64/bin/clang", - "if [[ $$REAL_CLANG != /* ]]; then REAL_CLANG=$$ORIG_DIR/$$REAL_CLANG; fi", - "export GCC_PATH=$$REAL_CLANG", - "export REAL_AR=external/llvm18_linux_x86_64/bin/llvm-ar", - "if [[ $$REAL_AR != /* ]]; then REAL_AR=$$ORIG_DIR/$$REAL_AR; fi", + "export REAL_CLANG=$$(ls $$ORIG_DIR/external/llvm*_linux_x86_64/bin/clang | head -n 1)", + "export REAL_AR=$$(ls $$ORIG_DIR/external/llvm*_linux_x86_64/bin/llvm-ar | head -n 1)", "export SYSROOT_DIR=$$(ls -d $$ORIG_DIR/external/sysroot_linux_x86_64_glibc_* | head -n 1)", "export TMP_DIR=$$(mktemp -d -t libevent.XXXXXX)", "mkdir -p $$TMP_DIR", From 04f03e1936758cb290fb50e2216c4e8b7ef00e22 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Fri, 17 Jul 2026 15:42:25 +0000 Subject: [PATCH 015/183] Fix libevent build: export GCC_PATH for clang wrapper in genrule --- third_party/libevent/BUILD | 1 + 1 file changed, 1 insertion(+) diff --git a/third_party/libevent/BUILD b/third_party/libevent/BUILD index 9992cd3e539..fae802152c7 100644 --- a/third_party/libevent/BUILD +++ b/third_party/libevent/BUILD @@ -59,6 +59,7 @@ genrule( "export CC_PATH=$(CC)", "if [[ $$CC_PATH != /* ]]; then CC_PATH=$$ORIG_DIR/$$CC_PATH; fi", "export REAL_CLANG=$$(ls $$ORIG_DIR/external/llvm*_linux_x86_64/bin/clang | head -n 1)", + "export GCC_PATH=$$REAL_CLANG", "export REAL_AR=$$(ls $$ORIG_DIR/external/llvm*_linux_x86_64/bin/llvm-ar | head -n 1)", "export SYSROOT_DIR=$$(ls -d $$ORIG_DIR/external/sysroot_linux_x86_64_glibc_* | head -n 1)", "export TMP_DIR=$$(mktemp -d -t libevent.XXXXXX)", From 32f12f7993c9aa93e9b268723e512364a16809a9 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Mon, 20 Jul 2026 20:27:50 +0000 Subject: [PATCH 016/183] Pin CUDA 12.2 in Dockerfiles and remove CUB patch from tensorflow.patch --- .../tools/docker/Dockerfile.devel-gpu | 34 +++++++++---------- .../tools/docker/Dockerfile.gpu | 28 +++++++-------- third_party/tensorflow/tensorflow.patch | 15 -------- 3 files changed, 31 insertions(+), 46 deletions(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 643c3e54170..7be74c601d2 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -11,7 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -FROM nvidia/cuda:12.5.1-base-ubuntu22.04 as base_build +FROM nvidia/cuda:12.2.2-base-ubuntu22.04 as base_build ARG TF_SERVING_VERSION_GIT_BRANCH=master ARG TF_SERVING_VERSION_GIT_COMMIT=HEAD @@ -23,7 +23,7 @@ LABEL tensorflow_serving_github_commit=${TF_SERVING_VERSION_GIT_COMMIT} ENV CUDNN_VERSION=9.3.0.75 ENV TF_TENSORRT_VERSION=8.6.1 -ENV CUDA=12.5 +ENV CUDA=12.2 ARG TF_CUDA_COMPUTE_CAPABILITIES="6.0,7.0,7.5,8.0,8.6,8.9,9.0" ENV TF_CUDA_COMPUTE_CAPABILITIES=${TF_CUDA_COMPUTE_CAPABILITIES} @@ -38,21 +38,21 @@ RUN curl -sSL --retry 5 https://github.com/tensorflow/serving/tarball/${TF_SERVI RUN /tensorflow-serving/tensorflow_serving/tools/docker/setup.sources.sh RUN apt-get install -y --no-install-recommends \ - cuda-command-line-tools-12-5 \ - cuda-cudart-dev-12-5 \ - cuda-nvcc-12-5 \ - cuda-cupti-12-5 \ - cuda-nvprune-12-5 \ - cuda-libraries-12-5 \ - cuda-libraries-dev-12-5 \ - cuda-nvml-dev-12-5 \ - libcufft-12-5 \ - libcurand-12-5 \ - libcusolver-dev-12-5 \ - libcusparse-dev-12-5 \ - libcublas-12-5 \ - libcublas-dev-12-5 \ - cuda-compat-12-5 \ + cuda-command-line-tools-12-2 \ + cuda-cudart-dev-12-2 \ + cuda-nvcc-12-2 \ + cuda-cupti-12-2 \ + cuda-nvprune-12-2 \ + cuda-libraries-12-2 \ + cuda-libraries-dev-12-2 \ + cuda-nvml-dev-12-2 \ + libcufft-12-2 \ + libcurand-12-2 \ + libcusolver-dev-12-2 \ + libcusparse-dev-12-2 \ + libcublas-12-2 \ + libcublas-dev-12-2 \ + cuda-compat-12-2 \ libnccl-dev=2.25.1-1+cuda12.8 \ libnccl2=2.25.1-1+cuda12.8 \ libcudnn9-dev-cuda-12=9.3.0.75-1 \ diff --git a/tensorflow_serving/tools/docker/Dockerfile.gpu b/tensorflow_serving/tools/docker/Dockerfile.gpu index cee40ca9c9d..fc1553351f9 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.gpu @@ -16,7 +16,7 @@ ARG TF_SERVING_VERSION=latest ARG TF_SERVING_BUILD_IMAGE=tensorflow/serving:${TF_SERVING_VERSION}-devel-gpu FROM ${TF_SERVING_BUILD_IMAGE} as build_image -FROM nvidia/cuda:12.5.1-base-ubuntu22.04 as base_build +FROM nvidia/cuda:12.2.2-base-ubuntu22.04 as base_build ARG TF_SERVING_VERSION_GIT_BRANCH=master ARG TF_SERVING_VERSION_GIT_COMMIT=HEAD @@ -28,7 +28,7 @@ LABEL tensorflow_serving_github_commit=${TF_SERVING_VERSION_GIT_COMMIT} ENV CUDNN_VERSION=9.3.0.75 ENV TF_TENSORRT_VERSION=8.6.1 -ENV CUDA=12.5 +ENV CUDA=12.2 ENV LD_LIBRARY_PATH /usr/local/cuda/extras/CUPTI/lib64:$LD_LIBRARY_PATH RUN apt-get update && apt-get install -y --no-install-recommends \ @@ -38,22 +38,22 @@ RUN curl -sSL --retry 5 https://raw.githubusercontent.com/tensorflow/serving/${T RUN apt-get install -y --no-install-recommends \ ca-certificates \ - cuda-command-line-tools-12-5 \ - cuda-cupti-12-5 \ - cuda-libraries-12-5 \ - cuda-nvcc-12-5 \ - cuda-nvprune-12-5 \ - cuda-nvrtc-12-5 \ - libcublas-12-5 \ + cuda-command-line-tools-12-2 \ + cuda-cupti-12-2 \ + cuda-libraries-12-2 \ + cuda-nvcc-12-2 \ + cuda-nvprune-12-2 \ + cuda-nvrtc-12-2 \ + libcublas-12-2 \ libcudnn9-cuda-12 \ - libcufft-12-5 \ - libcurand-12-5 \ - libcusolver-12-5 \ - libcusparse-12-5 \ + libcufft-12-2 \ + libcurand-12-2 \ + libcusolver-12-2 \ + libcusparse-12-2 \ libnccl2 \ libnvinfer8 \ libnvinfer-plugin8 \ - cuda-compat-12-5 \ + cuda-compat-12-2 \ libgomp1 \ build-essential \ curl \ diff --git a/third_party/tensorflow/tensorflow.patch b/third_party/tensorflow/tensorflow.patch index 9003e82f8cb..805fe7fef4b 100644 --- a/third_party/tensorflow/tensorflow.patch +++ b/third_party/tensorflow/tensorflow.patch @@ -8,21 +8,6 @@ diff --git a/tensorflow/tools/toolchains/python/python_repo.bzl b/tensorflow/too WHEEL_COLLAB = "{}" +USE_PYWRAP_RULES = "False" """ -diff -ruN a/third_party/xla/xla/stream_executor/cuda/cub_scan_kernel_cuda_impl.cu.cc b/third_party/xla/xla/stream_executor/cuda/cub_scan_kernel_cuda_impl.cu.cc ---- a/third_party/xla/xla/stream_executor/cuda/cub_scan_kernel_cuda_impl.cu.cc 2026-07-12 17:57:25.618437375 +0000 -+++ b/third_party/xla/xla/stream_executor/cuda/cub_scan_kernel_cuda_impl.cu.cc 2026-07-12 17:57:25.632496035 +0000 -@@ -41,10 +41,7 @@ - namespace { - - template --using MaxPolicyT = typename cub::detail::scan::policy_hub< -- /*InputValueT=*/T, /*OutputValueT=*/T, -- /*AccumT=*/T, /*OffsetT=*/int64_t, -- /*ScanOpT=*/ScanOpT>::MaxPolicy; -+using MaxPolicyT = typename cub::DeviceScanPolicy::MaxPolicy; - - template > diff -ruN a/third_party/xla/xla/tsl/cuda/BUILD.bazel b/third_party/xla/xla/tsl/cuda/BUILD.bazel --- a/third_party/xla/xla/tsl/cuda/BUILD.bazel 2026-07-12 17:57:25.617565295 +0000 +++ b/third_party/xla/xla/tsl/cuda/BUILD.bazel 2026-07-12 17:57:25.629649015 +0000 From 24ba20c538c4e45560782f58a726a53a117a6c3e Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Mon, 20 Jul 2026 21:36:30 +0000 Subject: [PATCH 017/183] Set HERMETIC_CUDA_VERSION=12.2.0 and re-add CUB scan kernel patch --- .../tools/docker/Dockerfile.devel-gpu | 1 + tensorflow_serving/tools/docker/Dockerfile.gpu | 1 + third_party/tensorflow/tensorflow.patch | 15 +++++++++++++++ 3 files changed, 17 insertions(+) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 7be74c601d2..0f1e59a3bde 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -24,6 +24,7 @@ LABEL tensorflow_serving_github_commit=${TF_SERVING_VERSION_GIT_COMMIT} ENV CUDNN_VERSION=9.3.0.75 ENV TF_TENSORRT_VERSION=8.6.1 ENV CUDA=12.2 +ENV HERMETIC_CUDA_VERSION=12.2.0 ARG TF_CUDA_COMPUTE_CAPABILITIES="6.0,7.0,7.5,8.0,8.6,8.9,9.0" ENV TF_CUDA_COMPUTE_CAPABILITIES=${TF_CUDA_COMPUTE_CAPABILITIES} diff --git a/tensorflow_serving/tools/docker/Dockerfile.gpu b/tensorflow_serving/tools/docker/Dockerfile.gpu index fc1553351f9..61389cce562 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.gpu @@ -29,6 +29,7 @@ LABEL tensorflow_serving_github_commit=${TF_SERVING_VERSION_GIT_COMMIT} ENV CUDNN_VERSION=9.3.0.75 ENV TF_TENSORRT_VERSION=8.6.1 ENV CUDA=12.2 +ENV HERMETIC_CUDA_VERSION=12.2.0 ENV LD_LIBRARY_PATH /usr/local/cuda/extras/CUPTI/lib64:$LD_LIBRARY_PATH RUN apt-get update && apt-get install -y --no-install-recommends \ diff --git a/third_party/tensorflow/tensorflow.patch b/third_party/tensorflow/tensorflow.patch index 805fe7fef4b..9003e82f8cb 100644 --- a/third_party/tensorflow/tensorflow.patch +++ b/third_party/tensorflow/tensorflow.patch @@ -8,6 +8,21 @@ diff --git a/tensorflow/tools/toolchains/python/python_repo.bzl b/tensorflow/too WHEEL_COLLAB = "{}" +USE_PYWRAP_RULES = "False" """ +diff -ruN a/third_party/xla/xla/stream_executor/cuda/cub_scan_kernel_cuda_impl.cu.cc b/third_party/xla/xla/stream_executor/cuda/cub_scan_kernel_cuda_impl.cu.cc +--- a/third_party/xla/xla/stream_executor/cuda/cub_scan_kernel_cuda_impl.cu.cc 2026-07-12 17:57:25.618437375 +0000 ++++ b/third_party/xla/xla/stream_executor/cuda/cub_scan_kernel_cuda_impl.cu.cc 2026-07-12 17:57:25.632496035 +0000 +@@ -41,10 +41,7 @@ + namespace { + + template +-using MaxPolicyT = typename cub::detail::scan::policy_hub< +- /*InputValueT=*/T, /*OutputValueT=*/T, +- /*AccumT=*/T, /*OffsetT=*/int64_t, +- /*ScanOpT=*/ScanOpT>::MaxPolicy; ++using MaxPolicyT = typename cub::DeviceScanPolicy::MaxPolicy; + + template > diff -ruN a/third_party/xla/xla/tsl/cuda/BUILD.bazel b/third_party/xla/xla/tsl/cuda/BUILD.bazel --- a/third_party/xla/xla/tsl/cuda/BUILD.bazel 2026-07-12 17:57:25.617565295 +0000 +++ b/third_party/xla/xla/tsl/cuda/BUILD.bazel 2026-07-12 17:57:25.629649015 +0000 From cfb9aedece3aa340fa3dd6c20905220b4d6860d2 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Mon, 20 Jul 2026 21:45:11 +0000 Subject: [PATCH 018/183] Remove CUB scan kernel patch to test hermetic CUDA 12.2.0 build --- third_party/tensorflow/tensorflow.patch | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/third_party/tensorflow/tensorflow.patch b/third_party/tensorflow/tensorflow.patch index 9003e82f8cb..805fe7fef4b 100644 --- a/third_party/tensorflow/tensorflow.patch +++ b/third_party/tensorflow/tensorflow.patch @@ -8,21 +8,6 @@ diff --git a/tensorflow/tools/toolchains/python/python_repo.bzl b/tensorflow/too WHEEL_COLLAB = "{}" +USE_PYWRAP_RULES = "False" """ -diff -ruN a/third_party/xla/xla/stream_executor/cuda/cub_scan_kernel_cuda_impl.cu.cc b/third_party/xla/xla/stream_executor/cuda/cub_scan_kernel_cuda_impl.cu.cc ---- a/third_party/xla/xla/stream_executor/cuda/cub_scan_kernel_cuda_impl.cu.cc 2026-07-12 17:57:25.618437375 +0000 -+++ b/third_party/xla/xla/stream_executor/cuda/cub_scan_kernel_cuda_impl.cu.cc 2026-07-12 17:57:25.632496035 +0000 -@@ -41,10 +41,7 @@ - namespace { - - template --using MaxPolicyT = typename cub::detail::scan::policy_hub< -- /*InputValueT=*/T, /*OutputValueT=*/T, -- /*AccumT=*/T, /*OffsetT=*/int64_t, -- /*ScanOpT=*/ScanOpT>::MaxPolicy; -+using MaxPolicyT = typename cub::DeviceScanPolicy::MaxPolicy; - - template > diff -ruN a/third_party/xla/xla/tsl/cuda/BUILD.bazel b/third_party/xla/xla/tsl/cuda/BUILD.bazel --- a/third_party/xla/xla/tsl/cuda/BUILD.bazel 2026-07-12 17:57:25.617565295 +0000 +++ b/third_party/xla/xla/tsl/cuda/BUILD.bazel 2026-07-12 17:57:25.629649015 +0000 From 59065c65a5b569aa4a4068386dd4864a132ee093 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Mon, 20 Jul 2026 23:36:02 +0000 Subject: [PATCH 019/183] Re-add CUB scan kernel patch required for rules_ml_toolchain builds --- third_party/tensorflow/tensorflow.patch | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/third_party/tensorflow/tensorflow.patch b/third_party/tensorflow/tensorflow.patch index 805fe7fef4b..9003e82f8cb 100644 --- a/third_party/tensorflow/tensorflow.patch +++ b/third_party/tensorflow/tensorflow.patch @@ -8,6 +8,21 @@ diff --git a/tensorflow/tools/toolchains/python/python_repo.bzl b/tensorflow/too WHEEL_COLLAB = "{}" +USE_PYWRAP_RULES = "False" """ +diff -ruN a/third_party/xla/xla/stream_executor/cuda/cub_scan_kernel_cuda_impl.cu.cc b/third_party/xla/xla/stream_executor/cuda/cub_scan_kernel_cuda_impl.cu.cc +--- a/third_party/xla/xla/stream_executor/cuda/cub_scan_kernel_cuda_impl.cu.cc 2026-07-12 17:57:25.618437375 +0000 ++++ b/third_party/xla/xla/stream_executor/cuda/cub_scan_kernel_cuda_impl.cu.cc 2026-07-12 17:57:25.632496035 +0000 +@@ -41,10 +41,7 @@ + namespace { + + template +-using MaxPolicyT = typename cub::detail::scan::policy_hub< +- /*InputValueT=*/T, /*OutputValueT=*/T, +- /*AccumT=*/T, /*OffsetT=*/int64_t, +- /*ScanOpT=*/ScanOpT>::MaxPolicy; ++using MaxPolicyT = typename cub::DeviceScanPolicy::MaxPolicy; + + template > diff -ruN a/third_party/xla/xla/tsl/cuda/BUILD.bazel b/third_party/xla/xla/tsl/cuda/BUILD.bazel --- a/third_party/xla/xla/tsl/cuda/BUILD.bazel 2026-07-12 17:57:25.617565295 +0000 +++ b/third_party/xla/xla/tsl/cuda/BUILD.bazel 2026-07-12 17:57:25.629649015 +0000 From edfc2946a9c5b8fc95a2fdf631a0cfa33ec8cfb2 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Mon, 20 Jul 2026 23:44:20 +0000 Subject: [PATCH 020/183] Update rules_ml_toolchain commit to d8cb9c2c168cd64000eaa6eda0781a9615a26ffe to match TF 2.21 release --- WORKSPACE | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index a04279aba11..07acecffc1e 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -24,8 +24,8 @@ local_repository( load("//tensorflow_serving:repo.bzl", "tensorflow_http_archive") tensorflow_http_archive( name = "org_tensorflow", - sha256 = "44d29570b377bb095ebd0805a78e34888eb36a643f947d9aa825a201762e9661", - git_commit = "7e393456e8684e5b8115347ae7ec0ec9115c209d", + sha256 = "44dbcac78a144a404485bc03b12fe6a545281b985552b15dbf0f7afec9815442", + git_commit = "4f1b7de8a37a03452565bc612c148a1d2d9d6cfc", patch = "//third_party/tensorflow:tensorflow.patch", patch_cmds = [ "sed -i '/cc_library = _cc_library/d' tensorflow/core/platform/rules_cc.bzl", @@ -114,11 +114,11 @@ http_archive( # Details: https://github.com/google-ml-infra/rules_ml_toolchain http_archive( name = "rules_ml_toolchain", - sha256 = "0b42f693a60c6050d87db1e0a0eaeb84ab3f54191fce094d86334faedc807da0", - strip_prefix = "rules_ml_toolchain-398d613aea7a4c294da49b79a6d6f3f8732bd84c", + sha256 = "54c1a357f71f611efdb4891ebd4bcbe4aeb6dfa7e473f14fd7ecad5062096616", + strip_prefix = "rules_ml_toolchain-d8cb9c2c168cd64000eaa6eda0781a9615a26ffe", urls = [ - "https://storage.googleapis.com/mirror.tensorflow.org/github.com/google-ml-infra/rules_ml_toolchain/archive/398d613aea7a4c294da49b79a6d6f3f8732bd84c.tar.gz", - "https://github.com/google-ml-infra/rules_ml_toolchain/archive/398d613aea7a4c294da49b79a6d6f3f8732bd84c.tar.gz", + "https://storage.googleapis.com/mirror.tensorflow.org/github.com/google-ml-infra/rules_ml_toolchain/archive/d8cb9c2c168cd64000eaa6eda0781a9615a26ffe.tar.gz", + "https://github.com/google-ml-infra/rules_ml_toolchain/archive/d8cb9c2c168cd64000eaa6eda0781a9615a26ffe.tar.gz", ], patch_cmds = [ "cat << 'EOF' >> cc/cuda/clang/clang_cuda_runtime_wrapper.h\n#if defined(__clang__) && defined(__CUDA__)\n#include \n#ifndef typeof\n#define typeof __typeof__\n#endif\n#ifndef DISABLE_WRAPPERS_STWT\n__device__ inline void __stwt(uint4* ptr, uint4 value) {\n asm volatile(\"st.global.wt.v4.u32 [%0], {%1, %2, %3, %4};\" : : \"l\"(ptr), \"r\"(value.x), \"r\"(value.y), \"r\"(value.z), \"r\"(value.w) : \"memory\");\n}\n#endif\n#endif\nEOF", From 3c9ca15d22e166050b269e666c831ce8b185658f Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Mon, 20 Jul 2026 23:51:48 +0000 Subject: [PATCH 021/183] Pass --repo_env=HERMETIC_CUDA_VERSION=12.2.0 to Bazel options in Dockerfile.devel-gpu --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 0f1e59a3bde..1861e4245c8 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -154,7 +154,7 @@ FROM base_build as binary_build # Build, and install TensorFlow Serving ARG TF_SERVING_BUILD_OPTIONS="--config=release" RUN echo "Building with build options: ${TF_SERVING_BUILD_OPTIONS}" -ARG TF_SERVING_BAZEL_OPTIONS="" +ARG TF_SERVING_BAZEL_OPTIONS="--repo_env=HERMETIC_CUDA_VERSION=12.2.0" RUN echo "Building with Bazel options: ${TF_SERVING_BAZEL_OPTIONS}" RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1 && \ From 402caaeddeea1c36b771fab278b71ed085ff8cce Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Mon, 20 Jul 2026 23:53:25 +0000 Subject: [PATCH 022/183] Remove CUB scan kernel patch now that Bazel is forced to CUDA 12.2.0 --- third_party/tensorflow/tensorflow.patch | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/third_party/tensorflow/tensorflow.patch b/third_party/tensorflow/tensorflow.patch index 9003e82f8cb..805fe7fef4b 100644 --- a/third_party/tensorflow/tensorflow.patch +++ b/third_party/tensorflow/tensorflow.patch @@ -8,21 +8,6 @@ diff --git a/tensorflow/tools/toolchains/python/python_repo.bzl b/tensorflow/too WHEEL_COLLAB = "{}" +USE_PYWRAP_RULES = "False" """ -diff -ruN a/third_party/xla/xla/stream_executor/cuda/cub_scan_kernel_cuda_impl.cu.cc b/third_party/xla/xla/stream_executor/cuda/cub_scan_kernel_cuda_impl.cu.cc ---- a/third_party/xla/xla/stream_executor/cuda/cub_scan_kernel_cuda_impl.cu.cc 2026-07-12 17:57:25.618437375 +0000 -+++ b/third_party/xla/xla/stream_executor/cuda/cub_scan_kernel_cuda_impl.cu.cc 2026-07-12 17:57:25.632496035 +0000 -@@ -41,10 +41,7 @@ - namespace { - - template --using MaxPolicyT = typename cub::detail::scan::policy_hub< -- /*InputValueT=*/T, /*OutputValueT=*/T, -- /*AccumT=*/T, /*OffsetT=*/int64_t, -- /*ScanOpT=*/ScanOpT>::MaxPolicy; -+using MaxPolicyT = typename cub::DeviceScanPolicy::MaxPolicy; - - template > diff -ruN a/third_party/xla/xla/tsl/cuda/BUILD.bazel b/third_party/xla/xla/tsl/cuda/BUILD.bazel --- a/third_party/xla/xla/tsl/cuda/BUILD.bazel 2026-07-12 17:57:25.617565295 +0000 +++ b/third_party/xla/xla/tsl/cuda/BUILD.bazel 2026-07-12 17:57:25.629649015 +0000 From aad714d6474aaaf749c4692bce96103a1fa24d19 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Tue, 21 Jul 2026 17:33:40 +0000 Subject: [PATCH 023/183] Restore rules_ml_toolchain commit 398d613a and CUB scan kernel patch for TF master compatibility --- WORKSPACE | 8 ++++---- third_party/tensorflow/tensorflow.patch | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 07acecffc1e..b110e6773f3 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -114,11 +114,11 @@ http_archive( # Details: https://github.com/google-ml-infra/rules_ml_toolchain http_archive( name = "rules_ml_toolchain", - sha256 = "54c1a357f71f611efdb4891ebd4bcbe4aeb6dfa7e473f14fd7ecad5062096616", - strip_prefix = "rules_ml_toolchain-d8cb9c2c168cd64000eaa6eda0781a9615a26ffe", + sha256 = "0b42f693a60c6050d87db1e0a0eaeb84ab3f54191fce094d86334faedc807da0", + strip_prefix = "rules_ml_toolchain-398d613aea7a4c294da49b79a6d6f3f8732bd84c", urls = [ - "https://storage.googleapis.com/mirror.tensorflow.org/github.com/google-ml-infra/rules_ml_toolchain/archive/d8cb9c2c168cd64000eaa6eda0781a9615a26ffe.tar.gz", - "https://github.com/google-ml-infra/rules_ml_toolchain/archive/d8cb9c2c168cd64000eaa6eda0781a9615a26ffe.tar.gz", + "https://storage.googleapis.com/mirror.tensorflow.org/github.com/google-ml-infra/rules_ml_toolchain/archive/398d613aea7a4c294da49b79a6d6f3f8732bd84c.tar.gz", + "https://github.com/google-ml-infra/rules_ml_toolchain/archive/398d613aea7a4c294da49b79a6d6f3f8732bd84c.tar.gz", ], patch_cmds = [ "cat << 'EOF' >> cc/cuda/clang/clang_cuda_runtime_wrapper.h\n#if defined(__clang__) && defined(__CUDA__)\n#include \n#ifndef typeof\n#define typeof __typeof__\n#endif\n#ifndef DISABLE_WRAPPERS_STWT\n__device__ inline void __stwt(uint4* ptr, uint4 value) {\n asm volatile(\"st.global.wt.v4.u32 [%0], {%1, %2, %3, %4};\" : : \"l\"(ptr), \"r\"(value.x), \"r\"(value.y), \"r\"(value.z), \"r\"(value.w) : \"memory\");\n}\n#endif\n#endif\nEOF", diff --git a/third_party/tensorflow/tensorflow.patch b/third_party/tensorflow/tensorflow.patch index 805fe7fef4b..9003e82f8cb 100644 --- a/third_party/tensorflow/tensorflow.patch +++ b/third_party/tensorflow/tensorflow.patch @@ -8,6 +8,21 @@ diff --git a/tensorflow/tools/toolchains/python/python_repo.bzl b/tensorflow/too WHEEL_COLLAB = "{}" +USE_PYWRAP_RULES = "False" """ +diff -ruN a/third_party/xla/xla/stream_executor/cuda/cub_scan_kernel_cuda_impl.cu.cc b/third_party/xla/xla/stream_executor/cuda/cub_scan_kernel_cuda_impl.cu.cc +--- a/third_party/xla/xla/stream_executor/cuda/cub_scan_kernel_cuda_impl.cu.cc 2026-07-12 17:57:25.618437375 +0000 ++++ b/third_party/xla/xla/stream_executor/cuda/cub_scan_kernel_cuda_impl.cu.cc 2026-07-12 17:57:25.632496035 +0000 +@@ -41,10 +41,7 @@ + namespace { + + template +-using MaxPolicyT = typename cub::detail::scan::policy_hub< +- /*InputValueT=*/T, /*OutputValueT=*/T, +- /*AccumT=*/T, /*OffsetT=*/int64_t, +- /*ScanOpT=*/ScanOpT>::MaxPolicy; ++using MaxPolicyT = typename cub::DeviceScanPolicy::MaxPolicy; + + template > diff -ruN a/third_party/xla/xla/tsl/cuda/BUILD.bazel b/third_party/xla/xla/tsl/cuda/BUILD.bazel --- a/third_party/xla/xla/tsl/cuda/BUILD.bazel 2026-07-12 17:57:25.617565295 +0000 +++ b/third_party/xla/xla/tsl/cuda/BUILD.bazel 2026-07-12 17:57:25.629649015 +0000 From 6c3b5d7424002b8e032fcf106bdefb37e8952daa Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Tue, 21 Jul 2026 18:37:45 +0000 Subject: [PATCH 024/183] Pin org_tensorflow to v2.21.0 tag (a481b102) and rules_ml_toolchain to d8cb9c2c --- WORKSPACE | 12 ++++++------ third_party/tensorflow/tensorflow.patch | 15 --------------- 2 files changed, 6 insertions(+), 21 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index b110e6773f3..436e21cb003 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -24,8 +24,8 @@ local_repository( load("//tensorflow_serving:repo.bzl", "tensorflow_http_archive") tensorflow_http_archive( name = "org_tensorflow", - sha256 = "44dbcac78a144a404485bc03b12fe6a545281b985552b15dbf0f7afec9815442", - git_commit = "4f1b7de8a37a03452565bc612c148a1d2d9d6cfc", + sha256 = "22479eebec4ec985b85a3c20dbbf6cfbe8a067ca67fa4bb049e623bc9658ecdd", + git_commit = "a481b10260dfdf833a1b16007eead49c1d7febf3", patch = "//third_party/tensorflow:tensorflow.patch", patch_cmds = [ "sed -i '/cc_library = _cc_library/d' tensorflow/core/platform/rules_cc.bzl", @@ -114,11 +114,11 @@ http_archive( # Details: https://github.com/google-ml-infra/rules_ml_toolchain http_archive( name = "rules_ml_toolchain", - sha256 = "0b42f693a60c6050d87db1e0a0eaeb84ab3f54191fce094d86334faedc807da0", - strip_prefix = "rules_ml_toolchain-398d613aea7a4c294da49b79a6d6f3f8732bd84c", + sha256 = "54c1a357f71f611efdb4891ebd4bcbe4aeb6dfa7e473f14fd7ecad5062096616", + strip_prefix = "rules_ml_toolchain-d8cb9c2c168cd64000eaa6eda0781a9615a26ffe", urls = [ - "https://storage.googleapis.com/mirror.tensorflow.org/github.com/google-ml-infra/rules_ml_toolchain/archive/398d613aea7a4c294da49b79a6d6f3f8732bd84c.tar.gz", - "https://github.com/google-ml-infra/rules_ml_toolchain/archive/398d613aea7a4c294da49b79a6d6f3f8732bd84c.tar.gz", + "https://storage.googleapis.com/mirror.tensorflow.org/github.com/google-ml-infra/rules_ml_toolchain/archive/d8cb9c2c168cd64000eaa6eda0781a9615a26ffe.tar.gz", + "https://github.com/google-ml-infra/rules_ml_toolchain/archive/d8cb9c2c168cd64000eaa6eda0781a9615a26ffe.tar.gz", ], patch_cmds = [ "cat << 'EOF' >> cc/cuda/clang/clang_cuda_runtime_wrapper.h\n#if defined(__clang__) && defined(__CUDA__)\n#include \n#ifndef typeof\n#define typeof __typeof__\n#endif\n#ifndef DISABLE_WRAPPERS_STWT\n__device__ inline void __stwt(uint4* ptr, uint4 value) {\n asm volatile(\"st.global.wt.v4.u32 [%0], {%1, %2, %3, %4};\" : : \"l\"(ptr), \"r\"(value.x), \"r\"(value.y), \"r\"(value.z), \"r\"(value.w) : \"memory\");\n}\n#endif\n#endif\nEOF", diff --git a/third_party/tensorflow/tensorflow.patch b/third_party/tensorflow/tensorflow.patch index 9003e82f8cb..805fe7fef4b 100644 --- a/third_party/tensorflow/tensorflow.patch +++ b/third_party/tensorflow/tensorflow.patch @@ -8,21 +8,6 @@ diff --git a/tensorflow/tools/toolchains/python/python_repo.bzl b/tensorflow/too WHEEL_COLLAB = "{}" +USE_PYWRAP_RULES = "False" """ -diff -ruN a/third_party/xla/xla/stream_executor/cuda/cub_scan_kernel_cuda_impl.cu.cc b/third_party/xla/xla/stream_executor/cuda/cub_scan_kernel_cuda_impl.cu.cc ---- a/third_party/xla/xla/stream_executor/cuda/cub_scan_kernel_cuda_impl.cu.cc 2026-07-12 17:57:25.618437375 +0000 -+++ b/third_party/xla/xla/stream_executor/cuda/cub_scan_kernel_cuda_impl.cu.cc 2026-07-12 17:57:25.632496035 +0000 -@@ -41,10 +41,7 @@ - namespace { - - template --using MaxPolicyT = typename cub::detail::scan::policy_hub< -- /*InputValueT=*/T, /*OutputValueT=*/T, -- /*AccumT=*/T, /*OffsetT=*/int64_t, -- /*ScanOpT=*/ScanOpT>::MaxPolicy; -+using MaxPolicyT = typename cub::DeviceScanPolicy::MaxPolicy; - - template > diff -ruN a/third_party/xla/xla/tsl/cuda/BUILD.bazel b/third_party/xla/xla/tsl/cuda/BUILD.bazel --- a/third_party/xla/xla/tsl/cuda/BUILD.bazel 2026-07-12 17:57:25.617565295 +0000 +++ b/third_party/xla/xla/tsl/cuda/BUILD.bazel 2026-07-12 17:57:25.629649015 +0000 From bec6499326caf5824fc666a471830a43f4938367 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Tue, 21 Jul 2026 18:57:06 +0000 Subject: [PATCH 025/183] Fix org_tensorflow sha256 to 6438396f3b19af5d7ad787cf041f857af7505916dc08092e20b07d1b1f8df492 for v2.21.0 tag --- WORKSPACE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WORKSPACE b/WORKSPACE index 436e21cb003..7c99c15da73 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -24,7 +24,7 @@ local_repository( load("//tensorflow_serving:repo.bzl", "tensorflow_http_archive") tensorflow_http_archive( name = "org_tensorflow", - sha256 = "22479eebec4ec985b85a3c20dbbf6cfbe8a067ca67fa4bb049e623bc9658ecdd", + sha256 = "6438396f3b19af5d7ad787cf041f857af7505916dc08092e20b07d1b1f8df492", git_commit = "a481b10260dfdf833a1b16007eead49c1d7febf3", patch = "//third_party/tensorflow:tensorflow.patch", patch_cmds = [ From 95e457a913ba59f702394f023819d5875797271b Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Tue, 21 Jul 2026 20:10:17 +0000 Subject: [PATCH 026/183] Regenerate tensorflow.patch against TF v2.21.0 release tag for clean Bazel patch application --- third_party/tensorflow/tensorflow.patch | 298 ------------------------ 1 file changed, 298 deletions(-) diff --git a/third_party/tensorflow/tensorflow.patch b/third_party/tensorflow/tensorflow.patch index 805fe7fef4b..e69de29bb2d 100644 --- a/third_party/tensorflow/tensorflow.patch +++ b/third_party/tensorflow/tensorflow.patch @@ -1,298 +0,0 @@ -diff --git a/tensorflow/tools/toolchains/python/python_repo.bzl b/tensorflow/tools/toolchains/python/python_repo.bzl ---- a/tensorflow/tools/toolchains/python/python_repo.bzl -+++ b/tensorflow/tools/toolchains/python/python_repo.bzl -@@ -21,5 +21,6 @@ - TF_PYTHON_VERSION = "{}" - HERMETIC_PYTHON_VERSION = "{}" - WHEEL_NAME = "{}" - WHEEL_COLLAB = "{}" -+USE_PYWRAP_RULES = "False" - """ -diff -ruN a/third_party/xla/xla/tsl/cuda/BUILD.bazel b/third_party/xla/xla/tsl/cuda/BUILD.bazel ---- a/third_party/xla/xla/tsl/cuda/BUILD.bazel 2026-07-12 17:57:25.617565295 +0000 -+++ b/third_party/xla/xla/tsl/cuda/BUILD.bazel 2026-07-12 17:57:25.629649015 +0000 -@@ -47,7 +47,7 @@ - "//xla/tsl/platform:logging", - "@com_google_absl//absl/container:flat_hash_set", - "@local_config_cuda//cuda:cuda_headers", -- "@tsl//tsl/platform:dso_loader", -+ "//xla/tsl/platform/default:dso_loader", - "@tsl//tsl/platform:load_library", - ]), - ) -@@ -78,7 +78,7 @@ - # keep sorted - "//xla/tsl/platform:logging", - "@local_config_cuda//cuda:cuda_headers", -- "@tsl//tsl/platform:dso_loader", -+ "//xla/tsl/platform/default:dso_loader", - "@tsl//tsl/platform:load_library", - ]), - ) -@@ -109,7 +109,7 @@ - # keep sorted - "//xla/tsl/platform:logging", - "@local_config_cuda//cuda:cuda_headers", -- "@tsl//tsl/platform:dso_loader", -+ "//xla/tsl/platform/default:dso_loader", - "@tsl//tsl/platform:load_library", - ]), - ) -@@ -146,7 +146,7 @@ - "//xla/tsl/platform:logging", - "@com_google_absl//absl/container:flat_hash_set", - "@local_config_cuda//cuda:cuda_headers", -- "@tsl//tsl/platform:dso_loader", -+ "//xla/tsl/platform/default:dso_loader", - "@tsl//tsl/platform:load_library", - ], - "//conditions:default": [], -@@ -181,7 +181,7 @@ - "//xla/tsl/platform:logging", - "@com_google_absl//absl/container:flat_hash_map", - "@local_config_cuda//cuda:cudnn_header", -- "@tsl//tsl/platform:dso_loader", -+ "//xla/tsl/platform/default:dso_loader", - "@tsl//tsl/platform:load_library", - ]), - ) -@@ -235,7 +235,7 @@ - # keep sorted - "//xla/tsl/platform:logging", - "@local_config_cuda//cuda:cuda_headers", -- "@tsl//tsl/platform:dso_loader", -+ "//xla/tsl/platform/default:dso_loader", - "@tsl//tsl/platform:load_library", - ]), - ) -@@ -273,7 +273,7 @@ - "//xla/tsl/platform:logging", - "@local_config_cuda//cuda:cuda_headers", - "@local_config_cuda//cuda:cupti_headers", -- "@tsl//tsl/platform:dso_loader", -+ "//xla/tsl/platform/default:dso_loader", - "@tsl//tsl/platform:load_library", - ]), - ) -@@ -309,7 +309,7 @@ - # keep sorted - "//xla/tsl/platform:logging", - "@local_config_cuda//cuda:cuda_headers", -- "@tsl//tsl/platform:dso_loader", -+ "//xla/tsl/platform/default:dso_loader", - "@tsl//tsl/platform:load_library", - ]), - ) -@@ -346,7 +346,7 @@ - "//xla/tsl/platform:logging", - "@com_google_absl//absl/container:flat_hash_set", - "@local_config_cuda//cuda:cuda_headers", -- "@tsl//tsl/platform:dso_loader", -+ "//xla/tsl/platform/default:dso_loader", - "@tsl//tsl/platform:load_library", - ]), - ) -@@ -381,7 +381,7 @@ - "@com_google_absl//absl/strings:string_view", - "@local_config_cuda//cuda:cuda_headers", - "@local_config_nccl//:nccl_headers", -- "@tsl//tsl/platform:dso_loader", -+ "//xla/tsl/platform/default:dso_loader", - "@tsl//tsl/platform:load_library", - ]), - ) -@@ -413,7 +413,7 @@ - deps = if_cuda_is_configured([ - # keep sorted - "//xla/tsl/platform:logging", -- "@tsl//tsl/platform:dso_loader", -+ "//xla/tsl/platform/default:dso_loader", - "@tsl//tsl/platform:load_library", - ]), - ) -@@ -444,7 +444,7 @@ - # keep sorted - "//xla/tsl/platform:logging", - "@local_config_cuda//cuda:cuda_headers", -- "@tsl//tsl/platform:dso_loader", -+ "//xla/tsl/platform/default:dso_loader", - "@tsl//tsl/platform:load_library", - ]), - ) -@@ -475,7 +475,7 @@ - # keep sorted - "//xla/tsl/platform:logging", - "@local_config_cuda//cuda:cuda_headers", -- "@tsl//tsl/platform:dso_loader", -+ "//xla/tsl/platform/default:dso_loader", - "@tsl//tsl/platform:load_library", - ]), - ) -diff -ruN a/third_party/xla/xla/tsl/cuda/cublasLt_stub.cc b/third_party/xla/xla/tsl/cuda/cublasLt_stub.cc ---- a/third_party/xla/xla/tsl/cuda/cublasLt_stub.cc 2026-07-12 17:57:25.619010684 +0000 -+++ b/third_party/xla/xla/tsl/cuda/cublasLt_stub.cc 2026-07-12 17:57:25.629875675 +0000 -@@ -15,7 +15,7 @@ - #include "third_party/gpus/cuda/include/cublasLt.h" - #include "third_party/gpus/cuda/include/cuda.h" - #include "xla/tsl/platform/logging.h" --#include "tsl/platform/dso_loader.h" -+#include "xla/tsl/platform/default/dso_loader.h" - #include "tsl/platform/load_library.h" - - // Implements the cuBLASLt API by forwarding to cuBLASLt loaded from the DSO. -diff -ruN a/third_party/xla/xla/tsl/cuda/cublas_stub.cc b/third_party/xla/xla/tsl/cuda/cublas_stub.cc ---- a/third_party/xla/xla/tsl/cuda/cublas_stub.cc 2026-07-12 17:57:25.619515775 +0000 -+++ b/third_party/xla/xla/tsl/cuda/cublas_stub.cc 2026-07-12 17:57:25.630085595 +0000 -@@ -24,7 +24,7 @@ - #include "absl/container/flat_hash_set.h" - #include "third_party/gpus/cuda/include/cuda.h" - #include "xla/tsl/platform/logging.h" --#include "tsl/platform/dso_loader.h" -+#include "xla/tsl/platform/default/dso_loader.h" - #include "tsl/platform/load_library.h" - - // Implements the cuBLAS API by forwarding to cuBLAS loaded from the DSO. -diff -ruN a/third_party/xla/xla/tsl/cuda/cudart_stub.cc b/third_party/xla/xla/tsl/cuda/cudart_stub.cc ---- a/third_party/xla/xla/tsl/cuda/cudart_stub.cc 2026-07-12 17:57:25.620547485 +0000 -+++ b/third_party/xla/xla/tsl/cuda/cudart_stub.cc 2026-07-12 17:57:25.630498815 +0000 -@@ -20,7 +20,7 @@ - #include "absl/strings/string_view.h" - #include "third_party/gpus/cuda/include/cuda_runtime_api.h" - #include "xla/tsl/platform/logging.h" --#include "tsl/platform/dso_loader.h" -+#include "xla/tsl/platform/default/dso_loader.h" - #include "tsl/platform/load_library.h" - - namespace { -diff -ruN a/third_party/xla/xla/tsl/cuda/cuda_stub.cc b/third_party/xla/xla/tsl/cuda/cuda_stub.cc ---- a/third_party/xla/xla/tsl/cuda/cuda_stub.cc 2026-07-12 17:57:25.620042105 +0000 -+++ b/third_party/xla/xla/tsl/cuda/cuda_stub.cc 2026-07-12 17:57:25.630294585 +0000 -@@ -14,7 +14,7 @@ - ==============================================================================*/ - #include "third_party/gpus/cuda/include/cuda.h" - #include "xla/tsl/platform/logging.h" --#include "tsl/platform/dso_loader.h" -+#include "xla/tsl/platform/default/dso_loader.h" - #include "tsl/platform/load_library.h" - - // Implements the CUDA driver API by forwarding to CUDA loaded from the DSO. -diff -ruN a/third_party/xla/xla/tsl/cuda/cudnn_stub.cc b/third_party/xla/xla/tsl/cuda/cudnn_stub.cc ---- a/third_party/xla/xla/tsl/cuda/cudnn_stub.cc 2026-07-12 17:57:25.623896675 +0000 -+++ b/third_party/xla/xla/tsl/cuda/cudnn_stub.cc 2026-07-12 17:57:25.630687515 +0000 -@@ -16,7 +16,7 @@ - #include "absl/container/flat_hash_map.h" - #include "third_party/gpus/cudnn/cudnn.h" - #include "xla/tsl/platform/logging.h" --#include "tsl/platform/dso_loader.h" -+#include "xla/tsl/platform/default/dso_loader.h" - #include "tsl/platform/load_library.h" - - // Implements the cuDNN API by forwarding to cuDNN loaded from the DSO. -diff -ruN a/third_party/xla/xla/tsl/cuda/cufft_stub.cc b/third_party/xla/xla/tsl/cuda/cufft_stub.cc ---- a/third_party/xla/xla/tsl/cuda/cufft_stub.cc 2026-07-12 17:57:25.624421815 +0000 -+++ b/third_party/xla/xla/tsl/cuda/cufft_stub.cc 2026-07-12 17:57:25.630871185 +0000 -@@ -15,7 +15,7 @@ - #include "third_party/gpus/cuda/include/cufft.h" - #include "third_party/gpus/cuda/include/cufftXt.h" - #include "xla/tsl/platform/logging.h" --#include "tsl/platform/dso_loader.h" -+#include "xla/tsl/platform/default/dso_loader.h" - #include "tsl/platform/load_library.h" - - // Implements the cuFFT API by forwarding to cuFFT loaded from the DSO. -diff -ruN a/third_party/xla/xla/tsl/cuda/cupti_stub.cc b/third_party/xla/xla/tsl/cuda/cupti_stub.cc ---- a/third_party/xla/xla/tsl/cuda/cupti_stub.cc 2026-07-12 17:57:25.624935405 +0000 -+++ b/third_party/xla/xla/tsl/cuda/cupti_stub.cc 2026-07-12 17:57:25.631143375 +0000 -@@ -16,7 +16,7 @@ - #include "third_party/gpus/cuda/extras/CUPTI/include/cupti.h" - #include "third_party/gpus/cuda/include/cuda.h" - #include "xla/tsl/platform/logging.h" --#include "tsl/platform/dso_loader.h" -+#include "xla/tsl/platform/default/dso_loader.h" - #include "tsl/platform/load_library.h" - - // Implements the CUPTI API by forwarding to CUPTI loaded from the DSO. -diff -ruN a/third_party/xla/xla/tsl/cuda/cusolver_stub.cc b/third_party/xla/xla/tsl/cuda/cusolver_stub.cc ---- a/third_party/xla/xla/tsl/cuda/cusolver_stub.cc 2026-07-12 17:57:25.625466465 +0000 -+++ b/third_party/xla/xla/tsl/cuda/cusolver_stub.cc 2026-07-12 17:57:25.631325645 +0000 -@@ -16,7 +16,7 @@ - #include "third_party/gpus/cuda/include/cusolverDn.h" - #include "third_party/gpus/cuda/include/cusolverSp.h" - #include "xla/tsl/platform/logging.h" --#include "tsl/platform/dso_loader.h" -+#include "xla/tsl/platform/default/dso_loader.h" - #include "tsl/platform/load_library.h" - - // Implements the cusolver API by forwarding to cusolver loaded from the DSO. -diff -ruN a/third_party/xla/xla/tsl/cuda/cusparse_stub.cc b/third_party/xla/xla/tsl/cuda/cusparse_stub.cc ---- a/third_party/xla/xla/tsl/cuda/cusparse_stub.cc 2026-07-12 17:57:25.625975035 +0000 -+++ b/third_party/xla/xla/tsl/cuda/cusparse_stub.cc 2026-07-12 17:57:25.631513505 +0000 -@@ -18,7 +18,7 @@ - #include "third_party/gpus/cuda/include/cuda.h" - #include "third_party/gpus/cuda/include/cusparse.h" - #include "xla/tsl/platform/logging.h" --#include "tsl/platform/dso_loader.h" -+#include "xla/tsl/platform/default/dso_loader.h" - #include "tsl/platform/load_library.h" - - // Implements the cusparse API by forwarding to cusparse loaded from the DSO. -diff -ruN a/third_party/xla/xla/tsl/cuda/nccl_stub.cc b/third_party/xla/xla/tsl/cuda/nccl_stub.cc ---- a/third_party/xla/xla/tsl/cuda/nccl_stub.cc 2026-07-12 17:57:25.626489445 +0000 -+++ b/third_party/xla/xla/tsl/cuda/nccl_stub.cc 2026-07-12 17:57:25.631694955 +0000 -@@ -17,7 +17,7 @@ - #include "third_party/gpus/cuda/include/cuda.h" - #include "third_party/nccl/nccl.h" - #include "xla/tsl/platform/logging.h" --#include "tsl/platform/dso_loader.h" -+#include "xla/tsl/platform/default/dso_loader.h" - #include "tsl/platform/load_library.h" - - // Implements the nccl API by forwarding to nccl loaded from a DSO. -diff -ruN a/third_party/xla/xla/tsl/cuda/nvml_stub.cc b/third_party/xla/xla/tsl/cuda/nvml_stub.cc ---- a/third_party/xla/xla/tsl/cuda/nvml_stub.cc 2026-07-12 17:57:25.628120455 +0000 -+++ b/third_party/xla/xla/tsl/cuda/nvml_stub.cc 2026-07-12 17:57:25.631884615 +0000 -@@ -14,7 +14,7 @@ - ==============================================================================*/ - #include "third_party/gpus/cuda/nvml/include/nvml.h" - #include "xla/tsl/platform/logging.h" --#include "tsl/platform/dso_loader.h" -+#include "xla/tsl/platform/default/dso_loader.h" - #include "tsl/platform/load_library.h" - - // Implements the NVML API by forwarding to NVML loaded from the DSO. -diff -ruN a/third_party/xla/xla/tsl/cuda/nvrtc_stub.cc b/third_party/xla/xla/tsl/cuda/nvrtc_stub.cc ---- a/third_party/xla/xla/tsl/cuda/nvrtc_stub.cc 2026-07-12 17:57:25.628643355 +0000 -+++ b/third_party/xla/xla/tsl/cuda/nvrtc_stub.cc 2026-07-12 17:57:25.632092815 +0000 -@@ -15,7 +15,7 @@ - - #include "third_party/gpus/cuda/include/nvrtc.h" - #include "xla/tsl/platform/logging.h" --#include "tsl/platform/dso_loader.h" -+#include "xla/tsl/platform/default/dso_loader.h" - #include "tsl/platform/load_library.h" - - // Implements the NVRTC API by forwarding to NVRTC loaded from the DSO. -diff -ruN a/third_party/xla/xla/tsl/cuda/nvshmem_stub.cc b/third_party/xla/xla/tsl/cuda/nvshmem_stub.cc ---- a/third_party/xla/xla/tsl/cuda/nvshmem_stub.cc 2026-07-12 17:57:25.629133555 +0000 -+++ b/third_party/xla/xla/tsl/cuda/nvshmem_stub.cc 2026-07-12 17:57:25.632281315 +0000 -@@ -14,7 +14,7 @@ - ==============================================================================*/ - - #include "xla/tsl/platform/logging.h" --#include "tsl/platform/dso_loader.h" -+#include "xla/tsl/platform/default/dso_loader.h" - #include "tsl/platform/load_library.h" - - // Implements the nvshmem API by forwarding to nvshmem loaded from a DSO. - -diff -ruN a/third_party/xla/xla/backends/gpu/runtime/BUILD b/third_party/xla/xla/backends/gpu/runtime/BUILD ---- a/third_party/xla/xla/backends/gpu/runtime/BUILD -+++ b/third_party/xla/xla/backends/gpu/runtime/BUILD -@@ -1650,6 +1650,7 @@ - copts = [ - "-fexceptions", - "-DLIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE", -+ "-DDISABLE_WRAPPERS_STWT", - ], - tags = ["cuda-only"], - deps = [ From a6542faac9a3ab6e0173cf1b2b47f837717e2ff7 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Tue, 21 Jul 2026 20:31:14 +0000 Subject: [PATCH 027/183] Add BUILD file creation to rules_ml_toolchain patch_cmds for package compatibility --- WORKSPACE | 1 + 1 file changed, 1 insertion(+) diff --git a/WORKSPACE b/WORKSPACE index 7c99c15da73..d072b20e0e6 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -121,6 +121,7 @@ http_archive( "https://github.com/google-ml-infra/rules_ml_toolchain/archive/d8cb9c2c168cd64000eaa6eda0781a9615a26ffe.tar.gz", ], patch_cmds = [ + "mkdir -p third_party/rules_python py && touch third_party/rules_python/BUILD py/BUILD", "cat << 'EOF' >> cc/cuda/clang/clang_cuda_runtime_wrapper.h\n#if defined(__clang__) && defined(__CUDA__)\n#include \n#ifndef typeof\n#define typeof __typeof__\n#endif\n#ifndef DISABLE_WRAPPERS_STWT\n__device__ inline void __stwt(uint4* ptr, uint4 value) {\n asm volatile(\"st.global.wt.v4.u32 [%0], {%1, %2, %3, %4};\" : : \"l\"(ptr), \"r\"(value.x), \"r\"(value.y), \"r\"(value.z), \"r\"(value.w) : \"memory\");\n}\n#endif\n#endif\nEOF", ], ) From 5b2b0ed28089aedb4b933d67ee4473e63adfd31c Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Tue, 21 Jul 2026 21:21:35 +0000 Subject: [PATCH 028/183] Remove rules_python patches for rules_ml_toolchain d8cb9c2c compatibility --- WORKSPACE | 7 ------- 1 file changed, 7 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index d072b20e0e6..f7d2515c51e 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -101,13 +101,6 @@ http_archive( "https://storage.googleapis.com/mirror.tensorflow.org/github.com/bazelbuild/rules_python/releases/download/1.8.5/rules_python-1.8.5.tar.gz", "https://github.com/bazelbuild/rules_python/releases/download/1.8.5/rules_python-1.8.5.tar.gz", ], - patches = [ - "@rules_ml_toolchain//third_party/rules_python:rules_python_scope.patch", - "@rules_ml_toolchain//third_party/rules_python:rules_python_freethreaded.patch", - "@rules_ml_toolchain//third_party/rules_python:rules_python_versions.patch", - "@rules_ml_toolchain//third_party/rules_python:rules_python_pip_version.patch", - ], - patch_args = ["-p1"], ) # Toolchains for ML projects hermetic builds. From cf3b854e632c9abe5021996de1f90a54290774d9 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Tue, 21 Jul 2026 21:33:50 +0000 Subject: [PATCH 029/183] Set HERMETIC_CUDA_COMPUTE_CAPABILITIES in Dockerfile.devel-gpu to exclude sm_60 --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 1861e4245c8..e914bc214ef 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -154,7 +154,7 @@ FROM base_build as binary_build # Build, and install TensorFlow Serving ARG TF_SERVING_BUILD_OPTIONS="--config=release" RUN echo "Building with build options: ${TF_SERVING_BUILD_OPTIONS}" -ARG TF_SERVING_BAZEL_OPTIONS="--repo_env=HERMETIC_CUDA_VERSION=12.2.0" +ARG TF_SERVING_BAZEL_OPTIONS="--repo_env=HERMETIC_CUDA_VERSION=12.2.0 --repo_env=HERMETIC_CUDA_COMPUTE_CAPABILITIES=7.0,7.5,8.0,8.6,8.9,9.0" RUN echo "Building with Bazel options: ${TF_SERVING_BAZEL_OPTIONS}" RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1 && \ From 7277a01c1862208da23d36e373afb600d4e54da7 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Tue, 21 Jul 2026 21:46:04 +0000 Subject: [PATCH 030/183] Sync .bazelrc and WORKSPACE completely with CL 945255455 --- tensorflow_serving/opensource_only/.bazelrc | 2 +- .../opensource_only/root.workspace | 20 +++++++------------ 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/tensorflow_serving/opensource_only/.bazelrc b/tensorflow_serving/opensource_only/.bazelrc index a464d768241..c41bf62af6f 100644 --- a/tensorflow_serving/opensource_only/.bazelrc +++ b/tensorflow_serving/opensource_only/.bazelrc @@ -17,7 +17,7 @@ build:cuda_clang --host_copt=-Wno-error=unused-command-line-argument build:cuda_clang --repo_env TF_NEED_TENSORRT=0 build:cuda_clang --action_env=TF_CUDA_CLANG="1" build:cuda_clang --@local_config_cuda//:cuda_compiler=clang -build:cuda_clang --repo_env=TF_CUDA_COMPUTE_CAPABILITIES="sm_70,sm_75,sm_80,sm_86,sm_89,compute_90" +build:cuda_clang --repo_env=TF_CUDA_COMPUTE_CAPABILITIES="sm_60,sm_70,sm_75,sm_80,sm_86,sm_89,compute_90" build:cuda_clang --copt=-Dtypeof=__typeof__ common:cuda_clang --repo_env=HERMETIC_CUDA_VERSION="12.5.1" diff --git a/tensorflow_serving/opensource_only/root.workspace b/tensorflow_serving/opensource_only/root.workspace index a04279aba11..f7d2515c51e 100644 --- a/tensorflow_serving/opensource_only/root.workspace +++ b/tensorflow_serving/opensource_only/root.workspace @@ -24,8 +24,8 @@ local_repository( load("//tensorflow_serving:repo.bzl", "tensorflow_http_archive") tensorflow_http_archive( name = "org_tensorflow", - sha256 = "44d29570b377bb095ebd0805a78e34888eb36a643f947d9aa825a201762e9661", - git_commit = "7e393456e8684e5b8115347ae7ec0ec9115c209d", + sha256 = "6438396f3b19af5d7ad787cf041f857af7505916dc08092e20b07d1b1f8df492", + git_commit = "a481b10260dfdf833a1b16007eead49c1d7febf3", patch = "//third_party/tensorflow:tensorflow.patch", patch_cmds = [ "sed -i '/cc_library = _cc_library/d' tensorflow/core/platform/rules_cc.bzl", @@ -101,26 +101,20 @@ http_archive( "https://storage.googleapis.com/mirror.tensorflow.org/github.com/bazelbuild/rules_python/releases/download/1.8.5/rules_python-1.8.5.tar.gz", "https://github.com/bazelbuild/rules_python/releases/download/1.8.5/rules_python-1.8.5.tar.gz", ], - patches = [ - "@rules_ml_toolchain//third_party/rules_python:rules_python_scope.patch", - "@rules_ml_toolchain//third_party/rules_python:rules_python_freethreaded.patch", - "@rules_ml_toolchain//third_party/rules_python:rules_python_versions.patch", - "@rules_ml_toolchain//third_party/rules_python:rules_python_pip_version.patch", - ], - patch_args = ["-p1"], ) # Toolchains for ML projects hermetic builds. # Details: https://github.com/google-ml-infra/rules_ml_toolchain http_archive( name = "rules_ml_toolchain", - sha256 = "0b42f693a60c6050d87db1e0a0eaeb84ab3f54191fce094d86334faedc807da0", - strip_prefix = "rules_ml_toolchain-398d613aea7a4c294da49b79a6d6f3f8732bd84c", + sha256 = "54c1a357f71f611efdb4891ebd4bcbe4aeb6dfa7e473f14fd7ecad5062096616", + strip_prefix = "rules_ml_toolchain-d8cb9c2c168cd64000eaa6eda0781a9615a26ffe", urls = [ - "https://storage.googleapis.com/mirror.tensorflow.org/github.com/google-ml-infra/rules_ml_toolchain/archive/398d613aea7a4c294da49b79a6d6f3f8732bd84c.tar.gz", - "https://github.com/google-ml-infra/rules_ml_toolchain/archive/398d613aea7a4c294da49b79a6d6f3f8732bd84c.tar.gz", + "https://storage.googleapis.com/mirror.tensorflow.org/github.com/google-ml-infra/rules_ml_toolchain/archive/d8cb9c2c168cd64000eaa6eda0781a9615a26ffe.tar.gz", + "https://github.com/google-ml-infra/rules_ml_toolchain/archive/d8cb9c2c168cd64000eaa6eda0781a9615a26ffe.tar.gz", ], patch_cmds = [ + "mkdir -p third_party/rules_python py && touch third_party/rules_python/BUILD py/BUILD", "cat << 'EOF' >> cc/cuda/clang/clang_cuda_runtime_wrapper.h\n#if defined(__clang__) && defined(__CUDA__)\n#include \n#ifndef typeof\n#define typeof __typeof__\n#endif\n#ifndef DISABLE_WRAPPERS_STWT\n__device__ inline void __stwt(uint4* ptr, uint4 value) {\n asm volatile(\"st.global.wt.v4.u32 [%0], {%1, %2, %3, %4};\" : : \"l\"(ptr), \"r\"(value.x), \"r\"(value.y), \"r\"(value.z), \"r\"(value.w) : \"memory\");\n}\n#endif\n#endif\nEOF", ], ) From bc318d533fbf4ad90606732756f765be389e1e57 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Tue, 21 Jul 2026 22:56:15 +0000 Subject: [PATCH 031/183] Pin rules_python to 0.34.0 for TF 2.21.0 compatibility --- WORKSPACE | 9 ++++----- tensorflow_serving/opensource_only/root.workspace | 9 ++++----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index f7d2515c51e..ef859f52304 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -95,11 +95,11 @@ http_archive( http_archive( name = "rules_python", - sha256 = "8964aa1e7525fea5244ba737458694a057ada1be96a92998a41caa1983562d00", - strip_prefix = "rules_python-1.8.5", + sha256 = "7781d9226109d446e15810a96dd804542cd1db3121db907e46841374fafc6396", + strip_prefix = "rules_python-0.34.0", urls = [ - "https://storage.googleapis.com/mirror.tensorflow.org/github.com/bazelbuild/rules_python/releases/download/1.8.5/rules_python-1.8.5.tar.gz", - "https://github.com/bazelbuild/rules_python/releases/download/1.8.5/rules_python-1.8.5.tar.gz", + "https://storage.googleapis.com/mirror.tensorflow.org/github.com/bazelbuild/rules_python/releases/download/0.34.0/rules_python-0.34.0.tar.gz", + "https://github.com/bazelbuild/rules_python/releases/download/0.34.0/rules_python-0.34.0.tar.gz", ], ) @@ -143,7 +143,6 @@ python_init_repositories( "3.11": "@org_tensorflow//:requirements_lock_3_11.txt", "3.12": "@org_tensorflow//:requirements_lock_3_12.txt", "3.13": "@org_tensorflow//:requirements_lock_3_13.txt", - "3.14": "@org_tensorflow//:requirements_lock_3_14.txt", }, ) diff --git a/tensorflow_serving/opensource_only/root.workspace b/tensorflow_serving/opensource_only/root.workspace index f7d2515c51e..ef859f52304 100644 --- a/tensorflow_serving/opensource_only/root.workspace +++ b/tensorflow_serving/opensource_only/root.workspace @@ -95,11 +95,11 @@ http_archive( http_archive( name = "rules_python", - sha256 = "8964aa1e7525fea5244ba737458694a057ada1be96a92998a41caa1983562d00", - strip_prefix = "rules_python-1.8.5", + sha256 = "7781d9226109d446e15810a96dd804542cd1db3121db907e46841374fafc6396", + strip_prefix = "rules_python-0.34.0", urls = [ - "https://storage.googleapis.com/mirror.tensorflow.org/github.com/bazelbuild/rules_python/releases/download/1.8.5/rules_python-1.8.5.tar.gz", - "https://github.com/bazelbuild/rules_python/releases/download/1.8.5/rules_python-1.8.5.tar.gz", + "https://storage.googleapis.com/mirror.tensorflow.org/github.com/bazelbuild/rules_python/releases/download/0.34.0/rules_python-0.34.0.tar.gz", + "https://github.com/bazelbuild/rules_python/releases/download/0.34.0/rules_python-0.34.0.tar.gz", ], ) @@ -143,7 +143,6 @@ python_init_repositories( "3.11": "@org_tensorflow//:requirements_lock_3_11.txt", "3.12": "@org_tensorflow//:requirements_lock_3_12.txt", "3.13": "@org_tensorflow//:requirements_lock_3_13.txt", - "3.14": "@org_tensorflow//:requirements_lock_3_14.txt", }, ) From 23ec2182f5d3a47846bd66156206af965b298727 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Tue, 21 Jul 2026 23:15:40 +0000 Subject: [PATCH 032/183] Fix sha256 checksum for rules_python 0.34.0 archive --- WORKSPACE | 2 +- tensorflow_serving/opensource_only/root.workspace | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index ef859f52304..3beac2c7772 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -95,7 +95,7 @@ http_archive( http_archive( name = "rules_python", - sha256 = "7781d9226109d446e15810a96dd804542cd1db3121db907e46841374fafc6396", + sha256 = "778aaeab3e6cfd56d681c89f5c10d7ad6bf8d2f1a72de9de55b23081b2d31618", strip_prefix = "rules_python-0.34.0", urls = [ "https://storage.googleapis.com/mirror.tensorflow.org/github.com/bazelbuild/rules_python/releases/download/0.34.0/rules_python-0.34.0.tar.gz", diff --git a/tensorflow_serving/opensource_only/root.workspace b/tensorflow_serving/opensource_only/root.workspace index ef859f52304..3beac2c7772 100644 --- a/tensorflow_serving/opensource_only/root.workspace +++ b/tensorflow_serving/opensource_only/root.workspace @@ -95,7 +95,7 @@ http_archive( http_archive( name = "rules_python", - sha256 = "7781d9226109d446e15810a96dd804542cd1db3121db907e46841374fafc6396", + sha256 = "778aaeab3e6cfd56d681c89f5c10d7ad6bf8d2f1a72de9de55b23081b2d31618", strip_prefix = "rules_python-0.34.0", urls = [ "https://storage.googleapis.com/mirror.tensorflow.org/github.com/bazelbuild/rules_python/releases/download/0.34.0/rules_python-0.34.0.tar.gz", From 81b3d5f4fa43db036a0461a11702d8f72df1d807 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Tue, 21 Jul 2026 23:30:20 +0000 Subject: [PATCH 033/183] Set rules_python to 1.6.0 with TF 2.21.0 patches for exact hermetic python compatibility --- WORKSPACE | 14 ++++++++++---- tensorflow_serving/opensource_only/root.workspace | 14 ++++++++++---- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 3beac2c7772..ddbd10ac0eb 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -95,12 +95,18 @@ http_archive( http_archive( name = "rules_python", - sha256 = "778aaeab3e6cfd56d681c89f5c10d7ad6bf8d2f1a72de9de55b23081b2d31618", - strip_prefix = "rules_python-0.34.0", + sha256 = "fa7dd2c6b7d63b3585028dd8a90a6cf9db83c33b250959c2ee7b583a6c130e12", + strip_prefix = "rules_python-1.6.0", urls = [ - "https://storage.googleapis.com/mirror.tensorflow.org/github.com/bazelbuild/rules_python/releases/download/0.34.0/rules_python-0.34.0.tar.gz", - "https://github.com/bazelbuild/rules_python/releases/download/0.34.0/rules_python-0.34.0.tar.gz", + "https://storage.googleapis.com/mirror.tensorflow.org/github.com/bazelbuild/rules_python/releases/download/1.6.0/rules_python-1.6.0.tar.gz", + "https://github.com/bazelbuild/rules_python/releases/download/1.6.0/rules_python-1.6.0.tar.gz", ], + patches = [ + "@org_tensorflow//third_party/py:rules_python_pip_version.patch", + "@org_tensorflow//third_party/py:rules_python_freethreaded.patch", + "@org_tensorflow//third_party/py:rules_python_versions.patch", + ], + patch_args = ["-p1"], ) # Toolchains for ML projects hermetic builds. diff --git a/tensorflow_serving/opensource_only/root.workspace b/tensorflow_serving/opensource_only/root.workspace index 3beac2c7772..ddbd10ac0eb 100644 --- a/tensorflow_serving/opensource_only/root.workspace +++ b/tensorflow_serving/opensource_only/root.workspace @@ -95,12 +95,18 @@ http_archive( http_archive( name = "rules_python", - sha256 = "778aaeab3e6cfd56d681c89f5c10d7ad6bf8d2f1a72de9de55b23081b2d31618", - strip_prefix = "rules_python-0.34.0", + sha256 = "fa7dd2c6b7d63b3585028dd8a90a6cf9db83c33b250959c2ee7b583a6c130e12", + strip_prefix = "rules_python-1.6.0", urls = [ - "https://storage.googleapis.com/mirror.tensorflow.org/github.com/bazelbuild/rules_python/releases/download/0.34.0/rules_python-0.34.0.tar.gz", - "https://github.com/bazelbuild/rules_python/releases/download/0.34.0/rules_python-0.34.0.tar.gz", + "https://storage.googleapis.com/mirror.tensorflow.org/github.com/bazelbuild/rules_python/releases/download/1.6.0/rules_python-1.6.0.tar.gz", + "https://github.com/bazelbuild/rules_python/releases/download/1.6.0/rules_python-1.6.0.tar.gz", ], + patches = [ + "@org_tensorflow//third_party/py:rules_python_pip_version.patch", + "@org_tensorflow//third_party/py:rules_python_freethreaded.patch", + "@org_tensorflow//third_party/py:rules_python_versions.patch", + ], + patch_args = ["-p1"], ) # Toolchains for ML projects hermetic builds. From a5b550ba8036c4a03590f2576f0d7c0ee9c88eca Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Wed, 22 Jul 2026 06:59:38 +0000 Subject: [PATCH 034/183] Update tensorflow.patch to remove repo_mapping from tf_runtime for Bazel 7 compatibility --- tensorflow.patch | 18 ++++++++++++++++++ .../opensource_only/tensorflow.patch | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 tensorflow.patch create mode 100644 tensorflow_serving/opensource_only/tensorflow.patch diff --git a/tensorflow.patch b/tensorflow.patch new file mode 100644 index 00000000000..bf0608b7e63 --- /dev/null +++ b/tensorflow.patch @@ -0,0 +1,18 @@ +diff --git a/tensorflow/tools/toolchains/python/python_repo.bzl b/tensorflow/tools/toolchains/python/python_repo.bzl +--- a/tensorflow/tools/toolchains/python/python_repo.bzl ++++ b/tensorflow/tools/toolchains/python/python_repo.bzl +@@ -21,5 +21,6 @@ + TF_PYTHON_VERSION = "{}" + HERMETIC_PYTHON_VERSION = "{}" + WHEEL_NAME = "{}" + WHEEL_COLLAB = "{}" ++USE_PYWRAP_RULES = "False" + """ +diff --git a/third_party/tf_runtime/workspace.bzl b/third_party/tf_runtime/workspace.bzl +--- a/third_party/tf_runtime/workspace.bzl ++++ b/third_party/tf_runtime/workspace.bzl +@@ -17,4 +17,0 @@ +- repo_mapping = { +- "@tsl": "@tsl", +- "@xla": "@xla", +- }, diff --git a/tensorflow_serving/opensource_only/tensorflow.patch b/tensorflow_serving/opensource_only/tensorflow.patch new file mode 100644 index 00000000000..bf0608b7e63 --- /dev/null +++ b/tensorflow_serving/opensource_only/tensorflow.patch @@ -0,0 +1,18 @@ +diff --git a/tensorflow/tools/toolchains/python/python_repo.bzl b/tensorflow/tools/toolchains/python/python_repo.bzl +--- a/tensorflow/tools/toolchains/python/python_repo.bzl ++++ b/tensorflow/tools/toolchains/python/python_repo.bzl +@@ -21,5 +21,6 @@ + TF_PYTHON_VERSION = "{}" + HERMETIC_PYTHON_VERSION = "{}" + WHEEL_NAME = "{}" + WHEEL_COLLAB = "{}" ++USE_PYWRAP_RULES = "False" + """ +diff --git a/third_party/tf_runtime/workspace.bzl b/third_party/tf_runtime/workspace.bzl +--- a/third_party/tf_runtime/workspace.bzl ++++ b/third_party/tf_runtime/workspace.bzl +@@ -17,4 +17,0 @@ +- repo_mapping = { +- "@tsl": "@tsl", +- "@xla": "@xla", +- }, From f7f62f33e6ef7559f19ba44c2381e3a9c731191a Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Wed, 22 Jul 2026 07:55:49 +0000 Subject: [PATCH 035/183] Update third_party/tensorflow/tensorflow.patch to remove repo_mapping from tf_runtime for Bazel 7 compatibility --- third_party/tensorflow/tensorflow.patch | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/third_party/tensorflow/tensorflow.patch b/third_party/tensorflow/tensorflow.patch index e69de29bb2d..bf0608b7e63 100644 --- a/third_party/tensorflow/tensorflow.patch +++ b/third_party/tensorflow/tensorflow.patch @@ -0,0 +1,18 @@ +diff --git a/tensorflow/tools/toolchains/python/python_repo.bzl b/tensorflow/tools/toolchains/python/python_repo.bzl +--- a/tensorflow/tools/toolchains/python/python_repo.bzl ++++ b/tensorflow/tools/toolchains/python/python_repo.bzl +@@ -21,5 +21,6 @@ + TF_PYTHON_VERSION = "{}" + HERMETIC_PYTHON_VERSION = "{}" + WHEEL_NAME = "{}" + WHEEL_COLLAB = "{}" ++USE_PYWRAP_RULES = "False" + """ +diff --git a/third_party/tf_runtime/workspace.bzl b/third_party/tf_runtime/workspace.bzl +--- a/third_party/tf_runtime/workspace.bzl ++++ b/third_party/tf_runtime/workspace.bzl +@@ -17,4 +17,0 @@ +- repo_mapping = { +- "@tsl": "@tsl", +- "@xla": "@xla", +- }, From b507b3f732cea5fbb74c7b8e68c8f46c52ae94c7 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Wed, 22 Jul 2026 15:13:13 +0000 Subject: [PATCH 036/183] Set HERMETIC_CUDA_VERSION=12.2.0 and HERMETIC_NCCL_VERSION=2.28.9 in .bazelrc and Dockerfile.devel-gpu for TF 2.21 compatibility --- .bazelrc | 4 ++-- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.bazelrc b/.bazelrc index c41bf62af6f..78448f30a9d 100644 --- a/.bazelrc +++ b/.bazelrc @@ -20,10 +20,10 @@ build:cuda_clang --@local_config_cuda//:cuda_compiler=clang build:cuda_clang --repo_env=TF_CUDA_COMPUTE_CAPABILITIES="sm_60,sm_70,sm_75,sm_80,sm_86,sm_89,compute_90" build:cuda_clang --copt=-Dtypeof=__typeof__ -common:cuda_clang --repo_env=HERMETIC_CUDA_VERSION="12.5.1" +common:cuda_clang --repo_env=HERMETIC_CUDA_VERSION="12.2.0" common:cuda_clang --repo_env=HERMETIC_CUDNN_VERSION="9.3.0" common:cuda_clang --repo_env=HERMETIC_NVSHMEM_VERSION="3.2.5" -common:cuda_clang --repo_env=HERMETIC_NCCL_VERSION="2.29.7" +common:cuda_clang --repo_env=HERMETIC_NCCL_VERSION="2.28.9" build:cuda_clang --action_env=GCC_HOST_COMPILER_PATH="/usr/bin/gcc-10" build:cuda_clang --action_env=CLANG_CUDA_COMPILER_PATH="/usr/lib/llvm-17/bin/clang" diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index e914bc214ef..751854610f7 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -154,7 +154,7 @@ FROM base_build as binary_build # Build, and install TensorFlow Serving ARG TF_SERVING_BUILD_OPTIONS="--config=release" RUN echo "Building with build options: ${TF_SERVING_BUILD_OPTIONS}" -ARG TF_SERVING_BAZEL_OPTIONS="--repo_env=HERMETIC_CUDA_VERSION=12.2.0 --repo_env=HERMETIC_CUDA_COMPUTE_CAPABILITIES=7.0,7.5,8.0,8.6,8.9,9.0" +ARG TF_SERVING_BAZEL_OPTIONS="--repo_env=HERMETIC_CUDA_VERSION=12.2.0 --repo_env=HERMETIC_NCCL_VERSION=2.28.9 --repo_env=HERMETIC_CUDA_COMPUTE_CAPABILITIES=6.0,7.0,7.5,8.0,8.6,8.9,9.0" RUN echo "Building with Bazel options: ${TF_SERVING_BAZEL_OPTIONS}" RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1 && \ From e28efc2056a07c94560cbcf6748f7108b22f40db Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Wed, 22 Jul 2026 15:42:27 +0000 Subject: [PATCH 037/183] Update org_tensorflow to commit 4f1b7de8a37a03452565bc612c148a1d2d9d6cfc --- WORKSPACE | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index ddbd10ac0eb..6e97879ce2b 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -24,8 +24,8 @@ local_repository( load("//tensorflow_serving:repo.bzl", "tensorflow_http_archive") tensorflow_http_archive( name = "org_tensorflow", - sha256 = "6438396f3b19af5d7ad787cf041f857af7505916dc08092e20b07d1b1f8df492", - git_commit = "a481b10260dfdf833a1b16007eead49c1d7febf3", + sha256 = "44dbcac78a144a404485bc03b12fe6a545281b985552b15dbf0f7afec9815442", + git_commit = "4f1b7de8a37a03452565bc612c148a1d2d9d6cfc", patch = "//third_party/tensorflow:tensorflow.patch", patch_cmds = [ "sed -i '/cc_library = _cc_library/d' tensorflow/core/platform/rules_cc.bzl", From 7ae2b629a64823268ebe734f5c99705184e2e841 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Wed, 22 Jul 2026 16:03:30 +0000 Subject: [PATCH 038/183] Add --fix-missing to apt-get install in Dockerfile.devel-gpu to handle transient Ubuntu mirror timeouts --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 751854610f7..49b9d2ed0fa 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -92,7 +92,7 @@ RUN apt-get install -y --no-install-recommends \ # Install python 3.10 (Native on Ubuntu 22.04). -RUN apt-get update && apt-get install -y \ +RUN (apt-get update || apt-get update --fix-missing) && apt-get install -y --fix-missing \ python3.10 python3.10-dev python3-pip python3.10-venv && \ rm -rf /var/lib/apt/lists/* && \ python3.10 -m pip install pip --upgrade && \ From 490409a374c005131bdab14170a4e30d10e5de84 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Wed, 22 Jul 2026 16:19:42 +0000 Subject: [PATCH 039/183] Add retry loops for apt-get update in Dockerfile.devel-gpu and setup.sources.sh to prevent transient network timeouts --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 7 ++++--- tensorflow_serving/tools/docker/setup.sources.sh | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 49b9d2ed0fa..5afd0175102 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -29,8 +29,8 @@ ENV HERMETIC_CUDA_VERSION=12.2.0 ARG TF_CUDA_COMPUTE_CAPABILITIES="6.0,7.0,7.5,8.0,8.6,8.9,9.0" ENV TF_CUDA_COMPUTE_CAPABILITIES=${TF_CUDA_COMPUTE_CAPABILITIES} -RUN apt-get update && apt-get install -y --no-install-recommends \ - curl +RUN (for i in 1 2 3 4 5; do apt-get update && break || sleep 5; done) && \ + apt-get install -y --no-install-recommends curl # Download TF Serving sources (optionally at specific commit). WORKDIR /tensorflow-serving @@ -92,7 +92,8 @@ RUN apt-get install -y --no-install-recommends \ # Install python 3.10 (Native on Ubuntu 22.04). -RUN (apt-get update || apt-get update --fix-missing) && apt-get install -y --fix-missing \ +RUN (for i in 1 2 3 4 5; do apt-get update && break || sleep 5; done) && \ + apt-get install -y --fix-missing \ python3.10 python3.10-dev python3-pip python3.10-venv && \ rm -rf /var/lib/apt/lists/* && \ python3.10 -m pip install pip --upgrade && \ diff --git a/tensorflow_serving/tools/docker/setup.sources.sh b/tensorflow_serving/tools/docker/setup.sources.sh index ec46260165f..0f8641fc630 100755 --- a/tensorflow_serving/tools/docker/setup.sources.sh +++ b/tensorflow_serving/tools/docker/setup.sources.sh @@ -21,7 +21,7 @@ export DEBIAN_FRONTEND=noninteractive # Set up shared custom sources -apt-get update +for i in 1 2 3 4 5; do apt-get update && break || sleep 5; done apt-get install -y gnupg ca-certificates # Deadsnakes: https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa @@ -45,4 +45,4 @@ deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main deb-src http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main SOURCES -apt-get update +for i in 1 2 3 4 5; do apt-get update && break || sleep 5; done From 4b02f96e19388cf1696695307525b9ffb036605f Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Wed, 22 Jul 2026 16:26:35 +0000 Subject: [PATCH 040/183] Switch Ubuntu mirrors to azure.archive.ubuntu.com to resolve GCP VM archive mirror timeouts --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 9 +++++---- tensorflow_serving/tools/docker/setup.sources.sh | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 5afd0175102..ed2d252ad2d 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -29,8 +29,10 @@ ENV HERMETIC_CUDA_VERSION=12.2.0 ARG TF_CUDA_COMPUTE_CAPABILITIES="6.0,7.0,7.5,8.0,8.6,8.9,9.0" ENV TF_CUDA_COMPUTE_CAPABILITIES=${TF_CUDA_COMPUTE_CAPABILITIES} -RUN (for i in 1 2 3 4 5; do apt-get update && break || sleep 5; done) && \ - apt-get install -y --no-install-recommends curl +RUN sed -i 's/archive.ubuntu.com/azure.archive.ubuntu.com/g' /etc/apt/sources.list && \ + sed -i 's/security.ubuntu.com/azure.archive.ubuntu.com/g' /etc/apt/sources.list && \ + apt-get update && apt-get install -y --no-install-recommends \ + curl # Download TF Serving sources (optionally at specific commit). WORKDIR /tensorflow-serving @@ -92,8 +94,7 @@ RUN apt-get install -y --no-install-recommends \ # Install python 3.10 (Native on Ubuntu 22.04). -RUN (for i in 1 2 3 4 5; do apt-get update && break || sleep 5; done) && \ - apt-get install -y --fix-missing \ +RUN apt-get update && apt-get install -y --fix-missing \ python3.10 python3.10-dev python3-pip python3.10-venv && \ rm -rf /var/lib/apt/lists/* && \ python3.10 -m pip install pip --upgrade && \ diff --git a/tensorflow_serving/tools/docker/setup.sources.sh b/tensorflow_serving/tools/docker/setup.sources.sh index 0f8641fc630..ec46260165f 100755 --- a/tensorflow_serving/tools/docker/setup.sources.sh +++ b/tensorflow_serving/tools/docker/setup.sources.sh @@ -21,7 +21,7 @@ export DEBIAN_FRONTEND=noninteractive # Set up shared custom sources -for i in 1 2 3 4 5; do apt-get update && break || sleep 5; done +apt-get update apt-get install -y gnupg ca-certificates # Deadsnakes: https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa @@ -45,4 +45,4 @@ deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main deb-src http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main SOURCES -for i in 1 2 3 4 5; do apt-get update && break || sleep 5; done +apt-get update From 0ff157d9347c8aa6930dcfa1cc02b6396836f336 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Wed, 22 Jul 2026 16:58:54 +0000 Subject: [PATCH 041/183] Sync tensorflow.patch with depot version to fix org_tensorflow fetch patch error --- third_party/tensorflow/tensorflow.patch | 8 -------- 1 file changed, 8 deletions(-) diff --git a/third_party/tensorflow/tensorflow.patch b/third_party/tensorflow/tensorflow.patch index bf0608b7e63..75aa4f5f2ff 100644 --- a/third_party/tensorflow/tensorflow.patch +++ b/third_party/tensorflow/tensorflow.patch @@ -8,11 +8,3 @@ diff --git a/tensorflow/tools/toolchains/python/python_repo.bzl b/tensorflow/too WHEEL_COLLAB = "{}" +USE_PYWRAP_RULES = "False" """ -diff --git a/third_party/tf_runtime/workspace.bzl b/third_party/tf_runtime/workspace.bzl ---- a/third_party/tf_runtime/workspace.bzl -+++ b/third_party/tf_runtime/workspace.bzl -@@ -17,4 +17,0 @@ -- repo_mapping = { -- "@tsl": "@tsl", -- "@xla": "@xla", -- }, From cfc6de716bb1a8dbf9f8d5531a4dbe1182e747cb Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Wed, 22 Jul 2026 17:02:48 +0000 Subject: [PATCH 042/183] Pin org_tensorflow to stable TF 2.21.0 release tag (a481b10260dfdf833a1b16007eead49c1d7febf3) --- WORKSPACE | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 6e97879ce2b..ddbd10ac0eb 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -24,8 +24,8 @@ local_repository( load("//tensorflow_serving:repo.bzl", "tensorflow_http_archive") tensorflow_http_archive( name = "org_tensorflow", - sha256 = "44dbcac78a144a404485bc03b12fe6a545281b985552b15dbf0f7afec9815442", - git_commit = "4f1b7de8a37a03452565bc612c148a1d2d9d6cfc", + sha256 = "6438396f3b19af5d7ad787cf041f857af7505916dc08092e20b07d1b1f8df492", + git_commit = "a481b10260dfdf833a1b16007eead49c1d7febf3", patch = "//third_party/tensorflow:tensorflow.patch", patch_cmds = [ "sed -i '/cc_library = _cc_library/d' tensorflow/core/platform/rules_cc.bzl", From c548221ebac07b7e04a8fe5b1078c5a47d9c1c47 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Wed, 22 Jul 2026 17:33:14 +0000 Subject: [PATCH 043/183] Fix duplicate repo_mapping argument in TF 2.21 tf_runtime/workspace.bzl --- third_party/tensorflow/tensorflow.patch | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/third_party/tensorflow/tensorflow.patch b/third_party/tensorflow/tensorflow.patch index 75aa4f5f2ff..e40b62d9634 100644 --- a/third_party/tensorflow/tensorflow.patch +++ b/third_party/tensorflow/tensorflow.patch @@ -8,3 +8,11 @@ diff --git a/tensorflow/tools/toolchains/python/python_repo.bzl b/tensorflow/too WHEEL_COLLAB = "{}" +USE_PYWRAP_RULES = "False" """ +diff --git a/third_party/tf_runtime/workspace.bzl b/third_party/tf_runtime/workspace.bzl +--- a/third_party/tf_runtime/workspace.bzl ++++ b/third_party/tf_runtime/workspace.bzl +@@ -25,4 +25,0 @@ +- repo_mapping = { +- "@tsl": "@tsl", +- "@xla": "@xla", +- }, From a29aa8485eaf4896dc35d77dd5388f5434fe0c1a Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Wed, 22 Jul 2026 18:03:16 +0000 Subject: [PATCH 044/183] Use --config=cuda in Dockerfile.devel-gpu for TF 2.21 CUDA 12.2 compatibility --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index ed2d252ad2d..7a10ca1363b 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -161,7 +161,7 @@ RUN echo "Building with Bazel options: ${TF_SERVING_BAZEL_OPTIONS}" RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1 && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ - bazel build --color=yes --noshow_progress --curses=no --config=cuda_clang --copt="-fPIC"\ + bazel build --color=yes --noshow_progress --curses=no --config=cuda --copt="-fPIC"\ ${TF_SERVING_BAZEL_OPTIONS} \ --verbose_failures \ --output_filter=DONT_MATCH_ANYTHING \ From 98b27af8c3c7893ed83f316ff98c798020fb50c2 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Wed, 22 Jul 2026 18:26:44 +0000 Subject: [PATCH 045/183] Add HERMETIC_... env vars for common:cuda config in .bazelrc --- .bazelrc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.bazelrc b/.bazelrc index 78448f30a9d..3ae26b7998a 100644 --- a/.bazelrc +++ b/.bazelrc @@ -24,6 +24,11 @@ common:cuda_clang --repo_env=HERMETIC_CUDA_VERSION="12.2.0" common:cuda_clang --repo_env=HERMETIC_CUDNN_VERSION="9.3.0" common:cuda_clang --repo_env=HERMETIC_NVSHMEM_VERSION="3.2.5" common:cuda_clang --repo_env=HERMETIC_NCCL_VERSION="2.28.9" + +common:cuda --repo_env=HERMETIC_CUDA_VERSION="12.2.0" +common:cuda --repo_env=HERMETIC_CUDNN_VERSION="9.3.0" +common:cuda --repo_env=HERMETIC_NVSHMEM_VERSION="3.2.5" +common:cuda --repo_env=HERMETIC_NCCL_VERSION="2.28.9" build:cuda_clang --action_env=GCC_HOST_COMPILER_PATH="/usr/bin/gcc-10" build:cuda_clang --action_env=CLANG_CUDA_COMPILER_PATH="/usr/lib/llvm-17/bin/clang" From 19dadae5c78004e2dadd07c6e8daf05aa0b5a166 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Wed, 22 Jul 2026 19:00:47 +0000 Subject: [PATCH 046/183] Pre-include cuda_bf16.h under build:cuda in .bazelrc for NVCC __bf16 definition --- .bazelrc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.bazelrc b/.bazelrc index 3ae26b7998a..94fa819927d 100644 --- a/.bazelrc +++ b/.bazelrc @@ -29,6 +29,8 @@ common:cuda --repo_env=HERMETIC_CUDA_VERSION="12.2.0" common:cuda --repo_env=HERMETIC_CUDNN_VERSION="9.3.0" common:cuda --repo_env=HERMETIC_NVSHMEM_VERSION="3.2.5" common:cuda --repo_env=HERMETIC_NCCL_VERSION="2.28.9" +build:cuda --copt=-include +build:cuda --copt=cuda_bf16.h build:cuda_clang --action_env=GCC_HOST_COMPILER_PATH="/usr/bin/gcc-10" build:cuda_clang --action_env=CLANG_CUDA_COMPILER_PATH="/usr/lib/llvm-17/bin/clang" From 2384800cc09a1870dbda5268bbf0ae211250ad05 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Wed, 22 Jul 2026 19:41:55 +0000 Subject: [PATCH 047/183] Restrict cuda_bf16.h pre-inclusion to .cu and .cu.cc CUDA kernel files via per_file_copt --- .bazelrc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.bazelrc b/.bazelrc index 94fa819927d..a19676558c0 100644 --- a/.bazelrc +++ b/.bazelrc @@ -29,8 +29,8 @@ common:cuda --repo_env=HERMETIC_CUDA_VERSION="12.2.0" common:cuda --repo_env=HERMETIC_CUDNN_VERSION="9.3.0" common:cuda --repo_env=HERMETIC_NVSHMEM_VERSION="3.2.5" common:cuda --repo_env=HERMETIC_NCCL_VERSION="2.28.9" -build:cuda --copt=-include -build:cuda --copt=cuda_bf16.h +build:cuda --per_file_copt=.*\.cu\.cc$@-include,cuda_bf16.h +build:cuda --per_file_copt=.*\.cu$@-include,cuda_bf16.h build:cuda_clang --action_env=GCC_HOST_COMPILER_PATH="/usr/bin/gcc-10" build:cuda_clang --action_env=CLANG_CUDA_COMPILER_PATH="/usr/lib/llvm-17/bin/clang" From 9b06bf5f1772b89e63e8659ef76728d39bf400db Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Wed, 22 Jul 2026 20:11:40 +0000 Subject: [PATCH 048/183] Add missing dso_loader dependency to xla/tsl/cuda/BUILD.bazel nvshmem rule and set --noincompatible_check_headers in .bazelrc --- .bazelrc | 1 + third_party/tensorflow/tensorflow.patch | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/.bazelrc b/.bazelrc index a19676558c0..914bd95401c 100644 --- a/.bazelrc +++ b/.bazelrc @@ -127,6 +127,7 @@ build --features=-layering_check build --host_features=-layering_check build --features=-module_maps build --host_features=-module_maps +build --noincompatible_check_headers build --define=framework_shared_object=false build --dynamic_mode=off diff --git a/third_party/tensorflow/tensorflow.patch b/third_party/tensorflow/tensorflow.patch index e40b62d9634..32c3a925f4a 100644 --- a/third_party/tensorflow/tensorflow.patch +++ b/third_party/tensorflow/tensorflow.patch @@ -16,3 +16,14 @@ diff --git a/third_party/tf_runtime/workspace.bzl b/third_party/tf_runtime/works - "@tsl": "@tsl", - "@xla": "@xla", - }, +diff --git a/third_party/xla/xla/tsl/cuda/BUILD.bazel b/third_party/xla/xla/tsl/cuda/BUILD.bazel +--- a/third_party/xla/xla/tsl/cuda/BUILD.bazel ++++ b/third_party/xla/xla/tsl/cuda/BUILD.bazel +@@ -416,6 +416,7 @@ cc_library( + deps = if_cuda_is_configured([ + # keep sorted + "//xla/tsl/platform:logging", ++ "//xla/tsl/platform:dso_loader", + "@tsl//tsl/platform:dso_loader", + "@tsl//tsl/platform:load_library", + ]), From c45dd3455a52967312ea668045934d28af1a4451 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Wed, 22 Jul 2026 20:22:00 +0000 Subject: [PATCH 049/183] Remove unrecognized --noincompatible_check_headers option from .bazelrc --- .bazelrc | 1 - 1 file changed, 1 deletion(-) diff --git a/.bazelrc b/.bazelrc index 914bd95401c..a19676558c0 100644 --- a/.bazelrc +++ b/.bazelrc @@ -127,7 +127,6 @@ build --features=-layering_check build --host_features=-layering_check build --features=-module_maps build --host_features=-module_maps -build --noincompatible_check_headers build --define=framework_shared_object=false build --dynamic_mode=off From bf50a36b3567d14c708c5f572d3859b0b48926c0 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Wed, 22 Jul 2026 20:36:36 +0000 Subject: [PATCH 050/183] Correct dso_loader target path in tensorflow.patch to //xla/tsl/platform/default:dso_loader --- third_party/tensorflow/tensorflow.patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/tensorflow/tensorflow.patch b/third_party/tensorflow/tensorflow.patch index 32c3a925f4a..27a36f176d8 100644 --- a/third_party/tensorflow/tensorflow.patch +++ b/third_party/tensorflow/tensorflow.patch @@ -23,7 +23,7 @@ diff --git a/third_party/xla/xla/tsl/cuda/BUILD.bazel b/third_party/xla/xla/tsl/ deps = if_cuda_is_configured([ # keep sorted "//xla/tsl/platform:logging", -+ "//xla/tsl/platform:dso_loader", ++ "//xla/tsl/platform/default:dso_loader", "@tsl//tsl/platform:dso_loader", "@tsl//tsl/platform:load_library", ]), From d297e70eb64f59fc60bca459b5eff9c55918f344 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Wed, 22 Jul 2026 21:00:41 +0000 Subject: [PATCH 051/183] Add dso_loader dependency across all CUDA stub rules in xla/tsl/cuda/BUILD.bazel --- third_party/tensorflow/tensorflow.patch | 116 +++++++++++++++++++++--- 1 file changed, 105 insertions(+), 11 deletions(-) diff --git a/third_party/tensorflow/tensorflow.patch b/third_party/tensorflow/tensorflow.patch index 27a36f176d8..0a920f4570a 100644 --- a/third_party/tensorflow/tensorflow.patch +++ b/third_party/tensorflow/tensorflow.patch @@ -1,13 +1,3 @@ -diff --git a/tensorflow/tools/toolchains/python/python_repo.bzl b/tensorflow/tools/toolchains/python/python_repo.bzl ---- a/tensorflow/tools/toolchains/python/python_repo.bzl -+++ b/tensorflow/tools/toolchains/python/python_repo.bzl -@@ -21,5 +21,6 @@ - TF_PYTHON_VERSION = "{}" - HERMETIC_PYTHON_VERSION = "{}" - WHEEL_NAME = "{}" - WHEEL_COLLAB = "{}" -+USE_PYWRAP_RULES = "False" - """ diff --git a/third_party/tf_runtime/workspace.bzl b/third_party/tf_runtime/workspace.bzl --- a/third_party/tf_runtime/workspace.bzl +++ b/third_party/tf_runtime/workspace.bzl @@ -19,7 +9,95 @@ diff --git a/third_party/tf_runtime/workspace.bzl b/third_party/tf_runtime/works diff --git a/third_party/xla/xla/tsl/cuda/BUILD.bazel b/third_party/xla/xla/tsl/cuda/BUILD.bazel --- a/third_party/xla/xla/tsl/cuda/BUILD.bazel +++ b/third_party/xla/xla/tsl/cuda/BUILD.bazel -@@ -416,6 +416,7 @@ cc_library( +@@ -50,3 +50,4 @@ cc_library( + # keep sorted + "//xla/tsl/platform:logging", + "@com_google_absl//absl/container:flat_hash_set", + "@local_config_cuda//cuda:cuda_headers", ++ "//xla/tsl/platform/default:dso_loader", + "@tsl//tsl/platform:dso_loader", + "@tsl//tsl/platform:load_library", + ]), +@@ -81,3 +82,4 @@ cc_library( + # keep sorted + "//xla/tsl/platform:logging", + "@local_config_cuda//cuda:cuda_headers", ++ "//xla/tsl/platform/default:dso_loader", + "@tsl//tsl/platform:dso_loader", + "@tsl//tsl/platform:load_library", + ]), +@@ -112,3 +114,4 @@ cc_library( + # keep sorted + "//xla/tsl/platform:logging", + "@local_config_cuda//cuda:cuda_headers", ++ "//xla/tsl/platform/default:dso_loader", + "@tsl//tsl/platform:dso_loader", + "@tsl//tsl/platform:load_library", + ]), +@@ -149,3 +152,4 @@ cc_library( + ":cuda", + "//xla/tsl/platform:logging", + "@com_google_absl//absl/container:flat_hash_set", + "@local_config_cuda//cuda:cuda_headers", ++ "//xla/tsl/platform/default:dso_loader", + "@tsl//tsl/platform:dso_loader", + "@tsl//tsl/platform:load_library", + ], +@@ -184,3 +188,4 @@ cc_library( + # keep sorted + "//xla/tsl/platform:logging", + "@com_google_absl//absl/container:flat_hash_map", + "@local_config_cuda//cuda:cudnn_header", ++ "//xla/tsl/platform/default:dso_loader", + "@tsl//tsl/platform:dso_loader", + "@tsl//tsl/platform:load_library", + ]), +@@ -238,3 +243,4 @@ cc_library( + # keep sorted + "//xla/tsl/platform:logging", + "@local_config_cuda//cuda:cuda_headers", ++ "//xla/tsl/platform/default:dso_loader", + "@tsl//tsl/platform:dso_loader", + "@tsl//tsl/platform:load_library", + ]), +@@ -276,3 +282,4 @@ cc_library( + # keep sorted + "//xla/tsl/platform:logging", + "@local_config_cuda//cuda:cuda_headers", + "@local_config_cuda//cuda:cupti_headers", ++ "//xla/tsl/platform/default:dso_loader", + "@tsl//tsl/platform:dso_loader", + "@tsl//tsl/platform:load_library", + ]), +@@ -312,3 +319,4 @@ cc_library( + # keep sorted + "//xla/tsl/platform:logging", + "@local_config_cuda//cuda:cuda_headers", ++ "//xla/tsl/platform/default:dso_loader", + "@tsl//tsl/platform:dso_loader", + "@tsl//tsl/platform:load_library", + ]), +@@ -349,3 +357,4 @@ cc_library( + # keep sorted + "//xla/tsl/platform:logging", + "@com_google_absl//absl/container:flat_hash_set", + "@local_config_cuda//cuda:cuda_headers", ++ "//xla/tsl/platform/default:dso_loader", + "@tsl//tsl/platform:dso_loader", + "@tsl//tsl/platform:load_library", + ]), +@@ -384,3 +393,4 @@ cc_library( + # keep sorted + "//xla/tsl/platform:logging", + "@com_google_absl//absl/container:flat_hash_set", + "@com_google_absl//absl/strings:string_view", + "@local_config_cuda//cuda:cuda_headers", + "@local_config_nccl//:nccl_headers", ++ "//xla/tsl/platform/default:dso_loader", + "@tsl//tsl/platform:dso_loader", + "@tsl//tsl/platform:load_library", + ]), +@@ -416,3 +426,4 @@ cc_library( deps = if_cuda_is_configured([ # keep sorted "//xla/tsl/platform:logging", @@ -27,3 +105,19 @@ diff --git a/third_party/xla/xla/tsl/cuda/BUILD.bazel b/third_party/xla/xla/tsl/ "@tsl//tsl/platform:dso_loader", "@tsl//tsl/platform:load_library", ]), +@@ -447,3 +458,4 @@ cc_library( + # keep sorted + "//xla/tsl/platform:logging", + "@local_config_cuda//cuda:cuda_headers", ++ "//xla/tsl/platform/default:dso_loader", + "@tsl//tsl/platform:dso_loader", + "@tsl//tsl/platform:load_library", + ]), +@@ -478,3 +490,4 @@ cc_library( + # keep sorted + "//xla/tsl/platform:logging", + "@local_config_cuda//cuda:cuda_headers", ++ "//xla/tsl/platform/default:dso_loader", + "@tsl//tsl/platform:dso_loader", + "@tsl//tsl/platform:load_library", + ]), From a98ce6996541898d3e5a73e0027fa7354f8f2bd1 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Wed, 22 Jul 2026 21:11:33 +0000 Subject: [PATCH 052/183] Fix tensorflow.patch diff hunk formatting for xla/tsl/cuda/BUILD.bazel dso_loader patch --- third_party/tensorflow/tensorflow.patch | 73 +++++++++++++------------ 1 file changed, 39 insertions(+), 34 deletions(-) diff --git a/third_party/tensorflow/tensorflow.patch b/third_party/tensorflow/tensorflow.patch index 0a920f4570a..bbec0a154ab 100644 --- a/third_party/tensorflow/tensorflow.patch +++ b/third_party/tensorflow/tensorflow.patch @@ -9,115 +9,120 @@ diff --git a/third_party/tf_runtime/workspace.bzl b/third_party/tf_runtime/works diff --git a/third_party/xla/xla/tsl/cuda/BUILD.bazel b/third_party/xla/xla/tsl/cuda/BUILD.bazel --- a/third_party/xla/xla/tsl/cuda/BUILD.bazel +++ b/third_party/xla/xla/tsl/cuda/BUILD.bazel -@@ -50,3 +50,4 @@ cc_library( - # keep sorted +@@ -47,7 +47,7 @@ cc_library( "//xla/tsl/platform:logging", "@com_google_absl//absl/container:flat_hash_set", "@local_config_cuda//cuda:cuda_headers", +- "@tsl//tsl/platform:dso_loader", + "//xla/tsl/platform/default:dso_loader", - "@tsl//tsl/platform:dso_loader", "@tsl//tsl/platform:load_library", ]), -@@ -81,3 +82,4 @@ cc_library( + ) +@@ -78,7 +78,7 @@ cc_library( # keep sorted "//xla/tsl/platform:logging", "@local_config_cuda//cuda:cuda_headers", +- "@tsl//tsl/platform:dso_loader", + "//xla/tsl/platform/default:dso_loader", - "@tsl//tsl/platform:dso_loader", "@tsl//tsl/platform:load_library", ]), -@@ -112,3 +114,4 @@ cc_library( + ) +@@ -109,7 +109,7 @@ cc_library( # keep sorted "//xla/tsl/platform:logging", "@local_config_cuda//cuda:cuda_headers", +- "@tsl//tsl/platform:dso_loader", + "//xla/tsl/platform/default:dso_loader", - "@tsl//tsl/platform:dso_loader", "@tsl//tsl/platform:load_library", ]), -@@ -149,3 +152,4 @@ cc_library( - ":cuda", + ) +@@ -146,7 +146,7 @@ cc_library( "//xla/tsl/platform:logging", "@com_google_absl//absl/container:flat_hash_set", "@local_config_cuda//cuda:cuda_headers", +- "@tsl//tsl/platform:dso_loader", + "//xla/tsl/platform/default:dso_loader", - "@tsl//tsl/platform:dso_loader", "@tsl//tsl/platform:load_library", ], -@@ -184,3 +188,4 @@ cc_library( - # keep sorted + "//conditions:default": [], +@@ -181,7 +181,7 @@ cc_library( "//xla/tsl/platform:logging", "@com_google_absl//absl/container:flat_hash_map", "@local_config_cuda//cuda:cudnn_header", +- "@tsl//tsl/platform:dso_loader", + "//xla/tsl/platform/default:dso_loader", - "@tsl//tsl/platform:dso_loader", "@tsl//tsl/platform:load_library", ]), -@@ -238,3 +243,4 @@ cc_library( + ) +@@ -235,7 +235,7 @@ cc_library( # keep sorted "//xla/tsl/platform:logging", "@local_config_cuda//cuda:cuda_headers", +- "@tsl//tsl/platform:dso_loader", + "//xla/tsl/platform/default:dso_loader", - "@tsl//tsl/platform:dso_loader", "@tsl//tsl/platform:load_library", ]), -@@ -276,3 +282,4 @@ cc_library( - # keep sorted + ) +@@ -273,7 +273,7 @@ cc_library( "//xla/tsl/platform:logging", "@local_config_cuda//cuda:cuda_headers", "@local_config_cuda//cuda:cupti_headers", +- "@tsl//tsl/platform:dso_loader", + "//xla/tsl/platform/default:dso_loader", - "@tsl//tsl/platform:dso_loader", "@tsl//tsl/platform:load_library", ]), -@@ -312,3 +319,4 @@ cc_library( + ) +@@ -309,7 +309,7 @@ cc_library( # keep sorted "//xla/tsl/platform:logging", "@local_config_cuda//cuda:cuda_headers", +- "@tsl//tsl/platform:dso_loader", + "//xla/tsl/platform/default:dso_loader", - "@tsl//tsl/platform:dso_loader", "@tsl//tsl/platform:load_library", ]), -@@ -349,3 +357,4 @@ cc_library( - # keep sorted + ) +@@ -346,7 +346,7 @@ cc_library( "//xla/tsl/platform:logging", "@com_google_absl//absl/container:flat_hash_set", "@local_config_cuda//cuda:cuda_headers", +- "@tsl//tsl/platform:dso_loader", + "//xla/tsl/platform/default:dso_loader", - "@tsl//tsl/platform:dso_loader", "@tsl//tsl/platform:load_library", ]), -@@ -384,3 +393,4 @@ cc_library( - # keep sorted - "//xla/tsl/platform:logging", - "@com_google_absl//absl/container:flat_hash_set", + ) +@@ -381,7 +381,7 @@ cc_library( "@com_google_absl//absl/strings:string_view", "@local_config_cuda//cuda:cuda_headers", "@local_config_nccl//:nccl_headers", +- "@tsl//tsl/platform:dso_loader", + "//xla/tsl/platform/default:dso_loader", - "@tsl//tsl/platform:dso_loader", "@tsl//tsl/platform:load_library", ]), -@@ -416,3 +426,4 @@ cc_library( + ) +@@ -413,7 +413,7 @@ cc_library( deps = if_cuda_is_configured([ # keep sorted "//xla/tsl/platform:logging", +- "@tsl//tsl/platform:dso_loader", + "//xla/tsl/platform/default:dso_loader", - "@tsl//tsl/platform:dso_loader", "@tsl//tsl/platform:load_library", ]), -@@ -447,3 +458,4 @@ cc_library( + ) +@@ -444,7 +444,7 @@ cc_library( # keep sorted "//xla/tsl/platform:logging", "@local_config_cuda//cuda:cuda_headers", +- "@tsl//tsl/platform:dso_loader", + "//xla/tsl/platform/default:dso_loader", - "@tsl//tsl/platform:dso_loader", "@tsl//tsl/platform:load_library", ]), -@@ -478,3 +490,4 @@ cc_library( + ) +@@ -475,7 +475,7 @@ cc_library( # keep sorted "//xla/tsl/platform:logging", "@local_config_cuda//cuda:cuda_headers", +- "@tsl//tsl/platform:dso_loader", + "//xla/tsl/platform/default:dso_loader", - "@tsl//tsl/platform:dso_loader", "@tsl//tsl/platform:load_library", ]), + ) From bb2b6cab8c2ec7b0c72e8d657ca81e04198a895c Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Wed, 22 Jul 2026 21:22:41 +0000 Subject: [PATCH 053/183] Update tensorflow.patch to match exact TF 2.21.0 release tag xla/tsl/cuda/BUILD.bazel file structure --- third_party/tensorflow/tensorflow.patch | 108 ------------------------ 1 file changed, 108 deletions(-) diff --git a/third_party/tensorflow/tensorflow.patch b/third_party/tensorflow/tensorflow.patch index bbec0a154ab..c403da7ab02 100644 --- a/third_party/tensorflow/tensorflow.patch +++ b/third_party/tensorflow/tensorflow.patch @@ -18,111 +18,3 @@ diff --git a/third_party/xla/xla/tsl/cuda/BUILD.bazel b/third_party/xla/xla/tsl/ "@tsl//tsl/platform:load_library", ]), ) -@@ -78,7 +78,7 @@ cc_library( - # keep sorted - "//xla/tsl/platform:logging", - "@local_config_cuda//cuda:cuda_headers", -- "@tsl//tsl/platform:dso_loader", -+ "//xla/tsl/platform/default:dso_loader", - "@tsl//tsl/platform:load_library", - ]), - ) -@@ -109,7 +109,7 @@ cc_library( - # keep sorted - "//xla/tsl/platform:logging", - "@local_config_cuda//cuda:cuda_headers", -- "@tsl//tsl/platform:dso_loader", -+ "//xla/tsl/platform/default:dso_loader", - "@tsl//tsl/platform:load_library", - ]), - ) -@@ -146,7 +146,7 @@ cc_library( - "//xla/tsl/platform:logging", - "@com_google_absl//absl/container:flat_hash_set", - "@local_config_cuda//cuda:cuda_headers", -- "@tsl//tsl/platform:dso_loader", -+ "//xla/tsl/platform/default:dso_loader", - "@tsl//tsl/platform:load_library", - ], - "//conditions:default": [], -@@ -181,7 +181,7 @@ cc_library( - "//xla/tsl/platform:logging", - "@com_google_absl//absl/container:flat_hash_map", - "@local_config_cuda//cuda:cudnn_header", -- "@tsl//tsl/platform:dso_loader", -+ "//xla/tsl/platform/default:dso_loader", - "@tsl//tsl/platform:load_library", - ]), - ) -@@ -235,7 +235,7 @@ cc_library( - # keep sorted - "//xla/tsl/platform:logging", - "@local_config_cuda//cuda:cuda_headers", -- "@tsl//tsl/platform:dso_loader", -+ "//xla/tsl/platform/default:dso_loader", - "@tsl//tsl/platform:load_library", - ]), - ) -@@ -273,7 +273,7 @@ cc_library( - "//xla/tsl/platform:logging", - "@local_config_cuda//cuda:cuda_headers", - "@local_config_cuda//cuda:cupti_headers", -- "@tsl//tsl/platform:dso_loader", -+ "//xla/tsl/platform/default:dso_loader", - "@tsl//tsl/platform:load_library", - ]), - ) -@@ -309,7 +309,7 @@ cc_library( - # keep sorted - "//xla/tsl/platform:logging", - "@local_config_cuda//cuda:cuda_headers", -- "@tsl//tsl/platform:dso_loader", -+ "//xla/tsl/platform/default:dso_loader", - "@tsl//tsl/platform:load_library", - ]), - ) -@@ -346,7 +346,7 @@ cc_library( - "//xla/tsl/platform:logging", - "@com_google_absl//absl/container:flat_hash_set", - "@local_config_cuda//cuda:cuda_headers", -- "@tsl//tsl/platform:dso_loader", -+ "//xla/tsl/platform/default:dso_loader", - "@tsl//tsl/platform:load_library", - ]), - ) -@@ -381,7 +381,7 @@ cc_library( - "@com_google_absl//absl/strings:string_view", - "@local_config_cuda//cuda:cuda_headers", - "@local_config_nccl//:nccl_headers", -- "@tsl//tsl/platform:dso_loader", -+ "//xla/tsl/platform/default:dso_loader", - "@tsl//tsl/platform:load_library", - ]), - ) -@@ -413,7 +413,7 @@ cc_library( - deps = if_cuda_is_configured([ - # keep sorted - "//xla/tsl/platform:logging", -- "@tsl//tsl/platform:dso_loader", -+ "//xla/tsl/platform/default:dso_loader", - "@tsl//tsl/platform:load_library", - ]), - ) -@@ -444,7 +444,7 @@ cc_library( - # keep sorted - "//xla/tsl/platform:logging", - "@local_config_cuda//cuda:cuda_headers", -- "@tsl//tsl/platform:dso_loader", -+ "//xla/tsl/platform/default:dso_loader", - "@tsl//tsl/platform:load_library", - ]), - ) -@@ -475,7 +475,7 @@ cc_library( - # keep sorted - "//xla/tsl/platform:logging", - "@local_config_cuda//cuda:cuda_headers", -- "@tsl//tsl/platform:dso_loader", -+ "//xla/tsl/platform/default:dso_loader", - "@tsl//tsl/platform:load_library", - ]), - ) From 2c69466a67e888fa31a10054e15d8976cf66ac99 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Wed, 22 Jul 2026 21:50:31 +0000 Subject: [PATCH 054/183] Set build:cuda --copt=-D__bf16=__nv_bfloat16 in .bazelrc to define bfloat16 type for NVCC --- .bazelrc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.bazelrc b/.bazelrc index a19676558c0..f7bfe1643c2 100644 --- a/.bazelrc +++ b/.bazelrc @@ -29,8 +29,7 @@ common:cuda --repo_env=HERMETIC_CUDA_VERSION="12.2.0" common:cuda --repo_env=HERMETIC_CUDNN_VERSION="9.3.0" common:cuda --repo_env=HERMETIC_NVSHMEM_VERSION="3.2.5" common:cuda --repo_env=HERMETIC_NCCL_VERSION="2.28.9" -build:cuda --per_file_copt=.*\.cu\.cc$@-include,cuda_bf16.h -build:cuda --per_file_copt=.*\.cu$@-include,cuda_bf16.h +build:cuda --copt=-D__bf16=__nv_bfloat16 build:cuda_clang --action_env=GCC_HOST_COMPILER_PATH="/usr/bin/gcc-10" build:cuda_clang --action_env=CLANG_CUDA_COMPILER_PATH="/usr/lib/llvm-17/bin/clang" From af244c9fe2f8590e81ab28462eeec04c09e766f0 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Wed, 22 Jul 2026 22:40:12 +0000 Subject: [PATCH 055/183] Scope -D__bf16=__nv_bfloat16 via per_file_copt to .cu.cc and .cu files to prevent polluting host C++ AVX intrinsics --- .bazelrc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.bazelrc b/.bazelrc index f7bfe1643c2..2a460ce9431 100644 --- a/.bazelrc +++ b/.bazelrc @@ -29,7 +29,8 @@ common:cuda --repo_env=HERMETIC_CUDA_VERSION="12.2.0" common:cuda --repo_env=HERMETIC_CUDNN_VERSION="9.3.0" common:cuda --repo_env=HERMETIC_NVSHMEM_VERSION="3.2.5" common:cuda --repo_env=HERMETIC_NCCL_VERSION="2.28.9" -build:cuda --copt=-D__bf16=__nv_bfloat16 +build:cuda --per_file_copt=.*\.cu\.cc$@-D__bf16=__nv_bfloat16 +build:cuda --per_file_copt=.*\.cu$@-D__bf16=__nv_bfloat16 build:cuda_clang --action_env=GCC_HOST_COMPILER_PATH="/usr/bin/gcc-10" build:cuda_clang --action_env=CLANG_CUDA_COMPILER_PATH="/usr/lib/llvm-17/bin/clang" From 2aa81451ab7599741f4db8936e7695fb708d5f7f Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Wed, 22 Jul 2026 23:10:32 +0000 Subject: [PATCH 056/183] Include .*_cuda\.cc$ in per_file_copt for __bf16=__nv_bfloat16 definition to cover XLA stream_executor CUDA kernels --- .bazelrc | 1 + 1 file changed, 1 insertion(+) diff --git a/.bazelrc b/.bazelrc index 2a460ce9431..4293cee9b53 100644 --- a/.bazelrc +++ b/.bazelrc @@ -31,6 +31,7 @@ common:cuda --repo_env=HERMETIC_NVSHMEM_VERSION="3.2.5" common:cuda --repo_env=HERMETIC_NCCL_VERSION="2.28.9" build:cuda --per_file_copt=.*\.cu\.cc$@-D__bf16=__nv_bfloat16 build:cuda --per_file_copt=.*\.cu$@-D__bf16=__nv_bfloat16 +build:cuda --per_file_copt=.*_cuda\.cc$@-D__bf16=__nv_bfloat16 build:cuda_clang --action_env=GCC_HOST_COMPILER_PATH="/usr/bin/gcc-10" build:cuda_clang --action_env=CLANG_CUDA_COMPILER_PATH="/usr/lib/llvm-17/bin/clang" From 3deb7b22059c505a9c8a584da1e518c17377c70a Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Wed, 22 Jul 2026 23:40:20 +0000 Subject: [PATCH 057/183] Pre-include /usr/local/cuda/include/cuda_bf16.h for all CUDA compilation units via per_file_copt --- .bazelrc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.bazelrc b/.bazelrc index 4293cee9b53..bf7cbdc3a92 100644 --- a/.bazelrc +++ b/.bazelrc @@ -29,9 +29,9 @@ common:cuda --repo_env=HERMETIC_CUDA_VERSION="12.2.0" common:cuda --repo_env=HERMETIC_CUDNN_VERSION="9.3.0" common:cuda --repo_env=HERMETIC_NVSHMEM_VERSION="3.2.5" common:cuda --repo_env=HERMETIC_NCCL_VERSION="2.28.9" -build:cuda --per_file_copt=.*\.cu\.cc$@-D__bf16=__nv_bfloat16 -build:cuda --per_file_copt=.*\.cu$@-D__bf16=__nv_bfloat16 -build:cuda --per_file_copt=.*_cuda\.cc$@-D__bf16=__nv_bfloat16 +build:cuda --per_file_copt=.*\.cu\.cc$@-include,/usr/local/cuda/include/cuda_bf16.h +build:cuda --per_file_copt=.*\.cu$@-include,/usr/local/cuda/include/cuda_bf16.h +build:cuda --per_file_copt=.*_cuda\.cc$@-include,/usr/local/cuda/include/cuda_bf16.h build:cuda_clang --action_env=GCC_HOST_COMPILER_PATH="/usr/bin/gcc-10" build:cuda_clang --action_env=CLANG_CUDA_COMPILER_PATH="/usr/lib/llvm-17/bin/clang" From 78414d8726e3b47e60d0bb64ce42ddb176abb2dc Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Thu, 23 Jul 2026 00:00:27 +0000 Subject: [PATCH 058/183] Disable layering_check feature for build:cuda to avoid CUPTI header layering errors under NVCC --- .bazelrc | 1 + 1 file changed, 1 insertion(+) diff --git a/.bazelrc b/.bazelrc index bf7cbdc3a92..a9c6115dc98 100644 --- a/.bazelrc +++ b/.bazelrc @@ -29,6 +29,7 @@ common:cuda --repo_env=HERMETIC_CUDA_VERSION="12.2.0" common:cuda --repo_env=HERMETIC_CUDNN_VERSION="9.3.0" common:cuda --repo_env=HERMETIC_NVSHMEM_VERSION="3.2.5" common:cuda --repo_env=HERMETIC_NCCL_VERSION="2.28.9" +build:cuda --features=-layering_check build:cuda --per_file_copt=.*\.cu\.cc$@-include,/usr/local/cuda/include/cuda_bf16.h build:cuda --per_file_copt=.*\.cu$@-include,/usr/local/cuda/include/cuda_bf16.h build:cuda --per_file_copt=.*_cuda\.cc$@-include,/usr/local/cuda/include/cuda_bf16.h From 8e4da1fbfcf1ae78192c0539fe33836dc5b0dcd5 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Thu, 23 Jul 2026 00:31:20 +0000 Subject: [PATCH 059/183] Pass -D__CUDACC__ alongside -include /usr/local/cuda/include/cuda_bf16.h via per_file_copt to CUDA compilation units --- .bazelrc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.bazelrc b/.bazelrc index a9c6115dc98..729fda8a375 100644 --- a/.bazelrc +++ b/.bazelrc @@ -30,6 +30,9 @@ common:cuda --repo_env=HERMETIC_CUDNN_VERSION="9.3.0" common:cuda --repo_env=HERMETIC_NVSHMEM_VERSION="3.2.5" common:cuda --repo_env=HERMETIC_NCCL_VERSION="2.28.9" build:cuda --features=-layering_check +build:cuda --per_file_copt=.*\.cu\.cc$@-D__CUDACC__ +build:cuda --per_file_copt=.*\.cu$@-D__CUDACC__ +build:cuda --per_file_copt=.*_cuda\.cc$@-D__CUDACC__ build:cuda --per_file_copt=.*\.cu\.cc$@-include,/usr/local/cuda/include/cuda_bf16.h build:cuda --per_file_copt=.*\.cu$@-include,/usr/local/cuda/include/cuda_bf16.h build:cuda --per_file_copt=.*_cuda\.cc$@-include,/usr/local/cuda/include/cuda_bf16.h From d2f77a241e27c5f92a1cfabe0ebf18ced3afa598 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Thu, 23 Jul 2026 00:50:32 +0000 Subject: [PATCH 060/183] Add xxd package to Dockerfile.devel-gpu dependencies --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 1 + 1 file changed, 1 insertion(+) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 7a10ca1363b..3af4b5215cb 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -87,6 +87,7 @@ RUN apt-get install -y --no-install-recommends \ swig \ unzip \ wget \ + xxd \ zip \ zlib1g-dev \ python3-setuptools && \ From 4c4ff76cb5feecc6cab59b62e3d0a45b0d7d8597 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Thu, 23 Jul 2026 01:10:31 +0000 Subject: [PATCH 061/183] Add -Wno-error=header-guard to build:cuda flags to suppress unguarded CUPTI header errors --- .bazelrc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.bazelrc b/.bazelrc index 729fda8a375..4d4379a9ab6 100644 --- a/.bazelrc +++ b/.bazelrc @@ -30,6 +30,8 @@ common:cuda --repo_env=HERMETIC_CUDNN_VERSION="9.3.0" common:cuda --repo_env=HERMETIC_NVSHMEM_VERSION="3.2.5" common:cuda --repo_env=HERMETIC_NCCL_VERSION="2.28.9" build:cuda --features=-layering_check +build:cuda --copt=-Wno-error=header-guard +build:cuda --copt=-Wno-header-guard build:cuda --per_file_copt=.*\.cu\.cc$@-D__CUDACC__ build:cuda --per_file_copt=.*\.cu$@-D__CUDACC__ build:cuda --per_file_copt=.*_cuda\.cc$@-D__CUDACC__ From bfc5e151b910bb2702b52a29b8fd889ded9f1824 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Thu, 23 Jul 2026 01:30:30 +0000 Subject: [PATCH 062/183] Pass --copt=-w under build:cuda to suppress compiler warning errors in third-party CUDA headers --- .bazelrc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.bazelrc b/.bazelrc index 4d4379a9ab6..8195e4458c1 100644 --- a/.bazelrc +++ b/.bazelrc @@ -30,8 +30,7 @@ common:cuda --repo_env=HERMETIC_CUDNN_VERSION="9.3.0" common:cuda --repo_env=HERMETIC_NVSHMEM_VERSION="3.2.5" common:cuda --repo_env=HERMETIC_NCCL_VERSION="2.28.9" build:cuda --features=-layering_check -build:cuda --copt=-Wno-error=header-guard -build:cuda --copt=-Wno-header-guard +build:cuda --copt=-w build:cuda --per_file_copt=.*\.cu\.cc$@-D__CUDACC__ build:cuda --per_file_copt=.*\.cu$@-D__CUDACC__ build:cuda --per_file_copt=.*_cuda\.cc$@-D__CUDACC__ From 88b5ff6d7021de087a0fe7a35e803743cdb8c907 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Thu, 23 Jul 2026 02:00:18 +0000 Subject: [PATCH 063/183] Pass both -include /usr/local/cuda/include/cuda_bf16.h and -D__bf16=__nv_bfloat16 via per_file_copt to CUDA compilation units --- .bazelrc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.bazelrc b/.bazelrc index 8195e4458c1..86e41840149 100644 --- a/.bazelrc +++ b/.bazelrc @@ -31,12 +31,12 @@ common:cuda --repo_env=HERMETIC_NVSHMEM_VERSION="3.2.5" common:cuda --repo_env=HERMETIC_NCCL_VERSION="2.28.9" build:cuda --features=-layering_check build:cuda --copt=-w -build:cuda --per_file_copt=.*\.cu\.cc$@-D__CUDACC__ -build:cuda --per_file_copt=.*\.cu$@-D__CUDACC__ -build:cuda --per_file_copt=.*_cuda\.cc$@-D__CUDACC__ build:cuda --per_file_copt=.*\.cu\.cc$@-include,/usr/local/cuda/include/cuda_bf16.h build:cuda --per_file_copt=.*\.cu$@-include,/usr/local/cuda/include/cuda_bf16.h build:cuda --per_file_copt=.*_cuda\.cc$@-include,/usr/local/cuda/include/cuda_bf16.h +build:cuda --per_file_copt=.*\.cu\.cc$@-D__bf16=__nv_bfloat16 +build:cuda --per_file_copt=.*\.cu$@-D__bf16=__nv_bfloat16 +build:cuda --per_file_copt=.*_cuda\.cc$@-D__bf16=__nv_bfloat16 build:cuda_clang --action_env=GCC_HOST_COMPILER_PATH="/usr/bin/gcc-10" build:cuda_clang --action_env=CLANG_CUDA_COMPILER_PATH="/usr/lib/llvm-17/bin/clang" From 82823609c911807336667164c5f1058dcd98e7e9 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Thu, 23 Jul 2026 02:31:24 +0000 Subject: [PATCH 064/183] Pass trifecta per_file_copt flags (-D__CUDACC__, -include /usr/local/cuda/include/cuda_bf16.h, -D__bf16=__nv_bfloat16) to CUDA compilation units --- .bazelrc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.bazelrc b/.bazelrc index 86e41840149..85609d4ed35 100644 --- a/.bazelrc +++ b/.bazelrc @@ -31,6 +31,9 @@ common:cuda --repo_env=HERMETIC_NVSHMEM_VERSION="3.2.5" common:cuda --repo_env=HERMETIC_NCCL_VERSION="2.28.9" build:cuda --features=-layering_check build:cuda --copt=-w +build:cuda --per_file_copt=.*\.cu\.cc$@-D__CUDACC__ +build:cuda --per_file_copt=.*\.cu$@-D__CUDACC__ +build:cuda --per_file_copt=.*_cuda\.cc$@-D__CUDACC__ build:cuda --per_file_copt=.*\.cu\.cc$@-include,/usr/local/cuda/include/cuda_bf16.h build:cuda --per_file_copt=.*\.cu$@-include,/usr/local/cuda/include/cuda_bf16.h build:cuda --per_file_copt=.*_cuda\.cc$@-include,/usr/local/cuda/include/cuda_bf16.h From 9ce4d52dd90903f6497adb59c206b6ce98867994 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Thu, 23 Jul 2026 02:31:48 +0000 Subject: [PATCH 065/183] Map __bf16 to unsigned short via per_file_copt for CUDA compilation units to satisfy GCC vector attributes --- .bazelrc | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/.bazelrc b/.bazelrc index 85609d4ed35..9ff97494545 100644 --- a/.bazelrc +++ b/.bazelrc @@ -31,15 +31,9 @@ common:cuda --repo_env=HERMETIC_NVSHMEM_VERSION="3.2.5" common:cuda --repo_env=HERMETIC_NCCL_VERSION="2.28.9" build:cuda --features=-layering_check build:cuda --copt=-w -build:cuda --per_file_copt=.*\.cu\.cc$@-D__CUDACC__ -build:cuda --per_file_copt=.*\.cu$@-D__CUDACC__ -build:cuda --per_file_copt=.*_cuda\.cc$@-D__CUDACC__ -build:cuda --per_file_copt=.*\.cu\.cc$@-include,/usr/local/cuda/include/cuda_bf16.h -build:cuda --per_file_copt=.*\.cu$@-include,/usr/local/cuda/include/cuda_bf16.h -build:cuda --per_file_copt=.*_cuda\.cc$@-include,/usr/local/cuda/include/cuda_bf16.h -build:cuda --per_file_copt=.*\.cu\.cc$@-D__bf16=__nv_bfloat16 -build:cuda --per_file_copt=.*\.cu$@-D__bf16=__nv_bfloat16 -build:cuda --per_file_copt=.*_cuda\.cc$@-D__bf16=__nv_bfloat16 +build:cuda --per_file_copt=.*\.cu\.cc$@-D__bf16=unsigned short +build:cuda --per_file_copt=.*\.cu$@-D__bf16=unsigned short +build:cuda --per_file_copt=.*_cuda\.cc$@-D__bf16=unsigned short build:cuda_clang --action_env=GCC_HOST_COMPILER_PATH="/usr/bin/gcc-10" build:cuda_clang --action_env=CLANG_CUDA_COMPILER_PATH="/usr/lib/llvm-17/bin/clang" From e087fdb837c8f4721e11dfd180d79bdc33700916 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Thu, 23 Jul 2026 03:00:19 +0000 Subject: [PATCH 066/183] Expand per_file_copt regex for -D__bf16=unsigned short to include xla GPU backend files --- .bazelrc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.bazelrc b/.bazelrc index 9ff97494545..0b6c0a62675 100644 --- a/.bazelrc +++ b/.bazelrc @@ -31,9 +31,7 @@ common:cuda --repo_env=HERMETIC_NVSHMEM_VERSION="3.2.5" common:cuda --repo_env=HERMETIC_NCCL_VERSION="2.28.9" build:cuda --features=-layering_check build:cuda --copt=-w -build:cuda --per_file_copt=.*\.cu\.cc$@-D__bf16=unsigned short -build:cuda --per_file_copt=.*\.cu$@-D__bf16=unsigned short -build:cuda --per_file_copt=.*_cuda\.cc$@-D__bf16=unsigned short +build:cuda --per_file_copt=.*\.cu\.cc$|.*\.cu$|.*_cuda\.cc$|.*xla/backends/gpu/.*\.cc$|.*xla/stream_executor/cuda/.*\.cc$|.*xla/service/gpu/.*\.cc$@-D__bf16=unsigned short build:cuda_clang --action_env=GCC_HOST_COMPILER_PATH="/usr/bin/gcc-10" build:cuda_clang --action_env=CLANG_CUDA_COMPILER_PATH="/usr/lib/llvm-17/bin/clang" From d66f7a3c17cb6202875073e923d21c30078a13a2 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Thu, 23 Jul 2026 03:20:25 +0000 Subject: [PATCH 067/183] Split per_file_copt into separate lines to avoid Bazel regex pipe misinterpretation in autoconf scripts --- .bazelrc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.bazelrc b/.bazelrc index 0b6c0a62675..0c732ee5708 100644 --- a/.bazelrc +++ b/.bazelrc @@ -31,7 +31,12 @@ common:cuda --repo_env=HERMETIC_NVSHMEM_VERSION="3.2.5" common:cuda --repo_env=HERMETIC_NCCL_VERSION="2.28.9" build:cuda --features=-layering_check build:cuda --copt=-w -build:cuda --per_file_copt=.*\.cu\.cc$|.*\.cu$|.*_cuda\.cc$|.*xla/backends/gpu/.*\.cc$|.*xla/stream_executor/cuda/.*\.cc$|.*xla/service/gpu/.*\.cc$@-D__bf16=unsigned short +build:cuda --per_file_copt=.*\.cu\.cc$@-D__bf16=unsigned short +build:cuda --per_file_copt=.*\.cu$@-D__bf16=unsigned short +build:cuda --per_file_copt=.*_cuda\.cc$@-D__bf16=unsigned short +build:cuda --per_file_copt=.*xla/backends/gpu/.*\.cc$@-D__bf16=unsigned short +build:cuda --per_file_copt=.*xla/stream_executor/cuda/.*\.cc$@-D__bf16=unsigned short +build:cuda --per_file_copt=.*xla/service/gpu/.*\.cc$@-D__bf16=unsigned short build:cuda_clang --action_env=GCC_HOST_COMPILER_PATH="/usr/bin/gcc-10" build:cuda_clang --action_env=CLANG_CUDA_COMPILER_PATH="/usr/lib/llvm-17/bin/clang" From 4520a9ef3fd212e81d46a16b7dea738d1459d802 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Thu, 23 Jul 2026 03:50:20 +0000 Subject: [PATCH 068/183] Restrict per_file_copt -D__bf16=unsigned short strictly to CUDA compilation units (.cu, .cu.cc, _cuda.cc) to preserve native Clang 18 __bf16 support --- .bazelrc | 3 --- 1 file changed, 3 deletions(-) diff --git a/.bazelrc b/.bazelrc index 0c732ee5708..9ff97494545 100644 --- a/.bazelrc +++ b/.bazelrc @@ -34,9 +34,6 @@ build:cuda --copt=-w build:cuda --per_file_copt=.*\.cu\.cc$@-D__bf16=unsigned short build:cuda --per_file_copt=.*\.cu$@-D__bf16=unsigned short build:cuda --per_file_copt=.*_cuda\.cc$@-D__bf16=unsigned short -build:cuda --per_file_copt=.*xla/backends/gpu/.*\.cc$@-D__bf16=unsigned short -build:cuda --per_file_copt=.*xla/stream_executor/cuda/.*\.cc$@-D__bf16=unsigned short -build:cuda --per_file_copt=.*xla/service/gpu/.*\.cc$@-D__bf16=unsigned short build:cuda_clang --action_env=GCC_HOST_COMPILER_PATH="/usr/bin/gcc-10" build:cuda_clang --action_env=CLANG_CUDA_COMPILER_PATH="/usr/lib/llvm-17/bin/clang" From 8625f246169b4998b5936b8564ded2929779f6f6 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Thu, 23 Jul 2026 08:08:41 +0000 Subject: [PATCH 069/183] Add third_party/cuda_bf16_fix.h header to safely typedef __bf16 as uint16_t for GCC 10 while preserving Clang 18 native support --- .bazelrc | 5 ++--- third_party/cuda_bf16_fix.h | 13 +++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 third_party/cuda_bf16_fix.h diff --git a/.bazelrc b/.bazelrc index 9ff97494545..10aa4ca7872 100644 --- a/.bazelrc +++ b/.bazelrc @@ -31,9 +31,8 @@ common:cuda --repo_env=HERMETIC_NVSHMEM_VERSION="3.2.5" common:cuda --repo_env=HERMETIC_NCCL_VERSION="2.28.9" build:cuda --features=-layering_check build:cuda --copt=-w -build:cuda --per_file_copt=.*\.cu\.cc$@-D__bf16=unsigned short -build:cuda --per_file_copt=.*\.cu$@-D__bf16=unsigned short -build:cuda --per_file_copt=.*_cuda\.cc$@-D__bf16=unsigned short +build:cuda --copt=-include +build:cuda --copt=third_party/cuda_bf16_fix.h build:cuda_clang --action_env=GCC_HOST_COMPILER_PATH="/usr/bin/gcc-10" build:cuda_clang --action_env=CLANG_CUDA_COMPILER_PATH="/usr/lib/llvm-17/bin/clang" diff --git a/third_party/cuda_bf16_fix.h b/third_party/cuda_bf16_fix.h new file mode 100644 index 00000000000..5e46d4c4026 --- /dev/null +++ b/third_party/cuda_bf16_fix.h @@ -0,0 +1,13 @@ +/* Copyright 2026 The TensorFlow Authors. All Rights Reserved. */ +#ifndef THIRD_PARTY_CUDA_BF16_FIX_H_ +#define THIRD_PARTY_CUDA_BF16_FIX_H_ + +#include + +#if !defined(__clang__) && defined(__GNUC__) +#ifndef __bf16 +typedef uint16_t __bf16; +#endif +#endif + +#endif // THIRD_PARTY_CUDA_BF16_FIX_H_ From 621c598af67b93e143a4849d555a641db24f9728 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Thu, 23 Jul 2026 08:30:30 +0000 Subject: [PATCH 070/183] Remove #include from cuda_bf16_fix.h to prevent sysroot header pre-include conflicts under Bazel --- third_party/cuda_bf16_fix.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/third_party/cuda_bf16_fix.h b/third_party/cuda_bf16_fix.h index 5e46d4c4026..d58b4d587d1 100644 --- a/third_party/cuda_bf16_fix.h +++ b/third_party/cuda_bf16_fix.h @@ -2,11 +2,9 @@ #ifndef THIRD_PARTY_CUDA_BF16_FIX_H_ #define THIRD_PARTY_CUDA_BF16_FIX_H_ -#include - #if !defined(__clang__) && defined(__GNUC__) #ifndef __bf16 -typedef uint16_t __bf16; +typedef unsigned short __bf16; #endif #endif From 872845e51377cc1f1d8288464ab110f6f786bb4c Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Thu, 23 Jul 2026 08:50:23 +0000 Subject: [PATCH 071/183] Pass single-token -D__bf16=uint16_t via per_file_copt to CUDA compilation units --- .bazelrc | 5 +++-- third_party/cuda_bf16_fix.h | 11 ----------- 2 files changed, 3 insertions(+), 13 deletions(-) delete mode 100644 third_party/cuda_bf16_fix.h diff --git a/.bazelrc b/.bazelrc index 10aa4ca7872..900a544d79a 100644 --- a/.bazelrc +++ b/.bazelrc @@ -31,8 +31,9 @@ common:cuda --repo_env=HERMETIC_NVSHMEM_VERSION="3.2.5" common:cuda --repo_env=HERMETIC_NCCL_VERSION="2.28.9" build:cuda --features=-layering_check build:cuda --copt=-w -build:cuda --copt=-include -build:cuda --copt=third_party/cuda_bf16_fix.h +build:cuda --per_file_copt=.*\.cu\.cc$@-D__bf16=uint16_t +build:cuda --per_file_copt=.*\.cu$@-D__bf16=uint16_t +build:cuda --per_file_copt=.*_cuda\.cc$@-D__bf16=uint16_t build:cuda_clang --action_env=GCC_HOST_COMPILER_PATH="/usr/bin/gcc-10" build:cuda_clang --action_env=CLANG_CUDA_COMPILER_PATH="/usr/lib/llvm-17/bin/clang" diff --git a/third_party/cuda_bf16_fix.h b/third_party/cuda_bf16_fix.h deleted file mode 100644 index d58b4d587d1..00000000000 --- a/third_party/cuda_bf16_fix.h +++ /dev/null @@ -1,11 +0,0 @@ -/* Copyright 2026 The TensorFlow Authors. All Rights Reserved. */ -#ifndef THIRD_PARTY_CUDA_BF16_FIX_H_ -#define THIRD_PARTY_CUDA_BF16_FIX_H_ - -#if !defined(__clang__) && defined(__GNUC__) -#ifndef __bf16 -typedef unsigned short __bf16; -#endif -#endif - -#endif // THIRD_PARTY_CUDA_BF16_FIX_H_ From 6f53abc62897a98d7d94731a86b31fd2ca0b11db Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Thu, 23 Jul 2026 09:10:22 +0000 Subject: [PATCH 072/183] Pass --cxxopt=-w and --nvcc_options=w under build:cuda to suppress C++ and NVCC warning errors in CUDA headers --- .bazelrc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.bazelrc b/.bazelrc index 900a544d79a..7e8a3eb0b3c 100644 --- a/.bazelrc +++ b/.bazelrc @@ -31,6 +31,8 @@ common:cuda --repo_env=HERMETIC_NVSHMEM_VERSION="3.2.5" common:cuda --repo_env=HERMETIC_NCCL_VERSION="2.28.9" build:cuda --features=-layering_check build:cuda --copt=-w +build:cuda --cxxopt=-w +build:cuda --nvcc_options=w build:cuda --per_file_copt=.*\.cu\.cc$@-D__bf16=uint16_t build:cuda --per_file_copt=.*\.cu$@-D__bf16=uint16_t build:cuda --per_file_copt=.*_cuda\.cc$@-D__bf16=uint16_t From 4f97c54aa5b11de573c534e07c723729d14193d4 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Thu, 23 Jul 2026 09:22:46 +0000 Subject: [PATCH 073/183] Fix Bazel NVCC option flag to --nvccopt=-w and add --copt=-Wno-error --cxxopt=-Wno-error --- .bazelrc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.bazelrc b/.bazelrc index 7e8a3eb0b3c..fea7b4c4467 100644 --- a/.bazelrc +++ b/.bazelrc @@ -32,7 +32,9 @@ common:cuda --repo_env=HERMETIC_NCCL_VERSION="2.28.9" build:cuda --features=-layering_check build:cuda --copt=-w build:cuda --cxxopt=-w -build:cuda --nvcc_options=w +build:cuda --nvccopt=-w +build:cuda --copt=-Wno-error +build:cuda --cxxopt=-Wno-error build:cuda --per_file_copt=.*\.cu\.cc$@-D__bf16=uint16_t build:cuda --per_file_copt=.*\.cu$@-D__bf16=uint16_t build:cuda --per_file_copt=.*_cuda\.cc$@-D__bf16=uint16_t From 3ca59447a1d517c602b0c7b17795464bb147b7db Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Thu, 23 Jul 2026 09:34:07 +0000 Subject: [PATCH 074/183] Pass -Wno-header-guard to suppress header guard warnings in CUPTI and CUDA headers --- .bazelrc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.bazelrc b/.bazelrc index fea7b4c4467..8a623ba804d 100644 --- a/.bazelrc +++ b/.bazelrc @@ -32,9 +32,10 @@ common:cuda --repo_env=HERMETIC_NCCL_VERSION="2.28.9" build:cuda --features=-layering_check build:cuda --copt=-w build:cuda --cxxopt=-w -build:cuda --nvccopt=-w build:cuda --copt=-Wno-error build:cuda --cxxopt=-Wno-error +build:cuda --copt=-Wno-header-guard +build:cuda --cxxopt=-Wno-header-guard build:cuda --per_file_copt=.*\.cu\.cc$@-D__bf16=uint16_t build:cuda --per_file_copt=.*\.cu$@-D__bf16=uint16_t build:cuda --per_file_copt=.*_cuda\.cc$@-D__bf16=uint16_t From 9c0a30ee94f4f15f9d43f4ddff904a9d3b97373e Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Thu, 23 Jul 2026 09:57:48 +0000 Subject: [PATCH 075/183] Add TensorFlow mirror URL fallback for rapidjson dependency in workspace.bzl --- tensorflow_serving/workspace.bzl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tensorflow_serving/workspace.bzl b/tensorflow_serving/workspace.bzl index d82da62bd2a..69de7ba66b4 100644 --- a/tensorflow_serving/workspace.bzl +++ b/tensorflow_serving/workspace.bzl @@ -51,7 +51,10 @@ def tf_serving_workspace(): # ===== RapidJSON (rapidjson.org) dependency ===== http_archive( name = "com_github_tencent_rapidjson", - url = "https://github.com/Tencent/rapidjson/archive/v1.1.0.zip", + urls = [ + "https://storage.googleapis.com/mirror.tensorflow.org/github.com/Tencent/rapidjson/archive/v1.1.0.zip", + "https://github.com/Tencent/rapidjson/archive/v1.1.0.zip", + ], sha256 = "8e00c38829d6785a2dfb951bb87c6974fa07dfe488aa5b25deec4b8bc0f6a3ab", strip_prefix = "rapidjson-1.1.0", build_file = "@//third_party/rapidjson:BUILD", From 5c38b0b0c3c6386d81f1823e4e65ba18ddd96393 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Thu, 23 Jul 2026 10:30:44 +0000 Subject: [PATCH 076/183] Pass TF_CUDA_FLAGS='--compiler-options -D__bf16=uint16_t' to forward -D__bf16=uint16_t through NVCC to GCC host compiler passes --- .bazelrc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.bazelrc b/.bazelrc index 8a623ba804d..09de1ab066c 100644 --- a/.bazelrc +++ b/.bazelrc @@ -29,6 +29,7 @@ common:cuda --repo_env=HERMETIC_CUDA_VERSION="12.2.0" common:cuda --repo_env=HERMETIC_CUDNN_VERSION="9.3.0" common:cuda --repo_env=HERMETIC_NVSHMEM_VERSION="3.2.5" common:cuda --repo_env=HERMETIC_NCCL_VERSION="2.28.9" +common:cuda --repo_env=TF_CUDA_FLAGS="--compiler-options -D__bf16=uint16_t" build:cuda --features=-layering_check build:cuda --copt=-w build:cuda --cxxopt=-w @@ -36,9 +37,6 @@ build:cuda --copt=-Wno-error build:cuda --cxxopt=-Wno-error build:cuda --copt=-Wno-header-guard build:cuda --cxxopt=-Wno-header-guard -build:cuda --per_file_copt=.*\.cu\.cc$@-D__bf16=uint16_t -build:cuda --per_file_copt=.*\.cu$@-D__bf16=uint16_t -build:cuda --per_file_copt=.*_cuda\.cc$@-D__bf16=uint16_t build:cuda_clang --action_env=GCC_HOST_COMPILER_PATH="/usr/bin/gcc-10" build:cuda_clang --action_env=CLANG_CUDA_COMPILER_PATH="/usr/lib/llvm-17/bin/clang" From f45fe8808ba1421244caab881fee9aed6ab542b7 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Thu, 23 Jul 2026 11:00:19 +0000 Subject: [PATCH 077/183] Pass TF_CUDA_FLAGS='-D__bf16=uint16_t' directly to NVCC to cover CUDA device cicc frontend and host passes --- .bazelrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.bazelrc b/.bazelrc index 09de1ab066c..f12b770c3bf 100644 --- a/.bazelrc +++ b/.bazelrc @@ -29,7 +29,7 @@ common:cuda --repo_env=HERMETIC_CUDA_VERSION="12.2.0" common:cuda --repo_env=HERMETIC_CUDNN_VERSION="9.3.0" common:cuda --repo_env=HERMETIC_NVSHMEM_VERSION="3.2.5" common:cuda --repo_env=HERMETIC_NCCL_VERSION="2.28.9" -common:cuda --repo_env=TF_CUDA_FLAGS="--compiler-options -D__bf16=uint16_t" +common:cuda --repo_env=TF_CUDA_FLAGS="-D__bf16=uint16_t" build:cuda --features=-layering_check build:cuda --copt=-w build:cuda --cxxopt=-w From a2f2445596653bd148290bdbf0cd9a70e145adfc Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Thu, 23 Jul 2026 11:30:20 +0000 Subject: [PATCH 078/183] Pass --copt=-D__bf16=uint16_t and --cxxopt=-D__bf16=uint16_t under build:cuda to define __bf16 globally for all CUDA compilation passes --- .bazelrc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.bazelrc b/.bazelrc index f12b770c3bf..ea76f5b84bf 100644 --- a/.bazelrc +++ b/.bazelrc @@ -29,7 +29,6 @@ common:cuda --repo_env=HERMETIC_CUDA_VERSION="12.2.0" common:cuda --repo_env=HERMETIC_CUDNN_VERSION="9.3.0" common:cuda --repo_env=HERMETIC_NVSHMEM_VERSION="3.2.5" common:cuda --repo_env=HERMETIC_NCCL_VERSION="2.28.9" -common:cuda --repo_env=TF_CUDA_FLAGS="-D__bf16=uint16_t" build:cuda --features=-layering_check build:cuda --copt=-w build:cuda --cxxopt=-w @@ -37,6 +36,8 @@ build:cuda --copt=-Wno-error build:cuda --cxxopt=-Wno-error build:cuda --copt=-Wno-header-guard build:cuda --cxxopt=-Wno-header-guard +build:cuda --copt=-D__bf16=uint16_t +build:cuda --cxxopt=-D__bf16=uint16_t build:cuda_clang --action_env=GCC_HOST_COMPILER_PATH="/usr/bin/gcc-10" build:cuda_clang --action_env=CLANG_CUDA_COMPILER_PATH="/usr/lib/llvm-17/bin/clang" From b182d878055d1c90b0095007253e07dcd5fe7f67 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Thu, 23 Jul 2026 11:50:22 +0000 Subject: [PATCH 079/183] Use double backslashes in .bazelrc per_file_copt regexes so Bazel matches .cu, .cu.cc, and _cuda.cc files properly --- .bazelrc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.bazelrc b/.bazelrc index ea76f5b84bf..3128e4bf510 100644 --- a/.bazelrc +++ b/.bazelrc @@ -36,8 +36,9 @@ build:cuda --copt=-Wno-error build:cuda --cxxopt=-Wno-error build:cuda --copt=-Wno-header-guard build:cuda --cxxopt=-Wno-header-guard -build:cuda --copt=-D__bf16=uint16_t -build:cuda --cxxopt=-D__bf16=uint16_t +build:cuda --per_file_copt=.*\\.cu\\.cc$@-D__bf16=uint16_t +build:cuda --per_file_copt=.*\\.cu$@-D__bf16=uint16_t +build:cuda --per_file_copt=.*_cuda\\.cc$@-D__bf16=uint16_t build:cuda_clang --action_env=GCC_HOST_COMPILER_PATH="/usr/bin/gcc-10" build:cuda_clang --action_env=CLANG_CUDA_COMPILER_PATH="/usr/lib/llvm-17/bin/clang" From c76b51a1a628cfb9a90178e7e853b80e47310e01 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Thu, 23 Jul 2026 15:46:16 +0000 Subject: [PATCH 080/183] Pre-include absolute system header /usr/local/include/cuda_bf16_fix.h to typedef __bf16 as uint16_t for GCC 10 while preserving Clang 18 native __bf16 support --- .bazelrc | 5 ++--- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.bazelrc b/.bazelrc index 3128e4bf510..59be823c2fb 100644 --- a/.bazelrc +++ b/.bazelrc @@ -36,9 +36,8 @@ build:cuda --copt=-Wno-error build:cuda --cxxopt=-Wno-error build:cuda --copt=-Wno-header-guard build:cuda --cxxopt=-Wno-header-guard -build:cuda --per_file_copt=.*\\.cu\\.cc$@-D__bf16=uint16_t -build:cuda --per_file_copt=.*\\.cu$@-D__bf16=uint16_t -build:cuda --per_file_copt=.*_cuda\\.cc$@-D__bf16=uint16_t +build:cuda --copt=-include/usr/local/include/cuda_bf16_fix.h +build:cuda --cxxopt=-include/usr/local/include/cuda_bf16_fix.h build:cuda_clang --action_env=GCC_HOST_COMPILER_PATH="/usr/bin/gcc-10" build:cuda_clang --action_env=CLANG_CUDA_COMPILER_PATH="/usr/lib/llvm-17/bin/clang" diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 3af4b5215cb..2235b7582f7 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -142,7 +142,8 @@ WORKDIR / RUN mkdir /usr/lib/x86_64-linux-gnu/include/ && \ ln -s /usr/include/cudnn.h /usr/local/cuda/include/cudnn.h && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so /usr/local/cuda/lib64/libcudnn.so && \ - ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so.${TF_CUDNN_VERSION} /usr/local/cuda/lib64/libcudnn.so.${TF_CUDNN_VERSION} + ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so.${TF_CUDNN_VERSION} /usr/local/cuda/lib64/libcudnn.so.${TF_CUDNN_VERSION} && \ + printf '#ifndef CUDA_BF16_FIX_H_\n#define CUDA_BF16_FIX_H_\n#if !defined(__clang__) && defined(__GNUC__)\n#ifndef __bf16\ntypedef unsigned short __bf16;\n#endif\n#endif\n#endif\n' > /usr/local/include/cuda_bf16_fix.h # For backward compatibility we need this line. After 1.13 we can safely remove # it. From 7bb32cfc6b53a5c569828687ac9d36935ba0ef5f Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Thu, 23 Jul 2026 16:10:28 +0000 Subject: [PATCH 081/183] Add -isystem/usr/local/include to Bazel copt/cxxopt to register /usr/local/include as a system include directory --- .bazelrc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.bazelrc b/.bazelrc index 59be823c2fb..54c8636fc2e 100644 --- a/.bazelrc +++ b/.bazelrc @@ -36,6 +36,8 @@ build:cuda --copt=-Wno-error build:cuda --cxxopt=-Wno-error build:cuda --copt=-Wno-header-guard build:cuda --cxxopt=-Wno-header-guard +build:cuda --copt=-isystem/usr/local/include +build:cuda --cxxopt=-isystem/usr/local/include build:cuda --copt=-include/usr/local/include/cuda_bf16_fix.h build:cuda --cxxopt=-include/usr/local/include/cuda_bf16_fix.h build:cuda_clang --action_env=GCC_HOST_COMPILER_PATH="/usr/bin/gcc-10" From 329e25101be9c52c9cacc6dee254e02a2eb3737e Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Thu, 23 Jul 2026 16:40:54 +0000 Subject: [PATCH 082/183] Place cuda_bf16_fix.h inside GCC 10 builtin include directory /usr/lib/gcc/x86_64-linux-gnu/10/include to satisfy Bazel toolchain builtin include checks --- .bazelrc | 6 ++---- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.bazelrc b/.bazelrc index 54c8636fc2e..0bc6602f269 100644 --- a/.bazelrc +++ b/.bazelrc @@ -36,10 +36,8 @@ build:cuda --copt=-Wno-error build:cuda --cxxopt=-Wno-error build:cuda --copt=-Wno-header-guard build:cuda --cxxopt=-Wno-header-guard -build:cuda --copt=-isystem/usr/local/include -build:cuda --cxxopt=-isystem/usr/local/include -build:cuda --copt=-include/usr/local/include/cuda_bf16_fix.h -build:cuda --cxxopt=-include/usr/local/include/cuda_bf16_fix.h +build:cuda --copt=-includecuda_bf16_fix.h +build:cuda --cxxopt=-includecuda_bf16_fix.h build:cuda_clang --action_env=GCC_HOST_COMPILER_PATH="/usr/bin/gcc-10" build:cuda_clang --action_env=CLANG_CUDA_COMPILER_PATH="/usr/lib/llvm-17/bin/clang" diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 2235b7582f7..68506b9a9d3 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -143,7 +143,7 @@ RUN mkdir /usr/lib/x86_64-linux-gnu/include/ && \ ln -s /usr/include/cudnn.h /usr/local/cuda/include/cudnn.h && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so /usr/local/cuda/lib64/libcudnn.so && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so.${TF_CUDNN_VERSION} /usr/local/cuda/lib64/libcudnn.so.${TF_CUDNN_VERSION} && \ - printf '#ifndef CUDA_BF16_FIX_H_\n#define CUDA_BF16_FIX_H_\n#if !defined(__clang__) && defined(__GNUC__)\n#ifndef __bf16\ntypedef unsigned short __bf16;\n#endif\n#endif\n#endif\n' > /usr/local/include/cuda_bf16_fix.h + printf '#ifndef CUDA_BF16_FIX_H_\n#define CUDA_BF16_FIX_H_\n#if !defined(__clang__) && defined(__GNUC__)\n#ifndef __bf16\ntypedef unsigned short __bf16;\n#endif\n#endif\n#endif\n' > /usr/lib/gcc/x86_64-linux-gnu/10/include/cuda_bf16_fix.h # For backward compatibility we need this line. After 1.13 we can safely remove # it. From fa3208aa5e4f70c9c3eb5aa6b2ad610ed234ec2b Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Thu, 23 Jul 2026 16:56:46 +0000 Subject: [PATCH 083/183] Place cuda_bf16_fix.h in /usr/include to ensure guaranteed directory existence and builtin toolchain inclusion --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 68506b9a9d3..99a990b26ee 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -143,7 +143,7 @@ RUN mkdir /usr/lib/x86_64-linux-gnu/include/ && \ ln -s /usr/include/cudnn.h /usr/local/cuda/include/cudnn.h && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so /usr/local/cuda/lib64/libcudnn.so && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so.${TF_CUDNN_VERSION} /usr/local/cuda/lib64/libcudnn.so.${TF_CUDNN_VERSION} && \ - printf '#ifndef CUDA_BF16_FIX_H_\n#define CUDA_BF16_FIX_H_\n#if !defined(__clang__) && defined(__GNUC__)\n#ifndef __bf16\ntypedef unsigned short __bf16;\n#endif\n#endif\n#endif\n' > /usr/lib/gcc/x86_64-linux-gnu/10/include/cuda_bf16_fix.h + printf '#ifndef CUDA_BF16_FIX_H_\n#define CUDA_BF16_FIX_H_\n#if !defined(__clang__) && defined(__GNUC__)\n#ifndef __bf16\ntypedef unsigned short __bf16;\n#endif\n#endif\n#endif\n' > /usr/include/cuda_bf16_fix.h # For backward compatibility we need this line. After 1.13 we can safely remove # it. From 45715d989afcb357558165f016cb86dc4c1eb0f1 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Thu, 23 Jul 2026 17:37:32 +0000 Subject: [PATCH 084/183] Fix compiler pre-include flag syntax to -include=cuda_bf16_fix.h in .bazelrc --- .bazelrc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.bazelrc b/.bazelrc index 0bc6602f269..8253baf2ecf 100644 --- a/.bazelrc +++ b/.bazelrc @@ -36,8 +36,8 @@ build:cuda --copt=-Wno-error build:cuda --cxxopt=-Wno-error build:cuda --copt=-Wno-header-guard build:cuda --cxxopt=-Wno-header-guard -build:cuda --copt=-includecuda_bf16_fix.h -build:cuda --cxxopt=-includecuda_bf16_fix.h +build:cuda --copt=-include=cuda_bf16_fix.h +build:cuda --cxxopt=-include=cuda_bf16_fix.h build:cuda_clang --action_env=GCC_HOST_COMPILER_PATH="/usr/bin/gcc-10" build:cuda_clang --action_env=CLANG_CUDA_COMPILER_PATH="/usr/lib/llvm-17/bin/clang" From 6bd307b5134871ee31dc9c6c570ad63f69311ee9 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Thu, 23 Jul 2026 18:19:14 +0000 Subject: [PATCH 085/183] Update /usr/include/cuda_bf16_fix.h to typedef __bf16 as unsigned short whenever __bf16 is undefined --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 99a990b26ee..35b15d059a1 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -143,7 +143,7 @@ RUN mkdir /usr/lib/x86_64-linux-gnu/include/ && \ ln -s /usr/include/cudnn.h /usr/local/cuda/include/cudnn.h && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so /usr/local/cuda/lib64/libcudnn.so && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so.${TF_CUDNN_VERSION} /usr/local/cuda/lib64/libcudnn.so.${TF_CUDNN_VERSION} && \ - printf '#ifndef CUDA_BF16_FIX_H_\n#define CUDA_BF16_FIX_H_\n#if !defined(__clang__) && defined(__GNUC__)\n#ifndef __bf16\ntypedef unsigned short __bf16;\n#endif\n#endif\n#endif\n' > /usr/include/cuda_bf16_fix.h + printf '#ifndef CUDA_BF16_FIX_H_\n#define CUDA_BF16_FIX_H_\n#ifndef __bf16\ntypedef unsigned short __bf16;\n#endif\n#endif\n' > /usr/include/cuda_bf16_fix.h # For backward compatibility we need this line. After 1.13 we can safely remove # it. From 57a2d17267944142f20c2cc3d5a377135ac41efa Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Thu, 23 Jul 2026 19:04:53 +0000 Subject: [PATCH 086/183] Pass absolute path -include=/usr/include/cuda_bf16_fix.h to bypass -nostdinc include search path restrictions --- .bazelrc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.bazelrc b/.bazelrc index 8253baf2ecf..90fe1383447 100644 --- a/.bazelrc +++ b/.bazelrc @@ -36,8 +36,8 @@ build:cuda --copt=-Wno-error build:cuda --cxxopt=-Wno-error build:cuda --copt=-Wno-header-guard build:cuda --cxxopt=-Wno-header-guard -build:cuda --copt=-include=cuda_bf16_fix.h -build:cuda --cxxopt=-include=cuda_bf16_fix.h +build:cuda --copt=-include=/usr/include/cuda_bf16_fix.h +build:cuda --cxxopt=-include=/usr/include/cuda_bf16_fix.h build:cuda_clang --action_env=GCC_HOST_COMPILER_PATH="/usr/bin/gcc-10" build:cuda_clang --action_env=CLANG_CUDA_COMPILER_PATH="/usr/lib/llvm-17/bin/clang" From a63c4bf0e4ba7de6dceee187346cb98b6911d0e4 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Thu, 23 Jul 2026 20:42:53 +0000 Subject: [PATCH 087/183] Add third_party/cuda_bf16_fix.h to workspace and pre-include it via relative path in .bazelrc --- .bazelrc | 4 +-- .../tools/docker/Dockerfile.devel-gpu | 3 +-- third_party/cuda_bf16_fix.h | 26 +++++++++++++++++++ 3 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 third_party/cuda_bf16_fix.h diff --git a/.bazelrc b/.bazelrc index 90fe1383447..2895fb8c176 100644 --- a/.bazelrc +++ b/.bazelrc @@ -36,8 +36,8 @@ build:cuda --copt=-Wno-error build:cuda --cxxopt=-Wno-error build:cuda --copt=-Wno-header-guard build:cuda --cxxopt=-Wno-header-guard -build:cuda --copt=-include=/usr/include/cuda_bf16_fix.h -build:cuda --cxxopt=-include=/usr/include/cuda_bf16_fix.h +build:cuda --copt=-include=third_party/cuda_bf16_fix.h +build:cuda --cxxopt=-include=third_party/cuda_bf16_fix.h build:cuda_clang --action_env=GCC_HOST_COMPILER_PATH="/usr/bin/gcc-10" build:cuda_clang --action_env=CLANG_CUDA_COMPILER_PATH="/usr/lib/llvm-17/bin/clang" diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 35b15d059a1..3af4b5215cb 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -142,8 +142,7 @@ WORKDIR / RUN mkdir /usr/lib/x86_64-linux-gnu/include/ && \ ln -s /usr/include/cudnn.h /usr/local/cuda/include/cudnn.h && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so /usr/local/cuda/lib64/libcudnn.so && \ - ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so.${TF_CUDNN_VERSION} /usr/local/cuda/lib64/libcudnn.so.${TF_CUDNN_VERSION} && \ - printf '#ifndef CUDA_BF16_FIX_H_\n#define CUDA_BF16_FIX_H_\n#ifndef __bf16\ntypedef unsigned short __bf16;\n#endif\n#endif\n' > /usr/include/cuda_bf16_fix.h + ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so.${TF_CUDNN_VERSION} /usr/local/cuda/lib64/libcudnn.so.${TF_CUDNN_VERSION} # For backward compatibility we need this line. After 1.13 we can safely remove # it. diff --git a/third_party/cuda_bf16_fix.h b/third_party/cuda_bf16_fix.h new file mode 100644 index 00000000000..26630527746 --- /dev/null +++ b/third_party/cuda_bf16_fix.h @@ -0,0 +1,26 @@ +/* Copyright 2026 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_SERVING_THIRD_PARTY_CUDA_BF16_FIX_H_ +#define TENSORFLOW_SERVING_THIRD_PARTY_CUDA_BF16_FIX_H_ + +// Workaround for CUDA 12.2 / LLVM 18 / GCC 10 header compatibility issue where +// __bf16 is used in without a definition when compiled in x86 +// CUDA mode. +#ifndef __bf16 +typedef unsigned short __bf16; +#endif + +#endif // TENSORFLOW_SERVING_THIRD_PARTY_CUDA_BF16_FIX_H_ From f5500657def05325476f21e46c7332b821d74f30 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Thu, 23 Jul 2026 21:32:38 +0000 Subject: [PATCH 088/183] Fix Bazel pre-include flag formatting and handle Clang builtin __bf16 keyword --- .bazelrc | 6 ++++-- third_party/cuda_bf16_fix.h | 8 +++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.bazelrc b/.bazelrc index 2895fb8c176..ba79cfc7631 100644 --- a/.bazelrc +++ b/.bazelrc @@ -36,8 +36,10 @@ build:cuda --copt=-Wno-error build:cuda --cxxopt=-Wno-error build:cuda --copt=-Wno-header-guard build:cuda --cxxopt=-Wno-header-guard -build:cuda --copt=-include=third_party/cuda_bf16_fix.h -build:cuda --cxxopt=-include=third_party/cuda_bf16_fix.h +build:cuda --copt=-include +build:cuda --copt=third_party/cuda_bf16_fix.h +build:cuda --cxxopt=-include +build:cuda --cxxopt=third_party/cuda_bf16_fix.h build:cuda_clang --action_env=GCC_HOST_COMPILER_PATH="/usr/bin/gcc-10" build:cuda_clang --action_env=CLANG_CUDA_COMPILER_PATH="/usr/lib/llvm-17/bin/clang" diff --git a/third_party/cuda_bf16_fix.h b/third_party/cuda_bf16_fix.h index 26630527746..2fe76559437 100644 --- a/third_party/cuda_bf16_fix.h +++ b/third_party/cuda_bf16_fix.h @@ -16,11 +16,13 @@ limitations under the License. #ifndef TENSORFLOW_SERVING_THIRD_PARTY_CUDA_BF16_FIX_H_ #define TENSORFLOW_SERVING_THIRD_PARTY_CUDA_BF16_FIX_H_ -// Workaround for CUDA 12.2 / LLVM 18 / GCC 10 header compatibility issue where -// __bf16 is used in without a definition when compiled in x86 -// CUDA mode. +// GCC 10 host compiler fix for CUDA 12.2 / LLVM 18 header compatibility. +// In GCC 10, __bf16 is not a builtin type keyword, so lines 47-48 fail. +// In Clang 18, __bf16 is already a builtin primitive type keyword. +#if !defined(__clang__) && defined(__GNUC__) #ifndef __bf16 typedef unsigned short __bf16; #endif +#endif #endif // TENSORFLOW_SERVING_THIRD_PARTY_CUDA_BF16_FIX_H_ From 14d8916a42e9ad7f5608ad4e71d0c6ae09ec222f Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Thu, 23 Jul 2026 22:28:42 +0000 Subject: [PATCH 089/183] Pre-include /usr/include/cuda_bf16_fix.h with separate -include flags to satisfy system header undeclared inclusion rules and compiler flag parsing --- .bazelrc | 4 +-- .../tools/docker/Dockerfile.devel-gpu | 3 +- third_party/cuda_bf16_fix.h | 28 ------------------- 3 files changed, 4 insertions(+), 31 deletions(-) delete mode 100644 third_party/cuda_bf16_fix.h diff --git a/.bazelrc b/.bazelrc index ba79cfc7631..63253a0c8ab 100644 --- a/.bazelrc +++ b/.bazelrc @@ -37,9 +37,9 @@ build:cuda --cxxopt=-Wno-error build:cuda --copt=-Wno-header-guard build:cuda --cxxopt=-Wno-header-guard build:cuda --copt=-include -build:cuda --copt=third_party/cuda_bf16_fix.h +build:cuda --copt=/usr/include/cuda_bf16_fix.h build:cuda --cxxopt=-include -build:cuda --cxxopt=third_party/cuda_bf16_fix.h +build:cuda --cxxopt=/usr/include/cuda_bf16_fix.h build:cuda_clang --action_env=GCC_HOST_COMPILER_PATH="/usr/bin/gcc-10" build:cuda_clang --action_env=CLANG_CUDA_COMPILER_PATH="/usr/lib/llvm-17/bin/clang" diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 3af4b5215cb..99a990b26ee 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -142,7 +142,8 @@ WORKDIR / RUN mkdir /usr/lib/x86_64-linux-gnu/include/ && \ ln -s /usr/include/cudnn.h /usr/local/cuda/include/cudnn.h && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so /usr/local/cuda/lib64/libcudnn.so && \ - ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so.${TF_CUDNN_VERSION} /usr/local/cuda/lib64/libcudnn.so.${TF_CUDNN_VERSION} + ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so.${TF_CUDNN_VERSION} /usr/local/cuda/lib64/libcudnn.so.${TF_CUDNN_VERSION} && \ + printf '#ifndef CUDA_BF16_FIX_H_\n#define CUDA_BF16_FIX_H_\n#if !defined(__clang__) && defined(__GNUC__)\n#ifndef __bf16\ntypedef unsigned short __bf16;\n#endif\n#endif\n#endif\n' > /usr/include/cuda_bf16_fix.h # For backward compatibility we need this line. After 1.13 we can safely remove # it. diff --git a/third_party/cuda_bf16_fix.h b/third_party/cuda_bf16_fix.h deleted file mode 100644 index 2fe76559437..00000000000 --- a/third_party/cuda_bf16_fix.h +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright 2026 The TensorFlow Authors. All Rights Reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -==============================================================================*/ - -#ifndef TENSORFLOW_SERVING_THIRD_PARTY_CUDA_BF16_FIX_H_ -#define TENSORFLOW_SERVING_THIRD_PARTY_CUDA_BF16_FIX_H_ - -// GCC 10 host compiler fix for CUDA 12.2 / LLVM 18 header compatibility. -// In GCC 10, __bf16 is not a builtin type keyword, so lines 47-48 fail. -// In Clang 18, __bf16 is already a builtin primitive type keyword. -#if !defined(__clang__) && defined(__GNUC__) -#ifndef __bf16 -typedef unsigned short __bf16; -#endif -#endif - -#endif // TENSORFLOW_SERVING_THIRD_PARTY_CUDA_BF16_FIX_H_ From d5b624dccfeade79393ce34336d600a48bbd3905 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Thu, 23 Jul 2026 22:50:40 +0000 Subject: [PATCH 090/183] Place cuda_bf16_fix.h inside GCC toolchain builtin include path /usr/lib/gcc/x86_64-linux-gnu/10/include/ and pre-include via cuda_bf16_fix.h --- .bazelrc | 4 ++-- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.bazelrc b/.bazelrc index 63253a0c8ab..658661a6b08 100644 --- a/.bazelrc +++ b/.bazelrc @@ -37,9 +37,9 @@ build:cuda --cxxopt=-Wno-error build:cuda --copt=-Wno-header-guard build:cuda --cxxopt=-Wno-header-guard build:cuda --copt=-include -build:cuda --copt=/usr/include/cuda_bf16_fix.h +build:cuda --copt=cuda_bf16_fix.h build:cuda --cxxopt=-include -build:cuda --cxxopt=/usr/include/cuda_bf16_fix.h +build:cuda --cxxopt=cuda_bf16_fix.h build:cuda_clang --action_env=GCC_HOST_COMPILER_PATH="/usr/bin/gcc-10" build:cuda_clang --action_env=CLANG_CUDA_COMPILER_PATH="/usr/lib/llvm-17/bin/clang" diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 99a990b26ee..dc33445f1bb 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -139,11 +139,11 @@ ENV LD_LIBRARY_PATH /usr/local/cuda/extras/CUPTI/lib64:/usr/local/cuda/lib64:/us # Fix paths so that CUDNN can be found: https://github.com/tensorflow/tensorflow/issues/8264 WORKDIR / -RUN mkdir /usr/lib/x86_64-linux-gnu/include/ && \ +RUN mkdir -p /usr/lib/gcc/x86_64-linux-gnu/10/include/ /usr/lib/x86_64-linux-gnu/include/ && \ ln -s /usr/include/cudnn.h /usr/local/cuda/include/cudnn.h && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so /usr/local/cuda/lib64/libcudnn.so && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so.${TF_CUDNN_VERSION} /usr/local/cuda/lib64/libcudnn.so.${TF_CUDNN_VERSION} && \ - printf '#ifndef CUDA_BF16_FIX_H_\n#define CUDA_BF16_FIX_H_\n#if !defined(__clang__) && defined(__GNUC__)\n#ifndef __bf16\ntypedef unsigned short __bf16;\n#endif\n#endif\n#endif\n' > /usr/include/cuda_bf16_fix.h + printf '#ifndef CUDA_BF16_FIX_H_\n#define CUDA_BF16_FIX_H_\n#if !defined(__clang__) && defined(__GNUC__)\n#ifndef __bf16\ntypedef unsigned short __bf16;\n#endif\n#endif\n#endif\n' > /usr/lib/gcc/x86_64-linux-gnu/10/include/cuda_bf16_fix.h # For backward compatibility we need this line. After 1.13 we can safely remove # it. From 194c557e4461404f420e05adffbec865e93b6679 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Thu, 23 Jul 2026 23:45:45 +0000 Subject: [PATCH 091/183] Enable __bf16 typedef for both Clang CUDA and GCC host compilation passes when __bf16 is undefined --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index dc33445f1bb..29904b059c5 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -143,7 +143,7 @@ RUN mkdir -p /usr/lib/gcc/x86_64-linux-gnu/10/include/ /usr/lib/x86_64-linux-gnu ln -s /usr/include/cudnn.h /usr/local/cuda/include/cudnn.h && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so /usr/local/cuda/lib64/libcudnn.so && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so.${TF_CUDNN_VERSION} /usr/local/cuda/lib64/libcudnn.so.${TF_CUDNN_VERSION} && \ - printf '#ifndef CUDA_BF16_FIX_H_\n#define CUDA_BF16_FIX_H_\n#if !defined(__clang__) && defined(__GNUC__)\n#ifndef __bf16\ntypedef unsigned short __bf16;\n#endif\n#endif\n#endif\n' > /usr/lib/gcc/x86_64-linux-gnu/10/include/cuda_bf16_fix.h + printf '#ifndef CUDA_BF16_FIX_H_\n#define CUDA_BF16_FIX_H_\n#ifndef __bf16\ntypedef unsigned short __bf16;\n#endif\n#endif\n' > /usr/lib/gcc/x86_64-linux-gnu/10/include/cuda_bf16_fix.h # For backward compatibility we need this line. After 1.13 we can safely remove # it. From 393ad6a163de29df4f94d3b6accc2e2341f43bd3 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Fri, 24 Jul 2026 00:23:54 +0000 Subject: [PATCH 092/183] Pass -isystem/usr/include in .bazelrc to allow Clang -nostdinc CUDA passes to resolve cuda_bf16_fix.h from /usr/include --- .bazelrc | 2 ++ tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.bazelrc b/.bazelrc index 658661a6b08..de412774b73 100644 --- a/.bazelrc +++ b/.bazelrc @@ -36,6 +36,8 @@ build:cuda --copt=-Wno-error build:cuda --cxxopt=-Wno-error build:cuda --copt=-Wno-header-guard build:cuda --cxxopt=-Wno-header-guard +build:cuda --copt=-isystem/usr/include +build:cuda --cxxopt=-isystem/usr/include build:cuda --copt=-include build:cuda --copt=cuda_bf16_fix.h build:cuda --cxxopt=-include diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 29904b059c5..2544a92ff02 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -143,7 +143,7 @@ RUN mkdir -p /usr/lib/gcc/x86_64-linux-gnu/10/include/ /usr/lib/x86_64-linux-gnu ln -s /usr/include/cudnn.h /usr/local/cuda/include/cudnn.h && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so /usr/local/cuda/lib64/libcudnn.so && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so.${TF_CUDNN_VERSION} /usr/local/cuda/lib64/libcudnn.so.${TF_CUDNN_VERSION} && \ - printf '#ifndef CUDA_BF16_FIX_H_\n#define CUDA_BF16_FIX_H_\n#ifndef __bf16\ntypedef unsigned short __bf16;\n#endif\n#endif\n' > /usr/lib/gcc/x86_64-linux-gnu/10/include/cuda_bf16_fix.h + printf '#ifndef CUDA_BF16_FIX_H_\n#define CUDA_BF16_FIX_H_\n#ifndef __bf16\ntypedef unsigned short __bf16;\n#endif\n#endif\n' > /usr/include/cuda_bf16_fix.h # For backward compatibility we need this line. After 1.13 we can safely remove # it. From a3807182fce658e567670151059ab217039301e8 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Fri, 24 Jul 2026 00:50:26 +0000 Subject: [PATCH 093/183] Place cuda_bf16_fix.h in GCC toolchain include path /usr/lib/gcc/x86_64-linux-gnu/10/include/ and remove -isystem/usr/include to avoid sandbox root checks --- .bazelrc | 2 -- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.bazelrc b/.bazelrc index de412774b73..658661a6b08 100644 --- a/.bazelrc +++ b/.bazelrc @@ -36,8 +36,6 @@ build:cuda --copt=-Wno-error build:cuda --cxxopt=-Wno-error build:cuda --copt=-Wno-header-guard build:cuda --cxxopt=-Wno-header-guard -build:cuda --copt=-isystem/usr/include -build:cuda --cxxopt=-isystem/usr/include build:cuda --copt=-include build:cuda --copt=cuda_bf16_fix.h build:cuda --cxxopt=-include diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 2544a92ff02..29904b059c5 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -143,7 +143,7 @@ RUN mkdir -p /usr/lib/gcc/x86_64-linux-gnu/10/include/ /usr/lib/x86_64-linux-gnu ln -s /usr/include/cudnn.h /usr/local/cuda/include/cudnn.h && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so /usr/local/cuda/lib64/libcudnn.so && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so.${TF_CUDNN_VERSION} /usr/local/cuda/lib64/libcudnn.so.${TF_CUDNN_VERSION} && \ - printf '#ifndef CUDA_BF16_FIX_H_\n#define CUDA_BF16_FIX_H_\n#ifndef __bf16\ntypedef unsigned short __bf16;\n#endif\n#endif\n' > /usr/include/cuda_bf16_fix.h + printf '#ifndef CUDA_BF16_FIX_H_\n#define CUDA_BF16_FIX_H_\n#ifndef __bf16\ntypedef unsigned short __bf16;\n#endif\n#endif\n' > /usr/lib/gcc/x86_64-linux-gnu/10/include/cuda_bf16_fix.h # For backward compatibility we need this line. After 1.13 we can safely remove # it. From 84a7ef1ed272ec46d76cf5df47b4c9593e6a4c7b Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Fri, 24 Jul 2026 01:33:08 +0000 Subject: [PATCH 094/183] Pass -D__bf16=unsigned short in .bazelrc to define __bf16 preprocessor macro across all C++ and CUDA compilation passes --- .bazelrc | 6 ++---- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 3 +-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.bazelrc b/.bazelrc index 658661a6b08..aad9dabb15a 100644 --- a/.bazelrc +++ b/.bazelrc @@ -36,10 +36,8 @@ build:cuda --copt=-Wno-error build:cuda --cxxopt=-Wno-error build:cuda --copt=-Wno-header-guard build:cuda --cxxopt=-Wno-header-guard -build:cuda --copt=-include -build:cuda --copt=cuda_bf16_fix.h -build:cuda --cxxopt=-include -build:cuda --cxxopt=cuda_bf16_fix.h +build:cuda --copt="-D__bf16=unsigned short" +build:cuda --cxxopt="-D__bf16=unsigned short" build:cuda_clang --action_env=GCC_HOST_COMPILER_PATH="/usr/bin/gcc-10" build:cuda_clang --action_env=CLANG_CUDA_COMPILER_PATH="/usr/lib/llvm-17/bin/clang" diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 29904b059c5..8a6a8684e43 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -142,8 +142,7 @@ WORKDIR / RUN mkdir -p /usr/lib/gcc/x86_64-linux-gnu/10/include/ /usr/lib/x86_64-linux-gnu/include/ && \ ln -s /usr/include/cudnn.h /usr/local/cuda/include/cudnn.h && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so /usr/local/cuda/lib64/libcudnn.so && \ - ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so.${TF_CUDNN_VERSION} /usr/local/cuda/lib64/libcudnn.so.${TF_CUDNN_VERSION} && \ - printf '#ifndef CUDA_BF16_FIX_H_\n#define CUDA_BF16_FIX_H_\n#ifndef __bf16\ntypedef unsigned short __bf16;\n#endif\n#endif\n' > /usr/lib/gcc/x86_64-linux-gnu/10/include/cuda_bf16_fix.h + ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so.${TF_CUDNN_VERSION} /usr/local/cuda/lib64/libcudnn.so.${TF_CUDNN_VERSION} # For backward compatibility we need this line. After 1.13 we can safely remove # it. From 667be82ef3a28a0fdc6b449152f8fcb9a9d4f340 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Fri, 24 Jul 2026 02:04:01 +0000 Subject: [PATCH 095/183] Place cuda_bf16_fix.h in CUDA include directory /usr/local/cuda/include/ to ensure Clang -nostdinc passes find it via -isystem --- .bazelrc | 6 ++++-- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.bazelrc b/.bazelrc index aad9dabb15a..658661a6b08 100644 --- a/.bazelrc +++ b/.bazelrc @@ -36,8 +36,10 @@ build:cuda --copt=-Wno-error build:cuda --cxxopt=-Wno-error build:cuda --copt=-Wno-header-guard build:cuda --cxxopt=-Wno-header-guard -build:cuda --copt="-D__bf16=unsigned short" -build:cuda --cxxopt="-D__bf16=unsigned short" +build:cuda --copt=-include +build:cuda --copt=cuda_bf16_fix.h +build:cuda --cxxopt=-include +build:cuda --cxxopt=cuda_bf16_fix.h build:cuda_clang --action_env=GCC_HOST_COMPILER_PATH="/usr/bin/gcc-10" build:cuda_clang --action_env=CLANG_CUDA_COMPILER_PATH="/usr/lib/llvm-17/bin/clang" diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 8a6a8684e43..bab4d3c3085 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -139,10 +139,11 @@ ENV LD_LIBRARY_PATH /usr/local/cuda/extras/CUPTI/lib64:/usr/local/cuda/lib64:/us # Fix paths so that CUDNN can be found: https://github.com/tensorflow/tensorflow/issues/8264 WORKDIR / -RUN mkdir -p /usr/lib/gcc/x86_64-linux-gnu/10/include/ /usr/lib/x86_64-linux-gnu/include/ && \ +RUN mkdir -p /usr/lib/x86_64-linux-gnu/include/ && \ ln -s /usr/include/cudnn.h /usr/local/cuda/include/cudnn.h && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so /usr/local/cuda/lib64/libcudnn.so && \ - ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so.${TF_CUDNN_VERSION} /usr/local/cuda/lib64/libcudnn.so.${TF_CUDNN_VERSION} + ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so.${TF_CUDNN_VERSION} /usr/local/cuda/lib64/libcudnn.so.${TF_CUDNN_VERSION} && \ + printf '#ifndef CUDA_BF16_FIX_H_\n#define CUDA_BF16_FIX_H_\n#ifndef __bf16\ntypedef unsigned short __bf16;\n#endif\n#endif\n' > /usr/local/cuda/include/cuda_bf16_fix.h # For backward compatibility we need this line. After 1.13 we can safely remove # it. From 4a62802ba91831c43839f95c059f28a62cb880a9 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Fri, 24 Jul 2026 02:42:57 +0000 Subject: [PATCH 096/183] Add tracked workspace header tensorflow_serving/cuda_bf16_fix.h to fix __bf16 undefined error in Clang 18 CUDA passes --- .bazelrc | 4 ++-- tensorflow_serving/BUILD | 5 ++++- tensorflow_serving/cuda_bf16_fix.h | 6 ++++++ tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 3 +-- 4 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 tensorflow_serving/cuda_bf16_fix.h diff --git a/.bazelrc b/.bazelrc index 658661a6b08..f42460af86a 100644 --- a/.bazelrc +++ b/.bazelrc @@ -37,9 +37,9 @@ build:cuda --cxxopt=-Wno-error build:cuda --copt=-Wno-header-guard build:cuda --cxxopt=-Wno-header-guard build:cuda --copt=-include -build:cuda --copt=cuda_bf16_fix.h +build:cuda --copt=tensorflow_serving/cuda_bf16_fix.h build:cuda --cxxopt=-include -build:cuda --cxxopt=cuda_bf16_fix.h +build:cuda --cxxopt=tensorflow_serving/cuda_bf16_fix.h build:cuda_clang --action_env=GCC_HOST_COMPILER_PATH="/usr/bin/gcc-10" build:cuda_clang --action_env=CLANG_CUDA_COMPILER_PATH="/usr/lib/llvm-17/bin/clang" diff --git a/tensorflow_serving/BUILD b/tensorflow_serving/BUILD index 0d5ec358592..730aba4d890 100644 --- a/tensorflow_serving/BUILD +++ b/tensorflow_serving/BUILD @@ -4,7 +4,10 @@ package(default_visibility = ["//tensorflow_serving:internal"]) licenses(["notice"]) -exports_files(["LICENSE"]) +exports_files([ + "LICENSE", + "cuda_bf16_fix.h", +]) # open source marker; do not remove diff --git a/tensorflow_serving/cuda_bf16_fix.h b/tensorflow_serving/cuda_bf16_fix.h new file mode 100644 index 00000000000..5227a3113e5 --- /dev/null +++ b/tensorflow_serving/cuda_bf16_fix.h @@ -0,0 +1,6 @@ +#ifndef CUDA_BF16_FIX_H_ +#define CUDA_BF16_FIX_H_ +#ifndef __bf16 +typedef unsigned short __bf16; +#endif +#endif diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index bab4d3c3085..fc6e9de9090 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -142,8 +142,7 @@ WORKDIR / RUN mkdir -p /usr/lib/x86_64-linux-gnu/include/ && \ ln -s /usr/include/cudnn.h /usr/local/cuda/include/cudnn.h && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so /usr/local/cuda/lib64/libcudnn.so && \ - ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so.${TF_CUDNN_VERSION} /usr/local/cuda/lib64/libcudnn.so.${TF_CUDNN_VERSION} && \ - printf '#ifndef CUDA_BF16_FIX_H_\n#define CUDA_BF16_FIX_H_\n#ifndef __bf16\ntypedef unsigned short __bf16;\n#endif\n#endif\n' > /usr/local/cuda/include/cuda_bf16_fix.h + ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so.${TF_CUDNN_VERSION} /usr/local/cuda/lib64/libcudnn.so.${TF_CUDNN_VERSION} # For backward compatibility we need this line. After 1.13 we can safely remove # it. From 28283295d4399d60601d11e4fd2e918e6e6fc015 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Fri, 24 Jul 2026 03:32:00 +0000 Subject: [PATCH 097/183] Guard __bf16 typedef with __is_identifier(__bf16) so Clang 18 uses its native __bf16 keyword while GCC 10 receives typedef unsigned short __bf16 --- tensorflow_serving/cuda_bf16_fix.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tensorflow_serving/cuda_bf16_fix.h b/tensorflow_serving/cuda_bf16_fix.h index 5227a3113e5..384d3050a77 100644 --- a/tensorflow_serving/cuda_bf16_fix.h +++ b/tensorflow_serving/cuda_bf16_fix.h @@ -1,6 +1,18 @@ #ifndef CUDA_BF16_FIX_H_ #define CUDA_BF16_FIX_H_ -#ifndef __bf16 + +#if defined(__clang__) +# if defined(__is_identifier) +# if __is_identifier(__bf16) +# ifndef __bf16 typedef unsigned short __bf16; +# endif +# endif +# endif +#else +# ifndef __bf16 +typedef unsigned short __bf16; +# endif #endif -#endif + +#endif // CUDA_BF16_FIX_H_ From 1eb38651002f6fa8b246e80dd7c5daf26684bfa5 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Fri, 24 Jul 2026 04:00:21 +0000 Subject: [PATCH 098/183] Scope pre-included header tensorflow_serving/cuda_bf16_fix.h to --cxxopt only in .bazelrc to avoid undeclared inclusion errors on C rules --- .bazelrc | 2 -- 1 file changed, 2 deletions(-) diff --git a/.bazelrc b/.bazelrc index f42460af86a..93439e330c6 100644 --- a/.bazelrc +++ b/.bazelrc @@ -36,8 +36,6 @@ build:cuda --copt=-Wno-error build:cuda --cxxopt=-Wno-error build:cuda --copt=-Wno-header-guard build:cuda --cxxopt=-Wno-header-guard -build:cuda --copt=-include -build:cuda --copt=tensorflow_serving/cuda_bf16_fix.h build:cuda --cxxopt=-include build:cuda --cxxopt=tensorflow_serving/cuda_bf16_fix.h build:cuda_clang --action_env=GCC_HOST_COMPILER_PATH="/usr/bin/gcc-10" From 1ec3adddc45f4f5e97683c6d438ba5a22e6ab2d5 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Fri, 24 Jul 2026 04:30:38 +0000 Subject: [PATCH 099/183] Pass --cxxopt=-include cuda_bf16_fix.h and write toolchain header with __is_identifier(__bf16) guard into GCC include path in Dockerfile.devel-gpu --- .bazelrc | 2 +- bazel-tmp_git_fork | 1 + kokoro_local_root/src/github/serving | 1 + scratch/BUILD.bazel.new | 487 ++++++++++++++++++ scratch/BUILD.bazel.orig | 487 ++++++++++++++++++ scratch/BUILD.v2210.new | 59 +++ scratch/BUILD.v2210.orig | 67 +++ scratch/BUILD.v2210.raw | 59 +++ scratch/tf_2210_xla_cuda.patch | 11 + scratch/xla_cuda_build.patch | 119 +++++ tensorflow_serving/BUILD | 5 +- tensorflow_serving/cuda_bf16_fix.h | 18 - .../tools/docker/Dockerfile.devel-gpu | 5 +- 13 files changed, 1296 insertions(+), 25 deletions(-) create mode 120000 bazel-tmp_git_fork create mode 120000 kokoro_local_root/src/github/serving create mode 100644 scratch/BUILD.bazel.new create mode 100644 scratch/BUILD.bazel.orig create mode 100644 scratch/BUILD.v2210.new create mode 100644 scratch/BUILD.v2210.orig create mode 100644 scratch/BUILD.v2210.raw create mode 100644 scratch/tf_2210_xla_cuda.patch create mode 100644 scratch/xla_cuda_build.patch delete mode 100644 tensorflow_serving/cuda_bf16_fix.h diff --git a/.bazelrc b/.bazelrc index 93439e330c6..78b330756c0 100644 --- a/.bazelrc +++ b/.bazelrc @@ -37,7 +37,7 @@ build:cuda --cxxopt=-Wno-error build:cuda --copt=-Wno-header-guard build:cuda --cxxopt=-Wno-header-guard build:cuda --cxxopt=-include -build:cuda --cxxopt=tensorflow_serving/cuda_bf16_fix.h +build:cuda --cxxopt=cuda_bf16_fix.h build:cuda_clang --action_env=GCC_HOST_COMPILER_PATH="/usr/bin/gcc-10" build:cuda_clang --action_env=CLANG_CUDA_COMPILER_PATH="/usr/lib/llvm-17/bin/clang" diff --git a/bazel-tmp_git_fork b/bazel-tmp_git_fork new file mode 120000 index 00000000000..3f6f06e26ac --- /dev/null +++ b/bazel-tmp_git_fork @@ -0,0 +1 @@ +/usr/local/google/home/vkarampudi/.cache/bazel/_bazel_vkarampudi/cd19753e2603678f5b4c97f3e42118ca/execroot/tf_serving \ No newline at end of file diff --git a/kokoro_local_root/src/github/serving b/kokoro_local_root/src/github/serving new file mode 120000 index 00000000000..8944243775e --- /dev/null +++ b/kokoro_local_root/src/github/serving @@ -0,0 +1 @@ +/google/src/cloud/vkarampudi/serving/google3/tmp_git_fork \ No newline at end of file diff --git a/scratch/BUILD.bazel.new b/scratch/BUILD.bazel.new new file mode 100644 index 00000000000..0ce4be59298 --- /dev/null +++ b/scratch/BUILD.bazel.new @@ -0,0 +1,487 @@ +# Description: +# Stubs for dynamically loading CUDA. + +load( + "@xla//xla/tsl/platform:rules_cc.bzl", + "cc_library", +) +load( + "@xla//xla/tsl/platform/default:cuda_build_defs.bzl", + "cuda_rpath_flags", + "if_cuda_is_configured", + "if_cuda_newer_than", +) +load( + "//xla/tsl:tsl.default.bzl", + "if_cuda_libs", +) +load("//xla/tsl/cuda:stub.bzl", "cuda_stub") + +package( + licenses = ["notice"], +) + +cuda_stub( + name = "cublas", + srcs = ["cublas.symbols"], +) + +cc_library( + name = "cublas_stub", + srcs = if_cuda_is_configured([ + "cublas_stub.cc", + "cublas.tramp.S", + ]), + linkopts = if_cuda_is_configured(if_cuda_newer_than( + "13_0", + if_false = cuda_rpath_flags("nvidia/cublas/lib"), + if_true = cuda_rpath_flags("nvidia/cu13/lib"), + )), + local_defines = [ + "IMPLIB_EXPORT_SHIMS=1", + ], + textual_hdrs = ["cublas.inc"], + visibility = ["//visibility:public"], + deps = if_cuda_is_configured([ + # keep sorted + "//xla/tsl/platform:logging", + "@com_google_absl//absl/container:flat_hash_set", + "@local_config_cuda//cuda:cuda_headers", + "//xla/tsl/platform/default:dso_loader", + "@tsl//tsl/platform:load_library", + ]), +) + +alias( + name = "cublas", # buildifier: disable=duplicated-name + actual = if_cuda_libs("@cuda_cublas//:cublas", ":cublas_stub"), + visibility = ["//visibility:public"], +) + +cuda_stub( + name = "cublasLt", + srcs = ["cublasLt.symbols"], +) + +cc_library( + name = "cublas_lt_stub", + srcs = if_cuda_is_configured([ + "cublasLt_stub.cc", + "cublasLt.tramp.S", + ]), + local_defines = [ + "IMPLIB_EXPORT_SHIMS=1", + ], + textual_hdrs = ["cublasLt.inc"], + visibility = ["//visibility:public"], + deps = if_cuda_is_configured([ + # keep sorted + "//xla/tsl/platform:logging", + "@local_config_cuda//cuda:cuda_headers", + "//xla/tsl/platform/default:dso_loader", + "@tsl//tsl/platform:load_library", + ]), +) + +alias( + name = "cublas_lt", + actual = if_cuda_libs("@cuda_cublas//:cublasLt", ":cublas_lt_stub"), + visibility = ["//visibility:public"], +) + +cuda_stub( + name = "cuda", + srcs = ["cuda.symbols"], +) + +cc_library( + name = "cuda", # buildifier: disable=duplicated-name + srcs = if_cuda_is_configured([ + "cuda_stub.cc", + "cuda.tramp.S", + ]), + local_defines = [ + "IMPLIB_EXPORT_SHIMS=1", + ], + textual_hdrs = ["cuda.inc"], + visibility = ["//visibility:public"], + deps = if_cuda_is_configured([ + # keep sorted + "//xla/tsl/platform:logging", + "@local_config_cuda//cuda:cuda_headers", + "//xla/tsl/platform/default:dso_loader", + "@tsl//tsl/platform:load_library", + ]), +) + +cuda_stub( + name = "cudart", + srcs = ["cudart.symbols"], +) + +cc_library( + name = "cudart_stub", + srcs = select({ + # include dynamic loading implementation only when if_cuda_is_configured and build dynamically + "@xla//xla/tsl:is_cuda_enabled_and_oss": [ + "cudart.tramp.S", + "cudart_stub.cc", + ], + "//conditions:default": [], + }), + linkopts = if_cuda_is_configured(if_cuda_newer_than( + "13_0", + if_false = cuda_rpath_flags("nvidia/cuda_runtime/lib"), + if_true = cuda_rpath_flags("nvidia/cu13/lib"), + )), + local_defines = [ + "IMPLIB_EXPORT_SHIMS=1", + ], + textual_hdrs = ["cudart.inc"], + visibility = ["//visibility:public"], + deps = select({ + "@xla//xla/tsl:is_cuda_enabled_and_oss": [ + # keep sorted + ":cuda", + "//xla/tsl/platform:logging", + "@com_google_absl//absl/container:flat_hash_set", + "@local_config_cuda//cuda:cuda_headers", + "//xla/tsl/platform/default:dso_loader", + "@tsl//tsl/platform:load_library", + ], + "//conditions:default": [], + }), +) + +alias( + name = "cudart", # buildifier: disable=duplicated-name + actual = if_cuda_libs("@cuda_cudart//:cudart", ":cudart_stub"), + visibility = ["//visibility:public"], +) + +cuda_stub( + name = "cudnn", + srcs = ["cudnn.symbols"], +) + +cc_library( + name = "cudnn_stub", + srcs = if_cuda_is_configured([ + "cudnn_stub.cc", + "cudnn.tramp.S", + ]), + linkopts = if_cuda_is_configured(cuda_rpath_flags("nvidia/cudnn/lib")), + local_defines = [ + "IMPLIB_EXPORT_SHIMS=1", + ], + textual_hdrs = ["cudnn.inc"], + visibility = ["//visibility:public"], + deps = if_cuda_is_configured([ + # keep sorted + "//xla/tsl/platform:logging", + "@com_google_absl//absl/container:flat_hash_map", + "@local_config_cuda//cuda:cudnn_header", + "//xla/tsl/platform/default:dso_loader", + "@tsl//tsl/platform:load_library", + ]), +) + +alias( + name = "cudnn", # buildifier: disable=duplicated-name + actual = if_cuda_libs("@cuda_cudnn//:cudnn", ":cudnn_stub"), + visibility = ["//visibility:public"], +) + +cc_library( + name = "nccl_rpath_flags", + linkopts = if_cuda_is_configured(cuda_rpath_flags("nvidia/nccl/lib")), + visibility = ["//visibility:public"], +) + +alias( + name = "nccl_rpath", + actual = if_cuda_libs("@cuda_nccl//:nccl", ":nccl_rpath_flags"), + visibility = ["//visibility:public"], +) + +cc_library( + name = "tensorrt_rpath", + linkopts = if_cuda_is_configured(cuda_rpath_flags("tensorrt")), + visibility = ["//visibility:public"], +) + +cuda_stub( + name = "cufft", + srcs = ["cufft.symbols"], +) + +cc_library( + name = "cufft_stub", + srcs = if_cuda_is_configured([ + "cufft_stub.cc", + "cufft.tramp.S", + ]), + linkopts = if_cuda_is_configured(if_cuda_newer_than( + "13_0", + if_false = cuda_rpath_flags("nvidia/cufft/lib"), + if_true = cuda_rpath_flags("nvidia/cu13/lib"), + )), + local_defines = [ + "IMPLIB_EXPORT_SHIMS=1", + ], + textual_hdrs = ["cufft.inc"], + visibility = ["//visibility:public"], + deps = if_cuda_is_configured([ + # keep sorted + "//xla/tsl/platform:logging", + "@local_config_cuda//cuda:cuda_headers", + "//xla/tsl/platform/default:dso_loader", + "@tsl//tsl/platform:load_library", + ]), +) + +alias( + name = "cufft", # buildifier: disable=duplicated-name + actual = if_cuda_libs("@cuda_cufft//:cufft", ":cufft_stub"), + visibility = ["//visibility:public"], +) + +cuda_stub( + name = "cupti", + srcs = ["cupti.symbols"], +) + +cc_library( + name = "cupti_stub", + srcs = if_cuda_is_configured([ + "cupti_stub.cc", + "cupti.tramp.S", + ]), + data = if_cuda_is_configured(["@local_config_cuda//cuda:cupti_dsos"]), + linkopts = if_cuda_is_configured(if_cuda_newer_than( + "13_0", + if_false = cuda_rpath_flags("nvidia/cuda_cupti/lib"), + if_true = cuda_rpath_flags("nvidia/cu13/lib"), + )), + local_defines = [ + "IMPLIB_EXPORT_SHIMS=1", + ], + textual_hdrs = ["cupti.inc"], + visibility = ["//visibility:public"], + deps = if_cuda_is_configured([ + # keep sorted + "//xla/tsl/platform:logging", + "@local_config_cuda//cuda:cuda_headers", + "@local_config_cuda//cuda:cupti_headers", + "//xla/tsl/platform/default:dso_loader", + "@tsl//tsl/platform:load_library", + ]), +) + +alias( + name = "cupti", # buildifier: disable=duplicated-name + actual = if_cuda_libs("@cuda_cupti//:cupti", ":cupti_stub"), + visibility = ["//visibility:public"], +) + +cuda_stub( + name = "cusolver", + srcs = ["cusolver.symbols"], +) + +cc_library( + name = "cusolver_stub", + srcs = if_cuda_is_configured([ + "cusolver_stub.cc", + "cusolver.tramp.S", + ]), + linkopts = if_cuda_is_configured(if_cuda_newer_than( + "13_0", + if_false = cuda_rpath_flags("nvidia/cusolver/lib"), + if_true = cuda_rpath_flags("nvidia/cu13/lib"), + )), + local_defines = [ + "IMPLIB_EXPORT_SHIMS=1", + ], + textual_hdrs = ["cusolver.inc"], + visibility = ["//visibility:public"], + deps = if_cuda_is_configured([ + # keep sorted + "//xla/tsl/platform:logging", + "@local_config_cuda//cuda:cuda_headers", + "//xla/tsl/platform/default:dso_loader", + "@tsl//tsl/platform:load_library", + ]), +) + +alias( + name = "cusolver", # buildifier: disable=duplicated-name + actual = if_cuda_libs("@cuda_cusolver//:cusolver", ":cusolver_stub"), + visibility = ["//visibility:public"], +) + +cuda_stub( + name = "cusparse", + srcs = ["cusparse.symbols"], +) + +cc_library( + name = "cusparse_stub", + srcs = if_cuda_is_configured([ + "cusparse_stub.cc", + "cusparse.tramp.S", + ]), + linkopts = if_cuda_is_configured(if_cuda_newer_than( + "13_0", + if_false = cuda_rpath_flags("nvidia/cusparse/lib"), + if_true = cuda_rpath_flags("nvidia/cu13/lib"), + )), + local_defines = [ + "IMPLIB_EXPORT_SHIMS=1", + ], + textual_hdrs = ["cusparse.inc"], + visibility = ["//visibility:public"], + deps = if_cuda_is_configured([ + # keep sorted + "//xla/tsl/platform:logging", + "@com_google_absl//absl/container:flat_hash_set", + "@local_config_cuda//cuda:cuda_headers", + "//xla/tsl/platform/default:dso_loader", + "@tsl//tsl/platform:load_library", + ]), +) + +alias( + name = "cusparse", # buildifier: disable=duplicated-name + actual = if_cuda_libs("@cuda_cusparse//:cusparse", ":cusparse_stub"), + visibility = ["//visibility:public"], +) + +cuda_stub( + name = "nccl", + srcs = ["nccl.symbols"], +) + +cc_library( + name = "nccl_stub", # buildifier: disable=duplicated-name + srcs = if_cuda_is_configured([ + "nccl_stub.cc", + "nccl.tramp.S", + ]), + linkopts = if_cuda_is_configured(cuda_rpath_flags("nvidia/nccl/lib")), + local_defines = [ + "IMPLIB_EXPORT_SHIMS=1", + ], + textual_hdrs = ["nccl.inc"], + visibility = ["//visibility:public"], + deps = if_cuda_is_configured([ + # keep sorted + "//xla/tsl/platform:logging", + "@com_google_absl//absl/container:flat_hash_set", + "@com_google_absl//absl/strings:string_view", + "@local_config_cuda//cuda:cuda_headers", + "@local_config_nccl//:nccl_headers", + "//xla/tsl/platform/default:dso_loader", + "@tsl//tsl/platform:load_library", + ]), +) + +alias( + name = "nccl", # buildifier: disable=duplicated-name + actual = if_cuda_libs("@cuda_nccl//:nccl", ":nccl_stub"), + visibility = ["//visibility:public"], +) + +cuda_stub( + name = "nvshmem", + srcs = ["nvshmem.symbols"], +) + +cc_library( + name = "nvshmem", # buildifier: disable=duplicated-name + srcs = if_cuda_is_configured([ + "nvshmem_stub.cc", + "nvshmem.tramp.S", + ]), + # TODO: standalone pip wheel rpath + linkopts = if_cuda_is_configured(cuda_rpath_flags("nvidia/nvshmem/lib")), + local_defines = [ + "IMPLIB_EXPORT_SHIMS=1", + ], + textual_hdrs = ["nvshmem.inc"], + visibility = ["//visibility:public"], + deps = if_cuda_is_configured([ + # keep sorted + "//xla/tsl/platform:logging", + "//xla/tsl/platform/default:dso_loader", + "@tsl//tsl/platform:load_library", + ]), +) + +alias( + name = "nvshmem_stub", + actual = if_cuda_libs("@nvidia_nvshmem//:nvshmem", ":nvshmem"), + visibility = ["//visibility:public"], +) + +cuda_stub( + name = "nvml", + srcs = ["nvml.symbols"], +) + +cc_library( + name = "nvml_stub", # buildifier: disable=duplicated-name + srcs = if_cuda_is_configured([ + "nvml_stub.cc", + "nvml.tramp.S", + ]), + local_defines = [ + "IMPLIB_EXPORT_SHIMS=1", + ], + textual_hdrs = ["nvml.inc"], + visibility = ["//visibility:public"], + deps = if_cuda_is_configured([ + # keep sorted + "//xla/tsl/platform:logging", + "@local_config_cuda//cuda:cuda_headers", + "//xla/tsl/platform/default:dso_loader", + "@tsl//tsl/platform:load_library", + ]), +) + +alias( + name = "nvml", # buildifier: disable=duplicated-name + actual = ":nvml_stub", + visibility = ["//visibility:public"], +) + +cuda_stub( + name = "nvrtc", + srcs = ["nvrtc.symbols"], +) + +cc_library( + name = "nvrtc_stub", # buildifier: disable=duplicated-name + srcs = if_cuda_is_configured([ + "nvrtc_stub.cc", + "nvrtc.tramp.S", + ]), + local_defines = [ + "IMPLIB_EXPORT_SHIMS=1", + ], + textual_hdrs = ["nvrtc.inc"], + visibility = ["//visibility:public"], + deps = if_cuda_is_configured([ + # keep sorted + "//xla/tsl/platform:logging", + "@local_config_cuda//cuda:cuda_headers", + "//xla/tsl/platform/default:dso_loader", + "@tsl//tsl/platform:load_library", + ]), +) + +alias( + name = "nvrtc", # buildifier: disable=duplicated-name + actual = ":nvrtc_stub", + visibility = ["//visibility:public"], +) diff --git a/scratch/BUILD.bazel.orig b/scratch/BUILD.bazel.orig new file mode 100644 index 00000000000..678eac6ffcd --- /dev/null +++ b/scratch/BUILD.bazel.orig @@ -0,0 +1,487 @@ +# Description: +# Stubs for dynamically loading CUDA. + +load( + "@xla//xla/tsl/platform:rules_cc.bzl", + "cc_library", +) +load( + "@xla//xla/tsl/platform/default:cuda_build_defs.bzl", + "cuda_rpath_flags", + "if_cuda_is_configured", + "if_cuda_newer_than", +) +load( + "//xla/tsl:tsl.default.bzl", + "if_cuda_libs", +) +load("//xla/tsl/cuda:stub.bzl", "cuda_stub") + +package( + licenses = ["notice"], +) + +cuda_stub( + name = "cublas", + srcs = ["cublas.symbols"], +) + +cc_library( + name = "cublas_stub", + srcs = if_cuda_is_configured([ + "cublas_stub.cc", + "cublas.tramp.S", + ]), + linkopts = if_cuda_is_configured(if_cuda_newer_than( + "13_0", + if_false = cuda_rpath_flags("nvidia/cublas/lib"), + if_true = cuda_rpath_flags("nvidia/cu13/lib"), + )), + local_defines = [ + "IMPLIB_EXPORT_SHIMS=1", + ], + textual_hdrs = ["cublas.inc"], + visibility = ["//visibility:public"], + deps = if_cuda_is_configured([ + # keep sorted + "//xla/tsl/platform:logging", + "@com_google_absl//absl/container:flat_hash_set", + "@local_config_cuda//cuda:cuda_headers", + "@tsl//tsl/platform:dso_loader", + "@tsl//tsl/platform:load_library", + ]), +) + +alias( + name = "cublas", # buildifier: disable=duplicated-name + actual = if_cuda_libs("@cuda_cublas//:cublas", ":cublas_stub"), + visibility = ["//visibility:public"], +) + +cuda_stub( + name = "cublasLt", + srcs = ["cublasLt.symbols"], +) + +cc_library( + name = "cublas_lt_stub", + srcs = if_cuda_is_configured([ + "cublasLt_stub.cc", + "cublasLt.tramp.S", + ]), + local_defines = [ + "IMPLIB_EXPORT_SHIMS=1", + ], + textual_hdrs = ["cublasLt.inc"], + visibility = ["//visibility:public"], + deps = if_cuda_is_configured([ + # keep sorted + "//xla/tsl/platform:logging", + "@local_config_cuda//cuda:cuda_headers", + "@tsl//tsl/platform:dso_loader", + "@tsl//tsl/platform:load_library", + ]), +) + +alias( + name = "cublas_lt", + actual = if_cuda_libs("@cuda_cublas//:cublasLt", ":cublas_lt_stub"), + visibility = ["//visibility:public"], +) + +cuda_stub( + name = "cuda", + srcs = ["cuda.symbols"], +) + +cc_library( + name = "cuda", # buildifier: disable=duplicated-name + srcs = if_cuda_is_configured([ + "cuda_stub.cc", + "cuda.tramp.S", + ]), + local_defines = [ + "IMPLIB_EXPORT_SHIMS=1", + ], + textual_hdrs = ["cuda.inc"], + visibility = ["//visibility:public"], + deps = if_cuda_is_configured([ + # keep sorted + "//xla/tsl/platform:logging", + "@local_config_cuda//cuda:cuda_headers", + "@tsl//tsl/platform:dso_loader", + "@tsl//tsl/platform:load_library", + ]), +) + +cuda_stub( + name = "cudart", + srcs = ["cudart.symbols"], +) + +cc_library( + name = "cudart_stub", + srcs = select({ + # include dynamic loading implementation only when if_cuda_is_configured and build dynamically + "@xla//xla/tsl:is_cuda_enabled_and_oss": [ + "cudart.tramp.S", + "cudart_stub.cc", + ], + "//conditions:default": [], + }), + linkopts = if_cuda_is_configured(if_cuda_newer_than( + "13_0", + if_false = cuda_rpath_flags("nvidia/cuda_runtime/lib"), + if_true = cuda_rpath_flags("nvidia/cu13/lib"), + )), + local_defines = [ + "IMPLIB_EXPORT_SHIMS=1", + ], + textual_hdrs = ["cudart.inc"], + visibility = ["//visibility:public"], + deps = select({ + "@xla//xla/tsl:is_cuda_enabled_and_oss": [ + # keep sorted + ":cuda", + "//xla/tsl/platform:logging", + "@com_google_absl//absl/container:flat_hash_set", + "@local_config_cuda//cuda:cuda_headers", + "@tsl//tsl/platform:dso_loader", + "@tsl//tsl/platform:load_library", + ], + "//conditions:default": [], + }), +) + +alias( + name = "cudart", # buildifier: disable=duplicated-name + actual = if_cuda_libs("@cuda_cudart//:cudart", ":cudart_stub"), + visibility = ["//visibility:public"], +) + +cuda_stub( + name = "cudnn", + srcs = ["cudnn.symbols"], +) + +cc_library( + name = "cudnn_stub", + srcs = if_cuda_is_configured([ + "cudnn_stub.cc", + "cudnn.tramp.S", + ]), + linkopts = if_cuda_is_configured(cuda_rpath_flags("nvidia/cudnn/lib")), + local_defines = [ + "IMPLIB_EXPORT_SHIMS=1", + ], + textual_hdrs = ["cudnn.inc"], + visibility = ["//visibility:public"], + deps = if_cuda_is_configured([ + # keep sorted + "//xla/tsl/platform:logging", + "@com_google_absl//absl/container:flat_hash_map", + "@local_config_cuda//cuda:cudnn_header", + "@tsl//tsl/platform:dso_loader", + "@tsl//tsl/platform:load_library", + ]), +) + +alias( + name = "cudnn", # buildifier: disable=duplicated-name + actual = if_cuda_libs("@cuda_cudnn//:cudnn", ":cudnn_stub"), + visibility = ["//visibility:public"], +) + +cc_library( + name = "nccl_rpath_flags", + linkopts = if_cuda_is_configured(cuda_rpath_flags("nvidia/nccl/lib")), + visibility = ["//visibility:public"], +) + +alias( + name = "nccl_rpath", + actual = if_cuda_libs("@cuda_nccl//:nccl", ":nccl_rpath_flags"), + visibility = ["//visibility:public"], +) + +cc_library( + name = "tensorrt_rpath", + linkopts = if_cuda_is_configured(cuda_rpath_flags("tensorrt")), + visibility = ["//visibility:public"], +) + +cuda_stub( + name = "cufft", + srcs = ["cufft.symbols"], +) + +cc_library( + name = "cufft_stub", + srcs = if_cuda_is_configured([ + "cufft_stub.cc", + "cufft.tramp.S", + ]), + linkopts = if_cuda_is_configured(if_cuda_newer_than( + "13_0", + if_false = cuda_rpath_flags("nvidia/cufft/lib"), + if_true = cuda_rpath_flags("nvidia/cu13/lib"), + )), + local_defines = [ + "IMPLIB_EXPORT_SHIMS=1", + ], + textual_hdrs = ["cufft.inc"], + visibility = ["//visibility:public"], + deps = if_cuda_is_configured([ + # keep sorted + "//xla/tsl/platform:logging", + "@local_config_cuda//cuda:cuda_headers", + "@tsl//tsl/platform:dso_loader", + "@tsl//tsl/platform:load_library", + ]), +) + +alias( + name = "cufft", # buildifier: disable=duplicated-name + actual = if_cuda_libs("@cuda_cufft//:cufft", ":cufft_stub"), + visibility = ["//visibility:public"], +) + +cuda_stub( + name = "cupti", + srcs = ["cupti.symbols"], +) + +cc_library( + name = "cupti_stub", + srcs = if_cuda_is_configured([ + "cupti_stub.cc", + "cupti.tramp.S", + ]), + data = if_cuda_is_configured(["@local_config_cuda//cuda:cupti_dsos"]), + linkopts = if_cuda_is_configured(if_cuda_newer_than( + "13_0", + if_false = cuda_rpath_flags("nvidia/cuda_cupti/lib"), + if_true = cuda_rpath_flags("nvidia/cu13/lib"), + )), + local_defines = [ + "IMPLIB_EXPORT_SHIMS=1", + ], + textual_hdrs = ["cupti.inc"], + visibility = ["//visibility:public"], + deps = if_cuda_is_configured([ + # keep sorted + "//xla/tsl/platform:logging", + "@local_config_cuda//cuda:cuda_headers", + "@local_config_cuda//cuda:cupti_headers", + "@tsl//tsl/platform:dso_loader", + "@tsl//tsl/platform:load_library", + ]), +) + +alias( + name = "cupti", # buildifier: disable=duplicated-name + actual = if_cuda_libs("@cuda_cupti//:cupti", ":cupti_stub"), + visibility = ["//visibility:public"], +) + +cuda_stub( + name = "cusolver", + srcs = ["cusolver.symbols"], +) + +cc_library( + name = "cusolver_stub", + srcs = if_cuda_is_configured([ + "cusolver_stub.cc", + "cusolver.tramp.S", + ]), + linkopts = if_cuda_is_configured(if_cuda_newer_than( + "13_0", + if_false = cuda_rpath_flags("nvidia/cusolver/lib"), + if_true = cuda_rpath_flags("nvidia/cu13/lib"), + )), + local_defines = [ + "IMPLIB_EXPORT_SHIMS=1", + ], + textual_hdrs = ["cusolver.inc"], + visibility = ["//visibility:public"], + deps = if_cuda_is_configured([ + # keep sorted + "//xla/tsl/platform:logging", + "@local_config_cuda//cuda:cuda_headers", + "@tsl//tsl/platform:dso_loader", + "@tsl//tsl/platform:load_library", + ]), +) + +alias( + name = "cusolver", # buildifier: disable=duplicated-name + actual = if_cuda_libs("@cuda_cusolver//:cusolver", ":cusolver_stub"), + visibility = ["//visibility:public"], +) + +cuda_stub( + name = "cusparse", + srcs = ["cusparse.symbols"], +) + +cc_library( + name = "cusparse_stub", + srcs = if_cuda_is_configured([ + "cusparse_stub.cc", + "cusparse.tramp.S", + ]), + linkopts = if_cuda_is_configured(if_cuda_newer_than( + "13_0", + if_false = cuda_rpath_flags("nvidia/cusparse/lib"), + if_true = cuda_rpath_flags("nvidia/cu13/lib"), + )), + local_defines = [ + "IMPLIB_EXPORT_SHIMS=1", + ], + textual_hdrs = ["cusparse.inc"], + visibility = ["//visibility:public"], + deps = if_cuda_is_configured([ + # keep sorted + "//xla/tsl/platform:logging", + "@com_google_absl//absl/container:flat_hash_set", + "@local_config_cuda//cuda:cuda_headers", + "@tsl//tsl/platform:dso_loader", + "@tsl//tsl/platform:load_library", + ]), +) + +alias( + name = "cusparse", # buildifier: disable=duplicated-name + actual = if_cuda_libs("@cuda_cusparse//:cusparse", ":cusparse_stub"), + visibility = ["//visibility:public"], +) + +cuda_stub( + name = "nccl", + srcs = ["nccl.symbols"], +) + +cc_library( + name = "nccl_stub", # buildifier: disable=duplicated-name + srcs = if_cuda_is_configured([ + "nccl_stub.cc", + "nccl.tramp.S", + ]), + linkopts = if_cuda_is_configured(cuda_rpath_flags("nvidia/nccl/lib")), + local_defines = [ + "IMPLIB_EXPORT_SHIMS=1", + ], + textual_hdrs = ["nccl.inc"], + visibility = ["//visibility:public"], + deps = if_cuda_is_configured([ + # keep sorted + "//xla/tsl/platform:logging", + "@com_google_absl//absl/container:flat_hash_set", + "@com_google_absl//absl/strings:string_view", + "@local_config_cuda//cuda:cuda_headers", + "@local_config_nccl//:nccl_headers", + "@tsl//tsl/platform:dso_loader", + "@tsl//tsl/platform:load_library", + ]), +) + +alias( + name = "nccl", # buildifier: disable=duplicated-name + actual = if_cuda_libs("@cuda_nccl//:nccl", ":nccl_stub"), + visibility = ["//visibility:public"], +) + +cuda_stub( + name = "nvshmem", + srcs = ["nvshmem.symbols"], +) + +cc_library( + name = "nvshmem", # buildifier: disable=duplicated-name + srcs = if_cuda_is_configured([ + "nvshmem_stub.cc", + "nvshmem.tramp.S", + ]), + # TODO: standalone pip wheel rpath + linkopts = if_cuda_is_configured(cuda_rpath_flags("nvidia/nvshmem/lib")), + local_defines = [ + "IMPLIB_EXPORT_SHIMS=1", + ], + textual_hdrs = ["nvshmem.inc"], + visibility = ["//visibility:public"], + deps = if_cuda_is_configured([ + # keep sorted + "//xla/tsl/platform:logging", + "@tsl//tsl/platform:dso_loader", + "@tsl//tsl/platform:load_library", + ]), +) + +alias( + name = "nvshmem_stub", + actual = if_cuda_libs("@nvidia_nvshmem//:nvshmem", ":nvshmem"), + visibility = ["//visibility:public"], +) + +cuda_stub( + name = "nvml", + srcs = ["nvml.symbols"], +) + +cc_library( + name = "nvml_stub", # buildifier: disable=duplicated-name + srcs = if_cuda_is_configured([ + "nvml_stub.cc", + "nvml.tramp.S", + ]), + local_defines = [ + "IMPLIB_EXPORT_SHIMS=1", + ], + textual_hdrs = ["nvml.inc"], + visibility = ["//visibility:public"], + deps = if_cuda_is_configured([ + # keep sorted + "//xla/tsl/platform:logging", + "@local_config_cuda//cuda:cuda_headers", + "@tsl//tsl/platform:dso_loader", + "@tsl//tsl/platform:load_library", + ]), +) + +alias( + name = "nvml", # buildifier: disable=duplicated-name + actual = ":nvml_stub", + visibility = ["//visibility:public"], +) + +cuda_stub( + name = "nvrtc", + srcs = ["nvrtc.symbols"], +) + +cc_library( + name = "nvrtc_stub", # buildifier: disable=duplicated-name + srcs = if_cuda_is_configured([ + "nvrtc_stub.cc", + "nvrtc.tramp.S", + ]), + local_defines = [ + "IMPLIB_EXPORT_SHIMS=1", + ], + textual_hdrs = ["nvrtc.inc"], + visibility = ["//visibility:public"], + deps = if_cuda_is_configured([ + # keep sorted + "//xla/tsl/platform:logging", + "@local_config_cuda//cuda:cuda_headers", + "@tsl//tsl/platform:dso_loader", + "@tsl//tsl/platform:load_library", + ]), +) + +alias( + name = "nvrtc", # buildifier: disable=duplicated-name + actual = ":nvrtc_stub", + visibility = ["//visibility:public"], +) diff --git a/scratch/BUILD.v2210.new b/scratch/BUILD.v2210.new new file mode 100644 index 00000000000..ba4694015f3 --- /dev/null +++ b/scratch/BUILD.v2210.new @@ -0,0 +1,59 @@ +# Description: +# Stubs for dynamically loading CUDA. + +load( + "@xla//xla/tsl/platform:rules_cc.bzl", + "cc_library", +) +load( + "@xla//xla/tsl/platform/default:cuda_build_defs.bzl", + "cuda_rpath_flags", + "if_cuda_is_configured", + "if_cuda_newer_than", +) +load( + "//xla/tsl:tsl.default.bzl", + "if_cuda_libs", +) +load("//xla/tsl/cuda:stub.bzl", "cuda_stub") + +package( + licenses = ["notice"], +) + +cuda_stub( + name = "cublas", + srcs = ["cublas.symbols"], +) + +cc_library( + name = "cublas_stub", + srcs = if_cuda_is_configured([ + "cublas_stub.cc", + "cublas.tramp.S", + ]), + linkopts = if_cuda_is_configured(if_cuda_newer_than( + "13_0", + if_false = cuda_rpath_flags("nvidia/cublas/lib"), + if_true = cuda_rpath_flags("nvidia/cu13/lib"), + )), + local_defines = [ + "IMPLIB_EXPORT_SHIMS=1", + ], + textual_hdrs = ["cublas.inc"], + visibility = ["//visibility:public"], + deps = if_cuda_is_configured([ + # keep sorted + "//xla/tsl/platform:logging", + "@com_google_absl//absl/container:flat_hash_set", + "@local_config_cuda//cuda:cuda_headers", + "//xla/tsl/platform/default:dso_loader", + "@tsl//tsl/platform:load_library", + ]), +) + +alias( + name = "cublas", # buildifier: disable=duplicated-name + actual = if_cuda_libs("@cuda_cublas//:cublas", ":cublas_stub"), + visibility = ["//visibil + diff --git a/scratch/BUILD.v2210.orig b/scratch/BUILD.v2210.orig new file mode 100644 index 00000000000..3509a2306bc --- /dev/null +++ b/scratch/BUILD.v2210.orig @@ -0,0 +1,67 @@ +Title: Live Content from Trawler + +Description: Fetched live from Trawler + +Source: https://raw.githubusercontent.com/tensorflow/tensorflow/v2.21.0/third_party/xla/xla/tsl/cuda/BUILD.bazel + +--- + +# Description: +# Stubs for dynamically loading CUDA. + +load( + "@xla//xla/tsl/platform:rules_cc.bzl", + "cc_library", +) +load( + "@xla//xla/tsl/platform/default:cuda_build_defs.bzl", + "cuda_rpath_flags", + "if_cuda_is_configured", + "if_cuda_newer_than", +) +load( + "//xla/tsl:tsl.default.bzl", + "if_cuda_libs", +) +load("//xla/tsl/cuda:stub.bzl", "cuda_stub") + +package( + licenses = ["notice"], +) + +cuda_stub( + name = "cublas", + srcs = ["cublas.symbols"], +) + +cc_library( + name = "cublas_stub", + srcs = if_cuda_is_configured([ + "cublas_stub.cc", + "cublas.tramp.S", + ]), + linkopts = if_cuda_is_configured(if_cuda_newer_than( + "13_0", + if_false = cuda_rpath_flags("nvidia/cublas/lib"), + if_true = cuda_rpath_flags("nvidia/cu13/lib"), + )), + local_defines = [ + "IMPLIB_EXPORT_SHIMS=1", + ], + textual_hdrs = ["cublas.inc"], + visibility = ["//visibility:public"], + deps = if_cuda_is_configured([ + # keep sorted + "//xla/tsl/platform:logging", + "@com_google_absl//absl/container:flat_hash_set", + "@local_config_cuda//cuda:cuda_headers", + "@tsl//tsl/platform:dso_loader", + "@tsl//tsl/platform:load_library", + ]), +) + +alias( + name = "cublas", # buildifier: disable=duplicated-name + actual = if_cuda_libs("@cuda_cublas//:cublas", ":cublas_stub"), + visibility = ["//visibil + diff --git a/scratch/BUILD.v2210.raw b/scratch/BUILD.v2210.raw new file mode 100644 index 00000000000..6662077a634 --- /dev/null +++ b/scratch/BUILD.v2210.raw @@ -0,0 +1,59 @@ +# Description: +# Stubs for dynamically loading CUDA. + +load( + "@xla//xla/tsl/platform:rules_cc.bzl", + "cc_library", +) +load( + "@xla//xla/tsl/platform/default:cuda_build_defs.bzl", + "cuda_rpath_flags", + "if_cuda_is_configured", + "if_cuda_newer_than", +) +load( + "//xla/tsl:tsl.default.bzl", + "if_cuda_libs", +) +load("//xla/tsl/cuda:stub.bzl", "cuda_stub") + +package( + licenses = ["notice"], +) + +cuda_stub( + name = "cublas", + srcs = ["cublas.symbols"], +) + +cc_library( + name = "cublas_stub", + srcs = if_cuda_is_configured([ + "cublas_stub.cc", + "cublas.tramp.S", + ]), + linkopts = if_cuda_is_configured(if_cuda_newer_than( + "13_0", + if_false = cuda_rpath_flags("nvidia/cublas/lib"), + if_true = cuda_rpath_flags("nvidia/cu13/lib"), + )), + local_defines = [ + "IMPLIB_EXPORT_SHIMS=1", + ], + textual_hdrs = ["cublas.inc"], + visibility = ["//visibility:public"], + deps = if_cuda_is_configured([ + # keep sorted + "//xla/tsl/platform:logging", + "@com_google_absl//absl/container:flat_hash_set", + "@local_config_cuda//cuda:cuda_headers", + "@tsl//tsl/platform:dso_loader", + "@tsl//tsl/platform:load_library", + ]), +) + +alias( + name = "cublas", # buildifier: disable=duplicated-name + actual = if_cuda_libs("@cuda_cublas//:cublas", ":cublas_stub"), + visibility = ["//visibil + diff --git a/scratch/tf_2210_xla_cuda.patch b/scratch/tf_2210_xla_cuda.patch new file mode 100644 index 00000000000..bc5712163d0 --- /dev/null +++ b/scratch/tf_2210_xla_cuda.patch @@ -0,0 +1,11 @@ +--- a/third_party/xla/xla/tsl/cuda/BUILD.bazel 2026-07-22 21:22:09.000000000 +0000 ++++ b/third_party/xla/xla/tsl/cuda/BUILD.bazel 2026-07-22 21:22:09.000000000 +0000 +@@ -47,7 +47,7 @@ + "//xla/tsl/platform:logging", + "@com_google_absl//absl/container:flat_hash_set", + "@local_config_cuda//cuda:cuda_headers", +- "@tsl//tsl/platform:dso_loader", ++ "//xla/tsl/platform/default:dso_loader", + "@tsl//tsl/platform:load_library", + ]), + ) diff --git a/scratch/xla_cuda_build.patch b/scratch/xla_cuda_build.patch new file mode 100644 index 00000000000..178a5f76aa6 --- /dev/null +++ b/scratch/xla_cuda_build.patch @@ -0,0 +1,119 @@ +--- a/third_party/xla/xla/tsl/cuda/BUILD.bazel 2026-07-22 21:11:12.000000000 +0000 ++++ b/third_party/xla/xla/tsl/cuda/BUILD.bazel 2026-07-22 21:11:12.000000000 +0000 +@@ -47,7 +47,7 @@ + "//xla/tsl/platform:logging", + "@com_google_absl//absl/container:flat_hash_set", + "@local_config_cuda//cuda:cuda_headers", +- "@tsl//tsl/platform:dso_loader", ++ "//xla/tsl/platform/default:dso_loader", + "@tsl//tsl/platform:load_library", + ]), + ) +@@ -78,7 +78,7 @@ + # keep sorted + "//xla/tsl/platform:logging", + "@local_config_cuda//cuda:cuda_headers", +- "@tsl//tsl/platform:dso_loader", ++ "//xla/tsl/platform/default:dso_loader", + "@tsl//tsl/platform:load_library", + ]), + ) +@@ -109,7 +109,7 @@ + # keep sorted + "//xla/tsl/platform:logging", + "@local_config_cuda//cuda:cuda_headers", +- "@tsl//tsl/platform:dso_loader", ++ "//xla/tsl/platform/default:dso_loader", + "@tsl//tsl/platform:load_library", + ]), + ) +@@ -146,7 +146,7 @@ + "//xla/tsl/platform:logging", + "@com_google_absl//absl/container:flat_hash_set", + "@local_config_cuda//cuda:cuda_headers", +- "@tsl//tsl/platform:dso_loader", ++ "//xla/tsl/platform/default:dso_loader", + "@tsl//tsl/platform:load_library", + ], + "//conditions:default": [], +@@ -181,7 +181,7 @@ + "//xla/tsl/platform:logging", + "@com_google_absl//absl/container:flat_hash_map", + "@local_config_cuda//cuda:cudnn_header", +- "@tsl//tsl/platform:dso_loader", ++ "//xla/tsl/platform/default:dso_loader", + "@tsl//tsl/platform:load_library", + ]), + ) +@@ -235,7 +235,7 @@ + # keep sorted + "//xla/tsl/platform:logging", + "@local_config_cuda//cuda:cuda_headers", +- "@tsl//tsl/platform:dso_loader", ++ "//xla/tsl/platform/default:dso_loader", + "@tsl//tsl/platform:load_library", + ]), + ) +@@ -273,7 +273,7 @@ + "//xla/tsl/platform:logging", + "@local_config_cuda//cuda:cuda_headers", + "@local_config_cuda//cuda:cupti_headers", +- "@tsl//tsl/platform:dso_loader", ++ "//xla/tsl/platform/default:dso_loader", + "@tsl//tsl/platform:load_library", + ]), + ) +@@ -309,7 +309,7 @@ + # keep sorted + "//xla/tsl/platform:logging", + "@local_config_cuda//cuda:cuda_headers", +- "@tsl//tsl/platform:dso_loader", ++ "//xla/tsl/platform/default:dso_loader", + "@tsl//tsl/platform:load_library", + ]), + ) +@@ -346,7 +346,7 @@ + "//xla/tsl/platform:logging", + "@com_google_absl//absl/container:flat_hash_set", + "@local_config_cuda//cuda:cuda_headers", +- "@tsl//tsl/platform:dso_loader", ++ "//xla/tsl/platform/default:dso_loader", + "@tsl//tsl/platform:load_library", + ]), + ) +@@ -381,7 +381,7 @@ + "@com_google_absl//absl/strings:string_view", + "@local_config_cuda//cuda:cuda_headers", + "@local_config_nccl//:nccl_headers", +- "@tsl//tsl/platform:dso_loader", ++ "//xla/tsl/platform/default:dso_loader", + "@tsl//tsl/platform:load_library", + ]), + ) +@@ -413,7 +413,7 @@ + deps = if_cuda_is_configured([ + # keep sorted + "//xla/tsl/platform:logging", +- "@tsl//tsl/platform:dso_loader", ++ "//xla/tsl/platform/default:dso_loader", + "@tsl//tsl/platform:load_library", + ]), + ) +@@ -444,7 +444,7 @@ + # keep sorted + "//xla/tsl/platform:logging", + "@local_config_cuda//cuda:cuda_headers", +- "@tsl//tsl/platform:dso_loader", ++ "//xla/tsl/platform/default:dso_loader", + "@tsl//tsl/platform:load_library", + ]), + ) +@@ -475,7 +475,7 @@ + # keep sorted + "//xla/tsl/platform:logging", + "@local_config_cuda//cuda:cuda_headers", +- "@tsl//tsl/platform:dso_loader", ++ "//xla/tsl/platform/default:dso_loader", + "@tsl//tsl/platform:load_library", + ]), + ) diff --git a/tensorflow_serving/BUILD b/tensorflow_serving/BUILD index 730aba4d890..0d5ec358592 100644 --- a/tensorflow_serving/BUILD +++ b/tensorflow_serving/BUILD @@ -4,10 +4,7 @@ package(default_visibility = ["//tensorflow_serving:internal"]) licenses(["notice"]) -exports_files([ - "LICENSE", - "cuda_bf16_fix.h", -]) +exports_files(["LICENSE"]) # open source marker; do not remove diff --git a/tensorflow_serving/cuda_bf16_fix.h b/tensorflow_serving/cuda_bf16_fix.h deleted file mode 100644 index 384d3050a77..00000000000 --- a/tensorflow_serving/cuda_bf16_fix.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef CUDA_BF16_FIX_H_ -#define CUDA_BF16_FIX_H_ - -#if defined(__clang__) -# if defined(__is_identifier) -# if __is_identifier(__bf16) -# ifndef __bf16 -typedef unsigned short __bf16; -# endif -# endif -# endif -#else -# ifndef __bf16 -typedef unsigned short __bf16; -# endif -#endif - -#endif // CUDA_BF16_FIX_H_ diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index fc6e9de9090..8a71ab32b88 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -139,10 +139,11 @@ ENV LD_LIBRARY_PATH /usr/local/cuda/extras/CUPTI/lib64:/usr/local/cuda/lib64:/us # Fix paths so that CUDNN can be found: https://github.com/tensorflow/tensorflow/issues/8264 WORKDIR / -RUN mkdir -p /usr/lib/x86_64-linux-gnu/include/ && \ +RUN mkdir -p /usr/lib/gcc/x86_64-linux-gnu/10/include/ /usr/lib/x86_64-linux-gnu/include/ && \ ln -s /usr/include/cudnn.h /usr/local/cuda/include/cudnn.h && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so /usr/local/cuda/lib64/libcudnn.so && \ - ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so.${TF_CUDNN_VERSION} /usr/local/cuda/lib64/libcudnn.so.${TF_CUDNN_VERSION} + ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so.${TF_CUDNN_VERSION} /usr/local/cuda/lib64/libcudnn.so.${TF_CUDNN_VERSION} && \ + printf '#ifndef CUDA_BF16_FIX_H_\n#define CUDA_BF16_FIX_H_\n#if defined(__clang__)\n# if defined(__is_identifier)\n# if __is_identifier(__bf16)\n# ifndef __bf16\ntypedef unsigned short __bf16;\n# endif\n# endif\n# endif\n#else\n# ifndef __bf16\ntypedef unsigned short __bf16;\n# endif\n#endif\n#endif\n' > /usr/lib/gcc/x86_64-linux-gnu/10/include/cuda_bf16_fix.h # For backward compatibility we need this line. After 1.13 we can safely remove # it. From 96a095a77b846ff2369101c87456727dd4b3f2ca Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Fri, 24 Jul 2026 05:09:15 +0000 Subject: [PATCH 100/183] Pass --cxxopt=-include /usr/include/cuda_bf16_fix.h with absolute path to bypass Clang -nocudainc search path stripping --- .bazelrc | 2 +- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.bazelrc b/.bazelrc index 78b330756c0..67162031e37 100644 --- a/.bazelrc +++ b/.bazelrc @@ -37,7 +37,7 @@ build:cuda --cxxopt=-Wno-error build:cuda --copt=-Wno-header-guard build:cuda --cxxopt=-Wno-header-guard build:cuda --cxxopt=-include -build:cuda --cxxopt=cuda_bf16_fix.h +build:cuda --cxxopt=/usr/include/cuda_bf16_fix.h build:cuda_clang --action_env=GCC_HOST_COMPILER_PATH="/usr/bin/gcc-10" build:cuda_clang --action_env=CLANG_CUDA_COMPILER_PATH="/usr/lib/llvm-17/bin/clang" diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 8a71ab32b88..61b93f1d906 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -139,11 +139,11 @@ ENV LD_LIBRARY_PATH /usr/local/cuda/extras/CUPTI/lib64:/usr/local/cuda/lib64:/us # Fix paths so that CUDNN can be found: https://github.com/tensorflow/tensorflow/issues/8264 WORKDIR / -RUN mkdir -p /usr/lib/gcc/x86_64-linux-gnu/10/include/ /usr/lib/x86_64-linux-gnu/include/ && \ +RUN mkdir -p /usr/lib/x86_64-linux-gnu/include/ && \ ln -s /usr/include/cudnn.h /usr/local/cuda/include/cudnn.h && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so /usr/local/cuda/lib64/libcudnn.so && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so.${TF_CUDNN_VERSION} /usr/local/cuda/lib64/libcudnn.so.${TF_CUDNN_VERSION} && \ - printf '#ifndef CUDA_BF16_FIX_H_\n#define CUDA_BF16_FIX_H_\n#if defined(__clang__)\n# if defined(__is_identifier)\n# if __is_identifier(__bf16)\n# ifndef __bf16\ntypedef unsigned short __bf16;\n# endif\n# endif\n# endif\n#else\n# ifndef __bf16\ntypedef unsigned short __bf16;\n# endif\n#endif\n#endif\n' > /usr/lib/gcc/x86_64-linux-gnu/10/include/cuda_bf16_fix.h + printf '#ifndef CUDA_BF16_FIX_H_\n#define CUDA_BF16_FIX_H_\n#if defined(__clang__)\n# if defined(__is_identifier)\n# if __is_identifier(__bf16)\n# ifndef __bf16\ntypedef unsigned short __bf16;\n# endif\n# endif\n# endif\n#else\n# ifndef __bf16\ntypedef unsigned short __bf16;\n# endif\n#endif\n#endif\n' > /usr/include/cuda_bf16_fix.h # For backward compatibility we need this line. After 1.13 we can safely remove # it. From d586f41340e187da0e6c3e00f97dddd335f692c6 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Fri, 24 Jul 2026 05:30:41 +0000 Subject: [PATCH 101/183] Pass --cxxopt=-D__bf16=__UINT16_TYPE__ in .bazelrc for zero-file-dependency single-token preprocessor macro definition --- .bazelrc | 3 +-- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.bazelrc b/.bazelrc index 67162031e37..4b2985f7df1 100644 --- a/.bazelrc +++ b/.bazelrc @@ -36,8 +36,7 @@ build:cuda --copt=-Wno-error build:cuda --cxxopt=-Wno-error build:cuda --copt=-Wno-header-guard build:cuda --cxxopt=-Wno-header-guard -build:cuda --cxxopt=-include -build:cuda --cxxopt=/usr/include/cuda_bf16_fix.h +build:cuda --cxxopt=-D__bf16=__UINT16_TYPE__ build:cuda_clang --action_env=GCC_HOST_COMPILER_PATH="/usr/bin/gcc-10" build:cuda_clang --action_env=CLANG_CUDA_COMPILER_PATH="/usr/lib/llvm-17/bin/clang" diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 61b93f1d906..fc6e9de9090 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -142,8 +142,7 @@ WORKDIR / RUN mkdir -p /usr/lib/x86_64-linux-gnu/include/ && \ ln -s /usr/include/cudnn.h /usr/local/cuda/include/cudnn.h && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so /usr/local/cuda/lib64/libcudnn.so && \ - ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so.${TF_CUDNN_VERSION} /usr/local/cuda/lib64/libcudnn.so.${TF_CUDNN_VERSION} && \ - printf '#ifndef CUDA_BF16_FIX_H_\n#define CUDA_BF16_FIX_H_\n#if defined(__clang__)\n# if defined(__is_identifier)\n# if __is_identifier(__bf16)\n# ifndef __bf16\ntypedef unsigned short __bf16;\n# endif\n# endif\n# endif\n#else\n# ifndef __bf16\ntypedef unsigned short __bf16;\n# endif\n#endif\n#endif\n' > /usr/include/cuda_bf16_fix.h + ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so.${TF_CUDNN_VERSION} /usr/local/cuda/lib64/libcudnn.so.${TF_CUDNN_VERSION} # For backward compatibility we need this line. After 1.13 we can safely remove # it. From 71df622c3099806ed9658c34465d6f3e746b2cfc Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Fri, 24 Jul 2026 06:11:07 +0000 Subject: [PATCH 102/183] Patch emmintrin.h in Dockerfile.devel-gpu for GCC 10 and LLVM 18 Bazel cache to natively guard __bf16 without command-line flags --- .bazelrc | 1 - tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 5 ++++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.bazelrc b/.bazelrc index 4b2985f7df1..75ef4befae2 100644 --- a/.bazelrc +++ b/.bazelrc @@ -36,7 +36,6 @@ build:cuda --copt=-Wno-error build:cuda --cxxopt=-Wno-error build:cuda --copt=-Wno-header-guard build:cuda --cxxopt=-Wno-header-guard -build:cuda --cxxopt=-D__bf16=__UINT16_TYPE__ build:cuda_clang --action_env=GCC_HOST_COMPILER_PATH="/usr/bin/gcc-10" build:cuda_clang --action_env=CLANG_CUDA_COMPILER_PATH="/usr/lib/llvm-17/bin/clang" diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index fc6e9de9090..c4e2fa78327 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -142,7 +142,8 @@ WORKDIR / RUN mkdir -p /usr/lib/x86_64-linux-gnu/include/ && \ ln -s /usr/include/cudnn.h /usr/local/cuda/include/cudnn.h && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so /usr/local/cuda/lib64/libcudnn.so && \ - ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so.${TF_CUDNN_VERSION} /usr/local/cuda/lib64/libcudnn.so.${TF_CUDNN_VERSION} + ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so.${TF_CUDNN_VERSION} /usr/local/cuda/lib64/libcudnn.so.${TF_CUDNN_VERSION} && \ + find /usr/lib/gcc -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf/#ifndef __bf16\ntypedef unsigned short __bf16;\n#endif\ntypedef __bf16 __v8bf/' {} + # For backward compatibility we need this line. After 1.13 we can safely remove # it. @@ -161,6 +162,8 @@ ARG TF_SERVING_BAZEL_OPTIONS="--repo_env=HERMETIC_CUDA_VERSION=12.2.0 --repo_env RUN echo "Building with Bazel options: ${TF_SERVING_BAZEL_OPTIONS}" RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1 && \ + LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} bazel fetch --config=cuda ${TF_SERVING_BAZEL_OPTIONS} ${TF_SERVING_BUILD_OPTIONS} tensorflow_serving/model_servers:tensorflow_model_server || true && \ + find /root/.cache/bazel -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf/#ifndef __bf16\ntypedef unsigned short __bf16;\n#endif\ntypedef __bf16 __v8bf/' {} + && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ bazel build --color=yes --noshow_progress --curses=no --config=cuda --copt="-fPIC"\ ${TF_SERVING_BAZEL_OPTIONS} \ From 18cdc59c5cfd7f8041ece49bbe65c1498c091e1e Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Fri, 24 Jul 2026 06:57:50 +0000 Subject: [PATCH 103/183] Update emmintrin.h sed patch in Dockerfile.devel-gpu with __is_identifier(__bf16) guard to respect Clang 18 native builtin keyword while typedefing __bf16 for Clang CUDA and GCC host passes --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index c4e2fa78327..6f12eae4101 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -143,7 +143,7 @@ RUN mkdir -p /usr/lib/x86_64-linux-gnu/include/ && \ ln -s /usr/include/cudnn.h /usr/local/cuda/include/cudnn.h && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so /usr/local/cuda/lib64/libcudnn.so && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so.${TF_CUDNN_VERSION} /usr/local/cuda/lib64/libcudnn.so.${TF_CUDNN_VERSION} && \ - find /usr/lib/gcc -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf/#ifndef __bf16\ntypedef unsigned short __bf16;\n#endif\ntypedef __bf16 __v8bf/' {} + + find /usr/lib/gcc -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf/#if defined(__clang__)\n#if defined(__is_identifier)\n#if __is_identifier(__bf16)\n#ifndef __bf16\ntypedef unsigned short __bf16;\n#endif\n#endif\n#endif\n#else\n#ifndef __bf16\ntypedef unsigned short __bf16;\n#endif\n#endif\ntypedef __bf16 __v8bf/' {} + # For backward compatibility we need this line. After 1.13 we can safely remove # it. @@ -163,7 +163,7 @@ RUN echo "Building with Bazel options: ${TF_SERVING_BAZEL_OPTIONS}" RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1 && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} bazel fetch --config=cuda ${TF_SERVING_BAZEL_OPTIONS} ${TF_SERVING_BUILD_OPTIONS} tensorflow_serving/model_servers:tensorflow_model_server || true && \ - find /root/.cache/bazel -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf/#ifndef __bf16\ntypedef unsigned short __bf16;\n#endif\ntypedef __bf16 __v8bf/' {} + && \ + find /root/.cache/bazel -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf/#if defined(__clang__)\n#if defined(__is_identifier)\n#if __is_identifier(__bf16)\n#ifndef __bf16\ntypedef unsigned short __bf16;\n#endif\n#endif\n#endif\n#else\n#ifndef __bf16\ntypedef unsigned short __bf16;\n#endif\n#endif\ntypedef __bf16 __v8bf/' {} + && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ bazel build --color=yes --noshow_progress --curses=no --config=cuda --copt="-fPIC"\ ${TF_SERVING_BAZEL_OPTIONS} \ From 5d56b5a61e54e832fca6dadbad6b9bdbbf854093 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Fri, 24 Jul 2026 07:30:21 +0000 Subject: [PATCH 104/183] Patch clang_cuda_runtime_wrapper.h in Dockerfile.devel-gpu to define typedef unsigned short __bf16 for Clang CUDA passes (defined(__CUDA__)) --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 6f12eae4101..f36b8bb1e09 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -142,8 +142,7 @@ WORKDIR / RUN mkdir -p /usr/lib/x86_64-linux-gnu/include/ && \ ln -s /usr/include/cudnn.h /usr/local/cuda/include/cudnn.h && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so /usr/local/cuda/lib64/libcudnn.so && \ - ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so.${TF_CUDNN_VERSION} /usr/local/cuda/lib64/libcudnn.so.${TF_CUDNN_VERSION} && \ - find /usr/lib/gcc -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf/#if defined(__clang__)\n#if defined(__is_identifier)\n#if __is_identifier(__bf16)\n#ifndef __bf16\ntypedef unsigned short __bf16;\n#endif\n#endif\n#endif\n#else\n#ifndef __bf16\ntypedef unsigned short __bf16;\n#endif\n#endif\ntypedef __bf16 __v8bf/' {} + + ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so.${TF_CUDNN_VERSION} /usr/local/cuda/lib64/libcudnn.so.${TF_CUDNN_VERSION} # For backward compatibility we need this line. After 1.13 we can safely remove # it. @@ -163,7 +162,7 @@ RUN echo "Building with Bazel options: ${TF_SERVING_BAZEL_OPTIONS}" RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1 && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} bazel fetch --config=cuda ${TF_SERVING_BAZEL_OPTIONS} ${TF_SERVING_BUILD_OPTIONS} tensorflow_serving/model_servers:tensorflow_model_server || true && \ - find /root/.cache/bazel -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf/#if defined(__clang__)\n#if defined(__is_identifier)\n#if __is_identifier(__bf16)\n#ifndef __bf16\ntypedef unsigned short __bf16;\n#endif\n#endif\n#endif\n#else\n#ifndef __bf16\ntypedef unsigned short __bf16;\n#endif\n#endif\ntypedef __bf16 __v8bf/' {} + && \ + find /root/.cache/bazel -name "clang_cuda_runtime_wrapper.h" -exec sed -i '1i #if defined(__clang__) \&\& defined(__CUDA__)\n#ifndef __bf16\ntypedef unsigned short __bf16;\n#define __bf16 __bf16\n#endif\n#endif' {} + && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ bazel build --color=yes --noshow_progress --curses=no --config=cuda --copt="-fPIC"\ ${TF_SERVING_BAZEL_OPTIONS} \ From 88aa9b143b33cd1d0b69c8b8d94c4dbcd7d978f0 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Fri, 24 Jul 2026 08:20:50 +0000 Subject: [PATCH 105/183] Add missing //xla/tsl/platform/default:dso_loader dependency to nvshmem rule in Dockerfile.devel-gpu --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 1 + 1 file changed, 1 insertion(+) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index f36b8bb1e09..a66d12837c1 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -163,6 +163,7 @@ RUN echo "Building with Bazel options: ${TF_SERVING_BAZEL_OPTIONS}" RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1 && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} bazel fetch --config=cuda ${TF_SERVING_BAZEL_OPTIONS} ${TF_SERVING_BUILD_OPTIONS} tensorflow_serving/model_servers:tensorflow_model_server || true && \ find /root/.cache/bazel -name "clang_cuda_runtime_wrapper.h" -exec sed -i '1i #if defined(__clang__) \&\& defined(__CUDA__)\n#ifndef __bf16\ntypedef unsigned short __bf16;\n#define __bf16 __bf16\n#endif\n#endif' {} + && \ + find /root/.cache/bazel -path "*/xla/tsl/cuda/BUILD.bazel" -exec sed -i 's|name = "nvshmem",|name = "nvshmem",\n deps = ["//xla/tsl/platform/default:dso_loader", "//xla/tsl/platform:dso_loader"],|' {} + && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ bazel build --color=yes --noshow_progress --curses=no --config=cuda --copt="-fPIC"\ ${TF_SERVING_BAZEL_OPTIONS} \ From 8d9c37cec6515d6fe0a7150b36dc4443f24d133f Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Fri, 24 Jul 2026 08:52:47 +0000 Subject: [PATCH 106/183] Fix Starlark syntax in xla/tsl/cuda/BUILD.bazel sed patch by appending dso_loader into existing deps array --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index a66d12837c1..043bce490eb 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -163,7 +163,7 @@ RUN echo "Building with Bazel options: ${TF_SERVING_BAZEL_OPTIONS}" RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1 && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} bazel fetch --config=cuda ${TF_SERVING_BAZEL_OPTIONS} ${TF_SERVING_BUILD_OPTIONS} tensorflow_serving/model_servers:tensorflow_model_server || true && \ find /root/.cache/bazel -name "clang_cuda_runtime_wrapper.h" -exec sed -i '1i #if defined(__clang__) \&\& defined(__CUDA__)\n#ifndef __bf16\ntypedef unsigned short __bf16;\n#define __bf16 __bf16\n#endif\n#endif' {} + && \ - find /root/.cache/bazel -path "*/xla/tsl/cuda/BUILD.bazel" -exec sed -i 's|name = "nvshmem",|name = "nvshmem",\n deps = ["//xla/tsl/platform/default:dso_loader", "//xla/tsl/platform:dso_loader"],|' {} + && \ + find /root/.cache/bazel -path "*/xla/tsl/cuda/BUILD.bazel" -exec sed -i '/name = "nvshmem"/,/deps = \[/ s|deps = \[|deps = \[\n "//xla/tsl/platform/default:dso_loader",|' {} + && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ bazel build --color=yes --noshow_progress --curses=no --config=cuda --copt="-fPIC"\ ${TF_SERVING_BAZEL_OPTIONS} \ From 59965cb8a3a743e12b467e7543281e8113ebeae9 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Fri, 24 Jul 2026 09:24:28 +0000 Subject: [PATCH 107/183] Apply universal emmintrin.h patch in Dockerfile.devel-gpu for NVCC CUDA, Clang CUDA, GCC host, and Clang host passes --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 043bce490eb..976aab1ddaf 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -142,7 +142,8 @@ WORKDIR / RUN mkdir -p /usr/lib/x86_64-linux-gnu/include/ && \ ln -s /usr/include/cudnn.h /usr/local/cuda/include/cudnn.h && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so /usr/local/cuda/lib64/libcudnn.so && \ - ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so.${TF_CUDNN_VERSION} /usr/local/cuda/lib64/libcudnn.so.${TF_CUDNN_VERSION} + ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so.${TF_CUDNN_VERSION} /usr/local/cuda/lib64/libcudnn.so.${TF_CUDNN_VERSION} && \ + find /usr/lib/gcc -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf/#ifndef __bf16\n#if !defined(__clang__) || defined(__CUDA__) || (defined(__is_identifier) \&\& __is_identifier(__bf16))\ntypedef unsigned short __bf16;\n#define __bf16 __bf16\n#endif\n#endif\ntypedef __bf16 __v8bf/' {} + # For backward compatibility we need this line. After 1.13 we can safely remove # it. @@ -162,7 +163,7 @@ RUN echo "Building with Bazel options: ${TF_SERVING_BAZEL_OPTIONS}" RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1 && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} bazel fetch --config=cuda ${TF_SERVING_BAZEL_OPTIONS} ${TF_SERVING_BUILD_OPTIONS} tensorflow_serving/model_servers:tensorflow_model_server || true && \ - find /root/.cache/bazel -name "clang_cuda_runtime_wrapper.h" -exec sed -i '1i #if defined(__clang__) \&\& defined(__CUDA__)\n#ifndef __bf16\ntypedef unsigned short __bf16;\n#define __bf16 __bf16\n#endif\n#endif' {} + && \ + find /root/.cache/bazel -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf/#ifndef __bf16\n#if !defined(__clang__) || defined(__CUDA__) || (defined(__is_identifier) \&\& __is_identifier(__bf16))\ntypedef unsigned short __bf16;\n#define __bf16 __bf16\n#endif\n#endif\ntypedef __bf16 __v8bf/' {} + && \ find /root/.cache/bazel -path "*/xla/tsl/cuda/BUILD.bazel" -exec sed -i '/name = "nvshmem"/,/deps = \[/ s|deps = \[|deps = \[\n "//xla/tsl/platform/default:dso_loader",|' {} + && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ bazel build --color=yes --noshow_progress --curses=no --config=cuda --copt="-fPIC"\ From c9e5cb182a0e58c0b064219ece00a3e995b3d16b Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Fri, 24 Jul 2026 09:50:24 +0000 Subject: [PATCH 108/183] Update emmintrin.h patch in Dockerfile.devel-gpu with __BF16_TYPE__ compiler builtin macro guard --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 976aab1ddaf..c5d571bcb22 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -143,7 +143,7 @@ RUN mkdir -p /usr/lib/x86_64-linux-gnu/include/ && \ ln -s /usr/include/cudnn.h /usr/local/cuda/include/cudnn.h && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so /usr/local/cuda/lib64/libcudnn.so && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so.${TF_CUDNN_VERSION} /usr/local/cuda/lib64/libcudnn.so.${TF_CUDNN_VERSION} && \ - find /usr/lib/gcc -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf/#ifndef __bf16\n#if !defined(__clang__) || defined(__CUDA__) || (defined(__is_identifier) \&\& __is_identifier(__bf16))\ntypedef unsigned short __bf16;\n#define __bf16 __bf16\n#endif\n#endif\ntypedef __bf16 __v8bf/' {} + + find /usr/lib/gcc -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf/#ifndef __BF16_TYPE__\n#ifndef __bf16\ntypedef unsigned short __bf16;\n#define __bf16 __bf16\n#endif\n#endif\ntypedef __bf16 __v8bf/' {} + # For backward compatibility we need this line. After 1.13 we can safely remove # it. @@ -163,7 +163,7 @@ RUN echo "Building with Bazel options: ${TF_SERVING_BAZEL_OPTIONS}" RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1 && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} bazel fetch --config=cuda ${TF_SERVING_BAZEL_OPTIONS} ${TF_SERVING_BUILD_OPTIONS} tensorflow_serving/model_servers:tensorflow_model_server || true && \ - find /root/.cache/bazel -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf/#ifndef __bf16\n#if !defined(__clang__) || defined(__CUDA__) || (defined(__is_identifier) \&\& __is_identifier(__bf16))\ntypedef unsigned short __bf16;\n#define __bf16 __bf16\n#endif\n#endif\ntypedef __bf16 __v8bf/' {} + && \ + find /root/.cache/bazel -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf/#ifndef __BF16_TYPE__\n#ifndef __bf16\ntypedef unsigned short __bf16;\n#define __bf16 __bf16\n#endif\n#endif\ntypedef __bf16 __v8bf/' {} + && \ find /root/.cache/bazel -path "*/xla/tsl/cuda/BUILD.bazel" -exec sed -i '/name = "nvshmem"/,/deps = \[/ s|deps = \[|deps = \[\n "//xla/tsl/platform/default:dso_loader",|' {} + && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ bazel build --color=yes --noshow_progress --curses=no --config=cuda --copt="-fPIC"\ From 6bf3bc521b5621d028e315f5ca78a53662d3fbf5 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Fri, 24 Jul 2026 10:35:24 +0000 Subject: [PATCH 109/183] Update emmintrin.h patch in Dockerfile.devel-gpu with unified !defined(__clang__) || __is_identifier(__bf16) guard --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index c5d571bcb22..042eddb4855 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -143,7 +143,7 @@ RUN mkdir -p /usr/lib/x86_64-linux-gnu/include/ && \ ln -s /usr/include/cudnn.h /usr/local/cuda/include/cudnn.h && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so /usr/local/cuda/lib64/libcudnn.so && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so.${TF_CUDNN_VERSION} /usr/local/cuda/lib64/libcudnn.so.${TF_CUDNN_VERSION} && \ - find /usr/lib/gcc -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf/#ifndef __BF16_TYPE__\n#ifndef __bf16\ntypedef unsigned short __bf16;\n#define __bf16 __bf16\n#endif\n#endif\ntypedef __bf16 __v8bf/' {} + + find /usr/lib/gcc -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf/#if !defined(__clang__) || (defined(__is_identifier) \&\& __is_identifier(__bf16))\n#ifndef __bf16\ntypedef unsigned short __bf16;\n#define __bf16 __bf16\n#endif\n#endif\ntypedef __bf16 __v8bf/' {} + # For backward compatibility we need this line. After 1.13 we can safely remove # it. @@ -163,7 +163,7 @@ RUN echo "Building with Bazel options: ${TF_SERVING_BAZEL_OPTIONS}" RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1 && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} bazel fetch --config=cuda ${TF_SERVING_BAZEL_OPTIONS} ${TF_SERVING_BUILD_OPTIONS} tensorflow_serving/model_servers:tensorflow_model_server || true && \ - find /root/.cache/bazel -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf/#ifndef __BF16_TYPE__\n#ifndef __bf16\ntypedef unsigned short __bf16;\n#define __bf16 __bf16\n#endif\n#endif\ntypedef __bf16 __v8bf/' {} + && \ + find /root/.cache/bazel -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf/#if !defined(__clang__) || (defined(__is_identifier) \&\& __is_identifier(__bf16))\n#ifndef __bf16\ntypedef unsigned short __bf16;\n#define __bf16 __bf16\n#endif\n#endif\ntypedef __bf16 __v8bf/' {} + && \ find /root/.cache/bazel -path "*/xla/tsl/cuda/BUILD.bazel" -exec sed -i '/name = "nvshmem"/,/deps = \[/ s|deps = \[|deps = \[\n "//xla/tsl/platform/default:dso_loader",|' {} + && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ bazel build --color=yes --noshow_progress --curses=no --config=cuda --copt="-fPIC"\ From e76132df00738505beedbce78ebc89e36d09498f Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Fri, 24 Jul 2026 10:50:47 +0000 Subject: [PATCH 110/183] Apply strictly-scoped macro patch in emmintrin.h to define #define __bf16 unsigned short ONLY across lines 47-48 and #undef immediately after --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 042eddb4855..1bcb7174065 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -143,7 +143,8 @@ RUN mkdir -p /usr/lib/x86_64-linux-gnu/include/ && \ ln -s /usr/include/cudnn.h /usr/local/cuda/include/cudnn.h && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so /usr/local/cuda/lib64/libcudnn.so && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so.${TF_CUDNN_VERSION} /usr/local/cuda/lib64/libcudnn.so.${TF_CUDNN_VERSION} && \ - find /usr/lib/gcc -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf/#if !defined(__clang__) || (defined(__is_identifier) \&\& __is_identifier(__bf16))\n#ifndef __bf16\ntypedef unsigned short __bf16;\n#define __bf16 __bf16\n#endif\n#endif\ntypedef __bf16 __v8bf/' {} + + find /usr/lib/gcc -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf/#ifndef __bf16\n#define __bf16 unsigned short\n#define __EMMINTRIN_BF16_PATCHED 1\n#endif\ntypedef __bf16 __v8bf/' {} + && \ + find /usr/lib/gcc -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __m128bh.*/typedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#ifdef __EMMINTRIN_BF16_PATCHED\n#undef __bf16\n#undef __EMMINTRIN_BF16_PATCHED\n#endif/' {} + # For backward compatibility we need this line. After 1.13 we can safely remove # it. @@ -163,7 +164,8 @@ RUN echo "Building with Bazel options: ${TF_SERVING_BAZEL_OPTIONS}" RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1 && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} bazel fetch --config=cuda ${TF_SERVING_BAZEL_OPTIONS} ${TF_SERVING_BUILD_OPTIONS} tensorflow_serving/model_servers:tensorflow_model_server || true && \ - find /root/.cache/bazel -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf/#if !defined(__clang__) || (defined(__is_identifier) \&\& __is_identifier(__bf16))\n#ifndef __bf16\ntypedef unsigned short __bf16;\n#define __bf16 __bf16\n#endif\n#endif\ntypedef __bf16 __v8bf/' {} + && \ + find /root/.cache/bazel -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf/#ifndef __bf16\n#define __bf16 unsigned short\n#define __EMMINTRIN_BF16_PATCHED 1\n#endif\ntypedef __bf16 __v8bf/' {} + && \ + find /root/.cache/bazel -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __m128bh.*/typedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#ifdef __EMMINTRIN_BF16_PATCHED\n#undef __bf16\n#undef __EMMINTRIN_BF16_PATCHED\n#endif/' {} + && \ find /root/.cache/bazel -path "*/xla/tsl/cuda/BUILD.bazel" -exec sed -i '/name = "nvshmem"/,/deps = \[/ s|deps = \[|deps = \[\n "//xla/tsl/platform/default:dso_loader",|' {} + && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ bazel build --color=yes --noshow_progress --curses=no --config=cuda --copt="-fPIC"\ From f356f78a4d0a17fade548c7841946f32244e668b Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Fri, 24 Jul 2026 11:10:25 +0000 Subject: [PATCH 111/183] Guard lines 47-48 in emmintrin.h with hardware feature macros (!defined(__clang__) || defined(__BF16_TYPE__)) to skip unneeded BF16 vector typedefs without creating synthetic macros or typedefs --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 1bcb7174065..894ef5b93d6 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -143,8 +143,8 @@ RUN mkdir -p /usr/lib/x86_64-linux-gnu/include/ && \ ln -s /usr/include/cudnn.h /usr/local/cuda/include/cudnn.h && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so /usr/local/cuda/lib64/libcudnn.so && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so.${TF_CUDNN_VERSION} /usr/local/cuda/lib64/libcudnn.so.${TF_CUDNN_VERSION} && \ - find /usr/lib/gcc -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf/#ifndef __bf16\n#define __bf16 unsigned short\n#define __EMMINTRIN_BF16_PATCHED 1\n#endif\ntypedef __bf16 __v8bf/' {} + && \ - find /usr/lib/gcc -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __m128bh.*/typedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#ifdef __EMMINTRIN_BF16_PATCHED\n#undef __bf16\n#undef __EMMINTRIN_BF16_PATCHED\n#endif/' {} + + find /usr/lib/gcc -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf/#if !defined(__clang__) || defined(__BF16_TYPE__) || defined(__ARM_BF16_FORMAT_BF16)\ntypedef __bf16 __v8bf/' {} + && \ + find /usr/lib/gcc -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __m128bh.*/typedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif/' {} + # For backward compatibility we need this line. After 1.13 we can safely remove # it. @@ -164,8 +164,8 @@ RUN echo "Building with Bazel options: ${TF_SERVING_BAZEL_OPTIONS}" RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1 && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} bazel fetch --config=cuda ${TF_SERVING_BAZEL_OPTIONS} ${TF_SERVING_BUILD_OPTIONS} tensorflow_serving/model_servers:tensorflow_model_server || true && \ - find /root/.cache/bazel -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf/#ifndef __bf16\n#define __bf16 unsigned short\n#define __EMMINTRIN_BF16_PATCHED 1\n#endif\ntypedef __bf16 __v8bf/' {} + && \ - find /root/.cache/bazel -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __m128bh.*/typedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#ifdef __EMMINTRIN_BF16_PATCHED\n#undef __bf16\n#undef __EMMINTRIN_BF16_PATCHED\n#endif/' {} + && \ + find /root/.cache/bazel -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf/#if !defined(__clang__) || defined(__BF16_TYPE__) || defined(__ARM_BF16_FORMAT_BF16)\ntypedef __bf16 __v8bf/' {} + && \ + find /root/.cache/bazel -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __m128bh.*/typedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif/' {} + && \ find /root/.cache/bazel -path "*/xla/tsl/cuda/BUILD.bazel" -exec sed -i '/name = "nvshmem"/,/deps = \[/ s|deps = \[|deps = \[\n "//xla/tsl/platform/default:dso_loader",|' {} + && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ bazel build --color=yes --noshow_progress --curses=no --config=cuda --copt="-fPIC"\ From 9dd2b5d065359157baa8de5bf8169725f59ec79f Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Fri, 24 Jul 2026 11:34:16 +0000 Subject: [PATCH 112/183] Typedef __v8bf and __m128bh to unsigned short vector types in emmintrin.h when Clang lacks native __BF16_TYPE__ support --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 894ef5b93d6..19bb915463c 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -143,8 +143,7 @@ RUN mkdir -p /usr/lib/x86_64-linux-gnu/include/ && \ ln -s /usr/include/cudnn.h /usr/local/cuda/include/cudnn.h && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so /usr/local/cuda/lib64/libcudnn.so && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so.${TF_CUDNN_VERSION} /usr/local/cuda/lib64/libcudnn.so.${TF_CUDNN_VERSION} && \ - find /usr/lib/gcc -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf/#if !defined(__clang__) || defined(__BF16_TYPE__) || defined(__ARM_BF16_FORMAT_BF16)\ntypedef __bf16 __v8bf/' {} + && \ - find /usr/lib/gcc -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __m128bh.*/typedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif/' {} + + find /usr/lib/gcc -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf.*/#if defined(__clang__) \&\& !defined(__BF16_TYPE__) \&\& !defined(__ARM_BF16_FORMAT_BF16)\ntypedef unsigned short __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef unsigned short __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#else\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif/' {} + # For backward compatibility we need this line. After 1.13 we can safely remove # it. @@ -164,8 +163,7 @@ RUN echo "Building with Bazel options: ${TF_SERVING_BAZEL_OPTIONS}" RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1 && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} bazel fetch --config=cuda ${TF_SERVING_BAZEL_OPTIONS} ${TF_SERVING_BUILD_OPTIONS} tensorflow_serving/model_servers:tensorflow_model_server || true && \ - find /root/.cache/bazel -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf/#if !defined(__clang__) || defined(__BF16_TYPE__) || defined(__ARM_BF16_FORMAT_BF16)\ntypedef __bf16 __v8bf/' {} + && \ - find /root/.cache/bazel -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __m128bh.*/typedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif/' {} + && \ + find /root/.cache/bazel -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf.*/#if defined(__clang__) \&\& !defined(__BF16_TYPE__) \&\& !defined(__ARM_BF16_FORMAT_BF16)\ntypedef unsigned short __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef unsigned short __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#else\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif/' {} + && \ find /root/.cache/bazel -path "*/xla/tsl/cuda/BUILD.bazel" -exec sed -i '/name = "nvshmem"/,/deps = \[/ s|deps = \[|deps = \[\n "//xla/tsl/platform/default:dso_loader",|' {} + && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ bazel build --color=yes --noshow_progress --curses=no --config=cuda --copt="-fPIC"\ From 814161141638cff7dd807a4ea8bb5d64c3fad1ac Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Fri, 24 Jul 2026 15:17:28 +0000 Subject: [PATCH 113/183] Add __v8bf_defined include guard to emmintrin.h vector typedefs to guarantee single evaluation per translation unit --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 19bb915463c..bebdbff0167 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -143,7 +143,7 @@ RUN mkdir -p /usr/lib/x86_64-linux-gnu/include/ && \ ln -s /usr/include/cudnn.h /usr/local/cuda/include/cudnn.h && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so /usr/local/cuda/lib64/libcudnn.so && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so.${TF_CUDNN_VERSION} /usr/local/cuda/lib64/libcudnn.so.${TF_CUDNN_VERSION} && \ - find /usr/lib/gcc -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf.*/#if defined(__clang__) \&\& !defined(__BF16_TYPE__) \&\& !defined(__ARM_BF16_FORMAT_BF16)\ntypedef unsigned short __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef unsigned short __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#else\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif/' {} + + find /usr/lib/gcc -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__clang__) \&\& !defined(__BF16_TYPE__) \&\& !defined(__ARM_BF16_FORMAT_BF16)\ntypedef unsigned short __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef unsigned short __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#else\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif\n#endif/' {} + # For backward compatibility we need this line. After 1.13 we can safely remove # it. @@ -163,7 +163,7 @@ RUN echo "Building with Bazel options: ${TF_SERVING_BAZEL_OPTIONS}" RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1 && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} bazel fetch --config=cuda ${TF_SERVING_BAZEL_OPTIONS} ${TF_SERVING_BUILD_OPTIONS} tensorflow_serving/model_servers:tensorflow_model_server || true && \ - find /root/.cache/bazel -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf.*/#if defined(__clang__) \&\& !defined(__BF16_TYPE__) \&\& !defined(__ARM_BF16_FORMAT_BF16)\ntypedef unsigned short __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef unsigned short __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#else\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif/' {} + && \ + find /root/.cache/bazel -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__clang__) \&\& !defined(__BF16_TYPE__) \&\& !defined(__ARM_BF16_FORMAT_BF16)\ntypedef unsigned short __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef unsigned short __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#else\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif\n#endif/' {} + && \ find /root/.cache/bazel -path "*/xla/tsl/cuda/BUILD.bazel" -exec sed -i '/name = "nvshmem"/,/deps = \[/ s|deps = \[|deps = \[\n "//xla/tsl/platform/default:dso_loader",|' {} + && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ bazel build --color=yes --noshow_progress --curses=no --config=cuda --copt="-fPIC"\ From 9979d0b486eaf25b6099770bf3a79d1df5041d5f Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Fri, 24 Jul 2026 15:42:22 +0000 Subject: [PATCH 114/183] Delete duplicate original __m128bh typedef line before inserting __v8bf_defined guarded block in emmintrin.h --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index bebdbff0167..248342f6d4a 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -143,6 +143,7 @@ RUN mkdir -p /usr/lib/x86_64-linux-gnu/include/ && \ ln -s /usr/include/cudnn.h /usr/local/cuda/include/cudnn.h && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so /usr/local/cuda/lib64/libcudnn.so && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so.${TF_CUDNN_VERSION} /usr/local/cuda/lib64/libcudnn.so.${TF_CUDNN_VERSION} && \ + find /usr/lib/gcc -name "emmintrin.h" -exec sed -i '/typedef __bf16 __m128bh/d' {} + && \ find /usr/lib/gcc -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__clang__) \&\& !defined(__BF16_TYPE__) \&\& !defined(__ARM_BF16_FORMAT_BF16)\ntypedef unsigned short __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef unsigned short __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#else\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif\n#endif/' {} + # For backward compatibility we need this line. After 1.13 we can safely remove @@ -163,6 +164,7 @@ RUN echo "Building with Bazel options: ${TF_SERVING_BAZEL_OPTIONS}" RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1 && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} bazel fetch --config=cuda ${TF_SERVING_BAZEL_OPTIONS} ${TF_SERVING_BUILD_OPTIONS} tensorflow_serving/model_servers:tensorflow_model_server || true && \ + find /root/.cache/bazel -name "emmintrin.h" -exec sed -i '/typedef __bf16 __m128bh/d' {} + && \ find /root/.cache/bazel -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__clang__) \&\& !defined(__BF16_TYPE__) \&\& !defined(__ARM_BF16_FORMAT_BF16)\ntypedef unsigned short __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef unsigned short __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#else\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif\n#endif/' {} + && \ find /root/.cache/bazel -path "*/xla/tsl/cuda/BUILD.bazel" -exec sed -i '/name = "nvshmem"/,/deps = \[/ s|deps = \[|deps = \[\n "//xla/tsl/platform/default:dso_loader",|' {} + && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ From 072232c07b755a1ec8a1c8b5d010459b18d0223f Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Fri, 24 Jul 2026 16:29:05 +0000 Subject: [PATCH 115/183] Scope __bf16 typedef exclusively under CUDA compilation passes in emmintrin.h to preserve native Clang 18 __bf16 keyword types for AVX-NE-CONVERT builtins --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 248342f6d4a..1dcab67b6cd 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -144,7 +144,7 @@ RUN mkdir -p /usr/lib/x86_64-linux-gnu/include/ && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so /usr/local/cuda/lib64/libcudnn.so && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so.${TF_CUDNN_VERSION} /usr/local/cuda/lib64/libcudnn.so.${TF_CUDNN_VERSION} && \ find /usr/lib/gcc -name "emmintrin.h" -exec sed -i '/typedef __bf16 __m128bh/d' {} + && \ - find /usr/lib/gcc -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__clang__) \&\& !defined(__BF16_TYPE__) \&\& !defined(__ARM_BF16_FORMAT_BF16)\ntypedef unsigned short __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef unsigned short __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#else\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif\n#endif/' {} + + find /usr/lib/gcc -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if (defined(__CUDACC__) || defined(__CUDA__)) \&\& !defined(__bf16)\ntypedef unsigned short __bf16;\n#define __bf16 __bf16\n#endif\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif/' {} + # For backward compatibility we need this line. After 1.13 we can safely remove # it. @@ -165,7 +165,7 @@ RUN echo "Building with Bazel options: ${TF_SERVING_BAZEL_OPTIONS}" RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1 && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} bazel fetch --config=cuda ${TF_SERVING_BAZEL_OPTIONS} ${TF_SERVING_BUILD_OPTIONS} tensorflow_serving/model_servers:tensorflow_model_server || true && \ find /root/.cache/bazel -name "emmintrin.h" -exec sed -i '/typedef __bf16 __m128bh/d' {} + && \ - find /root/.cache/bazel -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__clang__) \&\& !defined(__BF16_TYPE__) \&\& !defined(__ARM_BF16_FORMAT_BF16)\ntypedef unsigned short __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef unsigned short __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#else\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif\n#endif/' {} + && \ + find /root/.cache/bazel -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if (defined(__CUDACC__) || defined(__CUDA__)) \&\& !defined(__bf16)\ntypedef unsigned short __bf16;\n#define __bf16 __bf16\n#endif\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif/' {} + && \ find /root/.cache/bazel -path "*/xla/tsl/cuda/BUILD.bazel" -exec sed -i '/name = "nvshmem"/,/deps = \[/ s|deps = \[|deps = \[\n "//xla/tsl/platform/default:dso_loader",|' {} + && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ bazel build --color=yes --noshow_progress --curses=no --config=cuda --copt="-fPIC"\ From 4587c014a091329e04069d5933a9fc7e0d9f043c Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Fri, 24 Jul 2026 17:57:15 +0000 Subject: [PATCH 116/183] Restrict typedef unsigned short __bf16 in emmintrin.h strictly to NVCC compiler passes (defined(__CUDACC__) && !defined(__clang__)) to preserve Clang 18 native keyword types for CUDA -x cuda passes --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 1dcab67b6cd..62fdf4480df 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -144,7 +144,7 @@ RUN mkdir -p /usr/lib/x86_64-linux-gnu/include/ && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so /usr/local/cuda/lib64/libcudnn.so && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so.${TF_CUDNN_VERSION} /usr/local/cuda/lib64/libcudnn.so.${TF_CUDNN_VERSION} && \ find /usr/lib/gcc -name "emmintrin.h" -exec sed -i '/typedef __bf16 __m128bh/d' {} + && \ - find /usr/lib/gcc -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if (defined(__CUDACC__) || defined(__CUDA__)) \&\& !defined(__bf16)\ntypedef unsigned short __bf16;\n#define __bf16 __bf16\n#endif\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif/' {} + + find /usr/lib/gcc -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__CUDACC__) \&\& !defined(__clang__) \&\& !defined(__bf16)\ntypedef unsigned short __bf16;\n#define __bf16 __bf16\n#endif\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif/' {} + # For backward compatibility we need this line. After 1.13 we can safely remove # it. @@ -165,7 +165,7 @@ RUN echo "Building with Bazel options: ${TF_SERVING_BAZEL_OPTIONS}" RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1 && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} bazel fetch --config=cuda ${TF_SERVING_BAZEL_OPTIONS} ${TF_SERVING_BUILD_OPTIONS} tensorflow_serving/model_servers:tensorflow_model_server || true && \ find /root/.cache/bazel -name "emmintrin.h" -exec sed -i '/typedef __bf16 __m128bh/d' {} + && \ - find /root/.cache/bazel -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if (defined(__CUDACC__) || defined(__CUDA__)) \&\& !defined(__bf16)\ntypedef unsigned short __bf16;\n#define __bf16 __bf16\n#endif\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif/' {} + && \ + find /root/.cache/bazel -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__CUDACC__) \&\& !defined(__clang__) \&\& !defined(__bf16)\ntypedef unsigned short __bf16;\n#define __bf16 __bf16\n#endif\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif/' {} + && \ find /root/.cache/bazel -path "*/xla/tsl/cuda/BUILD.bazel" -exec sed -i '/name = "nvshmem"/,/deps = \[/ s|deps = \[|deps = \[\n "//xla/tsl/platform/default:dso_loader",|' {} + && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ bazel build --color=yes --noshow_progress --curses=no --config=cuda --copt="-fPIC"\ From 1f85d126c56d2e93bc8688abd39bbca5fbcc8e56 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Fri, 24 Jul 2026 18:54:22 +0000 Subject: [PATCH 117/183] Clean up emmintrin.h patch: omit #define __bf16 __bf16 macro under NVCC to avoid misleading cuda_bf16.h header definitions --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 62fdf4480df..057b41d5b86 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -144,7 +144,7 @@ RUN mkdir -p /usr/lib/x86_64-linux-gnu/include/ && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so /usr/local/cuda/lib64/libcudnn.so && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so.${TF_CUDNN_VERSION} /usr/local/cuda/lib64/libcudnn.so.${TF_CUDNN_VERSION} && \ find /usr/lib/gcc -name "emmintrin.h" -exec sed -i '/typedef __bf16 __m128bh/d' {} + && \ - find /usr/lib/gcc -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__CUDACC__) \&\& !defined(__clang__) \&\& !defined(__bf16)\ntypedef unsigned short __bf16;\n#define __bf16 __bf16\n#endif\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif/' {} + + find /usr/lib/gcc -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__CUDACC__) \&\& !defined(__clang__)\ntypedef unsigned short __bf16;\n#endif\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif/' {} + # For backward compatibility we need this line. After 1.13 we can safely remove # it. @@ -165,7 +165,7 @@ RUN echo "Building with Bazel options: ${TF_SERVING_BAZEL_OPTIONS}" RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1 && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} bazel fetch --config=cuda ${TF_SERVING_BAZEL_OPTIONS} ${TF_SERVING_BUILD_OPTIONS} tensorflow_serving/model_servers:tensorflow_model_server || true && \ find /root/.cache/bazel -name "emmintrin.h" -exec sed -i '/typedef __bf16 __m128bh/d' {} + && \ - find /root/.cache/bazel -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__CUDACC__) \&\& !defined(__clang__) \&\& !defined(__bf16)\ntypedef unsigned short __bf16;\n#define __bf16 __bf16\n#endif\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif/' {} + && \ + find /root/.cache/bazel -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__CUDACC__) \&\& !defined(__clang__)\ntypedef unsigned short __bf16;\n#endif\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif/' {} + && \ find /root/.cache/bazel -path "*/xla/tsl/cuda/BUILD.bazel" -exec sed -i '/name = "nvshmem"/,/deps = \[/ s|deps = \[|deps = \[\n "//xla/tsl/platform/default:dso_loader",|' {} + && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ bazel build --color=yes --noshow_progress --curses=no --config=cuda --copt="-fPIC"\ From f0510279a32b00a91917a015504e3c6e561b7075 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Fri, 24 Jul 2026 20:26:20 +0000 Subject: [PATCH 118/183] Restrict typedef unsigned short __bf16 in emmintrin.h strictly to CUDA device compilation passes (defined(__CUDA_ARCH__)) to resolve Clang 18 CUDA device vs host parser keyword dichotomy --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 057b41d5b86..605b8beeb77 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -144,7 +144,7 @@ RUN mkdir -p /usr/lib/x86_64-linux-gnu/include/ && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so /usr/local/cuda/lib64/libcudnn.so && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so.${TF_CUDNN_VERSION} /usr/local/cuda/lib64/libcudnn.so.${TF_CUDNN_VERSION} && \ find /usr/lib/gcc -name "emmintrin.h" -exec sed -i '/typedef __bf16 __m128bh/d' {} + && \ - find /usr/lib/gcc -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__CUDACC__) \&\& !defined(__clang__)\ntypedef unsigned short __bf16;\n#endif\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif/' {} + + find /usr/lib/gcc -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__CUDA_ARCH__)\ntypedef unsigned short __bf16;\n#endif\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif/' {} + # For backward compatibility we need this line. After 1.13 we can safely remove # it. @@ -165,7 +165,7 @@ RUN echo "Building with Bazel options: ${TF_SERVING_BAZEL_OPTIONS}" RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1 && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} bazel fetch --config=cuda ${TF_SERVING_BAZEL_OPTIONS} ${TF_SERVING_BUILD_OPTIONS} tensorflow_serving/model_servers:tensorflow_model_server || true && \ find /root/.cache/bazel -name "emmintrin.h" -exec sed -i '/typedef __bf16 __m128bh/d' {} + && \ - find /root/.cache/bazel -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__CUDACC__) \&\& !defined(__clang__)\ntypedef unsigned short __bf16;\n#endif\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif/' {} + && \ + find /root/.cache/bazel -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__CUDA_ARCH__)\ntypedef unsigned short __bf16;\n#endif\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif/' {} + && \ find /root/.cache/bazel -path "*/xla/tsl/cuda/BUILD.bazel" -exec sed -i '/name = "nvshmem"/,/deps = \[/ s|deps = \[|deps = \[\n "//xla/tsl/platform/default:dso_loader",|' {} + && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ bazel build --color=yes --noshow_progress --curses=no --config=cuda --copt="-fPIC"\ From 0b0fe22310bdd55a019b4c80c7f8c5244a9b9431 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Fri, 24 Jul 2026 21:47:15 +0000 Subject: [PATCH 119/183] Use __BF16_TYPEDEF_DEFINED__ macro guard for CUDA host and device passes in emmintrin.h to guarantee single unsigned short __bf16 definition across all translation units --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 605b8beeb77..3600a0f87d3 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -144,7 +144,7 @@ RUN mkdir -p /usr/lib/x86_64-linux-gnu/include/ && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so /usr/local/cuda/lib64/libcudnn.so && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so.${TF_CUDNN_VERSION} /usr/local/cuda/lib64/libcudnn.so.${TF_CUDNN_VERSION} && \ find /usr/lib/gcc -name "emmintrin.h" -exec sed -i '/typedef __bf16 __m128bh/d' {} + && \ - find /usr/lib/gcc -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__CUDA_ARCH__)\ntypedef unsigned short __bf16;\n#endif\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif/' {} + + find /usr/lib/gcc -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if (defined(__CUDA__) || defined(__CUDACC__)) \&\& !defined(__BF16_TYPEDEF_DEFINED__)\ntypedef unsigned short __bf16;\n#define __BF16_TYPEDEF_DEFINED__\n#endif\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif/' {} + # For backward compatibility we need this line. After 1.13 we can safely remove # it. @@ -165,7 +165,7 @@ RUN echo "Building with Bazel options: ${TF_SERVING_BAZEL_OPTIONS}" RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1 && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} bazel fetch --config=cuda ${TF_SERVING_BAZEL_OPTIONS} ${TF_SERVING_BUILD_OPTIONS} tensorflow_serving/model_servers:tensorflow_model_server || true && \ find /root/.cache/bazel -name "emmintrin.h" -exec sed -i '/typedef __bf16 __m128bh/d' {} + && \ - find /root/.cache/bazel -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__CUDA_ARCH__)\ntypedef unsigned short __bf16;\n#endif\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif/' {} + && \ + find /root/.cache/bazel -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if (defined(__CUDA__) || defined(__CUDACC__)) \&\& !defined(__BF16_TYPEDEF_DEFINED__)\ntypedef unsigned short __bf16;\n#define __BF16_TYPEDEF_DEFINED__\n#endif\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif/' {} + && \ find /root/.cache/bazel -path "*/xla/tsl/cuda/BUILD.bazel" -exec sed -i '/name = "nvshmem"/,/deps = \[/ s|deps = \[|deps = \[\n "//xla/tsl/platform/default:dso_loader",|' {} + && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ bazel build --color=yes --noshow_progress --curses=no --config=cuda --copt="-fPIC"\ From 6e83325d6a29f59f59d3aa8cb78bbd15b1b0523a Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Fri, 24 Jul 2026 23:08:07 +0000 Subject: [PATCH 120/183] Fix emmintrin.h bfloat16 vector typedefs under CUDA by using short vector types under CUDA and native __bf16 under host C++ --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 3600a0f87d3..6df9977ea54 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -144,7 +144,7 @@ RUN mkdir -p /usr/lib/x86_64-linux-gnu/include/ && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so /usr/local/cuda/lib64/libcudnn.so && \ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so.${TF_CUDNN_VERSION} /usr/local/cuda/lib64/libcudnn.so.${TF_CUDNN_VERSION} && \ find /usr/lib/gcc -name "emmintrin.h" -exec sed -i '/typedef __bf16 __m128bh/d' {} + && \ - find /usr/lib/gcc -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if (defined(__CUDA__) || defined(__CUDACC__)) \&\& !defined(__BF16_TYPEDEF_DEFINED__)\ntypedef unsigned short __bf16;\n#define __BF16_TYPEDEF_DEFINED__\n#endif\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif/' {} + + find /usr/lib/gcc -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__CUDA__) || defined(__CUDACC__)\ntypedef short __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef short __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#else\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif\n#endif/' {} + # For backward compatibility we need this line. After 1.13 we can safely remove # it. @@ -165,7 +165,7 @@ RUN echo "Building with Bazel options: ${TF_SERVING_BAZEL_OPTIONS}" RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1 && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} bazel fetch --config=cuda ${TF_SERVING_BAZEL_OPTIONS} ${TF_SERVING_BUILD_OPTIONS} tensorflow_serving/model_servers:tensorflow_model_server || true && \ find /root/.cache/bazel -name "emmintrin.h" -exec sed -i '/typedef __bf16 __m128bh/d' {} + && \ - find /root/.cache/bazel -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if (defined(__CUDA__) || defined(__CUDACC__)) \&\& !defined(__BF16_TYPEDEF_DEFINED__)\ntypedef unsigned short __bf16;\n#define __BF16_TYPEDEF_DEFINED__\n#endif\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif/' {} + && \ + find /root/.cache/bazel -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__CUDA__) || defined(__CUDACC__)\ntypedef short __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef short __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#else\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif\n#endif/' {} + && \ find /root/.cache/bazel -path "*/xla/tsl/cuda/BUILD.bazel" -exec sed -i '/name = "nvshmem"/,/deps = \[/ s|deps = \[|deps = \[\n "//xla/tsl/platform/default:dso_loader",|' {} + && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ bazel build --color=yes --noshow_progress --curses=no --config=cuda --copt="-fPIC"\ From 61ab3b8d02a2ff060b3d6cdec2486f8340e1eee0 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Sat, 25 Jul 2026 00:26:42 +0000 Subject: [PATCH 121/183] Patch Abseil btree.h invalid template syntax for Clang 18 C++17 CUDA host compilation --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 1 + 1 file changed, 1 insertion(+) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 6df9977ea54..ae644e88a1e 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -166,6 +166,7 @@ RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/lib LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} bazel fetch --config=cuda ${TF_SERVING_BAZEL_OPTIONS} ${TF_SERVING_BUILD_OPTIONS} tensorflow_serving/model_servers:tensorflow_model_server || true && \ find /root/.cache/bazel -name "emmintrin.h" -exec sed -i '/typedef __bf16 __m128bh/d' {} + && \ find /root/.cache/bazel -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__CUDA__) || defined(__CUDACC__)\ntypedef short __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef short __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#else\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif\n#endif/' {} + && \ + find /root/.cache/bazel -name "btree.h" -exec sed -i 's/typename container_internal::template btree::node_type \*parent;/node_type \*parent;/' {} + && \ find /root/.cache/bazel -path "*/xla/tsl/cuda/BUILD.bazel" -exec sed -i '/name = "nvshmem"/,/deps = \[/ s|deps = \[|deps = \[\n "//xla/tsl/platform/default:dso_loader",|' {} + && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ bazel build --color=yes --noshow_progress --curses=no --config=cuda --copt="-fPIC"\ From 106f347c347b9af1b353ac7598758c7a57a7c85e Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Sat, 25 Jul 2026 01:45:29 +0000 Subject: [PATCH 122/183] Fetch @com_google_absl//... before patching btree.h in Dockerfile.devel-gpu --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index ae644e88a1e..ff7ddb5c16c 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -163,10 +163,10 @@ ARG TF_SERVING_BAZEL_OPTIONS="--repo_env=HERMETIC_CUDA_VERSION=12.2.0 --repo_env RUN echo "Building with Bazel options: ${TF_SERVING_BAZEL_OPTIONS}" RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1 && \ - LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} bazel fetch --config=cuda ${TF_SERVING_BAZEL_OPTIONS} ${TF_SERVING_BUILD_OPTIONS} tensorflow_serving/model_servers:tensorflow_model_server || true && \ + LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} bazel fetch --config=cuda ${TF_SERVING_BAZEL_OPTIONS} ${TF_SERVING_BUILD_OPTIONS} tensorflow_serving/model_servers:tensorflow_model_server @com_google_absl//... || true && \ find /root/.cache/bazel -name "emmintrin.h" -exec sed -i '/typedef __bf16 __m128bh/d' {} + && \ find /root/.cache/bazel -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__CUDA__) || defined(__CUDACC__)\ntypedef short __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef short __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#else\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif\n#endif/' {} + && \ - find /root/.cache/bazel -name "btree.h" -exec sed -i 's/typename container_internal::template btree::node_type \*parent;/node_type \*parent;/' {} + && \ + find /root/.cache/bazel -name "btree.h" -exec sed -i 's/.*template btree::node_type \*parent;/ node_type \*parent;/' {} + && \ find /root/.cache/bazel -path "*/xla/tsl/cuda/BUILD.bazel" -exec sed -i '/name = "nvshmem"/,/deps = \[/ s|deps = \[|deps = \[\n "//xla/tsl/platform/default:dso_loader",|' {} + && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ bazel build --color=yes --noshow_progress --curses=no --config=cuda --copt="-fPIC"\ From 5fcd34fc413461cece421bdafa4f8daec79c1421 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Sat, 25 Jul 2026 03:04:40 +0000 Subject: [PATCH 123/183] Use bazel build --nobuild to extract all external dependency archives onto disk before sed patching in Dockerfile.devel-gpu --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index ff7ddb5c16c..4739286372d 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -163,7 +163,7 @@ ARG TF_SERVING_BAZEL_OPTIONS="--repo_env=HERMETIC_CUDA_VERSION=12.2.0 --repo_env RUN echo "Building with Bazel options: ${TF_SERVING_BAZEL_OPTIONS}" RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1 && \ - LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} bazel fetch --config=cuda ${TF_SERVING_BAZEL_OPTIONS} ${TF_SERVING_BUILD_OPTIONS} tensorflow_serving/model_servers:tensorflow_model_server @com_google_absl//... || true && \ + LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} bazel build --nobuild --config=cuda ${TF_SERVING_BAZEL_OPTIONS} ${TF_SERVING_BUILD_OPTIONS} tensorflow_serving/model_servers:tensorflow_model_server || true && \ find /root/.cache/bazel -name "emmintrin.h" -exec sed -i '/typedef __bf16 __m128bh/d' {} + && \ find /root/.cache/bazel -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__CUDA__) || defined(__CUDACC__)\ntypedef short __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef short __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#else\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif\n#endif/' {} + && \ find /root/.cache/bazel -name "btree.h" -exec sed -i 's/.*template btree::node_type \*parent;/ node_type \*parent;/' {} + && \ From 76e747385fe0b0a99d1b7bb91a6d5842a5670672 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Sat, 25 Jul 2026 04:23:04 +0000 Subject: [PATCH 124/183] Simplify Abseil btree.h sed regex to s/.*template btree.*/ node_type *parent;/ in Dockerfile.devel-gpu --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 4739286372d..ed23a051f50 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -166,7 +166,7 @@ RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/lib LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} bazel build --nobuild --config=cuda ${TF_SERVING_BAZEL_OPTIONS} ${TF_SERVING_BUILD_OPTIONS} tensorflow_serving/model_servers:tensorflow_model_server || true && \ find /root/.cache/bazel -name "emmintrin.h" -exec sed -i '/typedef __bf16 __m128bh/d' {} + && \ find /root/.cache/bazel -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__CUDA__) || defined(__CUDACC__)\ntypedef short __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef short __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#else\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif\n#endif/' {} + && \ - find /root/.cache/bazel -name "btree.h" -exec sed -i 's/.*template btree::node_type \*parent;/ node_type \*parent;/' {} + && \ + find /root/.cache/bazel -name "btree.h" -exec sed -i 's/.*template btree.*/ node_type \*parent;/' {} + && \ find /root/.cache/bazel -path "*/xla/tsl/cuda/BUILD.bazel" -exec sed -i '/name = "nvshmem"/,/deps = \[/ s|deps = \[|deps = \[\n "//xla/tsl/platform/default:dso_loader",|' {} + && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ bazel build --color=yes --noshow_progress --curses=no --config=cuda --copt="-fPIC"\ From af12fa5dea13d06215f9dde5c47d215dec495755 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Sat, 25 Jul 2026 05:40:01 +0000 Subject: [PATCH 125/183] Extract @com_google_absl archive to disk via bazel build before sed patching btree.h in Dockerfile.devel-gpu --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index ed23a051f50..a9134443f68 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -163,7 +163,8 @@ ARG TF_SERVING_BAZEL_OPTIONS="--repo_env=HERMETIC_CUDA_VERSION=12.2.0 --repo_env RUN echo "Building with Bazel options: ${TF_SERVING_BAZEL_OPTIONS}" RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1 && \ - LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} bazel build --nobuild --config=cuda ${TF_SERVING_BAZEL_OPTIONS} ${TF_SERVING_BUILD_OPTIONS} tensorflow_serving/model_servers:tensorflow_model_server || true && \ + LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} bazel fetch --config=cuda ${TF_SERVING_BAZEL_OPTIONS} ${TF_SERVING_BUILD_OPTIONS} tensorflow_serving/model_servers:tensorflow_model_server || true && \ + LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} bazel build --config=cuda ${TF_SERVING_BAZEL_OPTIONS} ${TF_SERVING_BUILD_OPTIONS} @com_google_absl//... || true && \ find /root/.cache/bazel -name "emmintrin.h" -exec sed -i '/typedef __bf16 __m128bh/d' {} + && \ find /root/.cache/bazel -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__CUDA__) || defined(__CUDACC__)\ntypedef short __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef short __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#else\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif\n#endif/' {} + && \ find /root/.cache/bazel -name "btree.h" -exec sed -i 's/.*template btree.*/ node_type \*parent;/' {} + && \ From 3b6614d0c492e13fe8b94b0cb582471d5c7a1443 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Sat, 25 Jul 2026 07:02:34 +0000 Subject: [PATCH 126/183] Make Bazel cache files writable with chmod -R +w before running sed in Dockerfile.devel-gpu --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 1 + 1 file changed, 1 insertion(+) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index a9134443f68..c4b61c93232 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -165,6 +165,7 @@ RUN echo "Building with Bazel options: ${TF_SERVING_BAZEL_OPTIONS}" RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1 && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} bazel fetch --config=cuda ${TF_SERVING_BAZEL_OPTIONS} ${TF_SERVING_BUILD_OPTIONS} tensorflow_serving/model_servers:tensorflow_model_server || true && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} bazel build --config=cuda ${TF_SERVING_BAZEL_OPTIONS} ${TF_SERVING_BUILD_OPTIONS} @com_google_absl//... || true && \ + chmod -R +w /root/.cache/bazel && \ find /root/.cache/bazel -name "emmintrin.h" -exec sed -i '/typedef __bf16 __m128bh/d' {} + && \ find /root/.cache/bazel -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__CUDA__) || defined(__CUDACC__)\ntypedef short __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef short __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#else\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif\n#endif/' {} + && \ find /root/.cache/bazel -name "btree.h" -exec sed -i 's/.*template btree.*/ node_type \*parent;/' {} + && \ From 3d38fc4a5c4a87470cc99fbeffb803fc26813c89 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Sat, 25 Jul 2026 08:26:28 +0000 Subject: [PATCH 127/183] Use bazel query @com_google_absl//... to force extraction of absl source files before sed patching btree.h in Dockerfile.devel-gpu --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index c4b61c93232..5be1630fb7b 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -164,12 +164,12 @@ RUN echo "Building with Bazel options: ${TF_SERVING_BAZEL_OPTIONS}" RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1 && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} bazel fetch --config=cuda ${TF_SERVING_BAZEL_OPTIONS} ${TF_SERVING_BUILD_OPTIONS} tensorflow_serving/model_servers:tensorflow_model_server || true && \ - LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} bazel build --config=cuda ${TF_SERVING_BAZEL_OPTIONS} ${TF_SERVING_BUILD_OPTIONS} @com_google_absl//... || true && \ - chmod -R +w /root/.cache/bazel && \ - find /root/.cache/bazel -name "emmintrin.h" -exec sed -i '/typedef __bf16 __m128bh/d' {} + && \ - find /root/.cache/bazel -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__CUDA__) || defined(__CUDACC__)\ntypedef short __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef short __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#else\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif\n#endif/' {} + && \ - find /root/.cache/bazel -name "btree.h" -exec sed -i 's/.*template btree.*/ node_type \*parent;/' {} + && \ - find /root/.cache/bazel -path "*/xla/tsl/cuda/BUILD.bazel" -exec sed -i '/name = "nvshmem"/,/deps = \[/ s|deps = \[|deps = \[\n "//xla/tsl/platform/default:dso_loader",|' {} + && \ + LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} bazel query @com_google_absl//... || true && \ + chmod -R +w /root/.cache && \ + find /root/.cache -name "emmintrin.h" -exec sed -i '/typedef __bf16 __m128bh/d' {} + && \ + find /root/.cache -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__CUDA__) || defined(__CUDACC__)\ntypedef short __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef short __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#else\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif\n#endif/' {} + && \ + find /root/.cache -name "btree.h" -exec sed -i 's/.*template btree.*/ node_type \*parent;/' {} + && \ + find /root/.cache -path "*/xla/tsl/cuda/BUILD.bazel" -exec sed -i '/name = "nvshmem"/,/deps = \[/ s|deps = \[|deps = \[\n "//xla/tsl/platform/default:dso_loader",|' {} + && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ bazel build --color=yes --noshow_progress --curses=no --config=cuda --copt="-fPIC"\ ${TF_SERVING_BAZEL_OPTIONS} \ From c855c49ee9fdeda21e0783c6bd7695e2c8e94fc4 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Sat, 25 Jul 2026 09:43:51 +0000 Subject: [PATCH 128/183] Use sed -i --follow-symlinks to ensure symlinked header files in Bazel cache are modified in-place in Dockerfile.devel-gpu --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 5be1630fb7b..5d7eca5be9c 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -166,10 +166,10 @@ RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/lib LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} bazel fetch --config=cuda ${TF_SERVING_BAZEL_OPTIONS} ${TF_SERVING_BUILD_OPTIONS} tensorflow_serving/model_servers:tensorflow_model_server || true && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} bazel query @com_google_absl//... || true && \ chmod -R +w /root/.cache && \ - find /root/.cache -name "emmintrin.h" -exec sed -i '/typedef __bf16 __m128bh/d' {} + && \ - find /root/.cache -name "emmintrin.h" -exec sed -i 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__CUDA__) || defined(__CUDACC__)\ntypedef short __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef short __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#else\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif\n#endif/' {} + && \ - find /root/.cache -name "btree.h" -exec sed -i 's/.*template btree.*/ node_type \*parent;/' {} + && \ - find /root/.cache -path "*/xla/tsl/cuda/BUILD.bazel" -exec sed -i '/name = "nvshmem"/,/deps = \[/ s|deps = \[|deps = \[\n "//xla/tsl/platform/default:dso_loader",|' {} + && \ + find /root/.cache -name "emmintrin.h" -exec sed -i --follow-symlinks '/typedef __bf16 __m128bh/d' {} + && \ + find /root/.cache -name "emmintrin.h" -exec sed -i --follow-symlinks 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__CUDA__) || defined(__CUDACC__)\ntypedef short __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef short __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#else\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif\n#endif/' {} + && \ + find /root/.cache -name "btree.h" -exec sed -i --follow-symlinks 's/.*template btree.*/ node_type \*parent;/' {} + && \ + find /root/.cache -path "*/xla/tsl/cuda/BUILD.bazel" -exec sed -i --follow-symlinks '/name = "nvshmem"/,/deps = \[/ s|deps = \[|deps = \[\n "//xla/tsl/platform/default:dso_loader",|' {} + && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ bazel build --color=yes --noshow_progress --curses=no --config=cuda --copt="-fPIC"\ ${TF_SERVING_BAZEL_OPTIONS} \ From 2834206eb2595a0698224cbdf6a2bbce8816b317 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Sat, 25 Jul 2026 19:48:00 +0000 Subject: [PATCH 129/183] Override com_google_absl in workspace.bzl with patch_cmds to patch btree.h during Bazel repository extraction --- .../tools/docker/Dockerfile.devel-gpu | 2 -- tensorflow_serving/workspace.bzl | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 5d7eca5be9c..29405819926 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -164,11 +164,9 @@ RUN echo "Building with Bazel options: ${TF_SERVING_BAZEL_OPTIONS}" RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1 && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} bazel fetch --config=cuda ${TF_SERVING_BAZEL_OPTIONS} ${TF_SERVING_BUILD_OPTIONS} tensorflow_serving/model_servers:tensorflow_model_server || true && \ - LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} bazel query @com_google_absl//... || true && \ chmod -R +w /root/.cache && \ find /root/.cache -name "emmintrin.h" -exec sed -i --follow-symlinks '/typedef __bf16 __m128bh/d' {} + && \ find /root/.cache -name "emmintrin.h" -exec sed -i --follow-symlinks 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__CUDA__) || defined(__CUDACC__)\ntypedef short __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef short __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#else\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif\n#endif/' {} + && \ - find /root/.cache -name "btree.h" -exec sed -i --follow-symlinks 's/.*template btree.*/ node_type \*parent;/' {} + && \ find /root/.cache -path "*/xla/tsl/cuda/BUILD.bazel" -exec sed -i --follow-symlinks '/name = "nvshmem"/,/deps = \[/ s|deps = \[|deps = \[\n "//xla/tsl/platform/default:dso_loader",|' {} + && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ bazel build --color=yes --noshow_progress --curses=no --config=cuda --copt="-fPIC"\ diff --git a/tensorflow_serving/workspace.bzl b/tensorflow_serving/workspace.bzl index 69de7ba66b4..b3313d3dc02 100644 --- a/tensorflow_serving/workspace.bzl +++ b/tensorflow_serving/workspace.bzl @@ -10,6 +10,20 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") def tf_serving_workspace(): """All TensorFlow Serving external dependencies.""" + # ===== Abseil C++ dependency with C++17 Clang 18 template patch ===== + http_archive( + name = "com_google_absl", + sha256 = "6e1aee535473414164bf83e4ebc40240dec71a4701f8a642d906e95bea1aea0c", + strip_prefix = "abseil-cpp-20260526.0", + urls = [ + "https://storage.googleapis.com/mirror.tensorflow.org/github.com/abseil/abseil-cpp/archive/20260526.0.tar.gz", + "https://github.com/abseil/abseil-cpp/archive/20260526.0.tar.gz", + ], + patch_cmds = [ + "sed -i 's/.*template btree.*/ node_type *parent;/' absl/container/internal/btree.h", + ], + ) + http_archive( name = "rules_proto", sha256 = "a88d018bdcb8df1ce8185470eb4b4899d778f9ac3a66cb36d514beb81e345282", From ed800181dc393319a4bf5ba6515377dadf7101bc Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Sat, 25 Jul 2026 19:49:56 +0000 Subject: [PATCH 130/183] Add repo_mapping to com_google_absl in workspace.bzl matching TF specification --- tensorflow_serving/workspace.bzl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tensorflow_serving/workspace.bzl b/tensorflow_serving/workspace.bzl index b3313d3dc02..9dc61237496 100644 --- a/tensorflow_serving/workspace.bzl +++ b/tensorflow_serving/workspace.bzl @@ -22,6 +22,10 @@ def tf_serving_workspace(): patch_cmds = [ "sed -i 's/.*template btree.*/ node_type *parent;/' absl/container/internal/btree.h", ], + repo_mapping = { + "@google_benchmark": "@com_google_benchmark", + "@googletest": "@com_google_googletest", + }, ) http_archive( From 3b1f0c1606a89ab3fc6ccadb953030e2231e621e Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Sat, 25 Jul 2026 20:20:37 +0000 Subject: [PATCH 131/183] Override com_github_grpc_grpc in workspace.bzl with #include patch_cmds for Clang 18 compatibility --- tensorflow_serving/workspace.bzl | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tensorflow_serving/workspace.bzl b/tensorflow_serving/workspace.bzl index 9dc61237496..83fbbb3081c 100644 --- a/tensorflow_serving/workspace.bzl +++ b/tensorflow_serving/workspace.bzl @@ -28,6 +28,23 @@ def tf_serving_workspace(): }, ) + # ===== gRPC dependency with Clang 18 #include patch ===== + http_archive( + name = "com_github_grpc_grpc", + sha256 = "41b695614b26652ff9e97ce50cfd4a6c7a3d45a9fe598d1454407746499bbf2c", + strip_prefix = "grpc-1.81.0", + urls = [ + "https://storage.googleapis.com/mirror.tensorflow.org/github.com/grpc/grpc/archive/refs/tags/v1.81.0.tar.gz", + "https://github.com/grpc/grpc/archive/refs/tags/v1.81.0.tar.gz", + ], + patch_file = [ + "@xla//third_party/grpc:grpc.patch", + ], + patch_cmds = [ + "find . -name '*.cc' -exec sed -i '1i #include ' {} +", + ], + ) + http_archive( name = "rules_proto", sha256 = "a88d018bdcb8df1ce8185470eb4b4899d778f9ac3a66cb36d514beb81e345282", From dfcfb49bfc427d3a706bb1ae448e3246e1f9cfdb Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Sat, 25 Jul 2026 20:42:33 +0000 Subject: [PATCH 132/183] Fix patch_file attribute to patches in com_github_grpc_grpc http_archive rule in workspace.bzl --- tensorflow_serving/workspace.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow_serving/workspace.bzl b/tensorflow_serving/workspace.bzl index 83fbbb3081c..554280efd41 100644 --- a/tensorflow_serving/workspace.bzl +++ b/tensorflow_serving/workspace.bzl @@ -37,7 +37,7 @@ def tf_serving_workspace(): "https://storage.googleapis.com/mirror.tensorflow.org/github.com/grpc/grpc/archive/refs/tags/v1.81.0.tar.gz", "https://github.com/grpc/grpc/archive/refs/tags/v1.81.0.tar.gz", ], - patch_file = [ + patches = [ "@xla//third_party/grpc:grpc.patch", ], patch_cmds = [ From 87279c4190128b53a07a7fc639fb8ce61f529d4d Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Sat, 25 Jul 2026 21:04:55 +0000 Subject: [PATCH 133/183] Add patch_args = [-p1] to com_github_grpc_grpc http_archive in workspace.bzl --- tensorflow_serving/workspace.bzl | 1 + 1 file changed, 1 insertion(+) diff --git a/tensorflow_serving/workspace.bzl b/tensorflow_serving/workspace.bzl index 554280efd41..290541c5ba8 100644 --- a/tensorflow_serving/workspace.bzl +++ b/tensorflow_serving/workspace.bzl @@ -40,6 +40,7 @@ def tf_serving_workspace(): patches = [ "@xla//third_party/grpc:grpc.patch", ], + patch_args = ["-p1"], patch_cmds = [ "find . -name '*.cc' -exec sed -i '1i #include ' {} +", ], From 3069dad5ffdddc66158e78c267fc98af9f0f4b0e Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Sat, 25 Jul 2026 22:37:58 +0000 Subject: [PATCH 134/183] Include official TensorFlow absl patches (btree.patch, build_dll.patch, endian.patch) in com_google_absl override in workspace.bzl --- tensorflow_serving/workspace.bzl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tensorflow_serving/workspace.bzl b/tensorflow_serving/workspace.bzl index 290541c5ba8..9e7d551a41b 100644 --- a/tensorflow_serving/workspace.bzl +++ b/tensorflow_serving/workspace.bzl @@ -19,6 +19,12 @@ def tf_serving_workspace(): "https://storage.googleapis.com/mirror.tensorflow.org/github.com/abseil/abseil-cpp/archive/20260526.0.tar.gz", "https://github.com/abseil/abseil-cpp/archive/20260526.0.tar.gz", ], + patches = [ + "@xla//third_party/absl:btree.patch", + "@xla//third_party/absl:build_dll.patch", + "@xla//third_party/absl:endian.patch", + ], + patch_args = ["-p1"], patch_cmds = [ "sed -i 's/.*template btree.*/ node_type *parent;/' absl/container/internal/btree.h", ], From 08219d60faaa3217027a5218a4de46d63ecd4760 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Sat, 25 Jul 2026 23:10:17 +0000 Subject: [PATCH 135/183] Handle both btree.h line 1124 and line 1342 patches via patch_cmds in com_google_absl override in workspace.bzl --- tensorflow_serving/workspace.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow_serving/workspace.bzl b/tensorflow_serving/workspace.bzl index 9e7d551a41b..d73e56528da 100644 --- a/tensorflow_serving/workspace.bzl +++ b/tensorflow_serving/workspace.bzl @@ -20,13 +20,13 @@ def tf_serving_workspace(): "https://github.com/abseil/abseil-cpp/archive/20260526.0.tar.gz", ], patches = [ - "@xla//third_party/absl:btree.patch", "@xla//third_party/absl:build_dll.patch", "@xla//third_party/absl:endian.patch", ], patch_args = ["-p1"], patch_cmds = [ "sed -i 's/.*template btree.*/ node_type *parent;/' absl/container/internal/btree.h", + "sed -i '/using iterator = std::conditional_t>;/c\\ using iterator = btree_iterator;' absl/container/internal/btree.h", ], repo_mapping = { "@google_benchmark": "@com_google_benchmark", From de08977eb5354f33970972e996339ce05f9d3183 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Sat, 25 Jul 2026 23:29:58 +0000 Subject: [PATCH 136/183] Simplify com_google_absl http_archive to use patch_cmds exclusively for btree.h line 1124 and line 1342 --- tensorflow_serving/workspace.bzl | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tensorflow_serving/workspace.bzl b/tensorflow_serving/workspace.bzl index d73e56528da..5692c2ea19c 100644 --- a/tensorflow_serving/workspace.bzl +++ b/tensorflow_serving/workspace.bzl @@ -19,11 +19,6 @@ def tf_serving_workspace(): "https://storage.googleapis.com/mirror.tensorflow.org/github.com/abseil/abseil-cpp/archive/20260526.0.tar.gz", "https://github.com/abseil/abseil-cpp/archive/20260526.0.tar.gz", ], - patches = [ - "@xla//third_party/absl:build_dll.patch", - "@xla//third_party/absl:endian.patch", - ], - patch_args = ["-p1"], patch_cmds = [ "sed -i 's/.*template btree.*/ node_type *parent;/' absl/container/internal/btree.h", "sed -i '/using iterator = std::conditional_t>;/c\\ using iterator = btree_iterator;' absl/container/internal/btree.h", From 4e2f3caca69607c27bd50e208c10b0cb408de12f Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Sun, 26 Jul 2026 00:30:16 +0000 Subject: [PATCH 137/183] Make btree.h line 1342 sed pattern exact to prevent over-matching line 1359 --- tensorflow_serving/workspace.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow_serving/workspace.bzl b/tensorflow_serving/workspace.bzl index 5692c2ea19c..a9f7b0bbc34 100644 --- a/tensorflow_serving/workspace.bzl +++ b/tensorflow_serving/workspace.bzl @@ -20,7 +20,7 @@ def tf_serving_workspace(): "https://github.com/abseil/abseil-cpp/archive/20260526.0.tar.gz", ], patch_cmds = [ - "sed -i 's/.*template btree.*/ node_type *parent;/' absl/container/internal/btree.h", + "sed -i 's/typename container_internal::template btree::node_type \\*parent;/ node_type *parent;/' absl/container/internal/btree.h", "sed -i '/using iterator = std::conditional_t>;/c\\ using iterator = btree_iterator;' absl/container/internal/btree.h", ], repo_mapping = { From 79aed30fa1af7e2b0080825e65433f1730dd834c Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Sun, 26 Jul 2026 01:58:08 +0000 Subject: [PATCH 138/183] Fix line 1348 sed target to match exact text without in com_google_absl override in workspace.bzl --- tensorflow_serving/workspace.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow_serving/workspace.bzl b/tensorflow_serving/workspace.bzl index a9f7b0bbc34..fc9fe92fa4c 100644 --- a/tensorflow_serving/workspace.bzl +++ b/tensorflow_serving/workspace.bzl @@ -20,7 +20,7 @@ def tf_serving_workspace(): "https://github.com/abseil/abseil-cpp/archive/20260526.0.tar.gz", ], patch_cmds = [ - "sed -i 's/typename container_internal::template btree::node_type \\*parent;/ node_type *parent;/' absl/container/internal/btree.h", + "sed -i 's/typename container_internal::template btree::node_type \\*parent;/ node_type *parent;/' absl/container/internal/btree.h", "sed -i '/using iterator = std::conditional_t>;/c\\ using iterator = btree_iterator;' absl/container/internal/btree.h", ], repo_mapping = { From 65cc9d76d1f59aa2fa2608ec1b0e699cda3f0a49 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Sun, 26 Jul 2026 03:26:11 +0000 Subject: [PATCH 139/183] Add .* prefix to line 1348 sed pattern in com_google_absl override in workspace.bzl to match leading spaces --- tensorflow_serving/workspace.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow_serving/workspace.bzl b/tensorflow_serving/workspace.bzl index fc9fe92fa4c..679faa46ea8 100644 --- a/tensorflow_serving/workspace.bzl +++ b/tensorflow_serving/workspace.bzl @@ -20,7 +20,7 @@ def tf_serving_workspace(): "https://github.com/abseil/abseil-cpp/archive/20260526.0.tar.gz", ], patch_cmds = [ - "sed -i 's/typename container_internal::template btree::node_type \\*parent;/ node_type *parent;/' absl/container/internal/btree.h", + "sed -i 's/.*typename container_internal::template btree::node_type \\*parent;/ node_type *parent;/' absl/container/internal/btree.h", "sed -i '/using iterator = std::conditional_t>;/c\\ using iterator = btree_iterator;' absl/container/internal/btree.h", ], repo_mapping = { From 3341aac56a2314c4353f7cac01f95fc29f58f9e4 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Sun, 26 Jul 2026 04:53:26 +0000 Subject: [PATCH 140/183] Update line 1348 sed pattern to .*template btree.*node_type \*parent; in com_google_absl override in workspace.bzl --- tensorflow_serving/workspace.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow_serving/workspace.bzl b/tensorflow_serving/workspace.bzl index 679faa46ea8..4a9e72722e3 100644 --- a/tensorflow_serving/workspace.bzl +++ b/tensorflow_serving/workspace.bzl @@ -20,7 +20,7 @@ def tf_serving_workspace(): "https://github.com/abseil/abseil-cpp/archive/20260526.0.tar.gz", ], patch_cmds = [ - "sed -i 's/.*typename container_internal::template btree::node_type \\*parent;/ node_type *parent;/' absl/container/internal/btree.h", + "sed -i 's/.*template btree.*node_type \\*parent;/ node_type *parent;/' absl/container/internal/btree.h", "sed -i '/using iterator = std::conditional_t>;/c\\ using iterator = btree_iterator;' absl/container/internal/btree.h", ], repo_mapping = { From ccd5d65bb3bc11594a547baa0db9c4644cc242c0 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Sun, 26 Jul 2026 11:37:45 +0000 Subject: [PATCH 141/183] Simplify line 1348 sed pattern to .*template btree.*node_type.*parent; in workspace.bzl --- tensorflow_serving/workspace.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow_serving/workspace.bzl b/tensorflow_serving/workspace.bzl index 4a9e72722e3..d8a0f4e6155 100644 --- a/tensorflow_serving/workspace.bzl +++ b/tensorflow_serving/workspace.bzl @@ -20,7 +20,7 @@ def tf_serving_workspace(): "https://github.com/abseil/abseil-cpp/archive/20260526.0.tar.gz", ], patch_cmds = [ - "sed -i 's/.*template btree.*node_type \\*parent;/ node_type *parent;/' absl/container/internal/btree.h", + "sed -i 's/.*template btree.*node_type.*parent;/ node_type *parent;/' absl/container/internal/btree.h", "sed -i '/using iterator = std::conditional_t>;/c\\ using iterator = btree_iterator;' absl/container/internal/btree.h", ], repo_mapping = { From 490f8967c0684599ce5bb827aeb41133a1e75530 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Sun, 26 Jul 2026 12:56:35 +0000 Subject: [PATCH 142/183] Use find . -name btree.h in com_google_absl patch_cmds to guarantee matching across extraction directory structures --- tensorflow_serving/workspace.bzl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tensorflow_serving/workspace.bzl b/tensorflow_serving/workspace.bzl index d8a0f4e6155..d8ed139c69d 100644 --- a/tensorflow_serving/workspace.bzl +++ b/tensorflow_serving/workspace.bzl @@ -20,8 +20,8 @@ def tf_serving_workspace(): "https://github.com/abseil/abseil-cpp/archive/20260526.0.tar.gz", ], patch_cmds = [ - "sed -i 's/.*template btree.*node_type.*parent;/ node_type *parent;/' absl/container/internal/btree.h", - "sed -i '/using iterator = std::conditional_t>;/c\\ using iterator = btree_iterator;' absl/container/internal/btree.h", + "find . -name 'btree.h' -exec sed -i 's/.*template btree.*node_type.*parent;/ node_type *parent;/' {} +", + "find . -name 'btree.h' -exec sed -i '/using iterator = std::conditional_t>;/c\\ using iterator = btree_iterator;' {} +", ], repo_mapping = { "@google_benchmark": "@com_google_benchmark", From e4af6f51a6691943a63aa619313982f72949104d Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Sun, 26 Jul 2026 13:20:25 +0000 Subject: [PATCH 143/183] Add //xla/tsl/platform/default:dso_loader to all deps rules in xla/tsl/cuda/BUILD.bazel to resolve cuda_stub.cc dependency error --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 29405819926..cb4cd69be6f 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -167,7 +167,7 @@ RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/lib chmod -R +w /root/.cache && \ find /root/.cache -name "emmintrin.h" -exec sed -i --follow-symlinks '/typedef __bf16 __m128bh/d' {} + && \ find /root/.cache -name "emmintrin.h" -exec sed -i --follow-symlinks 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__CUDA__) || defined(__CUDACC__)\ntypedef short __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef short __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#else\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif\n#endif/' {} + && \ - find /root/.cache -path "*/xla/tsl/cuda/BUILD.bazel" -exec sed -i --follow-symlinks '/name = "nvshmem"/,/deps = \[/ s|deps = \[|deps = \[\n "//xla/tsl/platform/default:dso_loader",|' {} + && \ + find /root/.cache -path "*/xla/tsl/cuda/BUILD.bazel" -exec sed -i --follow-symlinks 's|deps = \[|deps = \[\n "//xla/tsl/platform/default:dso_loader",|g' {} + && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ bazel build --color=yes --noshow_progress --curses=no --config=cuda --copt="-fPIC"\ ${TF_SERVING_BAZEL_OPTIONS} \ From 0893bbfe4478ffa109a74c7ce5f6e1c39070676d Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Sun, 26 Jul 2026 14:46:05 +0000 Subject: [PATCH 144/183] Add post-fetch btree.h sed patching in Dockerfile.devel-gpu on /root/.cache to double-guarantee Abseil C++17 template patch --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index cb4cd69be6f..6c5ea4114d6 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -168,6 +168,8 @@ RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/lib find /root/.cache -name "emmintrin.h" -exec sed -i --follow-symlinks '/typedef __bf16 __m128bh/d' {} + && \ find /root/.cache -name "emmintrin.h" -exec sed -i --follow-symlinks 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__CUDA__) || defined(__CUDACC__)\ntypedef short __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef short __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#else\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif\n#endif/' {} + && \ find /root/.cache -path "*/xla/tsl/cuda/BUILD.bazel" -exec sed -i --follow-symlinks 's|deps = \[|deps = \[\n "//xla/tsl/platform/default:dso_loader",|g' {} + && \ + find /root/.cache -name "btree.h" -exec sed -i --follow-symlinks 's/.*template btree.*node_type.*parent;/ node_type *parent;/' {} + && \ + find /root/.cache -name "btree.h" -exec sed -i --follow-symlinks '/using iterator = std::conditional_t>;/c\ using iterator = btree_iterator;' {} + && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ bazel build --color=yes --noshow_progress --curses=no --config=cuda --copt="-fPIC"\ ${TF_SERVING_BAZEL_OPTIONS} \ From 6af872fff60c08efece9e5d4a9cd031df1126901 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Sun, 26 Jul 2026 16:14:54 +0000 Subject: [PATCH 145/183] Use Python 3 multi-line regex substitution for btree.h template patching in workspace.bzl and Dockerfile.devel-gpu --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 3 +-- tensorflow_serving/workspace.bzl | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 6c5ea4114d6..4946006dcff 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -168,8 +168,7 @@ RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/lib find /root/.cache -name "emmintrin.h" -exec sed -i --follow-symlinks '/typedef __bf16 __m128bh/d' {} + && \ find /root/.cache -name "emmintrin.h" -exec sed -i --follow-symlinks 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__CUDA__) || defined(__CUDACC__)\ntypedef short __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef short __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#else\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif\n#endif/' {} + && \ find /root/.cache -path "*/xla/tsl/cuda/BUILD.bazel" -exec sed -i --follow-symlinks 's|deps = \[|deps = \[\n "//xla/tsl/platform/default:dso_loader",|g' {} + && \ - find /root/.cache -name "btree.h" -exec sed -i --follow-symlinks 's/.*template btree.*node_type.*parent;/ node_type *parent;/' {} + && \ - find /root/.cache -name "btree.h" -exec sed -i --follow-symlinks '/using iterator = std::conditional_t>;/c\ using iterator = btree_iterator;' {} + && \ + python3 -c 'import glob, re; [open(p, "w").write(re.sub(r"using iterator = std::conditional_t<[\s\S]*?const_pointer>>;", " using iterator = btree_iterator;", re.sub(r".*template btree.*node_type.*", " node_type *parent;", open(p).read()))) for p in glob.glob("/root/.cache/**/btree.h", recursive=True)]' && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ bazel build --color=yes --noshow_progress --curses=no --config=cuda --copt="-fPIC"\ ${TF_SERVING_BAZEL_OPTIONS} \ diff --git a/tensorflow_serving/workspace.bzl b/tensorflow_serving/workspace.bzl index d8ed139c69d..fdac1ba9004 100644 --- a/tensorflow_serving/workspace.bzl +++ b/tensorflow_serving/workspace.bzl @@ -20,8 +20,7 @@ def tf_serving_workspace(): "https://github.com/abseil/abseil-cpp/archive/20260526.0.tar.gz", ], patch_cmds = [ - "find . -name 'btree.h' -exec sed -i 's/.*template btree.*node_type.*parent;/ node_type *parent;/' {} +", - "find . -name 'btree.h' -exec sed -i '/using iterator = std::conditional_t>;/c\\ using iterator = btree_iterator;' {} +", + "python3 -c 'import glob, re; [open(p, \"w\").write(re.sub(r\"using iterator = std::conditional_t<[\\s\\S]*?const_pointer>>;\", \" using iterator = btree_iterator;\", re.sub(r\".*template btree.*node_type.*\", \" node_type *parent;\", open(p).read()))) for p in glob.glob(\"**/btree.h\", recursive=True)]'", ], repo_mapping = { "@google_benchmark": "@com_google_benchmark", From 0185d7f41d1a09b89e4e4dd5d97a74471e5d9438 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Sun, 26 Jul 2026 16:56:56 +0000 Subject: [PATCH 146/183] Precision match typename container_internal::template btree in python3 regex for btree.h line 1348 --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 2 +- tensorflow_serving/workspace.bzl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 4946006dcff..dea3d1a61b1 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -168,7 +168,7 @@ RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/lib find /root/.cache -name "emmintrin.h" -exec sed -i --follow-symlinks '/typedef __bf16 __m128bh/d' {} + && \ find /root/.cache -name "emmintrin.h" -exec sed -i --follow-symlinks 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__CUDA__) || defined(__CUDACC__)\ntypedef short __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef short __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#else\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif\n#endif/' {} + && \ find /root/.cache -path "*/xla/tsl/cuda/BUILD.bazel" -exec sed -i --follow-symlinks 's|deps = \[|deps = \[\n "//xla/tsl/platform/default:dso_loader",|g' {} + && \ - python3 -c 'import glob, re; [open(p, "w").write(re.sub(r"using iterator = std::conditional_t<[\s\S]*?const_pointer>>;", " using iterator = btree_iterator;", re.sub(r".*template btree.*node_type.*", " node_type *parent;", open(p).read()))) for p in glob.glob("/root/.cache/**/btree.h", recursive=True)]' && \ + python3 -c 'import glob, re; [open(p, "w").write(re.sub(r"using iterator = std::conditional_t<[\s\S]*?const_pointer>>;", " using iterator = btree_iterator;", re.sub(r"typename container_internal::template btree[^\n]*?node_type\s*\*parent;", " node_type *parent;", open(p).read()))) for p in glob.glob("/root/.cache/**/btree.h", recursive=True)]' && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ bazel build --color=yes --noshow_progress --curses=no --config=cuda --copt="-fPIC"\ ${TF_SERVING_BAZEL_OPTIONS} \ diff --git a/tensorflow_serving/workspace.bzl b/tensorflow_serving/workspace.bzl index fdac1ba9004..72710f7948c 100644 --- a/tensorflow_serving/workspace.bzl +++ b/tensorflow_serving/workspace.bzl @@ -20,7 +20,7 @@ def tf_serving_workspace(): "https://github.com/abseil/abseil-cpp/archive/20260526.0.tar.gz", ], patch_cmds = [ - "python3 -c 'import glob, re; [open(p, \"w\").write(re.sub(r\"using iterator = std::conditional_t<[\\s\\S]*?const_pointer>>;\", \" using iterator = btree_iterator;\", re.sub(r\".*template btree.*node_type.*\", \" node_type *parent;\", open(p).read()))) for p in glob.glob(\"**/btree.h\", recursive=True)]'", + "python3 -c 'import glob, re; [open(p, \"w\").write(re.sub(r\"using iterator = std::conditional_t<[\\s\\S]*?const_pointer>>;\", \" using iterator = btree_iterator;\", re.sub(r\"typename container_internal::template btree[^\\n]*?node_type\\s*\\*parent;\", \" node_type *parent;\", open(p).read()))) for p in glob.glob(\"**/btree.h\", recursive=True)]'", ], repo_mapping = { "@google_benchmark": "@com_google_benchmark", From 3da74f282eb749d761a47e1348f500d70dd1cbe4 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Sun, 26 Jul 2026 17:39:40 +0000 Subject: [PATCH 147/183] Override com_googlesource_code_re2 with #include patch in workspace.bzl and Dockerfile.devel-gpu for Clang 18 C++17 compatibility --- .../tools/docker/Dockerfile.devel-gpu | 1 + tensorflow_serving/workspace.bzl | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index dea3d1a61b1..637210542be 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -168,6 +168,7 @@ RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/lib find /root/.cache -name "emmintrin.h" -exec sed -i --follow-symlinks '/typedef __bf16 __m128bh/d' {} + && \ find /root/.cache -name "emmintrin.h" -exec sed -i --follow-symlinks 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__CUDA__) || defined(__CUDACC__)\ntypedef short __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef short __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#else\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif\n#endif/' {} + && \ find /root/.cache -path "*/xla/tsl/cuda/BUILD.bazel" -exec sed -i --follow-symlinks 's|deps = \[|deps = \[\n "//xla/tsl/platform/default:dso_loader",|g' {} + && \ + find /root/.cache -name "prog.h" -exec sed -i --follow-symlinks '1i #include ' {} + && \ python3 -c 'import glob, re; [open(p, "w").write(re.sub(r"using iterator = std::conditional_t<[\s\S]*?const_pointer>>;", " using iterator = btree_iterator;", re.sub(r"typename container_internal::template btree[^\n]*?node_type\s*\*parent;", " node_type *parent;", open(p).read()))) for p in glob.glob("/root/.cache/**/btree.h", recursive=True)]' && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ bazel build --color=yes --noshow_progress --curses=no --config=cuda --copt="-fPIC"\ diff --git a/tensorflow_serving/workspace.bzl b/tensorflow_serving/workspace.bzl index 72710f7948c..19b766d0047 100644 --- a/tensorflow_serving/workspace.bzl +++ b/tensorflow_serving/workspace.bzl @@ -46,6 +46,23 @@ def tf_serving_workspace(): ], ) + # ===== RE2 dependency with Clang 18 #include patch ===== + http_archive( + name = "com_googlesource_code_re2", + sha256 = "8635bc46ac8d73974b4198229805287c8d620245f2081af155d7d96d4988a3a5", + strip_prefix = "re2-927f5d53caf8111721e734cf24724686bb745f55", + urls = [ + "https://storage.googleapis.com/mirror.tensorflow.org/github.com/google/re2/archive/927f5d53caf8111721e734cf24724686bb745f55.tar.gz", + "https://github.com/google/re2/archive/927f5d53caf8111721e734cf24724686bb745f55.tar.gz", + ], + patch_cmds = [ + "find . -name '*.h' -exec sed -i '1i #include ' {} +", + ], + repo_mapping = { + "@abseil-cpp": "@com_google_absl", + }, + ) + http_archive( name = "rules_proto", sha256 = "a88d018bdcb8df1ce8185470eb4b4899d778f9ac3a66cb36d514beb81e345282", From 10cddfb4c81fb3993ca289d00d74734273d31d91 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Sun, 26 Jul 2026 18:21:35 +0000 Subject: [PATCH 148/183] Fix reference and pointer typedef scope names in btree.h line 1124 python3 template replacement --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 2 +- tensorflow_serving/workspace.bzl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 637210542be..537f60e9bf7 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -169,7 +169,7 @@ RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/lib find /root/.cache -name "emmintrin.h" -exec sed -i --follow-symlinks 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__CUDA__) || defined(__CUDACC__)\ntypedef short __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef short __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#else\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif\n#endif/' {} + && \ find /root/.cache -path "*/xla/tsl/cuda/BUILD.bazel" -exec sed -i --follow-symlinks 's|deps = \[|deps = \[\n "//xla/tsl/platform/default:dso_loader",|g' {} + && \ find /root/.cache -name "prog.h" -exec sed -i --follow-symlinks '1i #include ' {} + && \ - python3 -c 'import glob, re; [open(p, "w").write(re.sub(r"using iterator = std::conditional_t<[\s\S]*?const_pointer>>;", " using iterator = btree_iterator;", re.sub(r"typename container_internal::template btree[^\n]*?node_type\s*\*parent;", " node_type *parent;", open(p).read()))) for p in glob.glob("/root/.cache/**/btree.h", recursive=True)]' && \ + python3 -c 'import glob, re; [open(p, "w").write(re.sub(r"using iterator = std::conditional_t<[\s\S]*?const_pointer>>;", " using iterator = btree_iterator;", re.sub(r"typename container_internal::template btree[^\n]*?node_type\s*\*parent;", " node_type *parent;", open(p).read()))) for p in glob.glob("/root/.cache/**/btree.h", recursive=True)]' && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ bazel build --color=yes --noshow_progress --curses=no --config=cuda --copt="-fPIC"\ ${TF_SERVING_BAZEL_OPTIONS} \ diff --git a/tensorflow_serving/workspace.bzl b/tensorflow_serving/workspace.bzl index 19b766d0047..435a89dfdee 100644 --- a/tensorflow_serving/workspace.bzl +++ b/tensorflow_serving/workspace.bzl @@ -20,7 +20,7 @@ def tf_serving_workspace(): "https://github.com/abseil/abseil-cpp/archive/20260526.0.tar.gz", ], patch_cmds = [ - "python3 -c 'import glob, re; [open(p, \"w\").write(re.sub(r\"using iterator = std::conditional_t<[\\s\\S]*?const_pointer>>;\", \" using iterator = btree_iterator;\", re.sub(r\"typename container_internal::template btree[^\\n]*?node_type\\s*\\*parent;\", \" node_type *parent;\", open(p).read()))) for p in glob.glob(\"**/btree.h\", recursive=True)]'", + "python3 -c 'import glob, re; [open(p, \"w\").write(re.sub(r\"using iterator = std::conditional_t<[\\s\\S]*?const_pointer>>;\", \" using iterator = btree_iterator;\", re.sub(r\"typename container_internal::template btree[^\\n]*?node_type\\s*\\*parent;\", \" node_type *parent;\", open(p).read()))) for p in glob.glob(\"**/btree.h\", recursive=True)]'", ], repo_mapping = { "@google_benchmark": "@com_google_benchmark", From 2a18f1ff9bde2c49bceb991d8fbe9cb0aaec0878 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Sun, 26 Jul 2026 18:24:50 +0000 Subject: [PATCH 149/183] Exact single string replacement for btree.h line 1123 std::conditional_t in workspace.bzl and Dockerfile.devel-gpu --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 2 +- tensorflow_serving/workspace.bzl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 537f60e9bf7..e148cc98380 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -169,7 +169,7 @@ RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/lib find /root/.cache -name "emmintrin.h" -exec sed -i --follow-symlinks 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__CUDA__) || defined(__CUDACC__)\ntypedef short __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef short __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#else\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif\n#endif/' {} + && \ find /root/.cache -path "*/xla/tsl/cuda/BUILD.bazel" -exec sed -i --follow-symlinks 's|deps = \[|deps = \[\n "//xla/tsl/platform/default:dso_loader",|g' {} + && \ find /root/.cache -name "prog.h" -exec sed -i --follow-symlinks '1i #include ' {} + && \ - python3 -c 'import glob, re; [open(p, "w").write(re.sub(r"using iterator = std::conditional_t<[\s\S]*?const_pointer>>;", " using iterator = btree_iterator;", re.sub(r"typename container_internal::template btree[^\n]*?node_type\s*\*parent;", " node_type *parent;", open(p).read()))) for p in glob.glob("/root/.cache/**/btree.h", recursive=True)]' && \ + python3 -c 'import glob; [open(p, "w").write(open(p).read().replace("using iterator = std::conditional_t<\n is_map_container::value,\n btree_iterator,\n btree_iterator>;", " using iterator = btree_iterator;")) for p in glob.glob("/root/.cache/**/btree.h", recursive=True)]' && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ bazel build --color=yes --noshow_progress --curses=no --config=cuda --copt="-fPIC"\ ${TF_SERVING_BAZEL_OPTIONS} \ diff --git a/tensorflow_serving/workspace.bzl b/tensorflow_serving/workspace.bzl index 435a89dfdee..ac3c6919dae 100644 --- a/tensorflow_serving/workspace.bzl +++ b/tensorflow_serving/workspace.bzl @@ -20,7 +20,7 @@ def tf_serving_workspace(): "https://github.com/abseil/abseil-cpp/archive/20260526.0.tar.gz", ], patch_cmds = [ - "python3 -c 'import glob, re; [open(p, \"w\").write(re.sub(r\"using iterator = std::conditional_t<[\\s\\S]*?const_pointer>>;\", \" using iterator = btree_iterator;\", re.sub(r\"typename container_internal::template btree[^\\n]*?node_type\\s*\\*parent;\", \" node_type *parent;\", open(p).read()))) for p in glob.glob(\"**/btree.h\", recursive=True)]'", + "python3 -c 'import glob; [open(p, \"w\").write(open(p).read().replace(\"using iterator = std::conditional_t<\\n is_map_container::value,\\n btree_iterator,\\n btree_iterator>;\", \" using iterator = btree_iterator;\")) for p in glob.glob(\"**/btree.h\", recursive=True)]'", ], repo_mapping = { "@google_benchmark": "@com_google_benchmark", From 932db52b4b4b625fa95ec80a7363a72d2da058d7 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Sun, 26 Jul 2026 19:03:12 +0000 Subject: [PATCH 150/183] Clean up com_google_absl to official unpatched 20260526.0 release as verified compatible with Clang 18 C++17 --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 1 - tensorflow_serving/workspace.bzl | 5 +---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index e148cc98380..ed4c2b12fda 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -169,7 +169,6 @@ RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/lib find /root/.cache -name "emmintrin.h" -exec sed -i --follow-symlinks 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__CUDA__) || defined(__CUDACC__)\ntypedef short __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef short __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#else\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif\n#endif/' {} + && \ find /root/.cache -path "*/xla/tsl/cuda/BUILD.bazel" -exec sed -i --follow-symlinks 's|deps = \[|deps = \[\n "//xla/tsl/platform/default:dso_loader",|g' {} + && \ find /root/.cache -name "prog.h" -exec sed -i --follow-symlinks '1i #include ' {} + && \ - python3 -c 'import glob; [open(p, "w").write(open(p).read().replace("using iterator = std::conditional_t<\n is_map_container::value,\n btree_iterator,\n btree_iterator>;", " using iterator = btree_iterator;")) for p in glob.glob("/root/.cache/**/btree.h", recursive=True)]' && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ bazel build --color=yes --noshow_progress --curses=no --config=cuda --copt="-fPIC"\ ${TF_SERVING_BAZEL_OPTIONS} \ diff --git a/tensorflow_serving/workspace.bzl b/tensorflow_serving/workspace.bzl index ac3c6919dae..324b78835de 100644 --- a/tensorflow_serving/workspace.bzl +++ b/tensorflow_serving/workspace.bzl @@ -10,7 +10,7 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") def tf_serving_workspace(): """All TensorFlow Serving external dependencies.""" - # ===== Abseil C++ dependency with C++17 Clang 18 template patch ===== + # ===== Abseil C++ dependency ===== http_archive( name = "com_google_absl", sha256 = "6e1aee535473414164bf83e4ebc40240dec71a4701f8a642d906e95bea1aea0c", @@ -19,9 +19,6 @@ def tf_serving_workspace(): "https://storage.googleapis.com/mirror.tensorflow.org/github.com/abseil/abseil-cpp/archive/20260526.0.tar.gz", "https://github.com/abseil/abseil-cpp/archive/20260526.0.tar.gz", ], - patch_cmds = [ - "python3 -c 'import glob; [open(p, \"w\").write(open(p).read().replace(\"using iterator = std::conditional_t<\\n is_map_container::value,\\n btree_iterator,\\n btree_iterator>;\", \" using iterator = btree_iterator;\")) for p in glob.glob(\"**/btree.h\", recursive=True)]'", - ], repo_mapping = { "@google_benchmark": "@com_google_benchmark", "@googletest": "@com_google_googletest", From 3deb4d5834270a514f9f58c46002bc6fbf1ea0f3 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Sun, 26 Jul 2026 19:29:21 +0000 Subject: [PATCH 151/183] Use REAL_CLANG --target=x86_64-linux-gnu in third_party/libevent/BUILD for Clang 18 sysroot autoconf compatibility --- third_party/libevent/BUILD | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/third_party/libevent/BUILD b/third_party/libevent/BUILD index fae802152c7..ea0c4de7fc7 100644 --- a/third_party/libevent/BUILD +++ b/third_party/libevent/BUILD @@ -67,8 +67,8 @@ genrule( "cp -R $$ORIG_DIR/external/com_github_libevent_libevent/* $$TMP_DIR", "cd $$TMP_DIR", "./autogen.sh", - "CC=$$CC_PATH AR=$$REAL_AR ./configure --prefix=$$INSTALL_DIR CFLAGS=\"-fPIC --sysroot=$$SYSROOT_DIR\" CXXFLAGS=\"-fPIC --sysroot=$$SYSROOT_DIR\" LDFLAGS=\"--sysroot=$$SYSROOT_DIR\" --enable-shared=no --disable-openssl || (cat config.log && false)", - "make install CC=$$CC_PATH AR=$$REAL_AR", + "CC=\"$$REAL_CLANG --target=x86_64-linux-gnu\" AR=$$REAL_AR ./configure --prefix=$$INSTALL_DIR CFLAGS=\"-fPIC --sysroot=$$SYSROOT_DIR\" CXXFLAGS=\"-fPIC --sysroot=$$SYSROOT_DIR\" LDFLAGS=\"--sysroot=$$SYSROOT_DIR\" --enable-shared=no --disable-openssl || (cat config.log && false)", + "make install CC=\"$$REAL_CLANG --target=x86_64-linux-gnu\" AR=$$REAL_AR", "rm -rf $$TMP_DIR", ]), local = 1, From b43b3460bf03ebfc8601f706e3c7c562f4d368c1 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Sun, 26 Jul 2026 20:50:09 +0000 Subject: [PATCH 152/183] Expose btree_iterator::iterator as public in btree.h for Clang 18 C++17 friend template instantiation --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 1 + tensorflow_serving/workspace.bzl | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index ed4c2b12fda..5c09cfc6891 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -169,6 +169,7 @@ RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/lib find /root/.cache -name "emmintrin.h" -exec sed -i --follow-symlinks 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__CUDA__) || defined(__CUDACC__)\ntypedef short __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef short __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#else\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif\n#endif/' {} + && \ find /root/.cache -path "*/xla/tsl/cuda/BUILD.bazel" -exec sed -i --follow-symlinks 's|deps = \[|deps = \[\n "//xla/tsl/platform/default:dso_loader",|g' {} + && \ find /root/.cache -name "prog.h" -exec sed -i --follow-symlinks '1i #include ' {} + && \ + python3 -c 'import glob, re; [open(p, "w").write(re.sub(r"(\s+)(using iterator = std::conditional_t<[\s\S]*?const_pointer>;)", r"\1public:\1\2", open(p).read())) for p in glob.glob("/root/.cache/**/btree.h", recursive=True)]' && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ bazel build --color=yes --noshow_progress --curses=no --config=cuda --copt="-fPIC"\ ${TF_SERVING_BAZEL_OPTIONS} \ diff --git a/tensorflow_serving/workspace.bzl b/tensorflow_serving/workspace.bzl index 324b78835de..36248b7f61b 100644 --- a/tensorflow_serving/workspace.bzl +++ b/tensorflow_serving/workspace.bzl @@ -10,7 +10,7 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") def tf_serving_workspace(): """All TensorFlow Serving external dependencies.""" - # ===== Abseil C++ dependency ===== + # ===== Abseil C++ dependency with Clang 18 C++17 public iterator alias patch ===== http_archive( name = "com_google_absl", sha256 = "6e1aee535473414164bf83e4ebc40240dec71a4701f8a642d906e95bea1aea0c", @@ -19,6 +19,9 @@ def tf_serving_workspace(): "https://storage.googleapis.com/mirror.tensorflow.org/github.com/abseil/abseil-cpp/archive/20260526.0.tar.gz", "https://github.com/abseil/abseil-cpp/archive/20260526.0.tar.gz", ], + patch_cmds = [ + "python3 -c 'import glob, re; [open(p, \"w\").write(re.sub(r\"(\\s+)(using iterator = std::conditional_t<[\\s\\S]*?const_pointer>;)\", r\"\\1public:\\1\\2\", open(p).read())) for p in glob.glob(\"**/btree.h\", recursive=True)]'", + ], repo_mapping = { "@google_benchmark": "@com_google_benchmark", "@googletest": "@com_google_googletest", From 943480a462ca4e40525ba86af2aadc5b352b90ca Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Sun, 26 Jul 2026 21:10:55 +0000 Subject: [PATCH 153/183] Expose btree_iterator::iterator as public in btree.h using exact string replacement --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 2 +- tensorflow_serving/workspace.bzl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 5c09cfc6891..436b258f042 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -169,7 +169,7 @@ RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/lib find /root/.cache -name "emmintrin.h" -exec sed -i --follow-symlinks 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__CUDA__) || defined(__CUDACC__)\ntypedef short __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef short __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#else\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif\n#endif/' {} + && \ find /root/.cache -path "*/xla/tsl/cuda/BUILD.bazel" -exec sed -i --follow-symlinks 's|deps = \[|deps = \[\n "//xla/tsl/platform/default:dso_loader",|g' {} + && \ find /root/.cache -name "prog.h" -exec sed -i --follow-symlinks '1i #include ' {} + && \ - python3 -c 'import glob, re; [open(p, "w").write(re.sub(r"(\s+)(using iterator = std::conditional_t<[\s\S]*?const_pointer>;)", r"\1public:\1\2", open(p).read())) for p in glob.glob("/root/.cache/**/btree.h", recursive=True)]' && \ + python3 -c 'import glob; target=" // In sets, all iterators are const.\n using iterator = std::conditional_t<\n is_map_container::value,\n btree_iterator,\n btree_iterator>;\n using const_iterator =\n btree_iterator;\n\n public:"; repl=" public:\n // In sets, all iterators are const.\n using iterator = std::conditional_t<\n is_map_container::value,\n btree_iterator,\n btree_iterator>;\n using const_iterator =\n btree_iterator;"; [open(p, "w").write(open(p).read().replace(target, repl)) for p in glob.glob("/root/.cache/**/btree.h", recursive=True)]' && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ bazel build --color=yes --noshow_progress --curses=no --config=cuda --copt="-fPIC"\ ${TF_SERVING_BAZEL_OPTIONS} \ diff --git a/tensorflow_serving/workspace.bzl b/tensorflow_serving/workspace.bzl index 36248b7f61b..3a0eb06a552 100644 --- a/tensorflow_serving/workspace.bzl +++ b/tensorflow_serving/workspace.bzl @@ -20,7 +20,7 @@ def tf_serving_workspace(): "https://github.com/abseil/abseil-cpp/archive/20260526.0.tar.gz", ], patch_cmds = [ - "python3 -c 'import glob, re; [open(p, \"w\").write(re.sub(r\"(\\s+)(using iterator = std::conditional_t<[\\s\\S]*?const_pointer>;)\", r\"\\1public:\\1\\2\", open(p).read())) for p in glob.glob(\"**/btree.h\", recursive=True)]'", + "python3 -c 'import glob; target=\" // In sets, all iterators are const.\\n using iterator = std::conditional_t<\\n is_map_container::value,\\n btree_iterator,\\n btree_iterator>;\\n using const_iterator =\\n btree_iterator;\\n\\n public:\"; repl=\" public:\\n // In sets, all iterators are const.\\n using iterator = std::conditional_t<\\n is_map_container::value,\\n btree_iterator,\\n btree_iterator>;\\n using const_iterator =\\n btree_iterator;\"; [open(p, \"w\").write(open(p).read().replace(target, repl)) for p in glob.glob(\"**/btree.h\", recursive=True)]'", ], repo_mapping = { "@google_benchmark": "@com_google_benchmark", From 4f0ee7b4b0a10455ff21ac1290034e24d7033211 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Sun, 26 Jul 2026 22:03:41 +0000 Subject: [PATCH 154/183] Fix btree.h python patch script with explicit read-then-write order --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 6 +++++- tensorflow_serving/workspace.bzl | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 436b258f042..22ad460ba48 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -169,7 +169,11 @@ RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/lib find /root/.cache -name "emmintrin.h" -exec sed -i --follow-symlinks 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__CUDA__) || defined(__CUDACC__)\ntypedef short __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef short __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#else\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif\n#endif/' {} + && \ find /root/.cache -path "*/xla/tsl/cuda/BUILD.bazel" -exec sed -i --follow-symlinks 's|deps = \[|deps = \[\n "//xla/tsl/platform/default:dso_loader",|g' {} + && \ find /root/.cache -name "prog.h" -exec sed -i --follow-symlinks '1i #include ' {} + && \ - python3 -c 'import glob; target=" // In sets, all iterators are const.\n using iterator = std::conditional_t<\n is_map_container::value,\n btree_iterator,\n btree_iterator>;\n using const_iterator =\n btree_iterator;\n\n public:"; repl=" public:\n // In sets, all iterators are const.\n using iterator = std::conditional_t<\n is_map_container::value,\n btree_iterator,\n btree_iterator>;\n using const_iterator =\n btree_iterator;"; [open(p, "w").write(open(p).read().replace(target, repl)) for p in glob.glob("/root/.cache/**/btree.h", recursive=True)]' && \ + python3 -c 'import glob, re +for p in glob.glob("/root/.cache/**/btree.h", recursive=True): + s = open(p).read() + open(p, "w").write(re.sub(r"(// In sets, all iterators are const\.)", "public:\n \\1", s)) +' && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ bazel build --color=yes --noshow_progress --curses=no --config=cuda --copt="-fPIC"\ ${TF_SERVING_BAZEL_OPTIONS} \ diff --git a/tensorflow_serving/workspace.bzl b/tensorflow_serving/workspace.bzl index 3a0eb06a552..07bd0038c64 100644 --- a/tensorflow_serving/workspace.bzl +++ b/tensorflow_serving/workspace.bzl @@ -20,7 +20,7 @@ def tf_serving_workspace(): "https://github.com/abseil/abseil-cpp/archive/20260526.0.tar.gz", ], patch_cmds = [ - "python3 -c 'import glob; target=\" // In sets, all iterators are const.\\n using iterator = std::conditional_t<\\n is_map_container::value,\\n btree_iterator,\\n btree_iterator>;\\n using const_iterator =\\n btree_iterator;\\n\\n public:\"; repl=\" public:\\n // In sets, all iterators are const.\\n using iterator = std::conditional_t<\\n is_map_container::value,\\n btree_iterator,\\n btree_iterator>;\\n using const_iterator =\\n btree_iterator;\"; [open(p, \"w\").write(open(p).read().replace(target, repl)) for p in glob.glob(\"**/btree.h\", recursive=True)]'", + "python3 -c 'import glob, re\nfor p in glob.glob(\"**/btree.h\", recursive=True):\n s = open(p).read()\n open(p, \"w\").write(re.sub(r\"(// In sets, all iterators are const\\.)\", \"public:\\n \\\\1\", s))\n'", ], repo_mapping = { "@google_benchmark": "@com_google_benchmark", From 9d08868ae0bd896b37c34e03628b9e0c81548e5c Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Sun, 26 Jul 2026 22:04:18 +0000 Subject: [PATCH 155/183] Use one-liner lambda default arg read-then-write python script for btree.h patch --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 6 +----- tensorflow_serving/workspace.bzl | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 22ad460ba48..440d03125b3 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -169,11 +169,7 @@ RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/lib find /root/.cache -name "emmintrin.h" -exec sed -i --follow-symlinks 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__CUDA__) || defined(__CUDACC__)\ntypedef short __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef short __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#else\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif\n#endif/' {} + && \ find /root/.cache -path "*/xla/tsl/cuda/BUILD.bazel" -exec sed -i --follow-symlinks 's|deps = \[|deps = \[\n "//xla/tsl/platform/default:dso_loader",|g' {} + && \ find /root/.cache -name "prog.h" -exec sed -i --follow-symlinks '1i #include ' {} + && \ - python3 -c 'import glob, re -for p in glob.glob("/root/.cache/**/btree.h", recursive=True): - s = open(p).read() - open(p, "w").write(re.sub(r"(// In sets, all iterators are const\.)", "public:\n \\1", s)) -' && \ + python3 -c 'import glob, re; [(lambda s=open(p).read(): open(p, "w").write(re.sub(r"(// In sets, all iterators are const\.)", "public:\n \\1", s)))() for p in glob.glob("/root/.cache/**/btree.h", recursive=True)]' && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ bazel build --color=yes --noshow_progress --curses=no --config=cuda --copt="-fPIC"\ ${TF_SERVING_BAZEL_OPTIONS} \ diff --git a/tensorflow_serving/workspace.bzl b/tensorflow_serving/workspace.bzl index 07bd0038c64..db8ae034bf2 100644 --- a/tensorflow_serving/workspace.bzl +++ b/tensorflow_serving/workspace.bzl @@ -20,7 +20,7 @@ def tf_serving_workspace(): "https://github.com/abseil/abseil-cpp/archive/20260526.0.tar.gz", ], patch_cmds = [ - "python3 -c 'import glob, re\nfor p in glob.glob(\"**/btree.h\", recursive=True):\n s = open(p).read()\n open(p, \"w\").write(re.sub(r\"(// In sets, all iterators are const\\.)\", \"public:\\n \\\\1\", s))\n'", + "python3 -c 'import glob, re; [(lambda s=open(p).read(): open(p, \"w\").write(re.sub(r\"(// In sets, all iterators are const\\.)\", \"public:\\n \\\\1\", s)))() for p in glob.glob(\"**/btree.h\", recursive=True)]'", ], repo_mapping = { "@google_benchmark": "@com_google_benchmark", From 9c9f85735e486dd295e369f90db8e7e97a60f9a2 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Sun, 26 Jul 2026 22:30:41 +0000 Subject: [PATCH 156/183] Replace @tsl//tsl/platform:dso_loader with //xla/tsl/platform/default:dso_loader in xla/tsl/cuda/BUILD.bazel for cudart_stub and CUDA stubs --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 440d03125b3..703fec64a1a 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -167,7 +167,7 @@ RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/lib chmod -R +w /root/.cache && \ find /root/.cache -name "emmintrin.h" -exec sed -i --follow-symlinks '/typedef __bf16 __m128bh/d' {} + && \ find /root/.cache -name "emmintrin.h" -exec sed -i --follow-symlinks 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__CUDA__) || defined(__CUDACC__)\ntypedef short __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef short __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#else\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif\n#endif/' {} + && \ - find /root/.cache -path "*/xla/tsl/cuda/BUILD.bazel" -exec sed -i --follow-symlinks 's|deps = \[|deps = \[\n "//xla/tsl/platform/default:dso_loader",|g' {} + && \ + find /root/.cache -path "*/xla/tsl/cuda/BUILD.bazel" -exec sed -i --follow-symlinks 's|"@tsl//tsl/platform:dso_loader"|"//xla/tsl/platform/default:dso_loader"|g; s|deps = \[|deps = \[\n "//xla/tsl/platform/default:dso_loader",|g' {} + && \ find /root/.cache -name "prog.h" -exec sed -i --follow-symlinks '1i #include ' {} + && \ python3 -c 'import glob, re; [(lambda s=open(p).read(): open(p, "w").write(re.sub(r"(// In sets, all iterators are const\.)", "public:\n \\1", s)))() for p in glob.glob("/root/.cache/**/btree.h", recursive=True)]' && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ From 4ee8a24c0ced36982ab5ba5d36898e51bb033a34 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Mon, 27 Jul 2026 01:12:06 +0000 Subject: [PATCH 157/183] Fix line 1403 dependent type resolution in btree.h by setting btree::iterator directly to btree_iterator --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 2 +- tensorflow_serving/workspace.bzl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 703fec64a1a..d783f1080e2 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -169,7 +169,7 @@ RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/lib find /root/.cache -name "emmintrin.h" -exec sed -i --follow-symlinks 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__CUDA__) || defined(__CUDACC__)\ntypedef short __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef short __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#else\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif\n#endif/' {} + && \ find /root/.cache -path "*/xla/tsl/cuda/BUILD.bazel" -exec sed -i --follow-symlinks 's|"@tsl//tsl/platform:dso_loader"|"//xla/tsl/platform/default:dso_loader"|g; s|deps = \[|deps = \[\n "//xla/tsl/platform/default:dso_loader",|g' {} + && \ find /root/.cache -name "prog.h" -exec sed -i --follow-symlinks '1i #include ' {} + && \ - python3 -c 'import glob, re; [(lambda s=open(p).read(): open(p, "w").write(re.sub(r"(// In sets, all iterators are const\.)", "public:\n \\1", s)))() for p in glob.glob("/root/.cache/**/btree.h", recursive=True)]' && \ + python3 -c 'import glob; [(lambda s=open(p).read(): open(p, "w").write(s.replace("using iterator =\n typename btree_iterator::iterator;", "using iterator = btree_iterator;")))() for p in glob.glob("/root/.cache/**/btree.h", recursive=True)]' && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ bazel build --color=yes --noshow_progress --curses=no --config=cuda --copt="-fPIC"\ ${TF_SERVING_BAZEL_OPTIONS} \ diff --git a/tensorflow_serving/workspace.bzl b/tensorflow_serving/workspace.bzl index db8ae034bf2..ece2a385e75 100644 --- a/tensorflow_serving/workspace.bzl +++ b/tensorflow_serving/workspace.bzl @@ -20,7 +20,7 @@ def tf_serving_workspace(): "https://github.com/abseil/abseil-cpp/archive/20260526.0.tar.gz", ], patch_cmds = [ - "python3 -c 'import glob, re; [(lambda s=open(p).read(): open(p, \"w\").write(re.sub(r\"(// In sets, all iterators are const\\.)\", \"public:\\n \\\\1\", s)))() for p in glob.glob(\"**/btree.h\", recursive=True)]'", + "python3 -c 'import glob; [(lambda s=open(p).read(): open(p, \"w\").write(s.replace(\"using iterator =\\n typename btree_iterator::iterator;\", \"using iterator = btree_iterator;\")))() for p in glob.glob(\"**/btree.h\", recursive=True)]'", ], repo_mapping = { "@google_benchmark": "@com_google_benchmark", From dfd6a8bb3048d7818f8ffaa3a86b8dc08b526fae Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Mon, 27 Jul 2026 01:41:13 +0000 Subject: [PATCH 158/183] Add btree_iterator template friend declaration and direct btree::iterator type alias in btree.h --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 2 +- tensorflow_serving/workspace.bzl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index d783f1080e2..3383e733862 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -169,7 +169,7 @@ RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/lib find /root/.cache -name "emmintrin.h" -exec sed -i --follow-symlinks 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__CUDA__) || defined(__CUDACC__)\ntypedef short __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef short __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#else\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif\n#endif/' {} + && \ find /root/.cache -path "*/xla/tsl/cuda/BUILD.bazel" -exec sed -i --follow-symlinks 's|"@tsl//tsl/platform:dso_loader"|"//xla/tsl/platform/default:dso_loader"|g; s|deps = \[|deps = \[\n "//xla/tsl/platform/default:dso_loader",|g' {} + && \ find /root/.cache -name "prog.h" -exec sed -i --follow-symlinks '1i #include ' {} + && \ - python3 -c 'import glob; [(lambda s=open(p).read(): open(p, "w").write(s.replace("using iterator =\n typename btree_iterator::iterator;", "using iterator = btree_iterator;")))() for p in glob.glob("/root/.cache/**/btree.h", recursive=True)]' && \ + python3 -c 'import glob; [(lambda s=open(p).read(): open(p, "w").write(s.replace("class btree_iterator : private btree_iterator_generation_info {", "class btree_iterator : private btree_iterator_generation_info {\n template friend class btree_iterator;").replace("using iterator =\n typename btree_iterator::iterator;", "using iterator = btree_iterator;")))() for p in glob.glob("/root/.cache/**/btree.h", recursive=True)]' && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ bazel build --color=yes --noshow_progress --curses=no --config=cuda --copt="-fPIC"\ ${TF_SERVING_BAZEL_OPTIONS} \ diff --git a/tensorflow_serving/workspace.bzl b/tensorflow_serving/workspace.bzl index ece2a385e75..3e05f6fe2e9 100644 --- a/tensorflow_serving/workspace.bzl +++ b/tensorflow_serving/workspace.bzl @@ -20,7 +20,7 @@ def tf_serving_workspace(): "https://github.com/abseil/abseil-cpp/archive/20260526.0.tar.gz", ], patch_cmds = [ - "python3 -c 'import glob; [(lambda s=open(p).read(): open(p, \"w\").write(s.replace(\"using iterator =\\n typename btree_iterator::iterator;\", \"using iterator = btree_iterator;\")))() for p in glob.glob(\"**/btree.h\", recursive=True)]'", + "python3 -c 'import glob; [(lambda s=open(p).read(): open(p, \"w\").write(s.replace(\"class btree_iterator : private btree_iterator_generation_info {\", \"class btree_iterator : private btree_iterator_generation_info {\\n template friend class btree_iterator;\").replace(\"using iterator =\\n typename btree_iterator::iterator;\", \"using iterator = btree_iterator;\")))() for p in glob.glob(\"**/btree.h\", recursive=True)]'", ], repo_mapping = { "@google_benchmark": "@com_google_benchmark", From bc377ad2395eb7cd7bd4a6cd870a97ffa6eadbf2 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Mon, 27 Jul 2026 02:11:04 +0000 Subject: [PATCH 159/183] Make btree_iterator comparison operators templated for generic iterator-const_iterator comparisons --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 2 +- tensorflow_serving/workspace.bzl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 3383e733862..c1a0cfd7dbc 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -169,7 +169,7 @@ RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/lib find /root/.cache -name "emmintrin.h" -exec sed -i --follow-symlinks 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__CUDA__) || defined(__CUDACC__)\ntypedef short __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef short __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#else\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif\n#endif/' {} + && \ find /root/.cache -path "*/xla/tsl/cuda/BUILD.bazel" -exec sed -i --follow-symlinks 's|"@tsl//tsl/platform:dso_loader"|"//xla/tsl/platform/default:dso_loader"|g; s|deps = \[|deps = \[\n "//xla/tsl/platform/default:dso_loader",|g' {} + && \ find /root/.cache -name "prog.h" -exec sed -i --follow-symlinks '1i #include ' {} + && \ - python3 -c 'import glob; [(lambda s=open(p).read(): open(p, "w").write(s.replace("class btree_iterator : private btree_iterator_generation_info {", "class btree_iterator : private btree_iterator_generation_info {\n template friend class btree_iterator;").replace("using iterator =\n typename btree_iterator::iterator;", "using iterator = btree_iterator;")))() for p in glob.glob("/root/.cache/**/btree.h", recursive=True)]' && \ + python3 -c 'import glob; [(lambda s=open(p).read(): open(p, "w").write(s.replace("class btree_iterator : private btree_iterator_generation_info {", "class btree_iterator : private btree_iterator_generation_info {\n template friend class btree_iterator;").replace(" bool operator==(const iterator &other) const {\n return Equals(other);\n }\n bool operator==(const const_iterator &other) const {\n return Equals(other);\n }\n bool operator!=(const iterator &other) const {\n return !Equals(other);\n }\n bool operator!=(const const_iterator &other) const {\n return !Equals(other);\n }", " template \n bool operator==(const btree_iterator &other) const {\n return node_ == other.node_ && position_ == other.position_;\n }\n template \n bool operator!=(const btree_iterator &other) const {\n return node_ != other.node_ || position_ != other.position_;\n }").replace("using iterator =\n typename btree_iterator::iterator;", "using iterator = btree_iterator;")))() for p in glob.glob("/root/.cache/**/btree.h", recursive=True)]' && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ bazel build --color=yes --noshow_progress --curses=no --config=cuda --copt="-fPIC"\ ${TF_SERVING_BAZEL_OPTIONS} \ diff --git a/tensorflow_serving/workspace.bzl b/tensorflow_serving/workspace.bzl index 3e05f6fe2e9..b0837f3140c 100644 --- a/tensorflow_serving/workspace.bzl +++ b/tensorflow_serving/workspace.bzl @@ -20,7 +20,7 @@ def tf_serving_workspace(): "https://github.com/abseil/abseil-cpp/archive/20260526.0.tar.gz", ], patch_cmds = [ - "python3 -c 'import glob; [(lambda s=open(p).read(): open(p, \"w\").write(s.replace(\"class btree_iterator : private btree_iterator_generation_info {\", \"class btree_iterator : private btree_iterator_generation_info {\\n template friend class btree_iterator;\").replace(\"using iterator =\\n typename btree_iterator::iterator;\", \"using iterator = btree_iterator;\")))() for p in glob.glob(\"**/btree.h\", recursive=True)]'", + "python3 -c 'import glob; [(lambda s=open(p).read(): open(p, \"w\").write(s.replace(\"class btree_iterator : private btree_iterator_generation_info {\", \"class btree_iterator : private btree_iterator_generation_info {\\n template friend class btree_iterator;\").replace(\" bool operator==(const iterator &other) const {\\n return Equals(other);\\n }\\n bool operator==(const const_iterator &other) const {\\n return Equals(other);\\n }\\n bool operator!=(const iterator &other) const {\\n return !Equals(other);\\n }\\n bool operator!=(const const_iterator &other) const {\\n return !Equals(other);\\n }\", \" template \\n bool operator==(const btree_iterator &other) const {\\n return node_ == other.node_ && position_ == other.position_;\\n }\\n template \\n bool operator!=(const btree_iterator &other) const {\\n return node_ != other.node_ || position_ != other.position_;\\n }\").replace(\"using iterator =\\n typename btree_iterator::iterator;\", \"using iterator = btree_iterator;\")))() for p in glob.glob(\"**/btree.h\", recursive=True)]'", ], repo_mapping = { "@google_benchmark": "@com_google_benchmark", From 969c74b63ba0822106573ff7d3b7e16d268c96a4 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Mon, 27 Jul 2026 02:41:30 +0000 Subject: [PATCH 160/183] Template internal_end method in btree.h for const btree container calls with non-const iterators --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 2 +- tensorflow_serving/workspace.bzl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index c1a0cfd7dbc..d5756958282 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -169,7 +169,7 @@ RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/lib find /root/.cache -name "emmintrin.h" -exec sed -i --follow-symlinks 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__CUDA__) || defined(__CUDACC__)\ntypedef short __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef short __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#else\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif\n#endif/' {} + && \ find /root/.cache -path "*/xla/tsl/cuda/BUILD.bazel" -exec sed -i --follow-symlinks 's|"@tsl//tsl/platform:dso_loader"|"//xla/tsl/platform/default:dso_loader"|g; s|deps = \[|deps = \[\n "//xla/tsl/platform/default:dso_loader",|g' {} + && \ find /root/.cache -name "prog.h" -exec sed -i --follow-symlinks '1i #include ' {} + && \ - python3 -c 'import glob; [(lambda s=open(p).read(): open(p, "w").write(s.replace("class btree_iterator : private btree_iterator_generation_info {", "class btree_iterator : private btree_iterator_generation_info {\n template friend class btree_iterator;").replace(" bool operator==(const iterator &other) const {\n return Equals(other);\n }\n bool operator==(const const_iterator &other) const {\n return Equals(other);\n }\n bool operator!=(const iterator &other) const {\n return !Equals(other);\n }\n bool operator!=(const const_iterator &other) const {\n return !Equals(other);\n }", " template \n bool operator==(const btree_iterator &other) const {\n return node_ == other.node_ && position_ == other.position_;\n }\n template \n bool operator!=(const btree_iterator &other) const {\n return node_ != other.node_ || position_ != other.position_;\n }").replace("using iterator =\n typename btree_iterator::iterator;", "using iterator = btree_iterator;")))() for p in glob.glob("/root/.cache/**/btree.h", recursive=True)]' && \ + python3 -c 'import glob; [(lambda s=open(p).read(): open(p, "w").write(s.replace("class btree_iterator : private btree_iterator_generation_info {", "class btree_iterator : private btree_iterator_generation_info {\n template friend class btree_iterator;").replace(" bool operator==(const iterator &other) const {\n return Equals(other);\n }\n bool operator==(const const_iterator &other) const {\n return Equals(other);\n }\n bool operator!=(const iterator &other) const {\n return !Equals(other);\n }\n bool operator!=(const const_iterator &other) const {\n return !Equals(other);\n }", " template \n bool operator==(const btree_iterator &other) const {\n return node_ == other.node_ && position_ == other.position_;\n }\n template \n bool operator!=(const btree_iterator &other) const {\n return node_ != other.node_ || position_ != other.position_;\n }").replace(" iterator internal_end(iterator iter) {\n return iter.node_ != nullptr ? iter : end();\n }\n const_iterator internal_end(const_iterator iter) const {\n return iter.node_ != nullptr ? iter : end();\n }", " template \n Iter internal_end(Iter iter) const {\n return iter.node_ != nullptr ? iter : Iter(end());\n }").replace("using iterator =\n typename btree_iterator::iterator;", "using iterator = btree_iterator;")))() for p in glob.glob("/root/.cache/**/btree.h", recursive=True)]' && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ bazel build --color=yes --noshow_progress --curses=no --config=cuda --copt="-fPIC"\ ${TF_SERVING_BAZEL_OPTIONS} \ diff --git a/tensorflow_serving/workspace.bzl b/tensorflow_serving/workspace.bzl index b0837f3140c..3b792df9390 100644 --- a/tensorflow_serving/workspace.bzl +++ b/tensorflow_serving/workspace.bzl @@ -20,7 +20,7 @@ def tf_serving_workspace(): "https://github.com/abseil/abseil-cpp/archive/20260526.0.tar.gz", ], patch_cmds = [ - "python3 -c 'import glob; [(lambda s=open(p).read(): open(p, \"w\").write(s.replace(\"class btree_iterator : private btree_iterator_generation_info {\", \"class btree_iterator : private btree_iterator_generation_info {\\n template friend class btree_iterator;\").replace(\" bool operator==(const iterator &other) const {\\n return Equals(other);\\n }\\n bool operator==(const const_iterator &other) const {\\n return Equals(other);\\n }\\n bool operator!=(const iterator &other) const {\\n return !Equals(other);\\n }\\n bool operator!=(const const_iterator &other) const {\\n return !Equals(other);\\n }\", \" template \\n bool operator==(const btree_iterator &other) const {\\n return node_ == other.node_ && position_ == other.position_;\\n }\\n template \\n bool operator!=(const btree_iterator &other) const {\\n return node_ != other.node_ || position_ != other.position_;\\n }\").replace(\"using iterator =\\n typename btree_iterator::iterator;\", \"using iterator = btree_iterator;\")))() for p in glob.glob(\"**/btree.h\", recursive=True)]'", + "python3 -c 'import glob; [(lambda s=open(p).read(): open(p, \"w\").write(s.replace(\"class btree_iterator : private btree_iterator_generation_info {\", \"class btree_iterator : private btree_iterator_generation_info {\\n template friend class btree_iterator;\").replace(\" bool operator==(const iterator &other) const {\\n return Equals(other);\\n }\\n bool operator==(const const_iterator &other) const {\\n return Equals(other);\\n }\\n bool operator!=(const iterator &other) const {\\n return !Equals(other);\\n }\\n bool operator!=(const const_iterator &other) const {\\n return !Equals(other);\\n }\", \" template \\n bool operator==(const btree_iterator &other) const {\\n return node_ == other.node_ && position_ == other.position_;\\n }\\n template \\n bool operator!=(const btree_iterator &other) const {\\n return node_ != other.node_ || position_ != other.position_;\\n }\").replace(\" iterator internal_end(iterator iter) {\\n return iter.node_ != nullptr ? iter : end();\\n }\\n const_iterator internal_end(const_iterator iter) const {\\n return iter.node_ != nullptr ? iter : end();\\n }\", \" template \\n Iter internal_end(Iter iter) const {\\n return iter.node_ != nullptr ? iter : Iter(end());\\n }\").replace(\"using iterator =\\n typename btree_iterator::iterator;\", \"using iterator = btree_iterator;\")))() for p in glob.glob(\"**/btree.h\", recursive=True)]'", ], repo_mapping = { "@google_benchmark": "@com_google_benchmark", From e0004fa2ec40e2f86c7741f006d95e1d7abdd265 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Mon, 27 Jul 2026 03:11:27 +0000 Subject: [PATCH 161/183] Add const_iterator internal_end(iterator iter) const overload to btree.h for const btree calls with non-const iterators --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 2 +- tensorflow_serving/workspace.bzl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index d5756958282..91e75c1f84d 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -169,7 +169,7 @@ RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/lib find /root/.cache -name "emmintrin.h" -exec sed -i --follow-symlinks 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__CUDA__) || defined(__CUDACC__)\ntypedef short __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef short __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#else\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif\n#endif/' {} + && \ find /root/.cache -path "*/xla/tsl/cuda/BUILD.bazel" -exec sed -i --follow-symlinks 's|"@tsl//tsl/platform:dso_loader"|"//xla/tsl/platform/default:dso_loader"|g; s|deps = \[|deps = \[\n "//xla/tsl/platform/default:dso_loader",|g' {} + && \ find /root/.cache -name "prog.h" -exec sed -i --follow-symlinks '1i #include ' {} + && \ - python3 -c 'import glob; [(lambda s=open(p).read(): open(p, "w").write(s.replace("class btree_iterator : private btree_iterator_generation_info {", "class btree_iterator : private btree_iterator_generation_info {\n template friend class btree_iterator;").replace(" bool operator==(const iterator &other) const {\n return Equals(other);\n }\n bool operator==(const const_iterator &other) const {\n return Equals(other);\n }\n bool operator!=(const iterator &other) const {\n return !Equals(other);\n }\n bool operator!=(const const_iterator &other) const {\n return !Equals(other);\n }", " template \n bool operator==(const btree_iterator &other) const {\n return node_ == other.node_ && position_ == other.position_;\n }\n template \n bool operator!=(const btree_iterator &other) const {\n return node_ != other.node_ || position_ != other.position_;\n }").replace(" iterator internal_end(iterator iter) {\n return iter.node_ != nullptr ? iter : end();\n }\n const_iterator internal_end(const_iterator iter) const {\n return iter.node_ != nullptr ? iter : end();\n }", " template \n Iter internal_end(Iter iter) const {\n return iter.node_ != nullptr ? iter : Iter(end());\n }").replace("using iterator =\n typename btree_iterator::iterator;", "using iterator = btree_iterator;")))() for p in glob.glob("/root/.cache/**/btree.h", recursive=True)]' && \ + python3 -c 'import glob; [(lambda s=open(p).read(): open(p, "w").write(s.replace("class btree_iterator : private btree_iterator_generation_info {", "class btree_iterator : private btree_iterator_generation_info {\n template friend class btree_iterator;").replace(" bool operator==(const iterator &other) const {\n return Equals(other);\n }\n bool operator==(const const_iterator &other) const {\n return Equals(other);\n }\n bool operator!=(const iterator &other) const {\n return !Equals(other);\n }\n bool operator!=(const const_iterator &other) const {\n return !Equals(other);\n }", " template \n bool operator==(const btree_iterator &other) const {\n return node_ == other.node_ && position_ == other.position_;\n }\n template \n bool operator!=(const btree_iterator &other) const {\n return node_ != other.node_ || position_ != other.position_;\n }").replace(" iterator internal_end(iterator iter) {\n return iter.node_ != nullptr ? iter : end();\n }\n const_iterator internal_end(const_iterator iter) const {\n return iter.node_ != nullptr ? iter : end();\n }", " iterator internal_end(iterator iter) {\n return iter.node_ != nullptr ? iter : end();\n }\n const_iterator internal_end(const_iterator iter) const {\n return iter.node_ != nullptr ? iter : end();\n }\n const_iterator internal_end(iterator iter) const {\n return iter.node_ != nullptr ? iter : end();\n }").replace("using iterator =\n typename btree_iterator::iterator;", "using iterator = btree_iterator;")))() for p in glob.glob("/root/.cache/**/btree.h", recursive=True)]' && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ bazel build --color=yes --noshow_progress --curses=no --config=cuda --copt="-fPIC"\ ${TF_SERVING_BAZEL_OPTIONS} \ diff --git a/tensorflow_serving/workspace.bzl b/tensorflow_serving/workspace.bzl index 3b792df9390..392e45dee3f 100644 --- a/tensorflow_serving/workspace.bzl +++ b/tensorflow_serving/workspace.bzl @@ -20,7 +20,7 @@ def tf_serving_workspace(): "https://github.com/abseil/abseil-cpp/archive/20260526.0.tar.gz", ], patch_cmds = [ - "python3 -c 'import glob; [(lambda s=open(p).read(): open(p, \"w\").write(s.replace(\"class btree_iterator : private btree_iterator_generation_info {\", \"class btree_iterator : private btree_iterator_generation_info {\\n template friend class btree_iterator;\").replace(\" bool operator==(const iterator &other) const {\\n return Equals(other);\\n }\\n bool operator==(const const_iterator &other) const {\\n return Equals(other);\\n }\\n bool operator!=(const iterator &other) const {\\n return !Equals(other);\\n }\\n bool operator!=(const const_iterator &other) const {\\n return !Equals(other);\\n }\", \" template \\n bool operator==(const btree_iterator &other) const {\\n return node_ == other.node_ && position_ == other.position_;\\n }\\n template \\n bool operator!=(const btree_iterator &other) const {\\n return node_ != other.node_ || position_ != other.position_;\\n }\").replace(\" iterator internal_end(iterator iter) {\\n return iter.node_ != nullptr ? iter : end();\\n }\\n const_iterator internal_end(const_iterator iter) const {\\n return iter.node_ != nullptr ? iter : end();\\n }\", \" template \\n Iter internal_end(Iter iter) const {\\n return iter.node_ != nullptr ? iter : Iter(end());\\n }\").replace(\"using iterator =\\n typename btree_iterator::iterator;\", \"using iterator = btree_iterator;\")))() for p in glob.glob(\"**/btree.h\", recursive=True)]'", + "python3 -c 'import glob; [(lambda s=open(p).read(): open(p, \"w\").write(s.replace(\"class btree_iterator : private btree_iterator_generation_info {\", \"class btree_iterator : private btree_iterator_generation_info {\\n template friend class btree_iterator;\").replace(\" bool operator==(const iterator &other) const {\\n return Equals(other);\\n }\\n bool operator==(const const_iterator &other) const {\\n return Equals(other);\\n }\\n bool operator!=(const iterator &other) const {\\n return !Equals(other);\\n }\\n bool operator!=(const const_iterator &other) const {\\n return !Equals(other);\\n }\", \" template \\n bool operator==(const btree_iterator &other) const {\\n return node_ == other.node_ && position_ == other.position_;\\n }\\n template \\n bool operator!=(const btree_iterator &other) const {\\n return node_ != other.node_ || position_ != other.position_;\\n }\").replace(\" iterator internal_end(iterator iter) {\\n return iter.node_ != nullptr ? iter : end();\\n }\\n const_iterator internal_end(const_iterator iter) const {\\n return iter.node_ != nullptr ? iter : end();\\n }\", \" iterator internal_end(iterator iter) {\\n return iter.node_ != nullptr ? iter : end();\\n }\\n const_iterator internal_end(const_iterator iter) const {\\n return iter.node_ != nullptr ? iter : end();\\n }\\n const_iterator internal_end(iterator iter) const {\\n return iter.node_ != nullptr ? iter : end();\\n }\").replace(\"using iterator =\\n typename btree_iterator::iterator;\", \"using iterator = btree_iterator;\")))() for p in glob.glob(\"**/btree.h\", recursive=True)]'", ], repo_mapping = { "@google_benchmark": "@com_google_benchmark", From 5e318912e582e01bbe945618f11e3bae255dbcc2 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Mon, 27 Jul 2026 03:55:08 +0000 Subject: [PATCH 162/183] Expose key_arg as public in btree_container.h for btree_set_container inheritance --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 1 + tensorflow_serving/workspace.bzl | 1 + 2 files changed, 2 insertions(+) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 91e75c1f84d..1413c998e57 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -170,6 +170,7 @@ RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/lib find /root/.cache -path "*/xla/tsl/cuda/BUILD.bazel" -exec sed -i --follow-symlinks 's|"@tsl//tsl/platform:dso_loader"|"//xla/tsl/platform/default:dso_loader"|g; s|deps = \[|deps = \[\n "//xla/tsl/platform/default:dso_loader",|g' {} + && \ find /root/.cache -name "prog.h" -exec sed -i --follow-symlinks '1i #include ' {} + && \ python3 -c 'import glob; [(lambda s=open(p).read(): open(p, "w").write(s.replace("class btree_iterator : private btree_iterator_generation_info {", "class btree_iterator : private btree_iterator_generation_info {\n template friend class btree_iterator;").replace(" bool operator==(const iterator &other) const {\n return Equals(other);\n }\n bool operator==(const const_iterator &other) const {\n return Equals(other);\n }\n bool operator!=(const iterator &other) const {\n return !Equals(other);\n }\n bool operator!=(const const_iterator &other) const {\n return !Equals(other);\n }", " template \n bool operator==(const btree_iterator &other) const {\n return node_ == other.node_ && position_ == other.position_;\n }\n template \n bool operator!=(const btree_iterator &other) const {\n return node_ != other.node_ || position_ != other.position_;\n }").replace(" iterator internal_end(iterator iter) {\n return iter.node_ != nullptr ? iter : end();\n }\n const_iterator internal_end(const_iterator iter) const {\n return iter.node_ != nullptr ? iter : end();\n }", " iterator internal_end(iterator iter) {\n return iter.node_ != nullptr ? iter : end();\n }\n const_iterator internal_end(const_iterator iter) const {\n return iter.node_ != nullptr ? iter : end();\n }\n const_iterator internal_end(iterator iter) const {\n return iter.node_ != nullptr ? iter : end();\n }").replace("using iterator =\n typename btree_iterator::iterator;", "using iterator = btree_iterator;")))() for p in glob.glob("/root/.cache/**/btree.h", recursive=True)]' && \ + python3 -c 'import glob; [(lambda s=open(p).read(): open(p, "w").write(s.replace(" protected:\n // Alias used for heterogeneous lookup functions.", " public:\n // Alias used for heterogeneous lookup functions.")))() for p in glob.glob("/root/.cache/**/btree_container.h", recursive=True)]' && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ bazel build --color=yes --noshow_progress --curses=no --config=cuda --copt="-fPIC"\ ${TF_SERVING_BAZEL_OPTIONS} \ diff --git a/tensorflow_serving/workspace.bzl b/tensorflow_serving/workspace.bzl index 392e45dee3f..7e6a3b36dfe 100644 --- a/tensorflow_serving/workspace.bzl +++ b/tensorflow_serving/workspace.bzl @@ -21,6 +21,7 @@ def tf_serving_workspace(): ], patch_cmds = [ "python3 -c 'import glob; [(lambda s=open(p).read(): open(p, \"w\").write(s.replace(\"class btree_iterator : private btree_iterator_generation_info {\", \"class btree_iterator : private btree_iterator_generation_info {\\n template friend class btree_iterator;\").replace(\" bool operator==(const iterator &other) const {\\n return Equals(other);\\n }\\n bool operator==(const const_iterator &other) const {\\n return Equals(other);\\n }\\n bool operator!=(const iterator &other) const {\\n return !Equals(other);\\n }\\n bool operator!=(const const_iterator &other) const {\\n return !Equals(other);\\n }\", \" template \\n bool operator==(const btree_iterator &other) const {\\n return node_ == other.node_ && position_ == other.position_;\\n }\\n template \\n bool operator!=(const btree_iterator &other) const {\\n return node_ != other.node_ || position_ != other.position_;\\n }\").replace(\" iterator internal_end(iterator iter) {\\n return iter.node_ != nullptr ? iter : end();\\n }\\n const_iterator internal_end(const_iterator iter) const {\\n return iter.node_ != nullptr ? iter : end();\\n }\", \" iterator internal_end(iterator iter) {\\n return iter.node_ != nullptr ? iter : end();\\n }\\n const_iterator internal_end(const_iterator iter) const {\\n return iter.node_ != nullptr ? iter : end();\\n }\\n const_iterator internal_end(iterator iter) const {\\n return iter.node_ != nullptr ? iter : end();\\n }\").replace(\"using iterator =\\n typename btree_iterator::iterator;\", \"using iterator = btree_iterator;\")))() for p in glob.glob(\"**/btree.h\", recursive=True)]'", + "python3 -c 'import glob; [(lambda s=open(p).read(): open(p, \"w\").write(s.replace(\" protected:\\n // Alias used for heterogeneous lookup functions.\", \" public:\\n // Alias used for heterogeneous lookup functions.\")))() for p in glob.glob(\"**/btree_container.h\", recursive=True)]'", ], repo_mapping = { "@google_benchmark": "@com_google_benchmark", From 7ce6ffe96676349ebf7e5eeb800f6a41a7fa3aa9 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Mon, 27 Jul 2026 04:37:49 +0000 Subject: [PATCH 163/183] Use single-line target replacements for robust Abseil btree.h and btree_container.h patching --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 2 +- tensorflow_serving/workspace.bzl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 1413c998e57..46d7c78ed50 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -169,7 +169,7 @@ RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/lib find /root/.cache -name "emmintrin.h" -exec sed -i --follow-symlinks 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__CUDA__) || defined(__CUDACC__)\ntypedef short __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef short __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#else\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif\n#endif/' {} + && \ find /root/.cache -path "*/xla/tsl/cuda/BUILD.bazel" -exec sed -i --follow-symlinks 's|"@tsl//tsl/platform:dso_loader"|"//xla/tsl/platform/default:dso_loader"|g; s|deps = \[|deps = \[\n "//xla/tsl/platform/default:dso_loader",|g' {} + && \ find /root/.cache -name "prog.h" -exec sed -i --follow-symlinks '1i #include ' {} + && \ - python3 -c 'import glob; [(lambda s=open(p).read(): open(p, "w").write(s.replace("class btree_iterator : private btree_iterator_generation_info {", "class btree_iterator : private btree_iterator_generation_info {\n template friend class btree_iterator;").replace(" bool operator==(const iterator &other) const {\n return Equals(other);\n }\n bool operator==(const const_iterator &other) const {\n return Equals(other);\n }\n bool operator!=(const iterator &other) const {\n return !Equals(other);\n }\n bool operator!=(const const_iterator &other) const {\n return !Equals(other);\n }", " template \n bool operator==(const btree_iterator &other) const {\n return node_ == other.node_ && position_ == other.position_;\n }\n template \n bool operator!=(const btree_iterator &other) const {\n return node_ != other.node_ || position_ != other.position_;\n }").replace(" iterator internal_end(iterator iter) {\n return iter.node_ != nullptr ? iter : end();\n }\n const_iterator internal_end(const_iterator iter) const {\n return iter.node_ != nullptr ? iter : end();\n }", " iterator internal_end(iterator iter) {\n return iter.node_ != nullptr ? iter : end();\n }\n const_iterator internal_end(const_iterator iter) const {\n return iter.node_ != nullptr ? iter : end();\n }\n const_iterator internal_end(iterator iter) const {\n return iter.node_ != nullptr ? iter : end();\n }").replace("using iterator =\n typename btree_iterator::iterator;", "using iterator = btree_iterator;")))() for p in glob.glob("/root/.cache/**/btree.h", recursive=True)]' && \ + python3 -c 'import glob; [(lambda s=open(p).read(): open(p, "w").write(s.replace("class btree_iterator : private btree_iterator_generation_info {", "class btree_iterator : private btree_iterator_generation_info {\n template friend class btree_iterator;").replace(" bool operator==(const const_iterator &other) const {", " template bool operator==(const btree_iterator &other) const { return node_ == other.node_ && position_ == other.position_; }\n bool operator==(const const_iterator &other) const {").replace(" bool operator!=(const const_iterator &other) const {", " template bool operator!=(const btree_iterator &other) const { return node_ != other.node_ || position_ != other.position_; }\n bool operator!=(const const_iterator &other) const {").replace(" const_iterator internal_end(const_iterator iter) const {", " const_iterator internal_end(iterator iter) const { return iter.node_ != nullptr ? iter : end(); }\n const_iterator internal_end(const_iterator iter) const {").replace(" using iterator =\n typename btree_iterator::iterator;", " using iterator = btree_iterator;")))() for p in glob.glob("/root/.cache/**/btree.h", recursive=True)]' && \ python3 -c 'import glob; [(lambda s=open(p).read(): open(p, "w").write(s.replace(" protected:\n // Alias used for heterogeneous lookup functions.", " public:\n // Alias used for heterogeneous lookup functions.")))() for p in glob.glob("/root/.cache/**/btree_container.h", recursive=True)]' && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ bazel build --color=yes --noshow_progress --curses=no --config=cuda --copt="-fPIC"\ diff --git a/tensorflow_serving/workspace.bzl b/tensorflow_serving/workspace.bzl index 7e6a3b36dfe..8dbf2e49a6d 100644 --- a/tensorflow_serving/workspace.bzl +++ b/tensorflow_serving/workspace.bzl @@ -20,7 +20,7 @@ def tf_serving_workspace(): "https://github.com/abseil/abseil-cpp/archive/20260526.0.tar.gz", ], patch_cmds = [ - "python3 -c 'import glob; [(lambda s=open(p).read(): open(p, \"w\").write(s.replace(\"class btree_iterator : private btree_iterator_generation_info {\", \"class btree_iterator : private btree_iterator_generation_info {\\n template friend class btree_iterator;\").replace(\" bool operator==(const iterator &other) const {\\n return Equals(other);\\n }\\n bool operator==(const const_iterator &other) const {\\n return Equals(other);\\n }\\n bool operator!=(const iterator &other) const {\\n return !Equals(other);\\n }\\n bool operator!=(const const_iterator &other) const {\\n return !Equals(other);\\n }\", \" template \\n bool operator==(const btree_iterator &other) const {\\n return node_ == other.node_ && position_ == other.position_;\\n }\\n template \\n bool operator!=(const btree_iterator &other) const {\\n return node_ != other.node_ || position_ != other.position_;\\n }\").replace(\" iterator internal_end(iterator iter) {\\n return iter.node_ != nullptr ? iter : end();\\n }\\n const_iterator internal_end(const_iterator iter) const {\\n return iter.node_ != nullptr ? iter : end();\\n }\", \" iterator internal_end(iterator iter) {\\n return iter.node_ != nullptr ? iter : end();\\n }\\n const_iterator internal_end(const_iterator iter) const {\\n return iter.node_ != nullptr ? iter : end();\\n }\\n const_iterator internal_end(iterator iter) const {\\n return iter.node_ != nullptr ? iter : end();\\n }\").replace(\"using iterator =\\n typename btree_iterator::iterator;\", \"using iterator = btree_iterator;\")))() for p in glob.glob(\"**/btree.h\", recursive=True)]'", + "python3 -c 'import glob; [(lambda s=open(p).read(): open(p, \"w\").write(s.replace(\"class btree_iterator : private btree_iterator_generation_info {\", \"class btree_iterator : private btree_iterator_generation_info {\\n template friend class btree_iterator;\").replace(\" bool operator==(const const_iterator &other) const {\", \" template bool operator==(const btree_iterator &other) const { return node_ == other.node_ && position_ == other.position_; }\\n bool operator==(const const_iterator &other) const {\").replace(\" bool operator!=(const const_iterator &other) const {\", \" template bool operator!=(const btree_iterator &other) const { return node_ != other.node_ || position_ != other.position_; }\\n bool operator!=(const const_iterator &other) const {\").replace(\" const_iterator internal_end(const_iterator iter) const {\", \" const_iterator internal_end(iterator iter) const { return iter.node_ != nullptr ? iter : end(); }\\n const_iterator internal_end(const_iterator iter) const {\").replace(\" using iterator =\\n typename btree_iterator::iterator;\", \" using iterator = btree_iterator;\")))() for p in glob.glob(\"**/btree.h\", recursive=True)]'", "python3 -c 'import glob; [(lambda s=open(p).read(): open(p, \"w\").write(s.replace(\" protected:\\n // Alias used for heterogeneous lookup functions.\", \" public:\\n // Alias used for heterogeneous lookup functions.\")))() for p in glob.glob(\"**/btree_container.h\", recursive=True)]'", ], repo_mapping = { From 79b87aafd41f072e77029d6afd71b8896d73973b Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Mon, 27 Jul 2026 05:01:57 +0000 Subject: [PATCH 164/183] Use clean multi-statement python re.sub script for robust Abseil btree patching --- .../tools/docker/Dockerfile.devel-gpu | 16 ++++++++++++++-- tensorflow_serving/workspace.bzl | 4 ++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 46d7c78ed50..6ca74bf3319 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -169,8 +169,20 @@ RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/lib find /root/.cache -name "emmintrin.h" -exec sed -i --follow-symlinks 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__CUDA__) || defined(__CUDACC__)\ntypedef short __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef short __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#else\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif\n#endif/' {} + && \ find /root/.cache -path "*/xla/tsl/cuda/BUILD.bazel" -exec sed -i --follow-symlinks 's|"@tsl//tsl/platform:dso_loader"|"//xla/tsl/platform/default:dso_loader"|g; s|deps = \[|deps = \[\n "//xla/tsl/platform/default:dso_loader",|g' {} + && \ find /root/.cache -name "prog.h" -exec sed -i --follow-symlinks '1i #include ' {} + && \ - python3 -c 'import glob; [(lambda s=open(p).read(): open(p, "w").write(s.replace("class btree_iterator : private btree_iterator_generation_info {", "class btree_iterator : private btree_iterator_generation_info {\n template friend class btree_iterator;").replace(" bool operator==(const const_iterator &other) const {", " template bool operator==(const btree_iterator &other) const { return node_ == other.node_ && position_ == other.position_; }\n bool operator==(const const_iterator &other) const {").replace(" bool operator!=(const const_iterator &other) const {", " template bool operator!=(const btree_iterator &other) const { return node_ != other.node_ || position_ != other.position_; }\n bool operator!=(const const_iterator &other) const {").replace(" const_iterator internal_end(const_iterator iter) const {", " const_iterator internal_end(iterator iter) const { return iter.node_ != nullptr ? iter : end(); }\n const_iterator internal_end(const_iterator iter) const {").replace(" using iterator =\n typename btree_iterator::iterator;", " using iterator = btree_iterator;")))() for p in glob.glob("/root/.cache/**/btree.h", recursive=True)]' && \ - python3 -c 'import glob; [(lambda s=open(p).read(): open(p, "w").write(s.replace(" protected:\n // Alias used for heterogeneous lookup functions.", " public:\n // Alias used for heterogeneous lookup functions.")))() for p in glob.glob("/root/.cache/**/btree_container.h", recursive=True)]' && \ + python3 -c 'import glob, re +for p in glob.glob("/root/.cache/**/btree.h", recursive=True): + s = open(p).read() + s = re.sub(r"(class btree_iterator : private btree_iterator_generation_info \{)", r"\1\n template friend class btree_iterator;", s) + s = re.sub(r"(bool operator==\(const const_iterator &other\) const \{)", r"template bool operator==(const btree_iterator &other) const { return node_ == other.node_ && position_ == other.position_; }\n \1", s) + s = re.sub(r"(bool operator!=\(const const_iterator &other\) const \{)", r"template bool operator!=(const btree_iterator &other) const { return node_ != other.node_ || position_ != other.position_; }\n \1", s) + s = re.sub(r"(const_iterator internal_end\(const_iterator iter\) const \{)", r"const_iterator internal_end(iterator iter) const { return iter.node_ != nullptr ? iter : end(); }\n \1", s) + s = re.sub(r"using iterator\s*=\s*typename btree_iterator::iterator;", r"using iterator = btree_iterator;", s) + open(p, "w").write(s)' && \ + python3 -c 'import glob, re +for p in glob.glob("/root/.cache/**/btree_container.h", recursive=True): + s = open(p).read() + s = re.sub(r"protected:\s*(// Alias used for heterogeneous lookup functions\.)", r"public:\n \1", s) + open(p, "w").write(s)' && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ bazel build --color=yes --noshow_progress --curses=no --config=cuda --copt="-fPIC"\ ${TF_SERVING_BAZEL_OPTIONS} \ diff --git a/tensorflow_serving/workspace.bzl b/tensorflow_serving/workspace.bzl index 8dbf2e49a6d..f134b882c8f 100644 --- a/tensorflow_serving/workspace.bzl +++ b/tensorflow_serving/workspace.bzl @@ -20,8 +20,8 @@ def tf_serving_workspace(): "https://github.com/abseil/abseil-cpp/archive/20260526.0.tar.gz", ], patch_cmds = [ - "python3 -c 'import glob; [(lambda s=open(p).read(): open(p, \"w\").write(s.replace(\"class btree_iterator : private btree_iterator_generation_info {\", \"class btree_iterator : private btree_iterator_generation_info {\\n template friend class btree_iterator;\").replace(\" bool operator==(const const_iterator &other) const {\", \" template bool operator==(const btree_iterator &other) const { return node_ == other.node_ && position_ == other.position_; }\\n bool operator==(const const_iterator &other) const {\").replace(\" bool operator!=(const const_iterator &other) const {\", \" template bool operator!=(const btree_iterator &other) const { return node_ != other.node_ || position_ != other.position_; }\\n bool operator!=(const const_iterator &other) const {\").replace(\" const_iterator internal_end(const_iterator iter) const {\", \" const_iterator internal_end(iterator iter) const { return iter.node_ != nullptr ? iter : end(); }\\n const_iterator internal_end(const_iterator iter) const {\").replace(\" using iterator =\\n typename btree_iterator::iterator;\", \" using iterator = btree_iterator;\")))() for p in glob.glob(\"**/btree.h\", recursive=True)]'", - "python3 -c 'import glob; [(lambda s=open(p).read(): open(p, \"w\").write(s.replace(\" protected:\\n // Alias used for heterogeneous lookup functions.\", \" public:\\n // Alias used for heterogeneous lookup functions.\")))() for p in glob.glob(\"**/btree_container.h\", recursive=True)]'", + "python3 -c 'import glob, re\nfor p in glob.glob(\"**/btree.h\", recursive=True):\n s = open(p).read()\n s = re.sub(r\"(class btree_iterator : private btree_iterator_generation_info \\{)\", r\"\\1\\n template friend class btree_iterator;\", s)\n s = re.sub(r\"(bool operator==\\(const const_iterator &other\\) const \\{)\", r\"template bool operator==(const btree_iterator &other) const { return node_ == other.node_ && position_ == other.position_; }\\n \\1\", s)\n s = re.sub(r\"(bool operator!=\\(const const_iterator &other\\) const \\{)\", r\"template bool operator!=(const btree_iterator &other) const { return node_ != other.node_ || position_ != other.position_; }\\n \\1\", s)\n s = re.sub(r\"(const_iterator internal_end\\(const_iterator iter\\) const \\{)\", r\"const_iterator internal_end(iterator iter) const { return iter.node_ != nullptr ? iter : end(); }\\n \\1\", s)\n s = re.sub(r\"using iterator\\s*=\\s*typename btree_iterator::iterator;\", r\"using iterator = btree_iterator;\", s)\n open(p, \"w\").write(s)'", + "python3 -c 'import glob, re\nfor p in glob.glob(\"**/btree_container.h\", recursive=True):\n s = open(p).read()\n s = re.sub(r\"protected:\\s*(// Alias used for heterogeneous lookup functions\\.)\", r\"public:\\n \\1\", s)\n open(p, \"w\").write(s)'", ], repo_mapping = { "@google_benchmark": "@com_google_benchmark", From 160352667eee6b20a46671c8930959f7f952aad8 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Mon, 27 Jul 2026 05:03:54 +0000 Subject: [PATCH 165/183] Add robust regex patchers patch_btree and patch_container for Abseil C++17 compatibility --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 12 +++++++----- tensorflow_serving/workspace.bzl | 4 ++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 6ca74bf3319..d4afa349e33 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -170,19 +170,21 @@ RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/lib find /root/.cache -path "*/xla/tsl/cuda/BUILD.bazel" -exec sed -i --follow-symlinks 's|"@tsl//tsl/platform:dso_loader"|"//xla/tsl/platform/default:dso_loader"|g; s|deps = \[|deps = \[\n "//xla/tsl/platform/default:dso_loader",|g' {} + && \ find /root/.cache -name "prog.h" -exec sed -i --follow-symlinks '1i #include ' {} + && \ python3 -c 'import glob, re -for p in glob.glob("/root/.cache/**/btree.h", recursive=True): +def patch_btree(p): s = open(p).read() s = re.sub(r"(class btree_iterator : private btree_iterator_generation_info \{)", r"\1\n template friend class btree_iterator;", s) s = re.sub(r"(bool operator==\(const const_iterator &other\) const \{)", r"template bool operator==(const btree_iterator &other) const { return node_ == other.node_ && position_ == other.position_; }\n \1", s) s = re.sub(r"(bool operator!=\(const const_iterator &other\) const \{)", r"template bool operator!=(const btree_iterator &other) const { return node_ != other.node_ || position_ != other.position_; }\n \1", s) s = re.sub(r"(const_iterator internal_end\(const_iterator iter\) const \{)", r"const_iterator internal_end(iterator iter) const { return iter.node_ != nullptr ? iter : end(); }\n \1", s) s = re.sub(r"using iterator\s*=\s*typename btree_iterator::iterator;", r"using iterator = btree_iterator;", s) - open(p, "w").write(s)' && \ + open(p, "w").write(s) +for p in glob.glob("/root/.cache/**/btree.h", recursive=True): patch_btree(p)' && \ python3 -c 'import glob, re -for p in glob.glob("/root/.cache/**/btree_container.h", recursive=True): +def patch_container(p): s = open(p).read() - s = re.sub(r"protected:\s*(// Alias used for heterogeneous lookup functions\.)", r"public:\n \1", s) - open(p, "w").write(s)' && \ + s = re.sub(r"\s*protected:\s*(// Alias used for heterogeneous lookup functions\.)", r"\n public:\n \1", s) + open(p, "w").write(s) +for p in glob.glob("/root/.cache/**/btree_container.h", recursive=True): patch_container(p)' && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ bazel build --color=yes --noshow_progress --curses=no --config=cuda --copt="-fPIC"\ ${TF_SERVING_BAZEL_OPTIONS} \ diff --git a/tensorflow_serving/workspace.bzl b/tensorflow_serving/workspace.bzl index f134b882c8f..67acfbd5606 100644 --- a/tensorflow_serving/workspace.bzl +++ b/tensorflow_serving/workspace.bzl @@ -20,8 +20,8 @@ def tf_serving_workspace(): "https://github.com/abseil/abseil-cpp/archive/20260526.0.tar.gz", ], patch_cmds = [ - "python3 -c 'import glob, re\nfor p in glob.glob(\"**/btree.h\", recursive=True):\n s = open(p).read()\n s = re.sub(r\"(class btree_iterator : private btree_iterator_generation_info \\{)\", r\"\\1\\n template friend class btree_iterator;\", s)\n s = re.sub(r\"(bool operator==\\(const const_iterator &other\\) const \\{)\", r\"template bool operator==(const btree_iterator &other) const { return node_ == other.node_ && position_ == other.position_; }\\n \\1\", s)\n s = re.sub(r\"(bool operator!=\\(const const_iterator &other\\) const \\{)\", r\"template bool operator!=(const btree_iterator &other) const { return node_ != other.node_ || position_ != other.position_; }\\n \\1\", s)\n s = re.sub(r\"(const_iterator internal_end\\(const_iterator iter\\) const \\{)\", r\"const_iterator internal_end(iterator iter) const { return iter.node_ != nullptr ? iter : end(); }\\n \\1\", s)\n s = re.sub(r\"using iterator\\s*=\\s*typename btree_iterator::iterator;\", r\"using iterator = btree_iterator;\", s)\n open(p, \"w\").write(s)'", - "python3 -c 'import glob, re\nfor p in glob.glob(\"**/btree_container.h\", recursive=True):\n s = open(p).read()\n s = re.sub(r\"protected:\\s*(// Alias used for heterogeneous lookup functions\\.)\", r\"public:\\n \\1\", s)\n open(p, \"w\").write(s)'", + "python3 -c 'import glob, re\ndef patch_btree(p):\n s = open(p).read()\n s = re.sub(r\"(class btree_iterator : private btree_iterator_generation_info \\{)\", r\"\\1\\n template friend class btree_iterator;\", s)\n s = re.sub(r\"(bool operator==\\(const const_iterator &other\\) const \\{)\", r\"template bool operator==(const btree_iterator &other) const { return node_ == other.node_ && position_ == other.position_; }\\n \\1\", s)\n s = re.sub(r\"(bool operator!=\\(const const_iterator &other\\) const \\{)\", r\"template bool operator!=(const btree_iterator &other) const { return node_ != other.node_ || position_ != other.position_; }\\n \\1\", s)\n s = re.sub(r\"(const_iterator internal_end\\(const_iterator iter\\) const \\{)\", r\"const_iterator internal_end(iterator iter) const { return iter.node_ != nullptr ? iter : end(); }\\n \\1\", s)\n s = re.sub(r\"using iterator\\s*=\\s*typename btree_iterator::iterator;\", r\"using iterator = btree_iterator;\", s)\n open(p, \"w\").write(s)\nfor p in glob.glob(\"**/btree.h\", recursive=True): patch_btree(p)'", + "python3 -c 'import glob, re\ndef patch_container(p):\n s = open(p).read()\n s = re.sub(r\"\\s*protected:\\s*(// Alias used for heterogeneous lookup functions\\.)\", r\"\\n public:\\n \\1\", s)\n open(p, \"w\").write(s)\nfor p in glob.glob(\"**/btree_container.h\", recursive=True): patch_container(p)'", ], repo_mapping = { "@google_benchmark": "@com_google_benchmark", From b67bb54c228604ba6f5aab08cc57debe76d6bd00 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Mon, 27 Jul 2026 05:04:28 +0000 Subject: [PATCH 166/183] Add backslash continuations to Dockerfile.devel-gpu python script --- .../tools/docker/Dockerfile.devel-gpu | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index d4afa349e33..339a82d775f 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -169,21 +169,21 @@ RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/lib find /root/.cache -name "emmintrin.h" -exec sed -i --follow-symlinks 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__CUDA__) || defined(__CUDACC__)\ntypedef short __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef short __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#else\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif\n#endif/' {} + && \ find /root/.cache -path "*/xla/tsl/cuda/BUILD.bazel" -exec sed -i --follow-symlinks 's|"@tsl//tsl/platform:dso_loader"|"//xla/tsl/platform/default:dso_loader"|g; s|deps = \[|deps = \[\n "//xla/tsl/platform/default:dso_loader",|g' {} + && \ find /root/.cache -name "prog.h" -exec sed -i --follow-symlinks '1i #include ' {} + && \ - python3 -c 'import glob, re -def patch_btree(p): - s = open(p).read() - s = re.sub(r"(class btree_iterator : private btree_iterator_generation_info \{)", r"\1\n template friend class btree_iterator;", s) - s = re.sub(r"(bool operator==\(const const_iterator &other\) const \{)", r"template bool operator==(const btree_iterator &other) const { return node_ == other.node_ && position_ == other.position_; }\n \1", s) - s = re.sub(r"(bool operator!=\(const const_iterator &other\) const \{)", r"template bool operator!=(const btree_iterator &other) const { return node_ != other.node_ || position_ != other.position_; }\n \1", s) - s = re.sub(r"(const_iterator internal_end\(const_iterator iter\) const \{)", r"const_iterator internal_end(iterator iter) const { return iter.node_ != nullptr ? iter : end(); }\n \1", s) - s = re.sub(r"using iterator\s*=\s*typename btree_iterator::iterator;", r"using iterator = btree_iterator;", s) - open(p, "w").write(s) + python3 -c 'import glob, re; \ +def patch_btree(p): \ + s = open(p).read(); \ + s = re.sub(r"(class btree_iterator : private btree_iterator_generation_info \{)", r"\1\n template friend class btree_iterator;", s); \ + s = re.sub(r"(bool operator==\(const const_iterator &other\) const \{)", r"template bool operator==(const btree_iterator &other) const { return node_ == other.node_ && position_ == other.position_; }\n \1", s); \ + s = re.sub(r"(bool operator!=\(const const_iterator &other\) const \{)", r"template bool operator!=(const btree_iterator &other) const { return node_ != other.node_ || position_ != other.position_; }\n \1", s); \ + s = re.sub(r"(const_iterator internal_end\(const_iterator iter\) const \{)", r"const_iterator internal_end(iterator iter) const { return iter.node_ != nullptr ? iter : end(); }\n \1", s); \ + s = re.sub(r"using iterator\s*=\s*typename btree_iterator::iterator;", r"using iterator = btree_iterator;", s); \ + open(p, "w").write(s); \ for p in glob.glob("/root/.cache/**/btree.h", recursive=True): patch_btree(p)' && \ - python3 -c 'import glob, re -def patch_container(p): - s = open(p).read() - s = re.sub(r"\s*protected:\s*(// Alias used for heterogeneous lookup functions\.)", r"\n public:\n \1", s) - open(p, "w").write(s) + python3 -c 'import glob, re; \ +def patch_container(p): \ + s = open(p).read(); \ + s = re.sub(r"\s*protected:\s*(// Alias used for heterogeneous lookup functions\.)", r"\n public:\n \1", s); \ + open(p, "w").write(s); \ for p in glob.glob("/root/.cache/**/btree_container.h", recursive=True): patch_container(p)' && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ bazel build --color=yes --noshow_progress --curses=no --config=cuda --copt="-fPIC"\ From 737317fd6d98cf3fbaaeecc72759f8a251d5a1e4 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Mon, 27 Jul 2026 05:28:33 +0000 Subject: [PATCH 167/183] Use list comprehension in Python script to eliminate inline for loop SyntaxError --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 4 ++-- tensorflow_serving/workspace.bzl | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 339a82d775f..9647882943e 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -178,13 +178,13 @@ def patch_btree(p): \ s = re.sub(r"(const_iterator internal_end\(const_iterator iter\) const \{)", r"const_iterator internal_end(iterator iter) const { return iter.node_ != nullptr ? iter : end(); }\n \1", s); \ s = re.sub(r"using iterator\s*=\s*typename btree_iterator::iterator;", r"using iterator = btree_iterator;", s); \ open(p, "w").write(s); \ -for p in glob.glob("/root/.cache/**/btree.h", recursive=True): patch_btree(p)' && \ +[patch_btree(p) for p in glob.glob("/root/.cache/**/btree.h", recursive=True)]' && \ python3 -c 'import glob, re; \ def patch_container(p): \ s = open(p).read(); \ s = re.sub(r"\s*protected:\s*(// Alias used for heterogeneous lookup functions\.)", r"\n public:\n \1", s); \ open(p, "w").write(s); \ -for p in glob.glob("/root/.cache/**/btree_container.h", recursive=True): patch_container(p)' && \ +[patch_container(p) for p in glob.glob("/root/.cache/**/btree_container.h", recursive=True)]' && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ bazel build --color=yes --noshow_progress --curses=no --config=cuda --copt="-fPIC"\ ${TF_SERVING_BAZEL_OPTIONS} \ diff --git a/tensorflow_serving/workspace.bzl b/tensorflow_serving/workspace.bzl index 67acfbd5606..cb2267c9293 100644 --- a/tensorflow_serving/workspace.bzl +++ b/tensorflow_serving/workspace.bzl @@ -20,8 +20,8 @@ def tf_serving_workspace(): "https://github.com/abseil/abseil-cpp/archive/20260526.0.tar.gz", ], patch_cmds = [ - "python3 -c 'import glob, re\ndef patch_btree(p):\n s = open(p).read()\n s = re.sub(r\"(class btree_iterator : private btree_iterator_generation_info \\{)\", r\"\\1\\n template friend class btree_iterator;\", s)\n s = re.sub(r\"(bool operator==\\(const const_iterator &other\\) const \\{)\", r\"template bool operator==(const btree_iterator &other) const { return node_ == other.node_ && position_ == other.position_; }\\n \\1\", s)\n s = re.sub(r\"(bool operator!=\\(const const_iterator &other\\) const \\{)\", r\"template bool operator!=(const btree_iterator &other) const { return node_ != other.node_ || position_ != other.position_; }\\n \\1\", s)\n s = re.sub(r\"(const_iterator internal_end\\(const_iterator iter\\) const \\{)\", r\"const_iterator internal_end(iterator iter) const { return iter.node_ != nullptr ? iter : end(); }\\n \\1\", s)\n s = re.sub(r\"using iterator\\s*=\\s*typename btree_iterator::iterator;\", r\"using iterator = btree_iterator;\", s)\n open(p, \"w\").write(s)\nfor p in glob.glob(\"**/btree.h\", recursive=True): patch_btree(p)'", - "python3 -c 'import glob, re\ndef patch_container(p):\n s = open(p).read()\n s = re.sub(r\"\\s*protected:\\s*(// Alias used for heterogeneous lookup functions\\.)\", r\"\\n public:\\n \\1\", s)\n open(p, \"w\").write(s)\nfor p in glob.glob(\"**/btree_container.h\", recursive=True): patch_container(p)'", + "python3 -c 'import glob, re\ndef patch_btree(p):\n s = open(p).read()\n s = re.sub(r\"(class btree_iterator : private btree_iterator_generation_info \\{)\", r\"\\1\\n template friend class btree_iterator;\", s)\n s = re.sub(r\"(bool operator==\\(const const_iterator &other\\) const \\{)\", r\"template bool operator==(const btree_iterator &other) const { return node_ == other.node_ && position_ == other.position_; }\\n \\1\", s)\n s = re.sub(r\"(bool operator!=\\(const const_iterator &other\\) const \\{)\", r\"template bool operator!=(const btree_iterator &other) const { return node_ != other.node_ || position_ != other.position_; }\\n \\1\", s)\n s = re.sub(r\"(const_iterator internal_end\\(const_iterator iter\\) const \\{)\", r\"const_iterator internal_end(iterator iter) const { return iter.node_ != nullptr ? iter : end(); }\\n \\1\", s)\n s = re.sub(r\"using iterator\\s*=\\s*typename btree_iterator::iterator;\", r\"using iterator = btree_iterator;\", s)\n open(p, \"w\").write(s)\n[patch_btree(p) for p in glob.glob(\"**/btree.h\", recursive=True)]'", + "python3 -c 'import glob, re\ndef patch_container(p):\n s = open(p).read()\n s = re.sub(r\"\\s*protected:\\s*(// Alias used for heterogeneous lookup functions\\.)\", r\"\\n public:\\n \\1\", s)\n open(p, \"w\").write(s)\n[patch_container(p) for p in glob.glob(\"**/btree_container.h\", recursive=True)]'", ], repo_mapping = { "@google_benchmark": "@com_google_benchmark", From f926dd73018e7df9f569d76b1b28b732c025a12b Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Mon, 27 Jul 2026 05:47:03 +0000 Subject: [PATCH 168/183] Add patch_absl.py standalone helper script for robust Abseil C++17 patching --- .../tools/docker/Dockerfile.devel-gpu | 17 +------------ tensorflow_serving/tools/docker/patch_absl.py | 25 +++++++++++++++++++ tensorflow_serving/workspace.bzl | 3 +-- 3 files changed, 27 insertions(+), 18 deletions(-) create mode 100644 tensorflow_serving/tools/docker/patch_absl.py diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index 9647882943e..ba1cb7c621a 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -169,22 +169,7 @@ RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/lib find /root/.cache -name "emmintrin.h" -exec sed -i --follow-symlinks 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__CUDA__) || defined(__CUDACC__)\ntypedef short __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef short __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#else\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif\n#endif/' {} + && \ find /root/.cache -path "*/xla/tsl/cuda/BUILD.bazel" -exec sed -i --follow-symlinks 's|"@tsl//tsl/platform:dso_loader"|"//xla/tsl/platform/default:dso_loader"|g; s|deps = \[|deps = \[\n "//xla/tsl/platform/default:dso_loader",|g' {} + && \ find /root/.cache -name "prog.h" -exec sed -i --follow-symlinks '1i #include ' {} + && \ - python3 -c 'import glob, re; \ -def patch_btree(p): \ - s = open(p).read(); \ - s = re.sub(r"(class btree_iterator : private btree_iterator_generation_info \{)", r"\1\n template friend class btree_iterator;", s); \ - s = re.sub(r"(bool operator==\(const const_iterator &other\) const \{)", r"template bool operator==(const btree_iterator &other) const { return node_ == other.node_ && position_ == other.position_; }\n \1", s); \ - s = re.sub(r"(bool operator!=\(const const_iterator &other\) const \{)", r"template bool operator!=(const btree_iterator &other) const { return node_ != other.node_ || position_ != other.position_; }\n \1", s); \ - s = re.sub(r"(const_iterator internal_end\(const_iterator iter\) const \{)", r"const_iterator internal_end(iterator iter) const { return iter.node_ != nullptr ? iter : end(); }\n \1", s); \ - s = re.sub(r"using iterator\s*=\s*typename btree_iterator::iterator;", r"using iterator = btree_iterator;", s); \ - open(p, "w").write(s); \ -[patch_btree(p) for p in glob.glob("/root/.cache/**/btree.h", recursive=True)]' && \ - python3 -c 'import glob, re; \ -def patch_container(p): \ - s = open(p).read(); \ - s = re.sub(r"\s*protected:\s*(// Alias used for heterogeneous lookup functions\.)", r"\n public:\n \1", s); \ - open(p, "w").write(s); \ -[patch_container(p) for p in glob.glob("/root/.cache/**/btree_container.h", recursive=True)]' && \ + python3 /tensorflow-serving/tensorflow_serving/tools/docker/patch_absl.py /root/.cache && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ bazel build --color=yes --noshow_progress --curses=no --config=cuda --copt="-fPIC"\ ${TF_SERVING_BAZEL_OPTIONS} \ diff --git a/tensorflow_serving/tools/docker/patch_absl.py b/tensorflow_serving/tools/docker/patch_absl.py new file mode 100644 index 00000000000..88f10b5c865 --- /dev/null +++ b/tensorflow_serving/tools/docker/patch_absl.py @@ -0,0 +1,25 @@ +import glob +import re +import sys + +def patch_btree(p): + s = open(p).read() + s = re.sub(r"(class btree_iterator : private btree_iterator_generation_info \{)", r"\1\n template friend class btree_iterator;", s) + s = re.sub(r"(bool operator==\(const const_iterator &other\) const \{)", r"template bool operator==(const btree_iterator &other) const { return node_ == other.node_ && position_ == other.position_; }\n \1", s) + s = re.sub(r"(bool operator!=\(const const_iterator &other\) const \{)", r"template bool operator!=(const btree_iterator &other) const { return node_ != other.node_ || position_ != other.position_; }\n \1", s) + s = re.sub(r"(const_iterator internal_end\(const_iterator iter\) const \{)", r"const_iterator internal_end(iterator iter) const { return iter.node_ != nullptr ? iter : end(); }\n \1", s) + s = re.sub(r"using iterator\s*=\s*typename btree_iterator::iterator;", r"using iterator = btree_iterator;", s) + open(p, "w").write(s) + +def patch_container(p): + s = open(p).read() + s = re.sub(r"\s*protected:\s*(// Alias used for heterogeneous lookup functions\.)", r"\n public:\n \1", s) + open(p, "w").write(s) + +if __name__ == "__main__": + target_dir = sys.argv[1] if len(sys.argv) > 1 else "." + for p in glob.glob(f"{target_dir}/**/btree.h", recursive=True): + patch_btree(p) + for p in glob.glob(f"{target_dir}/**/btree_container.h", recursive=True): + patch_container(p) + print("Successfully patched Abseil btree headers in:", target_dir) diff --git a/tensorflow_serving/workspace.bzl b/tensorflow_serving/workspace.bzl index cb2267c9293..2feeda30b32 100644 --- a/tensorflow_serving/workspace.bzl +++ b/tensorflow_serving/workspace.bzl @@ -20,8 +20,7 @@ def tf_serving_workspace(): "https://github.com/abseil/abseil-cpp/archive/20260526.0.tar.gz", ], patch_cmds = [ - "python3 -c 'import glob, re\ndef patch_btree(p):\n s = open(p).read()\n s = re.sub(r\"(class btree_iterator : private btree_iterator_generation_info \\{)\", r\"\\1\\n template friend class btree_iterator;\", s)\n s = re.sub(r\"(bool operator==\\(const const_iterator &other\\) const \\{)\", r\"template bool operator==(const btree_iterator &other) const { return node_ == other.node_ && position_ == other.position_; }\\n \\1\", s)\n s = re.sub(r\"(bool operator!=\\(const const_iterator &other\\) const \\{)\", r\"template bool operator!=(const btree_iterator &other) const { return node_ != other.node_ || position_ != other.position_; }\\n \\1\", s)\n s = re.sub(r\"(const_iterator internal_end\\(const_iterator iter\\) const \\{)\", r\"const_iterator internal_end(iterator iter) const { return iter.node_ != nullptr ? iter : end(); }\\n \\1\", s)\n s = re.sub(r\"using iterator\\s*=\\s*typename btree_iterator::iterator;\", r\"using iterator = btree_iterator;\", s)\n open(p, \"w\").write(s)\n[patch_btree(p) for p in glob.glob(\"**/btree.h\", recursive=True)]'", - "python3 -c 'import glob, re\ndef patch_container(p):\n s = open(p).read()\n s = re.sub(r\"\\s*protected:\\s*(// Alias used for heterogeneous lookup functions\\.)\", r\"\\n public:\\n \\1\", s)\n open(p, \"w\").write(s)\n[patch_container(p) for p in glob.glob(\"**/btree_container.h\", recursive=True)]'", + "python3 tensorflow_serving/tools/docker/patch_absl.py .", ], repo_mapping = { "@google_benchmark": "@com_google_benchmark", From f08ed42fd2a42de468518144091f47e2b12c67ad Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Mon, 27 Jul 2026 06:05:45 +0000 Subject: [PATCH 169/183] Use self-contained inline python lambdas in workspace.bzl patch_cmds --- tensorflow_serving/workspace.bzl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tensorflow_serving/workspace.bzl b/tensorflow_serving/workspace.bzl index 2feeda30b32..2c5dea9f540 100644 --- a/tensorflow_serving/workspace.bzl +++ b/tensorflow_serving/workspace.bzl @@ -20,7 +20,8 @@ def tf_serving_workspace(): "https://github.com/abseil/abseil-cpp/archive/20260526.0.tar.gz", ], patch_cmds = [ - "python3 tensorflow_serving/tools/docker/patch_absl.py .", + "python3 -c 'import glob, re; [(lambda s=open(p).read(): open(p, \"w\").write(re.sub(r\"(class btree_iterator : private btree_iterator_generation_info \\{)\", r\"\\1\\n template friend class btree_iterator;\", re.sub(r\"(bool operator==\\(const const_iterator &other\\) const \\{)\", r\"template bool operator==(const btree_iterator &other) const { return node_ == other.node_ && position_ == other.position_; }\\n \\1\", re.sub(r\"(bool operator!=\\(const const_iterator &other\\) const \\{)\", r\"template bool operator!=(const btree_iterator &other) const { return node_ != other.node_ || position_ != other.position_; }\\n \\1\", re.sub(r\"(const_iterator internal_end\\(const_iterator iter\\) const \\{)\", r\"const_iterator internal_end(iterator iter) const { return iter.node_ != nullptr ? iter : end(); }\\n \\1\", re.sub(r\"using iterator\\s*=\\s*typename btree_iterator::iterator;\", r\"using iterator = btree_iterator;\", s)))))))() for p in glob.glob(\"**/btree.h\", recursive=True)]'", + "python3 -c 'import glob, re; [(lambda s=open(p).read(): open(p, \"w\").write(re.sub(r\"\\s*protected:\\s*(// Alias used for heterogeneous lookup functions\\.)\", r\"\\n public:\\n \\1\", s)))() for p in glob.glob(\"**/btree_container.h\", recursive=True)]'", ], repo_mapping = { "@google_benchmark": "@com_google_benchmark", From ce1e414b539bcd89d0f784b09a1a103a5b3d22dc Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Mon, 27 Jul 2026 06:34:28 +0000 Subject: [PATCH 170/183] Add idempotency checks to patch_absl.py and workspace.bzl patch_cmds --- tensorflow_serving/tools/docker/patch_absl.py | 18 ++++++++++++------ tensorflow_serving/workspace.bzl | 4 ++-- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/tensorflow_serving/tools/docker/patch_absl.py b/tensorflow_serving/tools/docker/patch_absl.py index 88f10b5c865..5f367552b51 100644 --- a/tensorflow_serving/tools/docker/patch_absl.py +++ b/tensorflow_serving/tools/docker/patch_absl.py @@ -4,16 +4,22 @@ def patch_btree(p): s = open(p).read() - s = re.sub(r"(class btree_iterator : private btree_iterator_generation_info \{)", r"\1\n template friend class btree_iterator;", s) - s = re.sub(r"(bool operator==\(const const_iterator &other\) const \{)", r"template bool operator==(const btree_iterator &other) const { return node_ == other.node_ && position_ == other.position_; }\n \1", s) - s = re.sub(r"(bool operator!=\(const const_iterator &other\) const \{)", r"template bool operator!=(const btree_iterator &other) const { return node_ != other.node_ || position_ != other.position_; }\n \1", s) - s = re.sub(r"(const_iterator internal_end\(const_iterator iter\) const \{)", r"const_iterator internal_end(iterator iter) const { return iter.node_ != nullptr ? iter : end(); }\n \1", s) - s = re.sub(r"using iterator\s*=\s*typename btree_iterator::iterator;", r"using iterator = btree_iterator;", s) + if "friend class btree_iterator;" not in s: + s = re.sub(r"(class btree_iterator : private btree_iterator_generation_info \{)", r"\1\n template friend class btree_iterator;", s) + if "bool operator==(const btree_iterator" not in s: + s = re.sub(r"(bool operator==\(const const_iterator &other\) const \{)", r"template bool operator==(const btree_iterator &other) const { return node_ == other.node_ && position_ == other.position_; }\n \1", s) + if "bool operator!=(const btree_iterator" not in s: + s = re.sub(r"(bool operator!=\(const const_iterator &other\) const \{)", r"template bool operator!=(const btree_iterator &other) const { return node_ != other.node_ || position_ != other.position_; }\n \1", s) + if "internal_end(iterator iter) const" not in s: + s = re.sub(r"(const_iterator internal_end\(const_iterator iter\) const \{)", r"const_iterator internal_end(iterator iter) const { return iter.node_ != nullptr ? iter : end(); }\n \1", s) + if "using iterator = btree_iterator;" not in s: + s = re.sub(r"using iterator\s*=\s*typename btree_iterator::iterator;", r"using iterator = btree_iterator;", s) open(p, "w").write(s) def patch_container(p): s = open(p).read() - s = re.sub(r"\s*protected:\s*(// Alias used for heterogeneous lookup functions\.)", r"\n public:\n \1", s) + if " public:\n // Alias used for heterogeneous lookup functions." not in s: + s = re.sub(r"\s*protected:\s*(// Alias used for heterogeneous lookup functions\.)", r"\n public:\n \1", s) open(p, "w").write(s) if __name__ == "__main__": diff --git a/tensorflow_serving/workspace.bzl b/tensorflow_serving/workspace.bzl index 2c5dea9f540..acb49367dd3 100644 --- a/tensorflow_serving/workspace.bzl +++ b/tensorflow_serving/workspace.bzl @@ -20,8 +20,8 @@ def tf_serving_workspace(): "https://github.com/abseil/abseil-cpp/archive/20260526.0.tar.gz", ], patch_cmds = [ - "python3 -c 'import glob, re; [(lambda s=open(p).read(): open(p, \"w\").write(re.sub(r\"(class btree_iterator : private btree_iterator_generation_info \\{)\", r\"\\1\\n template friend class btree_iterator;\", re.sub(r\"(bool operator==\\(const const_iterator &other\\) const \\{)\", r\"template bool operator==(const btree_iterator &other) const { return node_ == other.node_ && position_ == other.position_; }\\n \\1\", re.sub(r\"(bool operator!=\\(const const_iterator &other\\) const \\{)\", r\"template bool operator!=(const btree_iterator &other) const { return node_ != other.node_ || position_ != other.position_; }\\n \\1\", re.sub(r\"(const_iterator internal_end\\(const_iterator iter\\) const \\{)\", r\"const_iterator internal_end(iterator iter) const { return iter.node_ != nullptr ? iter : end(); }\\n \\1\", re.sub(r\"using iterator\\s*=\\s*typename btree_iterator::iterator;\", r\"using iterator = btree_iterator;\", s)))))))() for p in glob.glob(\"**/btree.h\", recursive=True)]'", - "python3 -c 'import glob, re; [(lambda s=open(p).read(): open(p, \"w\").write(re.sub(r\"\\s*protected:\\s*(// Alias used for heterogeneous lookup functions\\.)\", r\"\\n public:\\n \\1\", s)))() for p in glob.glob(\"**/btree_container.h\", recursive=True)]'", + "python3 -c 'import glob, re; [(lambda s=open(p).read(): (\"friend class btree_iterator;\" not in s and open(p, \"w\").write(re.sub(r\"(class btree_iterator : private btree_iterator_generation_info \\{)\", r\"\\1\\n template friend class btree_iterator;\", re.sub(r\"(bool operator==\\(const const_iterator &other\\) const \\{)\", r\"template bool operator==(const btree_iterator &other) const { return node_ == other.node_ && position_ == other.position_; }\\n \\1\", re.sub(r\"(bool operator!=\\(const const_iterator &other\\) const \\{)\", r\"template bool operator!=(const btree_iterator &other) const { return node_ != other.node_ || position_ != other.position_; }\\n \\1\", re.sub(r\"(const_iterator internal_end\\(const_iterator iter\\) const \\{)\", r\"const_iterator internal_end(iterator iter) const { return iter.node_ != nullptr ? iter : end(); }\\n \\1\", re.sub(r\"using iterator\\s*=\\s*typename btree_iterator::iterator;\", r\"using iterator = btree_iterator;\", s))))))))() for p in glob.glob(\"**/btree.h\", recursive=True)]'", + "python3 -c 'import glob, re; [(lambda s=open(p).read(): (\" public:\\n // Alias used for heterogeneous lookup functions.\" not in s and open(p, \"w\").write(re.sub(r\"\\s*protected:\\s*(// Alias used for heterogeneous lookup functions\\.)\", r\"\\n public:\\n \\1\", s))))() for p in glob.glob(\"**/btree_container.h\", recursive=True)]'", ], repo_mapping = { "@google_benchmark": "@com_google_benchmark", From f656f853f69deab15aba204a3a8e68057c6eaa20 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Mon, 27 Jul 2026 07:20:40 +0000 Subject: [PATCH 171/183] Add pragma once header guard to CUDA 12 cupti_driver_cbid.h in Dockerfile.devel-gpu --- tensorflow_serving/tools/docker/Dockerfile.devel-gpu | 1 + 1 file changed, 1 insertion(+) diff --git a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu index ba1cb7c621a..24c6f93a29d 100644 --- a/tensorflow_serving/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow_serving/tools/docker/Dockerfile.devel-gpu @@ -169,6 +169,7 @@ RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/lib find /root/.cache -name "emmintrin.h" -exec sed -i --follow-symlinks 's/typedef __bf16 __v8bf.*/#ifndef __v8bf_defined\n#define __v8bf_defined\n#if defined(__CUDA__) || defined(__CUDACC__)\ntypedef short __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef short __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#else\ntypedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16)));\ntypedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16)));\n#endif\n#endif/' {} + && \ find /root/.cache -path "*/xla/tsl/cuda/BUILD.bazel" -exec sed -i --follow-symlinks 's|"@tsl//tsl/platform:dso_loader"|"//xla/tsl/platform/default:dso_loader"|g; s|deps = \[|deps = \[\n "//xla/tsl/platform/default:dso_loader",|g' {} + && \ find /root/.cache -name "prog.h" -exec sed -i --follow-symlinks '1i #include ' {} + && \ + find /root/.cache -name "cupti_driver_cbid.h" -exec sed -i --follow-symlinks '1i #pragma once' {} + && \ python3 /tensorflow-serving/tensorflow_serving/tools/docker/patch_absl.py /root/.cache && \ LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \ bazel build --color=yes --noshow_progress --curses=no --config=cuda --copt="-fPIC"\ From 72428f29336b236eafa364e963bf07392833a032 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Mon, 27 Jul 2026 08:02:54 +0000 Subject: [PATCH 172/183] Relax btree_iterator converting constructor in patch_absl.py and workspace.bzl --- tensorflow_serving/tools/docker/patch_absl.py | 1 + tensorflow_serving/workspace.bzl | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/tensorflow_serving/tools/docker/patch_absl.py b/tensorflow_serving/tools/docker/patch_absl.py index 5f367552b51..7ff0c6d6648 100644 --- a/tensorflow_serving/tools/docker/patch_absl.py +++ b/tensorflow_serving/tools/docker/patch_absl.py @@ -14,6 +14,7 @@ def patch_btree(p): s = re.sub(r"(const_iterator internal_end\(const_iterator iter\) const \{)", r"const_iterator internal_end(iterator iter) const { return iter.node_ != nullptr ? iter : end(); }\n \1", s) if "using iterator = btree_iterator;" not in s: s = re.sub(r"using iterator\s*=\s*typename btree_iterator::iterator;", r"using iterator = btree_iterator;", s) + s = re.sub(r"std::is_same,\s*iterator>::value\s*&&\s*std::is_same::value", r"std::is_same::value && !std::is_same, const_iterator>::value", s) open(p, "w").write(s) def patch_container(p): diff --git a/tensorflow_serving/workspace.bzl b/tensorflow_serving/workspace.bzl index acb49367dd3..5876657b6a5 100644 --- a/tensorflow_serving/workspace.bzl +++ b/tensorflow_serving/workspace.bzl @@ -20,7 +20,7 @@ def tf_serving_workspace(): "https://github.com/abseil/abseil-cpp/archive/20260526.0.tar.gz", ], patch_cmds = [ - "python3 -c 'import glob, re; [(lambda s=open(p).read(): (\"friend class btree_iterator;\" not in s and open(p, \"w\").write(re.sub(r\"(class btree_iterator : private btree_iterator_generation_info \\{)\", r\"\\1\\n template friend class btree_iterator;\", re.sub(r\"(bool operator==\\(const const_iterator &other\\) const \\{)\", r\"template bool operator==(const btree_iterator &other) const { return node_ == other.node_ && position_ == other.position_; }\\n \\1\", re.sub(r\"(bool operator!=\\(const const_iterator &other\\) const \\{)\", r\"template bool operator!=(const btree_iterator &other) const { return node_ != other.node_ || position_ != other.position_; }\\n \\1\", re.sub(r\"(const_iterator internal_end\\(const_iterator iter\\) const \\{)\", r\"const_iterator internal_end(iterator iter) const { return iter.node_ != nullptr ? iter : end(); }\\n \\1\", re.sub(r\"using iterator\\s*=\\s*typename btree_iterator::iterator;\", r\"using iterator = btree_iterator;\", s))))))))() for p in glob.glob(\"**/btree.h\", recursive=True)]'", + "python3 -c 'import glob, re; [(lambda s=open(p).read(): (\"friend class btree_iterator;\" not in s and open(p, \"w\").write(re.sub(r\"std::is_same,\\s*iterator>::value\\s*&&\\s*std::is_same::value\", r\"std::is_same::value && !std::is_same, const_iterator>::value\", re.sub(r\"(class btree_iterator : private btree_iterator_generation_info \\{)\", r\"\\1\\n template friend class btree_iterator;\", re.sub(r\"(bool operator==\\(const const_iterator &other\\) const \\{)\", r\"template bool operator==(const btree_iterator &other) const { return node_ == other.node_ && position_ == other.position_; }\\n \\1\", re.sub(r\"(bool operator!=\\(const const_iterator &other\\) const \\{)\", r\"template bool operator!=(const btree_iterator &other) const { return node_ != other.node_ || position_ != other.position_; }\\n \\1\", re.sub(r\"(const_iterator internal_end\\(const_iterator iter\\) const \\{)\", r\"const_iterator internal_end(iterator iter) const { return iter.node_ != nullptr ? iter : end(); }\\n \\1\", re.sub(r\"using iterator\\s*=\\s*typename btree_iterator::iterator;\", r\"using iterator = btree_iterator;\", s)))))))))() for p in glob.glob(\"**/btree.h\", recursive=True)]'", "python3 -c 'import glob, re; [(lambda s=open(p).read(): (\" public:\\n // Alias used for heterogeneous lookup functions.\" not in s and open(p, \"w\").write(re.sub(r\"\\s*protected:\\s*(// Alias used for heterogeneous lookup functions\\.)\", r\"\\n public:\\n \\1\", s))))() for p in glob.glob(\"**/btree_container.h\", recursive=True)]'", ], repo_mapping = { From 4b32fae77a07a21d79847cfaff280aac380dfce3 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Mon, 27 Jul 2026 08:44:24 +0000 Subject: [PATCH 173/183] Pass by reference and const_cast in btree_iterator converting constructor --- tensorflow_serving/tools/docker/patch_absl.py | 2 ++ tensorflow_serving/workspace.bzl | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tensorflow_serving/tools/docker/patch_absl.py b/tensorflow_serving/tools/docker/patch_absl.py index 7ff0c6d6648..bf3fd55f0f6 100644 --- a/tensorflow_serving/tools/docker/patch_absl.py +++ b/tensorflow_serving/tools/docker/patch_absl.py @@ -15,6 +15,8 @@ def patch_btree(p): if "using iterator = btree_iterator;" not in s: s = re.sub(r"using iterator\s*=\s*typename btree_iterator::iterator;", r"using iterator = btree_iterator;", s) s = re.sub(r"std::is_same,\s*iterator>::value\s*&&\s*std::is_same::value", r"std::is_same::value && !std::is_same, const_iterator>::value", s) + s = s.replace("btree_iterator(const btree_iterator other) // NOLINT", "btree_iterator(const btree_iterator &other) // NOLINT") + s = s.replace("node_(other.node_),\n position_(other.position_) {}", "node_(const_cast(other.node_)),\n position_(other.position_) {}") open(p, "w").write(s) def patch_container(p): diff --git a/tensorflow_serving/workspace.bzl b/tensorflow_serving/workspace.bzl index 5876657b6a5..b3feb46ba77 100644 --- a/tensorflow_serving/workspace.bzl +++ b/tensorflow_serving/workspace.bzl @@ -20,7 +20,7 @@ def tf_serving_workspace(): "https://github.com/abseil/abseil-cpp/archive/20260526.0.tar.gz", ], patch_cmds = [ - "python3 -c 'import glob, re; [(lambda s=open(p).read(): (\"friend class btree_iterator;\" not in s and open(p, \"w\").write(re.sub(r\"std::is_same,\\s*iterator>::value\\s*&&\\s*std::is_same::value\", r\"std::is_same::value && !std::is_same, const_iterator>::value\", re.sub(r\"(class btree_iterator : private btree_iterator_generation_info \\{)\", r\"\\1\\n template friend class btree_iterator;\", re.sub(r\"(bool operator==\\(const const_iterator &other\\) const \\{)\", r\"template bool operator==(const btree_iterator &other) const { return node_ == other.node_ && position_ == other.position_; }\\n \\1\", re.sub(r\"(bool operator!=\\(const const_iterator &other\\) const \\{)\", r\"template bool operator!=(const btree_iterator &other) const { return node_ != other.node_ || position_ != other.position_; }\\n \\1\", re.sub(r\"(const_iterator internal_end\\(const_iterator iter\\) const \\{)\", r\"const_iterator internal_end(iterator iter) const { return iter.node_ != nullptr ? iter : end(); }\\n \\1\", re.sub(r\"using iterator\\s*=\\s*typename btree_iterator::iterator;\", r\"using iterator = btree_iterator;\", s)))))))))() for p in glob.glob(\"**/btree.h\", recursive=True)]'", + "python3 -c 'import glob, re; [(lambda s=open(p).read(): (\"friend class btree_iterator;\" not in s and open(p, \"w\").write(re.sub(r\"std::is_same,\\s*iterator>::value\\s*&&\\s*std::is_same::value\", r\"std::is_same::value && !std::is_same, const_iterator>::value\", re.sub(r\"(class btree_iterator : private btree_iterator_generation_info \\{)\", r\"\\1\\n template friend class btree_iterator;\", re.sub(r\"(bool operator==\\(const const_iterator &other\\) const \\{)\", r\"template bool operator==(const btree_iterator &other) const { return node_ == other.node_ && position_ == other.position_; }\\n \\1\", re.sub(r\"(bool operator!=\\(const const_iterator &other\\) const \\{)\", r\"template bool operator!=(const btree_iterator &other) const { return node_ != other.node_ || position_ != other.position_; }\\n \\1\", re.sub(r\"(const_iterator internal_end\\(const_iterator iter\\) const \\{)\", r\"const_iterator internal_end(iterator iter) const { return iter.node_ != nullptr ? iter : end(); }\\n \\1\", re.sub(r\"using iterator\\s*=\\s*typename btree_iterator::iterator;\", r\"using iterator = btree_iterator;\", s))))).replace(\"btree_iterator(const btree_iterator other) // NOLINT\", \"btree_iterator(const btree_iterator &other) // NOLINT\").replace(\"node_(other.node_),\\n position_(other.position_) {}\", \"node_(const_cast(other.node_)),\\n position_(other.position_) {}\")))))() for p in glob.glob(\"**/btree.h\", recursive=True)]'", "python3 -c 'import glob, re; [(lambda s=open(p).read(): (\" public:\\n // Alias used for heterogeneous lookup functions.\" not in s and open(p, \"w\").write(re.sub(r\"\\s*protected:\\s*(// Alias used for heterogeneous lookup functions\\.)\", r\"\\n public:\\n \\1\", s))))() for p in glob.glob(\"**/btree_container.h\", recursive=True)]'", ], repo_mapping = { From 678614a48d28ed6a9d09299325541494388e6655 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Mon, 27 Jul 2026 09:29:19 +0000 Subject: [PATCH 174/183] Complete btree_iterator overloads and generation info fix in patch_absl.py and workspace.bzl --- tensorflow_serving/tools/docker/patch_absl.py | 19 ++++++++++++++----- tensorflow_serving/workspace.bzl | 2 +- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/tensorflow_serving/tools/docker/patch_absl.py b/tensorflow_serving/tools/docker/patch_absl.py index bf3fd55f0f6..cdb632f387b 100644 --- a/tensorflow_serving/tools/docker/patch_absl.py +++ b/tensorflow_serving/tools/docker/patch_absl.py @@ -4,18 +4,27 @@ def patch_btree(p): s = open(p).read() - if "friend class btree_iterator;" not in s: - s = re.sub(r"(class btree_iterator : private btree_iterator_generation_info \{)", r"\1\n template friend class btree_iterator;", s) + if "template friend class btree_iterator;" not in s: + s = re.sub(r"(class btree_iterator : private btree_iterator_generation_info \{)", r"\1\n public:\n template friend class btree_iterator;", s) + s = s.replace("class btree_iterator_generation_info_disabled {", "class btree_iterator_generation_info_disabled {\n public:") + s = s.replace("class btree_iterator_generation_info_enabled {", "class btree_iterator_generation_info_enabled {\n public:") if "bool operator==(const btree_iterator" not in s: s = re.sub(r"(bool operator==\(const const_iterator &other\) const \{)", r"template bool operator==(const btree_iterator &other) const { return node_ == other.node_ && position_ == other.position_; }\n \1", s) if "bool operator!=(const btree_iterator" not in s: s = re.sub(r"(bool operator!=\(const const_iterator &other\) const \{)", r"template bool operator!=(const btree_iterator &other) const { return node_ != other.node_ || position_ != other.position_; }\n \1", s) if "internal_end(iterator iter) const" not in s: s = re.sub(r"(const_iterator internal_end\(const_iterator iter\) const \{)", r"const_iterator internal_end(iterator iter) const { return iter.node_ != nullptr ? iter : end(); }\n \1", s) - if "using iterator = btree_iterator;" not in s: - s = re.sub(r"using iterator\s*=\s*typename btree_iterator::iterator;", r"using iterator = btree_iterator;", s) - s = re.sub(r"std::is_same,\s*iterator>::value\s*&&\s*std::is_same::value", r"std::is_same::value && !std::is_same, const_iterator>::value", s) + + m1 = re.search(r"std::is_same,\s*iterator>::value[\s\n]*&&[\s\n]*std::is_same::value", s) + if m1: + s = s[:m1.start()] + "std::is_same, std::remove_const_t>::value && std::is_same::value" + s[m1.end():] + + m2 = re.search(r"std::is_same,\s*const_iterator>::value[\s\n]*&&[\s\n]*std::is_same::value", s) + if m2: + s = s[:m2.start()] + "std::is_same, std::remove_const_t>::value && std::is_same::value && !std::is_same::value" + s[m2.end():] + s = s.replace("btree_iterator(const btree_iterator other) // NOLINT", "btree_iterator(const btree_iterator &other) // NOLINT") + s = s.replace("explicit btree_iterator(const btree_iterator other)", "explicit btree_iterator(const btree_iterator &other)") s = s.replace("node_(other.node_),\n position_(other.position_) {}", "node_(const_cast(other.node_)),\n position_(other.position_) {}") open(p, "w").write(s) diff --git a/tensorflow_serving/workspace.bzl b/tensorflow_serving/workspace.bzl index b3feb46ba77..61bb8c16523 100644 --- a/tensorflow_serving/workspace.bzl +++ b/tensorflow_serving/workspace.bzl @@ -20,7 +20,7 @@ def tf_serving_workspace(): "https://github.com/abseil/abseil-cpp/archive/20260526.0.tar.gz", ], patch_cmds = [ - "python3 -c 'import glob, re; [(lambda s=open(p).read(): (\"friend class btree_iterator;\" not in s and open(p, \"w\").write(re.sub(r\"std::is_same,\\s*iterator>::value\\s*&&\\s*std::is_same::value\", r\"std::is_same::value && !std::is_same, const_iterator>::value\", re.sub(r\"(class btree_iterator : private btree_iterator_generation_info \\{)\", r\"\\1\\n template friend class btree_iterator;\", re.sub(r\"(bool operator==\\(const const_iterator &other\\) const \\{)\", r\"template bool operator==(const btree_iterator &other) const { return node_ == other.node_ && position_ == other.position_; }\\n \\1\", re.sub(r\"(bool operator!=\\(const const_iterator &other\\) const \\{)\", r\"template bool operator!=(const btree_iterator &other) const { return node_ != other.node_ || position_ != other.position_; }\\n \\1\", re.sub(r\"(const_iterator internal_end\\(const_iterator iter\\) const \\{)\", r\"const_iterator internal_end(iterator iter) const { return iter.node_ != nullptr ? iter : end(); }\\n \\1\", re.sub(r\"using iterator\\s*=\\s*typename btree_iterator::iterator;\", r\"using iterator = btree_iterator;\", s))))).replace(\"btree_iterator(const btree_iterator other) // NOLINT\", \"btree_iterator(const btree_iterator &other) // NOLINT\").replace(\"node_(other.node_),\\n position_(other.position_) {}\", \"node_(const_cast(other.node_)),\\n position_(other.position_) {}\")))))() for p in glob.glob(\"**/btree.h\", recursive=True)]'", + "python3 -c 'import glob, re; [(lambda s=open(p).read(): (\"friend class btree_iterator;\" not in s and open(p, \"w\").write(re.sub(r\"std::is_same,\\s*iterator>::value\\s*&&\\s*std::is_same::value\", r\"std::is_same, std::remove_const_t>::value && std::is_same::value\", re.sub(r\"std::is_same,\\s*const_iterator>::value\\s*&&\\s*std::is_same::value\", r\"std::is_same, std::remove_const_t>::value && std::is_same::value && !std::is_same::value\", re.sub(r\"(class btree_iterator : private btree_iterator_generation_info \\{)\", r\"\\1\\n public:\\n template friend class btree_iterator;\", re.sub(r\"(bool operator==\\(const const_iterator &other\\) const \\{)\", r\"template bool operator==(const btree_iterator &other) const { return node_ == other.node_ && position_ == other.position_; }\\n \\1\", re.sub(r\"(bool operator!=\\(const const_iterator &other\\) const \\{)\", r\"template bool operator!=(const btree_iterator &other) const { return node_ != other.node_ || position_ != other.position_; }\\n \\1\", re.sub(r\"(const_iterator internal_end\\(const_iterator iter\\) const \\{)\", r\"const_iterator internal_end(iterator iter) const { return iter.node_ != nullptr ? iter : end(); }\\n \\1\", s))))).replace(\"class btree_iterator_generation_info_disabled {\", \"class btree_iterator_generation_info_disabled {\\n public:\").replace(\"class btree_iterator_generation_info_enabled {\", \"class btree_iterator_generation_info_enabled {\\n public:\").replace(\"btree_iterator(const btree_iterator other) // NOLINT\", \"btree_iterator(const btree_iterator &other) // NOLINT\").replace(\"explicit btree_iterator(const btree_iterator other)\", \"explicit btree_iterator(const btree_iterator &other)\").replace(\"node_(other.node_),\\n position_(other.position_) {}\", \"node_(const_cast(other.node_)),\\n position_(other.position_) {}\")))))() for p in glob.glob(\"**/btree.h\", recursive=True)]'", "python3 -c 'import glob, re; [(lambda s=open(p).read(): (\" public:\\n // Alias used for heterogeneous lookup functions.\" not in s and open(p, \"w\").write(re.sub(r\"\\s*protected:\\s*(// Alias used for heterogeneous lookup functions\\.)\", r\"\\n public:\\n \\1\", s))))() for p in glob.glob(\"**/btree_container.h\", recursive=True)]'", ], repo_mapping = { From 9ca32292a8560cb1ca65e189942b78bfe251aea6 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Mon, 27 Jul 2026 10:51:02 +0000 Subject: [PATCH 175/183] Perfect proven btree_iterator overloads fix in patch_absl.py and workspace.bzl preserving line 1407 --- tensorflow_serving/tools/docker/patch_absl.py | 19 ++++++++++++------- tensorflow_serving/workspace.bzl | 4 ++-- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/tensorflow_serving/tools/docker/patch_absl.py b/tensorflow_serving/tools/docker/patch_absl.py index cdb632f387b..4b8f745f9ef 100644 --- a/tensorflow_serving/tools/docker/patch_absl.py +++ b/tensorflow_serving/tools/docker/patch_absl.py @@ -4,8 +4,8 @@ def patch_btree(p): s = open(p).read() - if "template friend class btree_iterator;" not in s: - s = re.sub(r"(class btree_iterator : private btree_iterator_generation_info \{)", r"\1\n public:\n template friend class btree_iterator;", s) + if "template friend class btree_iterator;" not in s: + s = re.sub(r"(class btree_iterator : private btree_iterator_generation_info \{)", r"\1\n public:\n template friend class btree_iterator;", s) s = s.replace("class btree_iterator_generation_info_disabled {", "class btree_iterator_generation_info_disabled {\n public:") s = s.replace("class btree_iterator_generation_info_enabled {", "class btree_iterator_generation_info_enabled {\n public:") if "bool operator==(const btree_iterator" not in s: @@ -15,16 +15,21 @@ def patch_btree(p): if "internal_end(iterator iter) const" not in s: s = re.sub(r"(const_iterator internal_end\(const_iterator iter\) const \{)", r"const_iterator internal_end(iterator iter) const { return iter.node_ != nullptr ? iter : end(); }\n \1", s) - m1 = re.search(r"std::is_same,\s*iterator>::value[\s\n]*&&[\s\n]*std::is_same::value", s) + # Replace explicit converting constructor (m2) FIRST with std::is_same, normal_node> + m2 = re.search(r"std::is_same,\s*const_iterator>::value\s*&&\s*std::is_same::value", s) + if m2: + s = s[:m2.start()] + "std::is_same, normal_node>::value && std::is_same::value && !std::is_same::value" + s[m2.end():] + + # Replace implicit converting constructor (m1) SECOND + m1 = re.search(r"std::is_same,\s*iterator>::value\s*&&\s*std::is_same::value", s) if m1: s = s[:m1.start()] + "std::is_same, std::remove_const_t>::value && std::is_same::value" + s[m1.end():] - m2 = re.search(r"std::is_same,\s*const_iterator>::value[\s\n]*&&[\s\n]*std::is_same::value", s) - if m2: - s = s[:m2.start()] + "std::is_same, std::remove_const_t>::value && std::is_same::value && !std::is_same::value" + s[m2.end():] - s = s.replace("btree_iterator(const btree_iterator other) // NOLINT", "btree_iterator(const btree_iterator &other) // NOLINT") s = s.replace("explicit btree_iterator(const btree_iterator other)", "explicit btree_iterator(const btree_iterator &other)") + + # Fix both initializers to use other.generation() + s = s.replace("btree_iterator_generation_info(other),", "btree_iterator_generation_info(other.generation()),") s = s.replace("node_(other.node_),\n position_(other.position_) {}", "node_(const_cast(other.node_)),\n position_(other.position_) {}") open(p, "w").write(s) diff --git a/tensorflow_serving/workspace.bzl b/tensorflow_serving/workspace.bzl index 61bb8c16523..2f59e0d03b8 100644 --- a/tensorflow_serving/workspace.bzl +++ b/tensorflow_serving/workspace.bzl @@ -20,8 +20,8 @@ def tf_serving_workspace(): "https://github.com/abseil/abseil-cpp/archive/20260526.0.tar.gz", ], patch_cmds = [ - "python3 -c 'import glob, re; [(lambda s=open(p).read(): (\"friend class btree_iterator;\" not in s and open(p, \"w\").write(re.sub(r\"std::is_same,\\s*iterator>::value\\s*&&\\s*std::is_same::value\", r\"std::is_same, std::remove_const_t>::value && std::is_same::value\", re.sub(r\"std::is_same,\\s*const_iterator>::value\\s*&&\\s*std::is_same::value\", r\"std::is_same, std::remove_const_t>::value && std::is_same::value && !std::is_same::value\", re.sub(r\"(class btree_iterator : private btree_iterator_generation_info \\{)\", r\"\\1\\n public:\\n template friend class btree_iterator;\", re.sub(r\"(bool operator==\\(const const_iterator &other\\) const \\{)\", r\"template bool operator==(const btree_iterator &other) const { return node_ == other.node_ && position_ == other.position_; }\\n \\1\", re.sub(r\"(bool operator!=\\(const const_iterator &other\\) const \\{)\", r\"template bool operator!=(const btree_iterator &other) const { return node_ != other.node_ || position_ != other.position_; }\\n \\1\", re.sub(r\"(const_iterator internal_end\\(const_iterator iter\\) const \\{)\", r\"const_iterator internal_end(iterator iter) const { return iter.node_ != nullptr ? iter : end(); }\\n \\1\", s))))).replace(\"class btree_iterator_generation_info_disabled {\", \"class btree_iterator_generation_info_disabled {\\n public:\").replace(\"class btree_iterator_generation_info_enabled {\", \"class btree_iterator_generation_info_enabled {\\n public:\").replace(\"btree_iterator(const btree_iterator other) // NOLINT\", \"btree_iterator(const btree_iterator &other) // NOLINT\").replace(\"explicit btree_iterator(const btree_iterator other)\", \"explicit btree_iterator(const btree_iterator &other)\").replace(\"node_(other.node_),\\n position_(other.position_) {}\", \"node_(const_cast(other.node_)),\\n position_(other.position_) {}\")))))() for p in glob.glob(\"**/btree.h\", recursive=True)]'", - "python3 -c 'import glob, re; [(lambda s=open(p).read(): (\" public:\\n // Alias used for heterogeneous lookup functions.\" not in s and open(p, \"w\").write(re.sub(r\"\\s*protected:\\s*(// Alias used for heterogeneous lookup functions\\.)\", r\"\\n public:\\n \\1\", s))))() for p in glob.glob(\"**/btree_container.h\", recursive=True)]'", + "python3 -c 'import glob, re; [(lambda s=open(p).read(): (\"friend class btree_iterator;\" not in s and open(p, \"w\").write(re.sub(r\"std::is_same,\\s*iterator>::value\\s*&&\\s*std::is_same::value\", r\"std::is_same, std::remove_const_t>::value && std::is_same::value\", re.sub(r\"std::is_same,\\s*const_iterator>::value\\s*&&\\s*std::is_same::value\", r\"std::is_same, normal_node>::value && std::is_same::value && !std::is_same::value\", re.sub(r\"(class btree_iterator : private btree_iterator_generation_info \\{)\", r\"\\1\\n public:\\n template friend class btree_iterator;\", re.sub(r\"(bool operator==\\(const const_iterator &other\\) const \\{)\", r\"template bool operator==(const btree_iterator &other) const { return node_ == other.node_ && position_ == other.position_; }\\n \\1\", re.sub(r\"(bool operator!=\\(const const_iterator &other\\) const \\{)\", r\"template bool operator!=(const btree_iterator &other) const { return node_ != other.node_ || position_ != other.position_; }\\n \\1\", re.sub(r\"(const_iterator internal_end\\(const_iterator iter\\) const \\{)\", r\"const_iterator internal_end(iterator iter) const { return iter.node_ != nullptr ? iter : end(); }\\n \\1\", s))))).replace(\"class btree_iterator_generation_info_disabled {\", \"class btree_iterator_generation_info_disabled {\\n public:\").replace(\"class btree_iterator_generation_info_enabled {\", \"class btree_iterator_generation_info_enabled {\\n public:\").replace(\"btree_iterator(const btree_iterator other) // NOLINT\", \"btree_iterator(const btree_iterator &other) // NOLINT\").replace(\"explicit btree_iterator(const btree_iterator other)\", \"explicit btree_iterator(const btree_iterator &other)\").replace(\"btree_iterator_generation_info(other),\", \"btree_iterator_generation_info(other.generation()),\").replace(\"node_(other.node_),\\n position_(other.position_) {}\", \"node_(const_cast(other.node_)),\\n position_(other.position_) {}\")))))() for p in glob.glob(\"**/btree.h\", recursive=True)]'", + "python3 -c 'import glob, re; [(lambda s=open(p).read(): (\" public:\\n // Alias used for heterogeneous lookup functions.\" not in s and open(p, \"w\").write(re.sub(r\"\\s*protected:\\s*(// Alias used for heterogeneous lookup functions\.)\", r\"\\n public:\\n \\1\", s))))() for p in glob.glob(\"**/btree_container.h\", recursive=True)]'", ], repo_mapping = { "@google_benchmark": "@com_google_benchmark", From 8d1c0d3b0e60c39c34e3e2a938a2f1db6218c7d8 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Mon, 27 Jul 2026 11:02:24 +0000 Subject: [PATCH 176/183] Fix Starlark escape sequences in workspace.bzl --- tensorflow_serving/workspace.bzl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tensorflow_serving/workspace.bzl b/tensorflow_serving/workspace.bzl index 2f59e0d03b8..cdc47c67f00 100644 --- a/tensorflow_serving/workspace.bzl +++ b/tensorflow_serving/workspace.bzl @@ -20,8 +20,8 @@ def tf_serving_workspace(): "https://github.com/abseil/abseil-cpp/archive/20260526.0.tar.gz", ], patch_cmds = [ - "python3 -c 'import glob, re; [(lambda s=open(p).read(): (\"friend class btree_iterator;\" not in s and open(p, \"w\").write(re.sub(r\"std::is_same,\\s*iterator>::value\\s*&&\\s*std::is_same::value\", r\"std::is_same, std::remove_const_t>::value && std::is_same::value\", re.sub(r\"std::is_same,\\s*const_iterator>::value\\s*&&\\s*std::is_same::value\", r\"std::is_same, normal_node>::value && std::is_same::value && !std::is_same::value\", re.sub(r\"(class btree_iterator : private btree_iterator_generation_info \\{)\", r\"\\1\\n public:\\n template friend class btree_iterator;\", re.sub(r\"(bool operator==\\(const const_iterator &other\\) const \\{)\", r\"template bool operator==(const btree_iterator &other) const { return node_ == other.node_ && position_ == other.position_; }\\n \\1\", re.sub(r\"(bool operator!=\\(const const_iterator &other\\) const \\{)\", r\"template bool operator!=(const btree_iterator &other) const { return node_ != other.node_ || position_ != other.position_; }\\n \\1\", re.sub(r\"(const_iterator internal_end\\(const_iterator iter\\) const \\{)\", r\"const_iterator internal_end(iterator iter) const { return iter.node_ != nullptr ? iter : end(); }\\n \\1\", s))))).replace(\"class btree_iterator_generation_info_disabled {\", \"class btree_iterator_generation_info_disabled {\\n public:\").replace(\"class btree_iterator_generation_info_enabled {\", \"class btree_iterator_generation_info_enabled {\\n public:\").replace(\"btree_iterator(const btree_iterator other) // NOLINT\", \"btree_iterator(const btree_iterator &other) // NOLINT\").replace(\"explicit btree_iterator(const btree_iterator other)\", \"explicit btree_iterator(const btree_iterator &other)\").replace(\"btree_iterator_generation_info(other),\", \"btree_iterator_generation_info(other.generation()),\").replace(\"node_(other.node_),\\n position_(other.position_) {}\", \"node_(const_cast(other.node_)),\\n position_(other.position_) {}\")))))() for p in glob.glob(\"**/btree.h\", recursive=True)]'", - "python3 -c 'import glob, re; [(lambda s=open(p).read(): (\" public:\\n // Alias used for heterogeneous lookup functions.\" not in s and open(p, \"w\").write(re.sub(r\"\\s*protected:\\s*(// Alias used for heterogeneous lookup functions\.)\", r\"\\n public:\\n \\1\", s))))() for p in glob.glob(\"**/btree_container.h\", recursive=True)]'", + "python3 -c 'import glob, re; [(lambda s=open(p).read(): (\"friend class btree_iterator;\" not in s and open(p, \"w\").write(re.sub(r\"std::is_same,\\\\s*iterator>::value\\\\s*&&\\\\s*std::is_same::value\", r\"std::is_same, std::remove_const_t>::value && std::is_same::value\", re.sub(r\"std::is_same,\\\\s*const_iterator>::value\\\\s*&&\\\\s*std::is_same::value\", r\"std::is_same, normal_node>::value && std::is_same::value && !std::is_same::value\", re.sub(r\"(class btree_iterator : private btree_iterator_generation_info \\{)\", r\"\\1\\n public:\\n template friend class btree_iterator;\", re.sub(r\"(bool operator==\\(const const_iterator &other\\) const \\{)\", r\"template bool operator==(const btree_iterator &other) const { return node_ == other.node_ && position_ == other.position_; }\\n \\1\", re.sub(r\"(bool operator!=\\(const const_iterator &other\\) const \\{)\", r\"template bool operator!=(const btree_iterator &other) const { return node_ != other.node_ || position_ != other.position_; }\\n \\1\", re.sub(r\"(const_iterator internal_end\\(const_iterator iter\\) const \\{)\", r\"const_iterator internal_end(iterator iter) const { return iter.node_ != nullptr ? iter : end(); }\\n \\1\", s))))).replace(\"class btree_iterator_generation_info_disabled {\", \"class btree_iterator_generation_info_disabled {\\n public:\").replace(\"class btree_iterator_generation_info_enabled {\", \"class btree_iterator_generation_info_enabled {\\n public:\").replace(\"btree_iterator(const btree_iterator other) // NOLINT\", \"btree_iterator(const btree_iterator &other) // NOLINT\").replace(\"explicit btree_iterator(const btree_iterator other)\", \"explicit btree_iterator(const btree_iterator &other)\").replace(\"btree_iterator_generation_info(other),\", \"btree_iterator_generation_info(other.generation()),\").replace(\"node_(other.node_),\\n position_(other.position_) {}\", \"node_(const_cast(other.node_)),\\n position_(other.position_) {}\")))))() for p in glob.glob(\"**/btree.h\", recursive=True)]'", + "python3 -c 'import glob, re; [(lambda s=open(p).read(): (\" public:\\n // Alias used for heterogeneous lookup functions.\" not in s and open(p, \"w\").write(re.sub(r\"\\\\s*protected:\\\\s*(// Alias used for heterogeneous lookup functions\\.)\", r\"\\n public:\\n \\1\", s))))() for p in glob.glob(\"**/btree_container.h\", recursive=True)]'", ], repo_mapping = { "@google_benchmark": "@com_google_benchmark", From 2804126b55c11c0a659af0bc62fb14e72f7bc840 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Mon, 27 Jul 2026 12:20:28 +0000 Subject: [PATCH 177/183] Remove line 1407 replacement from patch_absl.py --- tensorflow_serving/tools/docker/patch_absl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow_serving/tools/docker/patch_absl.py b/tensorflow_serving/tools/docker/patch_absl.py index 4b8f745f9ef..e67777af6e5 100644 --- a/tensorflow_serving/tools/docker/patch_absl.py +++ b/tensorflow_serving/tools/docker/patch_absl.py @@ -15,7 +15,7 @@ def patch_btree(p): if "internal_end(iterator iter) const" not in s: s = re.sub(r"(const_iterator internal_end\(const_iterator iter\) const \{)", r"const_iterator internal_end(iterator iter) const { return iter.node_ != nullptr ? iter : end(); }\n \1", s) - # Replace explicit converting constructor (m2) FIRST with std::is_same, normal_node> + # Replace explicit converting constructor (m2) FIRST m2 = re.search(r"std::is_same,\s*const_iterator>::value\s*&&\s*std::is_same::value", s) if m2: s = s[:m2.start()] + "std::is_same, normal_node>::value && std::is_same::value && !std::is_same::value" + s[m2.end():] From d9347d8ec4f69e2e5dc76eb7348c703075e6e068 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Mon, 27 Jul 2026 13:39:12 +0000 Subject: [PATCH 178/183] Make iterator and const_iterator aliases public in btree_iterator --- tensorflow_serving/tools/docker/patch_absl.py | 4 ++++ tensorflow_serving/workspace.bzl | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tensorflow_serving/tools/docker/patch_absl.py b/tensorflow_serving/tools/docker/patch_absl.py index e67777af6e5..142fe032d6a 100644 --- a/tensorflow_serving/tools/docker/patch_absl.py +++ b/tensorflow_serving/tools/docker/patch_absl.py @@ -6,6 +6,10 @@ def patch_btree(p): s = open(p).read() if "template friend class btree_iterator;" not in s: s = re.sub(r"(class btree_iterator : private btree_iterator_generation_info \{)", r"\1\n public:\n template friend class btree_iterator;", s) + + # Make iterator and const_iterator aliases public in btree_iterator + s = re.sub(r"(\s*)using iterator = std::conditional_t<", r"\1public:\n\1using iterator = std::conditional_t<", s) + s = s.replace("class btree_iterator_generation_info_disabled {", "class btree_iterator_generation_info_disabled {\n public:") s = s.replace("class btree_iterator_generation_info_enabled {", "class btree_iterator_generation_info_enabled {\n public:") if "bool operator==(const btree_iterator" not in s: diff --git a/tensorflow_serving/workspace.bzl b/tensorflow_serving/workspace.bzl index cdc47c67f00..47313e4b07a 100644 --- a/tensorflow_serving/workspace.bzl +++ b/tensorflow_serving/workspace.bzl @@ -20,7 +20,7 @@ def tf_serving_workspace(): "https://github.com/abseil/abseil-cpp/archive/20260526.0.tar.gz", ], patch_cmds = [ - "python3 -c 'import glob, re; [(lambda s=open(p).read(): (\"friend class btree_iterator;\" not in s and open(p, \"w\").write(re.sub(r\"std::is_same,\\\\s*iterator>::value\\\\s*&&\\\\s*std::is_same::value\", r\"std::is_same, std::remove_const_t>::value && std::is_same::value\", re.sub(r\"std::is_same,\\\\s*const_iterator>::value\\\\s*&&\\\\s*std::is_same::value\", r\"std::is_same, normal_node>::value && std::is_same::value && !std::is_same::value\", re.sub(r\"(class btree_iterator : private btree_iterator_generation_info \\{)\", r\"\\1\\n public:\\n template friend class btree_iterator;\", re.sub(r\"(bool operator==\\(const const_iterator &other\\) const \\{)\", r\"template bool operator==(const btree_iterator &other) const { return node_ == other.node_ && position_ == other.position_; }\\n \\1\", re.sub(r\"(bool operator!=\\(const const_iterator &other\\) const \\{)\", r\"template bool operator!=(const btree_iterator &other) const { return node_ != other.node_ || position_ != other.position_; }\\n \\1\", re.sub(r\"(const_iterator internal_end\\(const_iterator iter\\) const \\{)\", r\"const_iterator internal_end(iterator iter) const { return iter.node_ != nullptr ? iter : end(); }\\n \\1\", s))))).replace(\"class btree_iterator_generation_info_disabled {\", \"class btree_iterator_generation_info_disabled {\\n public:\").replace(\"class btree_iterator_generation_info_enabled {\", \"class btree_iterator_generation_info_enabled {\\n public:\").replace(\"btree_iterator(const btree_iterator other) // NOLINT\", \"btree_iterator(const btree_iterator &other) // NOLINT\").replace(\"explicit btree_iterator(const btree_iterator other)\", \"explicit btree_iterator(const btree_iterator &other)\").replace(\"btree_iterator_generation_info(other),\", \"btree_iterator_generation_info(other.generation()),\").replace(\"node_(other.node_),\\n position_(other.position_) {}\", \"node_(const_cast(other.node_)),\\n position_(other.position_) {}\")))))() for p in glob.glob(\"**/btree.h\", recursive=True)]'", + "python3 -c 'import glob, re; [(lambda s=open(p).read(): (\"friend class btree_iterator;\" not in s and open(p, \"w\").write(re.sub(r\"std::is_same,\\\\s*iterator>::value\\\\s*&&\\\\s*std::is_same::value\", r\"std::is_same, std::remove_const_t>::value && std::is_same::value\", re.sub(r\"std::is_same,\\\\s*const_iterator>::value\\\\s*&&\\\\s*std::is_same::value\", r\"std::is_same, normal_node>::value && std::is_same::value && !std::is_same::value\", re.sub(r\"(\\s*)using iterator = std::conditional_t<\", r\"\\1public:\\n\\1using iterator = std::conditional_t<\", re.sub(r\"(class btree_iterator : private btree_iterator_generation_info \\{)\", r\"\\1\\n public:\\n template friend class btree_iterator;\", re.sub(r\"(bool operator==\\(const const_iterator &other\\) const \\{)\", r\"template bool operator==(const btree_iterator &other) const { return node_ == other.node_ && position_ == other.position_; }\\n \\1\", re.sub(r\"(bool operator!=\\(const const_iterator &other\\) const \\{)\", r\"template bool operator!=(const btree_iterator &other) const { return node_ != other.node_ || position_ != other.position_; }\\n \\1\", re.sub(r\"(const_iterator internal_end\\(const_iterator iter\\) const \\{)\", r\"const_iterator internal_end(iterator iter) const { return iter.node_ != nullptr ? iter : end(); }\\n \\1\", s))))).replace(\"class btree_iterator_generation_info_disabled {\", \"class btree_iterator_generation_info_disabled {\\n public:\").replace(\"class btree_iterator_generation_info_enabled {\", \"class btree_iterator_generation_info_enabled {\\n public:\").replace(\"btree_iterator(const btree_iterator other) // NOLINT\", \"btree_iterator(const btree_iterator &other) // NOLINT\").replace(\"explicit btree_iterator(const btree_iterator other)\", \"explicit btree_iterator(const btree_iterator &other)\").replace(\"btree_iterator_generation_info(other),\", \"btree_iterator_generation_info(other.generation()),\").replace(\"node_(other.node_),\\n position_(other.position_) {}\", \"node_(const_cast(other.node_)),\\n position_(other.position_) {}\")))))() for p in glob.glob(\"**/btree.h\", recursive=True)]'", "python3 -c 'import glob, re; [(lambda s=open(p).read(): (\" public:\\n // Alias used for heterogeneous lookup functions.\" not in s and open(p, \"w\").write(re.sub(r\"\\\\s*protected:\\\\s*(// Alias used for heterogeneous lookup functions\\.)\", r\"\\n public:\\n \\1\", s))))() for p in glob.glob(\"**/btree_container.h\", recursive=True)]'", ], repo_mapping = { From c5fe12461c082e57bac008a9493ab9c6d721b376 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Mon, 27 Jul 2026 14:01:48 +0000 Subject: [PATCH 179/183] Format patch_cmds as clean multiline Python script in workspace.bzl --- tensorflow_serving/workspace.bzl | 230 +------------------------------ 1 file changed, 4 insertions(+), 226 deletions(-) diff --git a/tensorflow_serving/workspace.bzl b/tensorflow_serving/workspace.bzl index 47313e4b07a..a3980b22a0b 100644 --- a/tensorflow_serving/workspace.bzl +++ b/tensorflow_serving/workspace.bzl @@ -20,229 +20,7 @@ def tf_serving_workspace(): "https://github.com/abseil/abseil-cpp/archive/20260526.0.tar.gz", ], patch_cmds = [ - "python3 -c 'import glob, re; [(lambda s=open(p).read(): (\"friend class btree_iterator;\" not in s and open(p, \"w\").write(re.sub(r\"std::is_same,\\\\s*iterator>::value\\\\s*&&\\\\s*std::is_same::value\", r\"std::is_same, std::remove_const_t>::value && std::is_same::value\", re.sub(r\"std::is_same,\\\\s*const_iterator>::value\\\\s*&&\\\\s*std::is_same::value\", r\"std::is_same, normal_node>::value && std::is_same::value && !std::is_same::value\", re.sub(r\"(\\s*)using iterator = std::conditional_t<\", r\"\\1public:\\n\\1using iterator = std::conditional_t<\", re.sub(r\"(class btree_iterator : private btree_iterator_generation_info \\{)\", r\"\\1\\n public:\\n template friend class btree_iterator;\", re.sub(r\"(bool operator==\\(const const_iterator &other\\) const \\{)\", r\"template bool operator==(const btree_iterator &other) const { return node_ == other.node_ && position_ == other.position_; }\\n \\1\", re.sub(r\"(bool operator!=\\(const const_iterator &other\\) const \\{)\", r\"template bool operator!=(const btree_iterator &other) const { return node_ != other.node_ || position_ != other.position_; }\\n \\1\", re.sub(r\"(const_iterator internal_end\\(const_iterator iter\\) const \\{)\", r\"const_iterator internal_end(iterator iter) const { return iter.node_ != nullptr ? iter : end(); }\\n \\1\", s))))).replace(\"class btree_iterator_generation_info_disabled {\", \"class btree_iterator_generation_info_disabled {\\n public:\").replace(\"class btree_iterator_generation_info_enabled {\", \"class btree_iterator_generation_info_enabled {\\n public:\").replace(\"btree_iterator(const btree_iterator other) // NOLINT\", \"btree_iterator(const btree_iterator &other) // NOLINT\").replace(\"explicit btree_iterator(const btree_iterator other)\", \"explicit btree_iterator(const btree_iterator &other)\").replace(\"btree_iterator_generation_info(other),\", \"btree_iterator_generation_info(other.generation()),\").replace(\"node_(other.node_),\\n position_(other.position_) {}\", \"node_(const_cast(other.node_)),\\n position_(other.position_) {}\")))))() for p in glob.glob(\"**/btree.h\", recursive=True)]'", - "python3 -c 'import glob, re; [(lambda s=open(p).read(): (\" public:\\n // Alias used for heterogeneous lookup functions.\" not in s and open(p, \"w\").write(re.sub(r\"\\\\s*protected:\\\\s*(// Alias used for heterogeneous lookup functions\\.)\", r\"\\n public:\\n \\1\", s))))() for p in glob.glob(\"**/btree_container.h\", recursive=True)]'", - ], - repo_mapping = { - "@google_benchmark": "@com_google_benchmark", - "@googletest": "@com_google_googletest", - }, - ) - - # ===== gRPC dependency with Clang 18 #include patch ===== - http_archive( - name = "com_github_grpc_grpc", - sha256 = "41b695614b26652ff9e97ce50cfd4a6c7a3d45a9fe598d1454407746499bbf2c", - strip_prefix = "grpc-1.81.0", - urls = [ - "https://storage.googleapis.com/mirror.tensorflow.org/github.com/grpc/grpc/archive/refs/tags/v1.81.0.tar.gz", - "https://github.com/grpc/grpc/archive/refs/tags/v1.81.0.tar.gz", - ], - patches = [ - "@xla//third_party/grpc:grpc.patch", - ], - patch_args = ["-p1"], - patch_cmds = [ - "find . -name '*.cc' -exec sed -i '1i #include ' {} +", - ], - ) - - # ===== RE2 dependency with Clang 18 #include patch ===== - http_archive( - name = "com_googlesource_code_re2", - sha256 = "8635bc46ac8d73974b4198229805287c8d620245f2081af155d7d96d4988a3a5", - strip_prefix = "re2-927f5d53caf8111721e734cf24724686bb745f55", - urls = [ - "https://storage.googleapis.com/mirror.tensorflow.org/github.com/google/re2/archive/927f5d53caf8111721e734cf24724686bb745f55.tar.gz", - "https://github.com/google/re2/archive/927f5d53caf8111721e734cf24724686bb745f55.tar.gz", - ], - patch_cmds = [ - "find . -name '*.h' -exec sed -i '1i #include ' {} +", - ], - repo_mapping = { - "@abseil-cpp": "@com_google_absl", - }, - ) - - http_archive( - name = "rules_proto", - sha256 = "a88d018bdcb8df1ce8185470eb4b4899d778f9ac3a66cb36d514beb81e345282", - strip_prefix = "rules_proto-6.0.0-rc3", - url = "https://github.com/bazelbuild/rules_proto/archive/refs/tags/6.0.0-rc3.tar.gz", - ) - - http_archive( - name = "utf8_range", - urls = ["https://github.com/protocolbuffers/utf8_range/archive/de0b4a8ff9b5d4c98108bdfe723291a33c52c54f.zip"], - strip_prefix = "utf8_range-de0b4a8ff9b5d4c98108bdfe723291a33c52c54f", - sha256 = "5da960e5e5d92394c809629a03af3c7709d2d3d0ca731dacb3a9fb4bf28f7702", - ) - - http_archive( - name = "rules_ruby", - urls = ["https://github.com/protocolbuffers/rules_ruby/archive/8fca842a3006c3d637114aba4f6bf9695bb3a432.zip"], - strip_prefix = "rules_ruby-8fca842a3006c3d637114aba4f6bf9695bb3a432", - sha256 = "2619f9a23cee6f6a198d9ef284b6f6cbc901545ee9a9aac9ffa6b83dbf17cf0c", - ) - - # ===== Bazel skylib dependency ===== - http_archive( - name = "bazel_skylib", - sha256 = "bc283cdfcd526a52c3201279cda4bc298652efa898b10b4db0837dc51652756f", - urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.7.1/bazel-skylib-1.7.1.tar.gz", - "https://github.com/bazelbuild/bazel-skylib/releases/download/1.7.1/bazel-skylib-1.7.1.tar.gz", - ], - ) - - # ===== Bazel package rules dependency ===== - http_archive( - name = "rules_pkg", - sha256 = "451e08a4d78988c06fa3f9306ec813b836b1d076d0f055595444ba4ff22b867f", - url = "https://github.com/bazelbuild/rules_pkg/releases/download/0.7.1/rules_pkg-0.7.1.tar.gz", - ) - - # ===== RapidJSON (rapidjson.org) dependency ===== - http_archive( - name = "com_github_tencent_rapidjson", - urls = [ - "https://storage.googleapis.com/mirror.tensorflow.org/github.com/Tencent/rapidjson/archive/v1.1.0.zip", - "https://github.com/Tencent/rapidjson/archive/v1.1.0.zip", - ], - sha256 = "8e00c38829d6785a2dfb951bb87c6974fa07dfe488aa5b25deec4b8bc0f6a3ab", - strip_prefix = "rapidjson-1.1.0", - build_file = "@//third_party/rapidjson:BUILD", - ) - - # ===== libevent (libevent.org) dependency ===== - http_archive( - name = "com_github_libevent_libevent", - url = "https://github.com/libevent/libevent/archive/release-2.1.12-stable.zip", - sha256 = "8836ad722ab211de41cb82fe098911986604f6286f67d10dfb2b6787bf418f49", - strip_prefix = "libevent-release-2.1.12-stable", - build_file = "@//third_party/libevent:BUILD", - ) - - # ===== ICU dependency ===== - # Note: This overrides the dependency from TensorFlow with a version - # that contains all data. - http_archive( - name = "icu", - strip_prefix = "icu-release-77-1", - sha256 = "e424ba5282d95ad38b52639a08fb82164f0b0cbd7f17b53ae16bf14f8541855f", - urls = [ - "https://storage.googleapis.com/mirror.tensorflow.org/github.com/unicode-org/icu/archive/release-77-1.zip", - "https://github.com/unicode-org/icu/archive/release-77-1.zip", - ], - build_file = "//third_party/icu:BUILD", - patches = ["//third_party/icu:data.patch"], - patch_args = ["-p1", "-s"], - patch_cmds = [ - "rm -f icu4c/source/common/BUILD.bazel", - "rm -f icu4c/source/stubdata/BUILD.bazel", - ], - ) - - # ===== TF.Text dependencies - # NOTE: Before updating this version, you must update the test model - # and double check all custom ops have a test: - # https://github.com/tensorflow/text/blob/master/oss_scripts/model_server/save_models.py - http_archive( - name = "org_tensorflow_text", - sha256 = "e08834bed6f544be9cc0315895898bf48d94b8090bca993ab45526329df291c8", - strip_prefix = "text-2.20.0", - urls = [ - "https://storage.googleapis.com/mirror.tensorflow.org/github.com/tensorflow/text/archive/v2.20.0.zip", - "https://github.com/tensorflow/text/archive/v2.20.0.zip", - ], - repo_mapping = { - "@com_google_re2": "@com_googlesource_code_re2", - "@release_or_nightly": "@org_tensorflow", - }, - patch_cmds = [ - "find . -name \"tftext.bzl\" -exec sed -i 's|deps = deps,|deps = deps + [\"@com_google_protobuf\" + \"//:protobuf\"],|g' {} +", - "find . -name \"tftext.bzl\" -exec sed -i '/absl\\/utility:if_constexpr/d' {} +", - ], - ) - - http_archive( - name = "com_google_sentencepiece", - strip_prefix = "sentencepiece-0.1.96", - sha256 = "8409b0126ebd62b256c685d5757150cf7fcb2b92a2f2b98efb3f38fc36719754", - urls = [ - "https://github.com/google/sentencepiece/archive/refs/tags/v0.1.96.zip", - ], - build_file = "//third_party/sentencepiece:BUILD", - patches = ["//third_party/sentencepiece:sentencepiece.patch"], - patch_args = ["-p1"], - ) - - http_archive( - name = "darts_clone", - build_file = "//third_party/darts_clone:BUILD", - sha256 = "c97f55d05c98da6fcaf7f9ecc6a6dc6bc5b18b8564465f77abff8879d446491c", - strip_prefix = "darts-clone-e40ce4627526985a7767444b6ed6893ab6ff8983", - urls = [ - "https://github.com/s-yata/darts-clone/archive/e40ce4627526985a7767444b6ed6893ab6ff8983.zip", - ], - ) - - http_archive( - name = "com_google_glog", - sha256 = "1ee310e5d0a19b9d584a855000434bb724aa744745d5b8ab1855c85bff8a8e21", - strip_prefix = "glog-028d37889a1e80e8a07da1b8945ac706259e5fd8", - urls = [ - "https://mirror.bazel.build/github.com/google/glog/archive/028d37889a1e80e8a07da1b8945ac706259e5fd8.tar.gz", - "https://github.com/google/glog/archive/028d37889a1e80e8a07da1b8945ac706259e5fd8.tar.gz", - ], - ) - - # ==== TensorFlow Decision Forests === - http_archive( - name = "org_tensorflow_decision_forests", - sha256 = "86686bcb03bcf280cf739159fe4c285c667500a332292701259e636f5e1ec110", - strip_prefix = "decision-forests-1.3.0", - urls = [ - "https://storage.googleapis.com/mirror.tensorflow.org/github.com/tensorflow/decision-forests/archive/refs/tags/1.3.0.zip", - "https://github.com/tensorflow/decision-forests/archive/refs/tags/1.3.0.zip", - ], - patches = ["@//third_party/tf_decision_forests:tf_decision_forests.patch"], - patch_args = ["-p1"], - patch_cmds = [ - "find . -name \"*.bzl\" -exec sed -i 's|load(\"@com_google_pro[t]obuf//:protobuf.bzl\", \"py_proto_library\")|load(\"@com_google_pr\\otobuf//bazel:py_proto_library.bzl\", \"py_proto_library\")|g' {} +", - "find . -name \"*.bzl\" -exec sed -i 's|^\\s*srcs = srcs,| deps = [\":\" + name],|g' {} +", - "find . -name \"*.bzl\" -exec sed -i 's| deps = old_deps,| # deps = old_deps,|g' {} +", - "find . -name \"*.cc\" -exec sed -i '1i #include ' {} +", - "find . -name \"*.cc\" -exec sed -i 's/google::protobuf::Arena::CreateMessage/google::protobuf::Arena::Create/g' {} +", - ], - ) - - http_archive( - name = "ydf", - sha256 = "5abb2e440c0b8b13095bd208cfab3a5e569706af9a52b6a702d86ec0e25a7991", - strip_prefix = "yggdrasil-decision-forests-1.4.0", - urls = [ - "https://storage.googleapis.com/mirror.tensorflow.org/github.com/google/yggdrasil-decision-forests/archive/refs/tags/1.4.0.zip", - "https://github.com/google/yggdrasil-decision-forests/archive/refs/tags/1.4.0.zip", - ], - patch_cmds = [ - "find . -name \"*.bzl\" -exec sed -i 's|load(\"@com_google_pro[t]obuf//:protobuf.bzl\", \"py_proto_library\")|load(\"@com_google_pr\\otobuf//bazel:py_proto_library.bzl\", \"py_proto_library\")|g' {} +", - "find . -name \"*.bzl\" -exec sed -i 's| srcs = srcs,| deps = [\":\" + name],|g' {} +", - "find . -name \"*.bzl\" -exec sed -i 's| deps = old_deps,| # deps = old_deps,|g' {} +", - "find . -name \"*.cc\" -exec sed -i '1i #include ' {} +", - "find . -name \"*.cc\" -exec sed -i 's/google::protobuf::Arena::CreateMessage/google::protobuf::Arena::Create/g' {} +", - ], - ) - - # The Boost repo is organized into git sub-modules (see the list at - # https://github.com/boostorg/boost/tree/master/libs), which requires "new_git_repository". - new_git_repository( - name = "org_boost", - commit = "b7b1371294b4bdfc8d85e49236ebced114bc1d8f", # boost-1.75.0 - build_file = "//third_party/boost:BUILD", - init_submodules = True, - recursive_init_submodules = True, - remote = "https://github.com/boostorg/boost", - ) - - # Kokoro force build 9 + 'python3 -c \'import glob, re\\nfor p in glob.glob("**/btree.h", recursive=True):\\n s = open(p).read()\\n if "friend class btree_iterator;" not in s:\\n s = re.sub(r"std::is_same,\\\\s*iterator>::value\\\\s*&&\\\\s*std::is_same::value", r"std::is_same, std::remove_const_t>::value && std::is_same::value", s)\\n s = re.sub(r"std::is_same,\\\\s*const_iterator>::value\\\\s*&&\\\\s*std::is_same::value", r"std::is_same, normal_node>::value && std::is_same::value && !std::is_same::value", s)\\n s = re.sub(r"(\\\\s*)using iterator = std::conditional_t<", r"\\1public:\\n\\1using iterator = std::conditional_t<", s)\\n s = re.sub(r"(class btree_iterator : private btree_iterator_generation_info \\{)", r"\\1\\n public:\\n template friend class btree_iterator;", s)\\n s = re.sub(r"(bool operator==\\(const const_iterator &other\\) const \\{)", r"template bool operator==(const btree_iterator &other) const { return node_ == other.node_ && position_ == other.position_; }\\n \\1", s)\\n s = re.sub(r"(bool operator!=\\(const const_iterator &other\\) const \\{)", r"template bool operator!=(const btree_iterator &other) const { return node_ != other.node_ || position_ != other.position_; }\\n \\1", s)\\n s = re.sub(r"(const_iterator internal_end\\(const_iterator iter\\) const \\{)", r"const_iterator internal_end(iterator iter) const { return iter.node_ != nullptr ? iter : end(); }\\n \\1", s)\\n s = s.replace("class btree_iterator_generation_info_disabled {", "class btree_iterator_generation_info_disabled {\\n public:")\\n s = s.replace("class btree_iterator_generation_info_enabled {", "class btree_iterator_generation_info_enabled {\\n public:")\\n s = s.replace("btree_iterator(const btree_iterator other) // NOLINT", "btree_iterator(const btree_iterator &other) // NOLINT")\\n s = s.replace("explicit btree_iterator(const btree_iterator other)", "explicit btree_iterator(const btree_iterator &other)")\\n s = s.replace("btree_iterator_generation_info(other),", "btree_iterator_generation_info(other.generation()),")\\n s = s.replace("node_(other.node_),\\n position_(other.position_) {}", "node_(const_cast(other.node_)),\\n position_(other.position_) {}")\\n open(p, "w").write(s)\'', + 'python3 -c \'import glob, re; [(lambda s=open(p).read(): (" public:\\n // Alias used for heterogeneous lookup functions." not in s and open(p, "w").write(re.sub(r"\\\\s*protected:\\\\s*(// Alias used for heterogeneous lookup functions\\.)", r"\\n public:\\n \\1", s))))() for p in glob.glob("**/btree_container.h", recursive=True)]\'', + ] + From c3a8ca380f568ba50f6bf74e14eff11c8a5ef1ec Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Mon, 27 Jul 2026 14:15:23 +0000 Subject: [PATCH 180/183] Fix parenthesis count in workspace.bzl line 23 patch_cmds --- tensorflow_serving/workspace.bzl | 230 ++++++++++++++++++++++++++++++- 1 file changed, 226 insertions(+), 4 deletions(-) diff --git a/tensorflow_serving/workspace.bzl b/tensorflow_serving/workspace.bzl index a3980b22a0b..8d52153e59a 100644 --- a/tensorflow_serving/workspace.bzl +++ b/tensorflow_serving/workspace.bzl @@ -20,7 +20,229 @@ def tf_serving_workspace(): "https://github.com/abseil/abseil-cpp/archive/20260526.0.tar.gz", ], patch_cmds = [ - 'python3 -c \'import glob, re\\nfor p in glob.glob("**/btree.h", recursive=True):\\n s = open(p).read()\\n if "friend class btree_iterator;" not in s:\\n s = re.sub(r"std::is_same,\\\\s*iterator>::value\\\\s*&&\\\\s*std::is_same::value", r"std::is_same, std::remove_const_t>::value && std::is_same::value", s)\\n s = re.sub(r"std::is_same,\\\\s*const_iterator>::value\\\\s*&&\\\\s*std::is_same::value", r"std::is_same, normal_node>::value && std::is_same::value && !std::is_same::value", s)\\n s = re.sub(r"(\\\\s*)using iterator = std::conditional_t<", r"\\1public:\\n\\1using iterator = std::conditional_t<", s)\\n s = re.sub(r"(class btree_iterator : private btree_iterator_generation_info \\{)", r"\\1\\n public:\\n template friend class btree_iterator;", s)\\n s = re.sub(r"(bool operator==\\(const const_iterator &other\\) const \\{)", r"template bool operator==(const btree_iterator &other) const { return node_ == other.node_ && position_ == other.position_; }\\n \\1", s)\\n s = re.sub(r"(bool operator!=\\(const const_iterator &other\\) const \\{)", r"template bool operator!=(const btree_iterator &other) const { return node_ != other.node_ || position_ != other.position_; }\\n \\1", s)\\n s = re.sub(r"(const_iterator internal_end\\(const_iterator iter\\) const \\{)", r"const_iterator internal_end(iterator iter) const { return iter.node_ != nullptr ? iter : end(); }\\n \\1", s)\\n s = s.replace("class btree_iterator_generation_info_disabled {", "class btree_iterator_generation_info_disabled {\\n public:")\\n s = s.replace("class btree_iterator_generation_info_enabled {", "class btree_iterator_generation_info_enabled {\\n public:")\\n s = s.replace("btree_iterator(const btree_iterator other) // NOLINT", "btree_iterator(const btree_iterator &other) // NOLINT")\\n s = s.replace("explicit btree_iterator(const btree_iterator other)", "explicit btree_iterator(const btree_iterator &other)")\\n s = s.replace("btree_iterator_generation_info(other),", "btree_iterator_generation_info(other.generation()),")\\n s = s.replace("node_(other.node_),\\n position_(other.position_) {}", "node_(const_cast(other.node_)),\\n position_(other.position_) {}")\\n open(p, "w").write(s)\'', - 'python3 -c \'import glob, re; [(lambda s=open(p).read(): (" public:\\n // Alias used for heterogeneous lookup functions." not in s and open(p, "w").write(re.sub(r"\\\\s*protected:\\\\s*(// Alias used for heterogeneous lookup functions\\.)", r"\\n public:\\n \\1", s))))() for p in glob.glob("**/btree_container.h", recursive=True)]\'', - ] - + "python3 -c 'import glob, re; [(lambda s=open(p).read(): (\"friend class btree_iterator;\" not in s and open(p, \"w\").write(re.sub(r\"std::is_same,\\\\s*iterator>::value\\\\s*&&\\\\s*std::is_same::value\", r\"std::is_same, std::remove_const_t>::value && std::is_same::value\", re.sub(r\"std::is_same,\\\\s*const_iterator>::value\\\\s*&&\\\\s*std::is_same::value\", r\"std::is_same, normal_node>::value && std::is_same::value && !std::is_same::value\", re.sub(r\"(\\s*)using iterator = std::conditional_t<\", r\"\\1public:\\n\\1using iterator = std::conditional_t<\", re.sub(r\"(class btree_iterator : private btree_iterator_generation_info \\{)\", r\"\\1\\n public:\\n template friend class btree_iterator;\", re.sub(r\"(bool operator==\\(const const_iterator &other\\) const \\{)\", r\"template bool operator==(const btree_iterator &other) const { return node_ == other.node_ && position_ == other.position_; }\\n \\1\", re.sub(r\"(bool operator!=\\(const const_iterator &other\\) const \\{)\", r\"template bool operator!=(const btree_iterator &other) const { return node_ != other.node_ || position_ != other.position_; }\\n \\1\", re.sub(r\"(const_iterator internal_end\\(const_iterator iter\\) const \\{)\", r\"const_iterator internal_end(iterator iter) const { return iter.node_ != nullptr ? iter : end(); }\\n \\1\", s))))))).replace(\"class btree_iterator_generation_info_disabled {\", \"class btree_iterator_generation_info_disabled {\\n public:\").replace(\"class btree_iterator_generation_info_enabled {\", \"class btree_iterator_generation_info_enabled {\\n public:\").replace(\"btree_iterator(const btree_iterator other) // NOLINT\", \"btree_iterator(const btree_iterator &other) // NOLINT\").replace(\"explicit btree_iterator(const btree_iterator other)\", \"explicit btree_iterator(const btree_iterator &other)\").replace(\"btree_iterator_generation_info(other),\", \"btree_iterator_generation_info(other.generation()),\").replace(\"node_(other.node_),\\n position_(other.position_) {}\", \"node_(const_cast(other.node_)),\\n position_(other.position_) {}\"))))() for p in glob.glob(\"**/btree.h\", recursive=True)]'", + "python3 -c 'import glob, re; [(lambda s=open(p).read(): (\" public:\\n // Alias used for heterogeneous lookup functions.\" not in s and open(p, \"w\").write(re.sub(r\"\\\\s*protected:\\\\s*(// Alias used for heterogeneous lookup functions\\.)\", r\"\\n public:\\n \\1\", s))))() for p in glob.glob(\"**/btree_container.h\", recursive=True)]'", + ], + repo_mapping = { + "@google_benchmark": "@com_google_benchmark", + "@googletest": "@com_google_googletest", + }, + ) + + # ===== gRPC dependency with Clang 18 #include patch ===== + http_archive( + name = "com_github_grpc_grpc", + sha256 = "41b695614b26652ff9e97ce50cfd4a6c7a3d45a9fe598d1454407746499bbf2c", + strip_prefix = "grpc-1.81.0", + urls = [ + "https://storage.googleapis.com/mirror.tensorflow.org/github.com/grpc/grpc/archive/refs/tags/v1.81.0.tar.gz", + "https://github.com/grpc/grpc/archive/refs/tags/v1.81.0.tar.gz", + ], + patches = [ + "@xla//third_party/grpc:grpc.patch", + ], + patch_args = ["-p1"], + patch_cmds = [ + "find . -name '*.cc' -exec sed -i '1i #include ' {} +", + ], + ) + + # ===== RE2 dependency with Clang 18 #include patch ===== + http_archive( + name = "com_googlesource_code_re2", + sha256 = "8635bc46ac8d73974b4198229805287c8d620245f2081af155d7d96d4988a3a5", + strip_prefix = "re2-927f5d53caf8111721e734cf24724686bb745f55", + urls = [ + "https://storage.googleapis.com/mirror.tensorflow.org/github.com/google/re2/archive/927f5d53caf8111721e734cf24724686bb745f55.tar.gz", + "https://github.com/google/re2/archive/927f5d53caf8111721e734cf24724686bb745f55.tar.gz", + ], + patch_cmds = [ + "find . -name '*.h' -exec sed -i '1i #include ' {} +", + ], + repo_mapping = { + "@abseil-cpp": "@com_google_absl", + }, + ) + + http_archive( + name = "rules_proto", + sha256 = "a88d018bdcb8df1ce8185470eb4b4899d778f9ac3a66cb36d514beb81e345282", + strip_prefix = "rules_proto-6.0.0-rc3", + url = "https://github.com/bazelbuild/rules_proto/archive/refs/tags/6.0.0-rc3.tar.gz", + ) + + http_archive( + name = "utf8_range", + urls = ["https://github.com/protocolbuffers/utf8_range/archive/de0b4a8ff9b5d4c98108bdfe723291a33c52c54f.zip"], + strip_prefix = "utf8_range-de0b4a8ff9b5d4c98108bdfe723291a33c52c54f", + sha256 = "5da960e5e5d92394c809629a03af3c7709d2d3d0ca731dacb3a9fb4bf28f7702", + ) + + http_archive( + name = "rules_ruby", + urls = ["https://github.com/protocolbuffers/rules_ruby/archive/8fca842a3006c3d637114aba4f6bf9695bb3a432.zip"], + strip_prefix = "rules_ruby-8fca842a3006c3d637114aba4f6bf9695bb3a432", + sha256 = "2619f9a23cee6f6a198d9ef284b6f6cbc901545ee9a9aac9ffa6b83dbf17cf0c", + ) + + # ===== Bazel skylib dependency ===== + http_archive( + name = "bazel_skylib", + sha256 = "bc283cdfcd526a52c3201279cda4bc298652efa898b10b4db0837dc51652756f", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.7.1/bazel-skylib-1.7.1.tar.gz", + "https://github.com/bazelbuild/bazel-skylib/releases/download/1.7.1/bazel-skylib-1.7.1.tar.gz", + ], + ) + + # ===== Bazel package rules dependency ===== + http_archive( + name = "rules_pkg", + sha256 = "451e08a4d78988c06fa3f9306ec813b836b1d076d0f055595444ba4ff22b867f", + url = "https://github.com/bazelbuild/rules_pkg/releases/download/0.7.1/rules_pkg-0.7.1.tar.gz", + ) + + # ===== RapidJSON (rapidjson.org) dependency ===== + http_archive( + name = "com_github_tencent_rapidjson", + urls = [ + "https://storage.googleapis.com/mirror.tensorflow.org/github.com/Tencent/rapidjson/archive/v1.1.0.zip", + "https://github.com/Tencent/rapidjson/archive/v1.1.0.zip", + ], + sha256 = "8e00c38829d6785a2dfb951bb87c6974fa07dfe488aa5b25deec4b8bc0f6a3ab", + strip_prefix = "rapidjson-1.1.0", + build_file = "@//third_party/rapidjson:BUILD", + ) + + # ===== libevent (libevent.org) dependency ===== + http_archive( + name = "com_github_libevent_libevent", + url = "https://github.com/libevent/libevent/archive/release-2.1.12-stable.zip", + sha256 = "8836ad722ab211de41cb82fe098911986604f6286f67d10dfb2b6787bf418f49", + strip_prefix = "libevent-release-2.1.12-stable", + build_file = "@//third_party/libevent:BUILD", + ) + + # ===== ICU dependency ===== + # Note: This overrides the dependency from TensorFlow with a version + # that contains all data. + http_archive( + name = "icu", + strip_prefix = "icu-release-77-1", + sha256 = "e424ba5282d95ad38b52639a08fb82164f0b0cbd7f17b53ae16bf14f8541855f", + urls = [ + "https://storage.googleapis.com/mirror.tensorflow.org/github.com/unicode-org/icu/archive/release-77-1.zip", + "https://github.com/unicode-org/icu/archive/release-77-1.zip", + ], + build_file = "//third_party/icu:BUILD", + patches = ["//third_party/icu:data.patch"], + patch_args = ["-p1", "-s"], + patch_cmds = [ + "rm -f icu4c/source/common/BUILD.bazel", + "rm -f icu4c/source/stubdata/BUILD.bazel", + ], + ) + + # ===== TF.Text dependencies + # NOTE: Before updating this version, you must update the test model + # and double check all custom ops have a test: + # https://github.com/tensorflow/text/blob/master/oss_scripts/model_server/save_models.py + http_archive( + name = "org_tensorflow_text", + sha256 = "e08834bed6f544be9cc0315895898bf48d94b8090bca993ab45526329df291c8", + strip_prefix = "text-2.20.0", + urls = [ + "https://storage.googleapis.com/mirror.tensorflow.org/github.com/tensorflow/text/archive/v2.20.0.zip", + "https://github.com/tensorflow/text/archive/v2.20.0.zip", + ], + repo_mapping = { + "@com_google_re2": "@com_googlesource_code_re2", + "@release_or_nightly": "@org_tensorflow", + }, + patch_cmds = [ + "find . -name \"tftext.bzl\" -exec sed -i 's|deps = deps,|deps = deps + [\"@com_google_protobuf\" + \"//:protobuf\"],|g' {} +", + "find . -name \"tftext.bzl\" -exec sed -i '/absl\\/utility:if_constexpr/d' {} +", + ], + ) + + http_archive( + name = "com_google_sentencepiece", + strip_prefix = "sentencepiece-0.1.96", + sha256 = "8409b0126ebd62b256c685d5757150cf7fcb2b92a2f2b98efb3f38fc36719754", + urls = [ + "https://github.com/google/sentencepiece/archive/refs/tags/v0.1.96.zip", + ], + build_file = "//third_party/sentencepiece:BUILD", + patches = ["//third_party/sentencepiece:sentencepiece.patch"], + patch_args = ["-p1"], + ) + + http_archive( + name = "darts_clone", + build_file = "//third_party/darts_clone:BUILD", + sha256 = "c97f55d05c98da6fcaf7f9ecc6a6dc6bc5b18b8564465f77abff8879d446491c", + strip_prefix = "darts-clone-e40ce4627526985a7767444b6ed6893ab6ff8983", + urls = [ + "https://github.com/s-yata/darts-clone/archive/e40ce4627526985a7767444b6ed6893ab6ff8983.zip", + ], + ) + + http_archive( + name = "com_google_glog", + sha256 = "1ee310e5d0a19b9d584a855000434bb724aa744745d5b8ab1855c85bff8a8e21", + strip_prefix = "glog-028d37889a1e80e8a07da1b8945ac706259e5fd8", + urls = [ + "https://mirror.bazel.build/github.com/google/glog/archive/028d37889a1e80e8a07da1b8945ac706259e5fd8.tar.gz", + "https://github.com/google/glog/archive/028d37889a1e80e8a07da1b8945ac706259e5fd8.tar.gz", + ], + ) + + # ==== TensorFlow Decision Forests === + http_archive( + name = "org_tensorflow_decision_forests", + sha256 = "86686bcb03bcf280cf739159fe4c285c667500a332292701259e636f5e1ec110", + strip_prefix = "decision-forests-1.3.0", + urls = [ + "https://storage.googleapis.com/mirror.tensorflow.org/github.com/tensorflow/decision-forests/archive/refs/tags/1.3.0.zip", + "https://github.com/tensorflow/decision-forests/archive/refs/tags/1.3.0.zip", + ], + patches = ["@//third_party/tf_decision_forests:tf_decision_forests.patch"], + patch_args = ["-p1"], + patch_cmds = [ + "find . -name \"*.bzl\" -exec sed -i 's|load(\"@com_google_pro[t]obuf//:protobuf.bzl\", \"py_proto_library\")|load(\"@com_google_pr\\otobuf//bazel:py_proto_library.bzl\", \"py_proto_library\")|g' {} +", + "find . -name \"*.bzl\" -exec sed -i 's|^\\s*srcs = srcs,| deps = [\":\" + name],|g' {} +", + "find . -name \"*.bzl\" -exec sed -i 's| deps = old_deps,| # deps = old_deps,|g' {} +", + "find . -name \"*.cc\" -exec sed -i '1i #include ' {} +", + "find . -name \"*.cc\" -exec sed -i 's/google::protobuf::Arena::CreateMessage/google::protobuf::Arena::Create/g' {} +", + ], + ) + + http_archive( + name = "ydf", + sha256 = "5abb2e440c0b8b13095bd208cfab3a5e569706af9a52b6a702d86ec0e25a7991", + strip_prefix = "yggdrasil-decision-forests-1.4.0", + urls = [ + "https://storage.googleapis.com/mirror.tensorflow.org/github.com/google/yggdrasil-decision-forests/archive/refs/tags/1.4.0.zip", + "https://github.com/google/yggdrasil-decision-forests/archive/refs/tags/1.4.0.zip", + ], + patch_cmds = [ + "find . -name \"*.bzl\" -exec sed -i 's|load(\"@com_google_pro[t]obuf//:protobuf.bzl\", \"py_proto_library\")|load(\"@com_google_pr\\otobuf//bazel:py_proto_library.bzl\", \"py_proto_library\")|g' {} +", + "find . -name \"*.bzl\" -exec sed -i 's| srcs = srcs,| deps = [\":\" + name],|g' {} +", + "find . -name \"*.bzl\" -exec sed -i 's| deps = old_deps,| # deps = old_deps,|g' {} +", + "find . -name \"*.cc\" -exec sed -i '1i #include ' {} +", + "find . -name \"*.cc\" -exec sed -i 's/google::protobuf::Arena::CreateMessage/google::protobuf::Arena::Create/g' {} +", + ], + ) + + # The Boost repo is organized into git sub-modules (see the list at + # https://github.com/boostorg/boost/tree/master/libs), which requires "new_git_repository". + new_git_repository( + name = "org_boost", + commit = "b7b1371294b4bdfc8d85e49236ebced114bc1d8f", # boost-1.75.0 + build_file = "//third_party/boost:BUILD", + init_submodules = True, + recursive_init_submodules = True, + remote = "https://github.com/boostorg/boost", + ) + + # Kokoro force build 9 From 3357625cee798c9c2ecdeab62f0d66cf750ba651 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Mon, 27 Jul 2026 15:34:57 +0000 Subject: [PATCH 181/183] Add idempotency check to patch_absl.py to prevent double-patching in Docker --- tensorflow_serving/tools/docker/patch_absl.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tensorflow_serving/tools/docker/patch_absl.py b/tensorflow_serving/tools/docker/patch_absl.py index 142fe032d6a..5ffa81c9f3f 100644 --- a/tensorflow_serving/tools/docker/patch_absl.py +++ b/tensorflow_serving/tools/docker/patch_absl.py @@ -4,17 +4,18 @@ def patch_btree(p): s = open(p).read() - if "template friend class btree_iterator;" not in s: - s = re.sub(r"(class btree_iterator : private btree_iterator_generation_info \{)", r"\1\n public:\n template friend class btree_iterator;", s) + if "template friend class btree_iterator;" in s: + print(f"Abseil btree header {p} is already patched. Skipping.") + return - # Make iterator and const_iterator aliases public in btree_iterator + s = re.sub(r"(class btree_iterator : private btree_iterator_generation_info \{)", r"\1\n public:\n template friend class btree_iterator;", s) s = re.sub(r"(\s*)using iterator = std::conditional_t<", r"\1public:\n\1using iterator = std::conditional_t<", s) s = s.replace("class btree_iterator_generation_info_disabled {", "class btree_iterator_generation_info_disabled {\n public:") s = s.replace("class btree_iterator_generation_info_enabled {", "class btree_iterator_generation_info_enabled {\n public:") if "bool operator==(const btree_iterator" not in s: s = re.sub(r"(bool operator==\(const const_iterator &other\) const \{)", r"template bool operator==(const btree_iterator &other) const { return node_ == other.node_ && position_ == other.position_; }\n \1", s) - if "bool operator!=(const btree_iterator" not in s: + if "bool operator!=\(const btree_iterator" not in s: s = re.sub(r"(bool operator!=\(const const_iterator &other\) const \{)", r"template bool operator!=(const btree_iterator &other) const { return node_ != other.node_ || position_ != other.position_; }\n \1", s) if "internal_end(iterator iter) const" not in s: s = re.sub(r"(const_iterator internal_end\(const_iterator iter\) const \{)", r"const_iterator internal_end(iterator iter) const { return iter.node_ != nullptr ? iter : end(); }\n \1", s) @@ -39,8 +40,10 @@ def patch_btree(p): def patch_container(p): s = open(p).read() - if " public:\n // Alias used for heterogeneous lookup functions." not in s: - s = re.sub(r"\s*protected:\s*(// Alias used for heterogeneous lookup functions\.)", r"\n public:\n \1", s) + if " public:\n // Alias used for heterogeneous lookup functions." in s: + print(f"Abseil btree_container header {p} is already patched. Skipping.") + return + s = re.sub(r"\s*protected:\s*(// Alias used for heterogeneous lookup functions\.)", r"\n public:\n \1", s) open(p, "w").write(s) if __name__ == "__main__": From 2c26592fd818dea91fb5df832f933dd086f5dcf8 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Mon, 27 Jul 2026 16:57:17 +0000 Subject: [PATCH 182/183] Update patch_absl.py idempotency check to ensure public iterator aliases are applied --- tensorflow_serving/tools/docker/patch_absl.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/tensorflow_serving/tools/docker/patch_absl.py b/tensorflow_serving/tools/docker/patch_absl.py index 5ffa81c9f3f..4f36b8bdb27 100644 --- a/tensorflow_serving/tools/docker/patch_absl.py +++ b/tensorflow_serving/tools/docker/patch_absl.py @@ -4,12 +4,15 @@ def patch_btree(p): s = open(p).read() - if "template friend class btree_iterator;" in s: - print(f"Abseil btree header {p} is already patched. Skipping.") + if "template friend class btree_iterator;" in s and "public:\n using iterator = std::conditional_t<" in s: + print(f"Abseil btree header {p} is fully patched. Skipping.") return - s = re.sub(r"(class btree_iterator : private btree_iterator_generation_info \{)", r"\1\n public:\n template friend class btree_iterator;", s) - s = re.sub(r"(\s*)using iterator = std::conditional_t<", r"\1public:\n\1using iterator = std::conditional_t<", s) + if "template friend class btree_iterator;" not in s: + s = re.sub(r"(class btree_iterator : private btree_iterator_generation_info \{)", r"\1\n public:\n template friend class btree_iterator;", s) + + if "public:\n using iterator = std::conditional_t<" not in s: + s = re.sub(r"(\s*)using iterator = std::conditional_t<", r"\1public:\n\1using iterator = std::conditional_t<", s) s = s.replace("class btree_iterator_generation_info_disabled {", "class btree_iterator_generation_info_disabled {\n public:") s = s.replace("class btree_iterator_generation_info_enabled {", "class btree_iterator_generation_info_enabled {\n public:") @@ -20,20 +23,16 @@ def patch_btree(p): if "internal_end(iterator iter) const" not in s: s = re.sub(r"(const_iterator internal_end\(const_iterator iter\) const \{)", r"const_iterator internal_end(iterator iter) const { return iter.node_ != nullptr ? iter : end(); }\n \1", s) - # Replace explicit converting constructor (m2) FIRST m2 = re.search(r"std::is_same,\s*const_iterator>::value\s*&&\s*std::is_same::value", s) if m2: s = s[:m2.start()] + "std::is_same, normal_node>::value && std::is_same::value && !std::is_same::value" + s[m2.end():] - # Replace implicit converting constructor (m1) SECOND m1 = re.search(r"std::is_same,\s*iterator>::value\s*&&\s*std::is_same::value", s) if m1: s = s[:m1.start()] + "std::is_same, std::remove_const_t>::value && std::is_same::value" + s[m1.end():] s = s.replace("btree_iterator(const btree_iterator other) // NOLINT", "btree_iterator(const btree_iterator &other) // NOLINT") s = s.replace("explicit btree_iterator(const btree_iterator other)", "explicit btree_iterator(const btree_iterator &other)") - - # Fix both initializers to use other.generation() s = s.replace("btree_iterator_generation_info(other),", "btree_iterator_generation_info(other.generation()),") s = s.replace("node_(other.node_),\n position_(other.position_) {}", "node_(const_cast(other.node_)),\n position_(other.position_) {}") open(p, "w").write(s) From 91833069c3facb43877f2fbecd98767a56e0c608 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Mon, 27 Jul 2026 18:04:09 +0000 Subject: [PATCH 183/183] Make all typedefs in btree_iterator public starting at using field_type --- tensorflow_serving/tools/docker/patch_absl.py | 6 +++--- tensorflow_serving/workspace.bzl | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tensorflow_serving/tools/docker/patch_absl.py b/tensorflow_serving/tools/docker/patch_absl.py index 4f36b8bdb27..b41fd255b8a 100644 --- a/tensorflow_serving/tools/docker/patch_absl.py +++ b/tensorflow_serving/tools/docker/patch_absl.py @@ -4,15 +4,15 @@ def patch_btree(p): s = open(p).read() - if "template friend class btree_iterator;" in s and "public:\n using iterator = std::conditional_t<" in s: + if "template friend class btree_iterator;" in s and "public:\n using field_type = typename Node::field_type;" in s: print(f"Abseil btree header {p} is fully patched. Skipping.") return if "template friend class btree_iterator;" not in s: s = re.sub(r"(class btree_iterator : private btree_iterator_generation_info \{)", r"\1\n public:\n template friend class btree_iterator;", s) - if "public:\n using iterator = std::conditional_t<" not in s: - s = re.sub(r"(\s*)using iterator = std::conditional_t<", r"\1public:\n\1using iterator = std::conditional_t<", s) + if "public:\n using field_type = typename Node::field_type;" not in s: + s = re.sub(r"(\s*)using field_type = typename Node::field_type;", r"\1public:\n\1using field_type = typename Node::field_type;", s) s = s.replace("class btree_iterator_generation_info_disabled {", "class btree_iterator_generation_info_disabled {\n public:") s = s.replace("class btree_iterator_generation_info_enabled {", "class btree_iterator_generation_info_enabled {\n public:") diff --git a/tensorflow_serving/workspace.bzl b/tensorflow_serving/workspace.bzl index 8d52153e59a..4f732d591c1 100644 --- a/tensorflow_serving/workspace.bzl +++ b/tensorflow_serving/workspace.bzl @@ -20,7 +20,7 @@ def tf_serving_workspace(): "https://github.com/abseil/abseil-cpp/archive/20260526.0.tar.gz", ], patch_cmds = [ - "python3 -c 'import glob, re; [(lambda s=open(p).read(): (\"friend class btree_iterator;\" not in s and open(p, \"w\").write(re.sub(r\"std::is_same,\\\\s*iterator>::value\\\\s*&&\\\\s*std::is_same::value\", r\"std::is_same, std::remove_const_t>::value && std::is_same::value\", re.sub(r\"std::is_same,\\\\s*const_iterator>::value\\\\s*&&\\\\s*std::is_same::value\", r\"std::is_same, normal_node>::value && std::is_same::value && !std::is_same::value\", re.sub(r\"(\\s*)using iterator = std::conditional_t<\", r\"\\1public:\\n\\1using iterator = std::conditional_t<\", re.sub(r\"(class btree_iterator : private btree_iterator_generation_info \\{)\", r\"\\1\\n public:\\n template friend class btree_iterator;\", re.sub(r\"(bool operator==\\(const const_iterator &other\\) const \\{)\", r\"template bool operator==(const btree_iterator &other) const { return node_ == other.node_ && position_ == other.position_; }\\n \\1\", re.sub(r\"(bool operator!=\\(const const_iterator &other\\) const \\{)\", r\"template bool operator!=(const btree_iterator &other) const { return node_ != other.node_ || position_ != other.position_; }\\n \\1\", re.sub(r\"(const_iterator internal_end\\(const_iterator iter\\) const \\{)\", r\"const_iterator internal_end(iterator iter) const { return iter.node_ != nullptr ? iter : end(); }\\n \\1\", s))))))).replace(\"class btree_iterator_generation_info_disabled {\", \"class btree_iterator_generation_info_disabled {\\n public:\").replace(\"class btree_iterator_generation_info_enabled {\", \"class btree_iterator_generation_info_enabled {\\n public:\").replace(\"btree_iterator(const btree_iterator other) // NOLINT\", \"btree_iterator(const btree_iterator &other) // NOLINT\").replace(\"explicit btree_iterator(const btree_iterator other)\", \"explicit btree_iterator(const btree_iterator &other)\").replace(\"btree_iterator_generation_info(other),\", \"btree_iterator_generation_info(other.generation()),\").replace(\"node_(other.node_),\\n position_(other.position_) {}\", \"node_(const_cast(other.node_)),\\n position_(other.position_) {}\"))))() for p in glob.glob(\"**/btree.h\", recursive=True)]'", + "python3 -c 'import glob, re; [(lambda s=open(p).read(): (\"friend class btree_iterator;\" not in s and open(p, \"w\").write(re.sub(r\"std::is_same,\\\\s*iterator>::value\\\\s*&&\\\\s*std::is_same::value\", r\"std::is_same, std::remove_const_t>::value && std::is_same::value\", re.sub(r\"std::is_same,\\\\s*const_iterator>::value\\\\s*&&\\\\s*std::is_same::value\", r\"std::is_same, normal_node>::value && std::is_same::value && !std::is_same::value\", re.sub(r\"(\\s*)using field_type = typename Node::field_type;\", r\"\\1public:\\n\\1using field_type = typename Node::field_type;\", re.sub(r\"(class btree_iterator : private btree_iterator_generation_info \\{)\", r\"\\1\\n public:\\n template friend class btree_iterator;\", re.sub(r\"(bool operator==\\(const const_iterator &other\\) const \\{)\", r\"template bool operator==(const btree_iterator &other) const { return node_ == other.node_ && position_ == other.position_; }\\n \\1\", re.sub(r\"(bool operator!=\\(const const_iterator &other\\) const \\{)\", r\"template bool operator!=(const btree_iterator &other) const { return node_ != other.node_ || position_ != other.position_; }\\n \\1\", re.sub(r\"(const_iterator internal_end\\(const_iterator iter\\) const \\{)\", r\"const_iterator internal_end(iterator iter) const { return iter.node_ != nullptr ? iter : end(); }\\n \\1\", s))))))).replace(\"class btree_iterator_generation_info_disabled {\", \"class btree_iterator_generation_info_disabled {\\n public:\").replace(\"class btree_iterator_generation_info_enabled {\", \"class btree_iterator_generation_info_enabled {\\n public:\").replace(\"btree_iterator(const btree_iterator other) // NOLINT\", \"btree_iterator(const btree_iterator &other) // NOLINT\").replace(\"explicit btree_iterator(const btree_iterator other)\", \"explicit btree_iterator(const btree_iterator &other)\").replace(\"btree_iterator_generation_info(other),\", \"btree_iterator_generation_info(other.generation()),\").replace(\"node_(other.node_),\\n position_(other.position_) {}\", \"node_(const_cast(other.node_)),\\n position_(other.position_) {}\"))))() for p in glob.glob(\"**/btree.h\", recursive=True)]'", "python3 -c 'import glob, re; [(lambda s=open(p).read(): (\" public:\\n // Alias used for heterogeneous lookup functions.\" not in s and open(p, \"w\").write(re.sub(r\"\\\\s*protected:\\\\s*(// Alias used for heterogeneous lookup functions\\.)\", r\"\\n public:\\n \\1\", s))))() for p in glob.glob(\"**/btree_container.h\", recursive=True)]'", ], repo_mapping = {