From 2588c83774b15cafe7464151b9ff945b49ddeb36 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Mon, 30 Mar 2026 00:03:51 +0000 Subject: [PATCH 01/12] Upgrade Struct2Tensor to use TensorFlow 2.18.1, add ProtoGen patch, and Abseil patch --- .bazelrc | 3 + .bazelversion | 1 + WORKSPACE | 29 +- environment.yml | 4 +- setup.py | 2 +- struct2tensor/version.py | 2 +- third_party/absl.patch | 11 + third_party/proto_gen.patch | 51 ++++ third_party/tensorflow.patch | 540 ++--------------------------------- 9 files changed, 116 insertions(+), 527 deletions(-) create mode 100644 third_party/absl.patch create mode 100644 third_party/proto_gen.patch diff --git a/.bazelrc b/.bazelrc index 5f706c8..6fcd9f1 100644 --- a/.bazelrc +++ b/.bazelrc @@ -47,3 +47,6 @@ build:macos --host_cxxopt=-std=c++17 build:short_logs --output_filter=DONT_MATCH_ANYTHING build:macos --macos_minimum_os=10.12 +build --action_env TF_HEADER_DIR="/usr/local/google/home/vkarampudi/anaconda3/envs/3.11/lib/python3.11/site-packages/tensorflow/include" +build --action_env TF_SHARED_LIBRARY_DIR="/usr/local/google/home/vkarampudi/anaconda3/envs/3.11/lib/python3.11/site-packages/tensorflow" +build --action_env TF_SHARED_LIBRARY_NAME="libtensorflow_framework.so.2" diff --git a/.bazelversion b/.bazelversion index e69de29..f22d756 100644 --- a/.bazelversion +++ b/.bazelversion @@ -0,0 +1 @@ +6.5.0 diff --git a/WORKSPACE b/WORKSPACE index dcede96..579570d 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -60,8 +60,8 @@ http_archive( # 3. Request the new archive to be mirrored on mirror.bazel.build for more # reliable downloads. -_TENSORFLOW_GIT_COMMIT = "3c92ac03cab816044f7b18a86eb86aa01a294d95" # tf 2.17.1 -_TENSORFLOW_ARCHIVE_SHA256 = "317dd95c4830a408b14f3e802698eb68d70d81c7c7cfcd3d28b0ba023fe84a68" +_TENSORFLOW_GIT_COMMIT = "cb64295ec7308f770b22db6047a1e755b35b7bee" # tf 2.18.1 +_TENSORFLOW_ARCHIVE_SHA256 = "" http_archive( name = "org_tensorflow", @@ -70,10 +70,19 @@ http_archive( "https://github.com/tensorflow/tensorflow/archive/%s.tar.gz" % _TENSORFLOW_GIT_COMMIT, ], strip_prefix = "tensorflow-%s" % _TENSORFLOW_GIT_COMMIT, - patches = ["//third_party:tensorflow.patch"], - patch_args = ["-p1"], + patch_args = ["-p0"], + patches = [ + "//third_party:proto_gen.patch", + ], +) +local_repository( + name = "local_config_cuda", + path = "third_party/dummy_cuda", ) + + + load("//third_party:python_configure.bzl", "local_python_configure") local_python_configure(name = "local_config_python") local_python_configure(name = "local_execution_config_python") @@ -83,6 +92,18 @@ local_python_configure(name = "local_execution_config_python") load("//struct2tensor:workspace.bzl", "struct2tensor_workspace") struct2tensor_workspace() +# Overriding com_google_absl to apply local patch for GCC 15 compatibility +http_archive( + name = "com_google_absl", + patch_args = ["-p1"], + patches = ["//third_party:absl.patch"], + sha256 = "aa768256d0567f626334fcbe722f564c40b281518fc8423e2708a308e5f983ea", + strip_prefix = "abseil-cpp-fb3621f4f897824c0dbe0615fa94543df6192f30", + urls = [ + "https://github.com/abseil/abseil-cpp/archive/fb3621f4f897824c0dbe0615fa94543df6192f30.zip", + ], +) + # Load Protobuf dependencies load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") protobuf_deps() diff --git a/environment.yml b/environment.yml index 3f61772..dbac5d6 100644 --- a/environment.yml +++ b/environment.yml @@ -36,9 +36,9 @@ dependencies: - requests==2.32.5 - rich==14.3.3 - six==1.17.0 - - tensorboard==2.17.1 + - tensorboard==2.18.1 - tensorboard-data-server==0.7.2 - - tensorflow==2.17.1 + - tensorflow==2.18.1 - tensorflow-io-gcs-filesystem==0.37.1 - tensorflow-metadata==1.17.3 - termcolor==3.3.0 diff --git a/setup.py b/setup.py index f072d74..da01951 100644 --- a/setup.py +++ b/setup.py @@ -81,7 +81,7 @@ def select_constraint(default, nightly=None, git_master=None): 'numpy>=1.22', 'protobuf>=4.25.2,<6.0.0;python_version>="3.11"', 'protobuf>=4.21.6,<6.0.0;python_version<"3.11"', - 'tensorflow>=2.17,<2.18', + 'tensorflow>=2.18,<2.19', 'tensorflow-metadata' + select_constraint( default='>=1.17.0,<1.18.0', diff --git a/struct2tensor/version.py b/struct2tensor/version.py index b61835f..5f86b72 100644 --- a/struct2tensor/version.py +++ b/struct2tensor/version.py @@ -15,4 +15,4 @@ """Contains the version string of struct2tensor.""" # Note that setup.py uses this version. -__version__ = '0.49.0.dev' +__version__ = '0.49.0' diff --git a/third_party/absl.patch b/third_party/absl.patch new file mode 100644 index 0000000..3f5af62 --- /dev/null +++ b/third_party/absl.patch @@ -0,0 +1,11 @@ +diff --git a/absl/container/internal/container_memory.h b/absl/container/internal/container_memory.h +--- a/absl/container/internal/container_memory.h ++++ b/absl/container/internal/container_memory.h +@@ -15,5 +15,6 @@ + #ifndef ABSL_CONTAINER_INTERNAL_CONTAINER_MEMORY_H_ + #define ABSL_CONTAINER_INTERNAL_CONTAINER_MEMORY_H_ + + #include ++#include + #include + #include diff --git a/third_party/proto_gen.patch b/third_party/proto_gen.patch new file mode 100644 index 0000000..fd5f484 --- /dev/null +++ b/third_party/proto_gen.patch @@ -0,0 +1,51 @@ +--- third_party/xla/third_party/tsl/tsl/platform/default/build_config.bzl ++++ third_party/xla/third_party/tsl/tsl/platform/default/build_config.bzl +@@ -4,1 +4,1 @@ +-load("@com_google_protobuf//:protobuf.bzl", "proto_gen") ++# Removed load of missing proto_gen +@@ -848,2 +848,45 @@ + def tf_cuda_libdevice_path_deps(): + return tf_platform_deps("cuda_libdevice_path") ++def proto_gen_disabled(name, srcs = [], outs = [], gen_cc = 0, includes = [], **kwargs): ++ pass ++def proto_gen(name, srcs = [], outs = [], gen_cc = 0, includes = [], **kwargs): ++ if not srcs: ++ native.filegroup(name = name, srcs = kwargs.get("deps", [])) ++ return ++ protoc = "@com_google_protobuf//:protoc" ++ pkg = native.package_name() ++ cmd = "" ++ for s in srcs: ++ if type(s) == "string" and s.startswith(":"): ++ loc = "$(location " + s + ")" ++ else: ++ loc = "$(locations " + s + ")" ++ cmd += "for f in " + loc + "; do " ++ cmd += "rel=\"$$f\"; " ++ cmd += "if [[ \"$$f\" == external/org_tensorflow/third_party/xla/* ]]; then rel=\"$${f#external/org_tensorflow/third_party/xla/}\"; repo=\"external/org_tensorflow/third_party/xla\"; " ++ cmd += "elif [[ \"$$f\" == external/org_tensorflow/* ]]; then rel=\"$${f#external/org_tensorflow/}\"; repo=\"external/org_tensorflow\"; " ++ cmd += "elif [[ \"$$f\" == external/local_tsl/* ]]; then rel=\"$${f#external/local_tsl/}\"; repo=\"external/local_tsl\"; " ++ cmd += "elif [[ \"$$f\" == external/local_xla/* ]]; then rel=\"$${f#external/local_xla/}\"; repo=\"external/local_xla\"; " ++ cmd += "else rel=\"$$f\"; repo=\".\"; fi; " ++ cmd += "h_file=\"$${rel%.proto}.pb.h\"; " ++ cmd += "cc_file=\"$${rel%.proto}.pb.cc\"; " ++ cmd += "mkdir -p \"$(RULEDIR)/$$(dirname \"$$rel\")\"; " ++ cmd += "$(location " + protoc + ") -I$$repo -I. -Iexternal/org_tensorflow -Iexternal/local_tsl -Iexternal/local_xla -Iexternal/org_tensorflow/third_party/xla -Iexternal/com_google_protobuf/src --cpp_out=$(RULEDIR) $$rel; " ++ cmd += "if [[ -n \"" + pkg + "\" ]]; then " ++ cmd += " if [[ \"$(RULEDIR)/$$h_file\" != \"$(RULEDIR)/$${h_file#\"" + pkg + "\"/}\" ]]; then mv \"$(RULEDIR)/$$h_file\" \"$(RULEDIR)/$${h_file#\"" + pkg + "\"/}\"; fi; " ++ cmd += " if [[ \"$(RULEDIR)/$$cc_file\" != \"$(RULEDIR)/$${cc_file#\"" + pkg + "\"/}\" ]]; then mv \"$(RULEDIR)/$$cc_file\" \"$(RULEDIR)/$${cc_file#\"" + pkg + "\"/}\"; fi; " ++ cmd += "fi; done; " ++ stripped_outs = [] ++ for o in outs: ++ if pkg and o.startswith(pkg + "/"): ++ stripped_outs.append(o[len(pkg)+1:]) ++ else: ++ stripped_outs.append(o) ++ native.genrule( ++ name = name, ++ srcs = srcs, ++ outs = stripped_outs, ++ cmd = cmd, ++ tools = [protoc], ++ tags = ["no-sandbox"], ++ ) diff --git a/third_party/tensorflow.patch b/third_party/tensorflow.patch index f13f6fb..1aee5a9 100644 --- a/third_party/tensorflow.patch +++ b/third_party/tensorflow.patch @@ -1,523 +1,25 @@ -diff --git a/tensorflow/core/lib/gtl/BUILD b/tensorflow/core/lib/gtl/BUILD -index 868d05f09..4876f801c 100644 ---- a/tensorflow/core/lib/gtl/BUILD -+++ b/tensorflow/core/lib/gtl/BUILD -@@ -83,6 +83,7 @@ cc_library( - name = "flatrep", - hdrs = ["flatrep.h"], - deps = [ -+ "@com_google_absl//absl/base", - "@local_tsl//tsl/lib/gtl:flatrep", - ], - ) -diff --git a/tensorflow/core/util/BUILD b/tensorflow/core/util/BUILD -index 3902d1700..74f6adeae 100644 ---- a/tensorflow/core/util/BUILD -+++ b/tensorflow/core/util/BUILD -@@ -73,6 +73,7 @@ filegroup( - filegroup( - name = "mobile_srcs_only_runtime", - srcs = [ -+ "absl_base_prefetch.h", - "activation_mode.h", - "batch_util.cc", - "batch_util.h", -@@ -208,6 +209,7 @@ filegroup( - filegroup( - name = "framework_internal_impl_srcs", - srcs = [ -+ "absl_base_prefetch.h", - "activation_mode.cc", - "batch_util.cc", - "bcast.cc", -diff --git a/tensorflow/core/util/absl_base_prefetch.h b/tensorflow/core/util/absl_base_prefetch.h -new file mode 100644 -index 000000000..429a17315 ---- /dev/null -+++ b/tensorflow/core/util/absl_base_prefetch.h -@@ -0,0 +1,62 @@ -+/* 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 ABSL_BASE_PREFETCH_H_ -+#define ABSL_BASE_PREFETCH_H_ -+ -+// Minimal compatibility shim for absl/base/prefetch.h. Provides the prefetch -+// helpers used by TensorFlow when the corresponding Abseil header is absent. -+// This should be sufficient for builds that depend on an older Abseil release. -+ -+namespace absl { -+ -+// Hints the processor to prefetch the given address into the local cache for -+// read-mostly access. -+inline void PrefetchToLocalCache(const void* addr) { -+#if defined(__GNUC__) || defined(__clang__) -+ __builtin_prefetch(addr, 0 /* read */, 3 /* high temporal locality */); -+#else -+ (void)addr; -+#endif -+} -+ -+// Hints the processor to prefetch the given address into the local cache for -+// imminent writes. -+inline void PrefetchToLocalCacheForWrite(const void* addr) { -+#if defined(__GNUC__) || defined(__clang__) -+ __builtin_prefetch(addr, 1 /* write */, 3 /* high temporal locality */); -+#else -+ (void)addr; -+#endif -+} -+ -+// Non-temporal prefetch (prefer not to pollute caches). -+inline void PrefetchToLocalCacheNta(const void* addr) { -+#if defined(__GNUC__) || defined(__clang__) -+ __builtin_prefetch(addr, 0 /* read */, 0 /* no temporal locality */); -+#else -+ (void)addr; -+#endif -+} -+ -+// Convenience aliases mirroring Abseil's API. -+inline void Prefetch(const void* addr) { PrefetchToLocalCache(addr); } -+inline void PrefetchForWrite(const void* addr) { -+ PrefetchToLocalCacheForWrite(addr); -+} -+ -+} // namespace absl -+ -+#endif // ABSL_BASE_PREFETCH_H_ -diff --git a/tensorflow/core/util/presized_cuckoo_map.h b/tensorflow/core/util/presized_cuckoo_map.h -index 2a03c511e..8d73d6f85 100644 ---- a/tensorflow/core/util/presized_cuckoo_map.h -+++ b/tensorflow/core/util/presized_cuckoo_map.h -@@ -19,7 +19,7 @@ limitations under the License. - #include - #include - --#include "absl/base/prefetch.h" -+#include "absl_base_prefetch.h" - #include "absl/numeric/int128.h" - #include "tensorflow/core/framework/types.h" - #include "tensorflow/core/platform/macros.h" -diff --git a/third_party/xla/third_party/tsl/tsl/lib/gtl/BUILD b/third_party/xla/third_party/tsl/tsl/lib/gtl/BUILD -index ed2d8656f..fd53055c2 100644 ---- a/third_party/xla/third_party/tsl/tsl/lib/gtl/BUILD -+++ b/third_party/xla/third_party/tsl/tsl/lib/gtl/BUILD -@@ -58,8 +58,8 @@ cc_library( - name = "flatrep", - hdrs = ["flatrep.h"], - deps = [ -+ "//tsl/platform:prefetch", - "//tsl/platform:types", -- "@com_google_absl//absl/base:prefetch", - ], - ) - -diff --git a/third_party/xla/third_party/tsl/tsl/lib/gtl/flatrep.h b/third_party/xla/third_party/tsl/tsl/lib/gtl/flatrep.h -index dfc65844e..e9be67ca6 100644 ---- a/third_party/xla/third_party/tsl/tsl/lib/gtl/flatrep.h -+++ b/third_party/xla/third_party/tsl/tsl/lib/gtl/flatrep.h -@@ -20,7 +20,7 @@ limitations under the License. - - #include - --#include "absl/base/prefetch.h" -+#include "tsl/platform/prefetch.h" - #include "tsl/platform/types.h" - - namespace tsl { -diff --git a/third_party/xla/third_party/tsl/tsl/lib/hash/BUILD b/third_party/xla/third_party/tsl/tsl/lib/hash/BUILD -index c497abfe1..fffee96fe 100644 ---- a/third_party/xla/third_party/tsl/tsl/lib/hash/BUILD -+++ b/third_party/xla/third_party/tsl/tsl/lib/hash/BUILD -@@ -39,7 +39,6 @@ cc_library( - "//tsl/platform:types", - "@com_google_absl//absl/crc:crc32c", - "@com_google_absl//absl/strings:cord", -- "@com_google_absl//absl/strings:string_view", - ], - ) - -diff --git a/third_party/xla/third_party/tsl/tsl/platform/BUILD b/third_party/xla/third_party/tsl/tsl/platform/BUILD -index 273fd5306..028c5db06 100644 ---- a/third_party/xla/third_party/tsl/tsl/platform/BUILD -+++ b/third_party/xla/third_party/tsl/tsl/platform/BUILD -@@ -1069,10 +1069,13 @@ cc_library( - - cc_library( - name = "prefetch", -- hdrs = ["prefetch.h"], -+ hdrs = [ -+ "prefetch.h", -+ "absl_base_prefetch.h", -+ ], - compatible_with = get_compatible_with_portable(), - deps = [ -- "@com_google_absl//absl/base:prefetch", -+ "@com_google_absl//absl/base", - ], - ) - -diff --git a/third_party/xla/third_party/tsl/tsl/platform/absl_base_prefetch.h b/third_party/xla/third_party/tsl/tsl/platform/absl_base_prefetch.h -new file mode 100644 -index 000000000..429a17315 ---- /dev/null -+++ b/third_party/xla/third_party/tsl/tsl/platform/absl_base_prefetch.h -@@ -0,0 +1,62 @@ -+/* 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 ABSL_BASE_PREFETCH_H_ -+#define ABSL_BASE_PREFETCH_H_ -+ -+// Minimal compatibility shim for absl/base/prefetch.h. Provides the prefetch -+// helpers used by TensorFlow when the corresponding Abseil header is absent. -+// This should be sufficient for builds that depend on an older Abseil release. -+ -+namespace absl { -+ -+// Hints the processor to prefetch the given address into the local cache for -+// read-mostly access. -+inline void PrefetchToLocalCache(const void* addr) { -+#if defined(__GNUC__) || defined(__clang__) -+ __builtin_prefetch(addr, 0 /* read */, 3 /* high temporal locality */); -+#else -+ (void)addr; -+#endif -+} -+ -+// Hints the processor to prefetch the given address into the local cache for -+// imminent writes. -+inline void PrefetchToLocalCacheForWrite(const void* addr) { -+#if defined(__GNUC__) || defined(__clang__) -+ __builtin_prefetch(addr, 1 /* write */, 3 /* high temporal locality */); -+#else -+ (void)addr; -+#endif -+} -+ -+// Non-temporal prefetch (prefer not to pollute caches). -+inline void PrefetchToLocalCacheNta(const void* addr) { -+#if defined(__GNUC__) || defined(__clang__) -+ __builtin_prefetch(addr, 0 /* read */, 0 /* no temporal locality */); -+#else -+ (void)addr; -+#endif -+} -+ -+// Convenience aliases mirroring Abseil's API. -+inline void Prefetch(const void* addr) { PrefetchToLocalCache(addr); } -+inline void PrefetchForWrite(const void* addr) { -+ PrefetchToLocalCacheForWrite(addr); -+} -+ -+} // namespace absl -+ -+#endif // ABSL_BASE_PREFETCH_H_ diff --git a/third_party/xla/third_party/tsl/tsl/platform/default/build_config.bzl b/third_party/xla/third_party/tsl/tsl/platform/default/build_config.bzl -index 35cdcdc50..1920ec210 100644 --- a/third_party/xla/third_party/tsl/tsl/platform/default/build_config.bzl +++ b/third_party/xla/third_party/tsl/tsl/platform/default/build_config.bzl -@@ -1,7 +1,6 @@ - # Platform-specific build configurations. - - load("@com_github_grpc_grpc//bazel:generate_cc.bzl", "generate_cc") +@@ -8,1 +8,0 @@ -load("@com_google_protobuf//:protobuf.bzl", "proto_gen") - load( - "@local_xla//xla/tsl:tsl.bzl", - "clean_dep", -@@ -195,18 +194,13 @@ def cc_proto_library( - if protolib_name == None: - protolib_name = name - -- genproto_deps = ([s + "_genproto" for s in protolib_deps] + -- ["@com_google_protobuf//:cc_wkt_protos_genproto"]) - if internal_bootstrap_hack: - # For pre-checked-in generated files, we add the internal_bootstrap_hack - # which will skip the codegen action. -- proto_gen( -+ native.proto_library( - name = protolib_name + "_genproto", -- srcs = srcs, -- includes = includes, -- protoc = protoc, -+ deps = protolib_deps, - visibility = ["//visibility:public"], -- deps = genproto_deps, - ) - - # An empty cc_library to make rule dependency consistent. -@@ -227,18 +221,11 @@ def cc_proto_library( - gen_hdrs = _proto_cc_hdrs(srcs, use_grpc_plugin) - outs = gen_srcs + gen_hdrs - -- proto_gen( -- name = protolib_name + "_genproto", -- srcs = srcs, -- outs = outs, -- gen_cc = 1, -- includes = includes, -- plugin = grpc_cpp_plugin, -- plugin_language = "grpc", -- plugin_options = plugin_options, -- protoc = protoc, -- visibility = ["//visibility:public"], -- deps = genproto_deps, -+ # Don't create proto_library - it should already exist from tf_proto_library -+ # Just create cc_proto_library that depends on the existing proto_library -+ native.cc_proto_library( -+ name = protolib_name + "_cc_genproto", -+ deps = [":" + protolib_name], - ) - - if use_grpc_plugin: -@@ -263,11 +250,12 @@ def cc_proto_library( - visibility = kwargs["visibility"], - ) - -+ # Depend on generated cc_proto_library instead of declaring hdrs/srcs - native.cc_library( - name = impl_name, -- srcs = gen_srcs, -- hdrs = gen_hdrs, -- deps = cc_libs + deps, -+ srcs = [], -+ hdrs = [], -+ deps = cc_libs + deps + [":" + protolib_name + "_cc_genproto"], - includes = includes, - alwayslink = 1, - **kwargs -@@ -276,8 +264,9 @@ def cc_proto_library( - name = header_only_name, - deps = [ - "@com_google_protobuf//:protobuf_headers", -+ ":" + protolib_name + "_cc_genproto", - ] + header_only_deps + if_tsl_link_protobuf([impl_name]), -- hdrs = gen_hdrs, -+ hdrs = [], - **kwargs - ) - -@@ -348,6 +337,102 @@ def cc_grpc_library( - **kwargs - ) - -+# Custom implementation for py_proto_library to support Protobuf 4.x -+# which removed the built-in py_proto_library rule. -+def _tsl_py_proto_library_impl(ctx): -+ """Generate Python code from proto_library deps.""" -+ proto_deps = ctx.attr.deps -+ all_sources = [] -+ py_infos = [] -+ -+ for dep in proto_deps: -+ if ProtoInfo in dep: -+ all_sources.extend(dep[ProtoInfo].direct_sources) -+ elif PyInfo in dep: -+ py_infos.append(dep[PyInfo]) -+ -+ # Filter workspace sources only -+ workspace_sources = [] -+ for src in all_sources: -+ if not src.short_path.startswith("external/") and not src.short_path.startswith("../"): -+ workspace_sources.append(src) -+ -+ # Generate Python files -+ py_outputs = [] -+ for proto_src in workspace_sources: -+ basename = proto_src.basename[:-6] # Remove .proto -+ py_file = ctx.actions.declare_file(basename + "_pb2.py") -+ py_outputs.append(py_file) -+ -+ if py_outputs: -+ proto_path_args = ["--proto_path=."] -+ proto_paths = {".": True} -+ -+ for dep in proto_deps: -+ if ProtoInfo in dep: -+ for src in dep[ProtoInfo].transitive_sources.to_list(): -+ if src.path.startswith("external/com_google_protobuf/"): -+ proto_path = "external/com_google_protobuf/src" -+ if proto_path not in proto_paths: -+ proto_paths[proto_path] = True -+ proto_path_args.append("--proto_path=" + proto_path) -+ elif src.path.startswith("external/"): -+ parts = src.path.split("/") -+ if len(parts) >= 2: -+ proto_path = "/".join(parts[:2]) -+ if proto_path not in proto_paths: -+ proto_paths[proto_path] = True -+ proto_path_args.append("--proto_path=" + proto_path) -+ if src.root.path and src.root.path not in proto_paths: -+ proto_paths[src.root.path] = True -+ proto_path_args.append("--proto_path=" + src.root.path) -+ -+ proto_file_args = [src.short_path for src in workspace_sources] -+ output_root = ctx.bin_dir.path -+ -+ ctx.actions.run( -+ inputs = depset(direct = workspace_sources, transitive = [ -+ dep[ProtoInfo].transitive_sources for dep in proto_deps if ProtoInfo in dep -+ ]), -+ outputs = py_outputs, -+ executable = ctx.executable._protoc, -+ arguments = ["--python_out=" + output_root] + proto_path_args + proto_file_args, -+ mnemonic = "ProtocPython", -+ ) -+ -+ all_transitive_sources = [depset(py_outputs)] -+ all_imports = [depset([ctx.bin_dir.path])] if py_outputs else [] -+ -+ for py_info in py_infos: -+ all_transitive_sources.append(py_info.transitive_sources) -+ if hasattr(py_info, 'imports'): -+ all_imports.append(py_info.imports) -+ -+ return [ -+ DefaultInfo(files = depset(py_outputs)), -+ PyInfo( -+ transitive_sources = depset(transitive = all_transitive_sources), -+ imports = depset(transitive = all_imports), -+ has_py2_only_sources = False, -+ has_py3_only_sources = True, -+ ), -+ ] -+ -+_tsl_py_proto_library_rule = rule( -+ implementation = _tsl_py_proto_library_impl, -+ attrs = { -+ "deps": attr.label_list( -+ providers = [[ProtoInfo], [PyInfo]], -+ ), -+ "_protoc": attr.label( -+ default = "@com_google_protobuf//:protoc", -+ executable = True, -+ cfg = "exec", -+ ), -+ }, -+ provides = [PyInfo], -+) -+ - # Re-defined protocol buffer rule to bring in the change introduced in commit - # https://github.com/google/protobuf/commit/294b5758c373cbab4b72f35f4cb62dc1d8332b68 - # which was not part of a stable protobuf release in 04/2018. -@@ -402,32 +487,19 @@ def py_proto_library( - genproto_deps = [] - for dep in deps: - if dep != "@com_google_protobuf//:protobuf_python": -- genproto_deps.append(dep + "_genproto") -- else: -- genproto_deps.append("@com_google_protobuf//:well_known_types_py_pb2_genproto") -+ genproto_deps.append(dep) - -- proto_gen( -+ native.proto_library( - name = name + "_genproto", - srcs = srcs, -- outs = outs, -- gen_py = 1, -- includes = includes, -- plugin = grpc_python_plugin, -- plugin_language = "grpc", -- protoc = protoc, -- visibility = ["//visibility:public"], - deps = genproto_deps, -+ visibility = ["//visibility:public"], - ) - -- if default_runtime and not default_runtime in py_libs + deps: -- py_libs = py_libs + [default_runtime] -- -- native.py_library( -+ # Use custom rule instead of removed native.py_proto_library -+ _tsl_py_proto_library_rule( - name = name, -- srcs = outs + py_extra_srcs, -- deps = py_libs + deps, -- imports = includes, -- **kwargs -+ deps = [":" + name + "_genproto"] + deps, - ) - - def tf_proto_library_cc( -@@ -467,11 +539,10 @@ def tf_proto_library_cc( - if not srcs: - # This is a collection of sub-libraries. Build header-only and impl - # libraries containing all the sources. -- proto_gen( -+ native.proto_library( - name = name + "_genproto", -- protoc = "@com_google_protobuf//:protoc", -- visibility = ["//visibility:public"], - deps = [s + "_genproto" for s in protolib_deps], -+ visibility = ["//visibility:public"], - ) - - native.alias( -@@ -538,11 +609,10 @@ def tf_proto_library_py( - if not srcs: - # This is a collection of sub-libraries. Build header-only and impl - # libraries containing all the sources. -- proto_gen( -+ native.proto_library( - name = py_name + "_genproto", -- protoc = "@com_google_protobuf//:protoc", -- visibility = ["//visibility:public"], - deps = [s + "_genproto" for s in py_deps], -+ visibility = ["//visibility:public"], - ) - native.py_library( - name = py_name, -diff --git a/third_party/xla/third_party/tsl/tsl/platform/prefetch.h b/third_party/xla/third_party/tsl/tsl/platform/prefetch.h -index d883529c6..05f3469a4 100644 ---- a/third_party/xla/third_party/tsl/tsl/platform/prefetch.h -+++ b/third_party/xla/third_party/tsl/tsl/platform/prefetch.h -@@ -16,7 +16,7 @@ limitations under the License. - #ifndef TENSORFLOW_TSL_PLATFORM_PREFETCH_H_ - #define TENSORFLOW_TSL_PLATFORM_PREFETCH_H_ - --#include "absl/base/prefetch.h" -+#include "absl_base_prefetch.h" - - namespace tsl { - namespace port { -diff --git a/third_party/xla/third_party/tsl/tsl/platform/status.h b/third_party/xla/third_party/tsl/tsl/platform/status.h -index 84954ff48..724ad934b 100644 ---- a/third_party/xla/third_party/tsl/tsl/platform/status.h -+++ b/third_party/xla/third_party/tsl/tsl/platform/status.h -@@ -126,7 +126,10 @@ const char* NullTerminatedMessage(const absl::Status& status); - #else - ABSL_DEPRECATE_AND_INLINE() - inline const char* NullTerminatedMessage(const absl::Status& status) { -- return absl::StatusMessageAsCStr(status); -+ // absl::StatusMessageAsCStr doesn't exist in older Abseil versions -+ // Inline implementation from newer Abseil -+ auto sv_message = status.message(); -+ return sv_message.empty() ? "" : sv_message.data(); - } - #endif - +@@ -13,0 +12,18 @@ + load("//tsl/platform:build_config_root.bzl", "if_static") ++def proto_gen(name, srcs, outs = [], gen_cc = 0, includes = [], **kwargs): ++ protoc = "@com_google_protobuf//:protoc" ++ cmd = "$(location " + protoc + ") --cpp_out=$(RULEDIR) " ++ cmd += "-I. -I$(RULEDIR) " ++ src_locations = [] ++ for s in srcs: ++ if type(s) == "string" and s.startswith(":"): ++ src_locations.append("$(location " + s + ")") ++ else: ++ src_locations.append("$(locations " + s + ")") ++ cmd += " ".join(src_locations) ++ native.genrule( ++ name = name, ++ srcs = srcs, ++ outs = outs, ++ cmd = cmd, ++ tools = [protoc], ++ ) From 1d44935f6754bbd01a3fb07354aef6ae7d2c7309 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Mon, 30 Mar 2026 02:19:22 +0000 Subject: [PATCH 02/12] Upgrade pyarrow to 15.0.0 in environment.yml to fix macOS build --- environment.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/environment.yml b/environment.yml index dbac5d6..8a25da3 100644 --- a/environment.yml +++ b/environment.yml @@ -31,7 +31,8 @@ dependencies: - opt-einsum==3.4.0 - optree==0.19.0 - protobuf==4.25.8 - - pyarrow==10.0.1 + - pyarrow==15.0.0 + - pygments==2.19.2 - requests==2.32.5 - rich==14.3.3 From 46b1cc6234cae59a0d7fdf6c051cf9abb7ada36d Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Mon, 30 Mar 2026 02:40:17 +0000 Subject: [PATCH 03/12] Fix tensorboard version to 2.18.0 in environment.yml --- environment.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/environment.yml b/environment.yml index 8a25da3..4561e31 100644 --- a/environment.yml +++ b/environment.yml @@ -37,7 +37,8 @@ dependencies: - requests==2.32.5 - rich==14.3.3 - six==1.17.0 - - tensorboard==2.18.1 + - tensorboard==2.18.0 + - tensorboard-data-server==0.7.2 - tensorflow==2.18.1 - tensorflow-io-gcs-filesystem==0.37.1 From f0263a1b9c2e9ecfd654c90b6eab126ab257eedf Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Mon, 30 Mar 2026 07:12:06 +0000 Subject: [PATCH 04/12] Remove hardcoded paths from .bazelrc --- .bazelrc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.bazelrc b/.bazelrc index 6fcd9f1..31bbf94 100644 --- a/.bazelrc +++ b/.bazelrc @@ -47,6 +47,6 @@ build:macos --host_cxxopt=-std=c++17 build:short_logs --output_filter=DONT_MATCH_ANYTHING build:macos --macos_minimum_os=10.12 -build --action_env TF_HEADER_DIR="/usr/local/google/home/vkarampudi/anaconda3/envs/3.11/lib/python3.11/site-packages/tensorflow/include" -build --action_env TF_SHARED_LIBRARY_DIR="/usr/local/google/home/vkarampudi/anaconda3/envs/3.11/lib/python3.11/site-packages/tensorflow" -build --action_env TF_SHARED_LIBRARY_NAME="libtensorflow_framework.so.2" + + + From 22e2001ea8d31b166d939319faa7bfde72bbea91 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Mon, 30 Mar 2026 07:22:08 +0000 Subject: [PATCH 05/12] Rename dummy_cuda to cuda_stub and update WORKSPACE --- WORKSPACE | 3 ++- third_party/cuda_stub/WORKSPACE | 0 third_party/cuda_stub/cuda/BUILD | 23 +++++++++++++++++++++++ third_party/cuda_stub/cuda/build_defs.bzl | 21 +++++++++++++++++++++ 4 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 third_party/cuda_stub/WORKSPACE create mode 100644 third_party/cuda_stub/cuda/BUILD create mode 100644 third_party/cuda_stub/cuda/build_defs.bzl diff --git a/WORKSPACE b/WORKSPACE index 579570d..1458f5b 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -77,12 +77,13 @@ http_archive( ) local_repository( name = "local_config_cuda", - path = "third_party/dummy_cuda", + path = "third_party/cuda_stub", ) + load("//third_party:python_configure.bzl", "local_python_configure") local_python_configure(name = "local_config_python") local_python_configure(name = "local_execution_config_python") diff --git a/third_party/cuda_stub/WORKSPACE b/third_party/cuda_stub/WORKSPACE new file mode 100644 index 0000000..e69de29 diff --git a/third_party/cuda_stub/cuda/BUILD b/third_party/cuda_stub/cuda/BUILD new file mode 100644 index 0000000..b670c8d --- /dev/null +++ b/third_party/cuda_stub/cuda/BUILD @@ -0,0 +1,23 @@ +package(default_visibility = ["//visibility:public"]) + +filegroup( + name = "cuda_headers", + srcs = [], + visibility = ["//visibility:public"], +) + +config_setting( + name = "using_nvcc", + values = {"define": "using_nvcc=true"}, + visibility = ["//visibility:public"], +) + +config_setting( + name = "using_clang", + values = {"define": "using_clang=true"}, + visibility = ["//visibility:public"], +) + +cc_library( + name = "cuda", +) diff --git a/third_party/cuda_stub/cuda/build_defs.bzl b/third_party/cuda_stub/cuda/build_defs.bzl new file mode 100644 index 0000000..ac3b9f9 --- /dev/null +++ b/third_party/cuda_stub/cuda/build_defs.bzl @@ -0,0 +1,21 @@ +def cuda_library(name, **kwargs): + native.cc_library(name = name, **kwargs) + +def if_cuda_exec(if_true, if_false = []): + return if_false + +def if_cuda(if_true, if_false = []): + return if_false + +def if_cuda_is_configured(if_true, if_false = []): + return if_false + +def if_cuda_newer_than(wanted_ver, if_true, if_false = []): + return if_false + +def cuda_gpu_architectures(): + return [] + +def cuda_default_copts(): + return [] + From dc6cc90ee9075c40d6165316911e699fcc88a107 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Mon, 30 Mar 2026 08:02:51 +0000 Subject: [PATCH 06/12] Remove unused tensorflow.patch --- third_party/tensorflow.patch | 25 ------------------------- 1 file changed, 25 deletions(-) delete mode 100644 third_party/tensorflow.patch diff --git a/third_party/tensorflow.patch b/third_party/tensorflow.patch deleted file mode 100644 index 1aee5a9..0000000 --- a/third_party/tensorflow.patch +++ /dev/null @@ -1,25 +0,0 @@ -diff --git a/third_party/xla/third_party/tsl/tsl/platform/default/build_config.bzl b/third_party/xla/third_party/tsl/tsl/platform/default/build_config.bzl ---- a/third_party/xla/third_party/tsl/tsl/platform/default/build_config.bzl -+++ b/third_party/xla/third_party/tsl/tsl/platform/default/build_config.bzl -@@ -8,1 +8,0 @@ --load("@com_google_protobuf//:protobuf.bzl", "proto_gen") -@@ -13,0 +12,18 @@ - load("//tsl/platform:build_config_root.bzl", "if_static") -+def proto_gen(name, srcs, outs = [], gen_cc = 0, includes = [], **kwargs): -+ protoc = "@com_google_protobuf//:protoc" -+ cmd = "$(location " + protoc + ") --cpp_out=$(RULEDIR) " -+ cmd += "-I. -I$(RULEDIR) " -+ src_locations = [] -+ for s in srcs: -+ if type(s) == "string" and s.startswith(":"): -+ src_locations.append("$(location " + s + ")") -+ else: -+ src_locations.append("$(locations " + s + ")") -+ cmd += " ".join(src_locations) -+ native.genrule( -+ name = name, -+ srcs = srcs, -+ outs = outs, -+ cmd = cmd, -+ tools = [protoc], -+ ) From d7d9622af2ae2608d0a61a95fb96060696afc64c Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Mon, 30 Mar 2026 08:05:29 +0000 Subject: [PATCH 07/12] Fill in TensorFlow Archive SHA256 in WORKSPACE --- WORKSPACE | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/WORKSPACE b/WORKSPACE index 1458f5b..c3d2c11 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -61,7 +61,8 @@ http_archive( # reliable downloads. _TENSORFLOW_GIT_COMMIT = "cb64295ec7308f770b22db6047a1e755b35b7bee" # tf 2.18.1 -_TENSORFLOW_ARCHIVE_SHA256 = "" +_TENSORFLOW_ARCHIVE_SHA256 = "5fcca4ec0732e146547fc26f6966cf92236c2f85a9e086b85c83d303e2c38980" + http_archive( name = "org_tensorflow", From e13920fdd2209a10d544e457a9e2e9fee5ba2282 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Mon, 30 Mar 2026 08:09:07 +0000 Subject: [PATCH 08/12] Code formatting and whitespace cleanup --- .bazelrc | 5 +---- WORKSPACE | 4 ---- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/.bazelrc b/.bazelrc index 31bbf94..da9d40d 100644 --- a/.bazelrc +++ b/.bazelrc @@ -46,7 +46,4 @@ build:macos --host_cxxopt=-std=c++17 # Suppress all warning messages. build:short_logs --output_filter=DONT_MATCH_ANYTHING -build:macos --macos_minimum_os=10.12 - - - +build:macos --macos_minimum_os=10.12 \ No newline at end of file diff --git a/WORKSPACE b/WORKSPACE index c3d2c11..d790608 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -81,10 +81,6 @@ local_repository( path = "third_party/cuda_stub", ) - - - - load("//third_party:python_configure.bzl", "local_python_configure") local_python_configure(name = "local_config_python") local_python_configure(name = "local_execution_config_python") From dd209c76ad12c99d2ce6a36a67107ec7f0185a2c Mon Sep 17 00:00:00 2001 From: Madhur Karampudi <142544288+vkarampudi@users.noreply.github.com> Date: Mon, 30 Mar 2026 01:11:16 -0700 Subject: [PATCH 09/12] Update version.py --- struct2tensor/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/struct2tensor/version.py b/struct2tensor/version.py index 5f86b72..b61835f 100644 --- a/struct2tensor/version.py +++ b/struct2tensor/version.py @@ -15,4 +15,4 @@ """Contains the version string of struct2tensor.""" # Note that setup.py uses this version. -__version__ = '0.49.0' +__version__ = '0.49.0.dev' From a48e9635d14cca9a7738e6962b78c11c4d90edf0 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Mon, 30 Mar 2026 08:26:59 +0000 Subject: [PATCH 10/12] Use repo_env in configure.sh --- configure.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/configure.sh b/configure.sh index 170aa9b..d6e7927 100755 --- a/configure.sh +++ b/configure.sh @@ -24,10 +24,11 @@ function write_to_bazelrc() { echo "$1" >> .bazelrc } -function write_action_env_to_bazelrc() { - write_to_bazelrc "build --action_env $1=\"$2\"" +function write_repo_env_to_bazelrc() { + write_to_bazelrc "build --repo_env $1=\"$2\"" } + function has_tensorflow() { ${PYTHON_BIN_PATH} -c "import tensorflow" > /dev/null } @@ -64,7 +65,7 @@ ensure_tensorflow TF_CFLAGS=( $(${PYTHON_BIN_PATH} -c 'import tensorflow as tf; print(" ".join(tf.sysconfig.get_compile_flags()))') ) TF_LFLAGS="$(${PYTHON_BIN_PATH} -c 'import tensorflow as tf; print(" ".join(tf.sysconfig.get_link_flags()))')" -write_action_env_to_bazelrc "TF_HEADER_DIR" ${TF_CFLAGS:2} +write_repo_env_to_bazelrc "TF_HEADER_DIR" ${TF_CFLAGS:2} SHARED_LIBRARY_DIR=${TF_LFLAGS:2} SHARED_LIBRARY_NAME=$(echo $TF_LFLAGS | rev | cut -d":" -f1 | rev) if ! [[ $TF_LFLAGS =~ .*:.* ]]; then @@ -74,5 +75,5 @@ if ! [[ $TF_LFLAGS =~ .*:.* ]]; then SHARED_LIBRARY_NAME="libtensorflow_framework.so" fi fi -write_action_env_to_bazelrc "TF_SHARED_LIBRARY_DIR" ${SHARED_LIBRARY_DIR} -write_action_env_to_bazelrc "TF_SHARED_LIBRARY_NAME" ${SHARED_LIBRARY_NAME} +write_repo_env_to_bazelrc "TF_SHARED_LIBRARY_DIR" ${SHARED_LIBRARY_DIR} +write_repo_env_to_bazelrc "TF_SHARED_LIBRARY_NAME" ${SHARED_LIBRARY_NAME} From 02f28bbd618131b9f04d54af0057ddc7a547d7a6 Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Mon, 30 Mar 2026 08:39:48 +0000 Subject: [PATCH 11/12] Revert configure.sh to use action_env --- configure.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/configure.sh b/configure.sh index d6e7927..19cf58c 100755 --- a/configure.sh +++ b/configure.sh @@ -24,11 +24,12 @@ function write_to_bazelrc() { echo "$1" >> .bazelrc } -function write_repo_env_to_bazelrc() { - write_to_bazelrc "build --repo_env $1=\"$2\"" +function write_action_env_to_bazelrc() { + write_to_bazelrc "build --action_env $1=\"$2\"" } + function has_tensorflow() { ${PYTHON_BIN_PATH} -c "import tensorflow" > /dev/null } @@ -65,7 +66,7 @@ ensure_tensorflow TF_CFLAGS=( $(${PYTHON_BIN_PATH} -c 'import tensorflow as tf; print(" ".join(tf.sysconfig.get_compile_flags()))') ) TF_LFLAGS="$(${PYTHON_BIN_PATH} -c 'import tensorflow as tf; print(" ".join(tf.sysconfig.get_link_flags()))')" -write_repo_env_to_bazelrc "TF_HEADER_DIR" ${TF_CFLAGS:2} +write_action_env_to_bazelrc "TF_HEADER_DIR" ${TF_CFLAGS:2} SHARED_LIBRARY_DIR=${TF_LFLAGS:2} SHARED_LIBRARY_NAME=$(echo $TF_LFLAGS | rev | cut -d":" -f1 | rev) if ! [[ $TF_LFLAGS =~ .*:.* ]]; then @@ -75,5 +76,5 @@ if ! [[ $TF_LFLAGS =~ .*:.* ]]; then SHARED_LIBRARY_NAME="libtensorflow_framework.so" fi fi -write_repo_env_to_bazelrc "TF_SHARED_LIBRARY_DIR" ${SHARED_LIBRARY_DIR} -write_repo_env_to_bazelrc "TF_SHARED_LIBRARY_NAME" ${SHARED_LIBRARY_NAME} +write_action_env_to_bazelrc "TF_SHARED_LIBRARY_DIR" ${SHARED_LIBRARY_DIR} +write_action_env_to_bazelrc "TF_SHARED_LIBRARY_NAME" ${SHARED_LIBRARY_NAME} From 1e9bed1ed8574d7fc1045eac31624efcf803c08a Mon Sep 17 00:00:00 2001 From: Venkata Sai Madhur Karampudi Date: Mon, 30 Mar 2026 08:47:15 +0000 Subject: [PATCH 12/12] Fix .bazelrc trailing newline --- .bazelrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.bazelrc b/.bazelrc index da9d40d..5f706c8 100644 --- a/.bazelrc +++ b/.bazelrc @@ -46,4 +46,4 @@ build:macos --host_cxxopt=-std=c++17 # Suppress all warning messages. build:short_logs --output_filter=DONT_MATCH_ANYTHING -build:macos --macos_minimum_os=10.12 \ No newline at end of file +build:macos --macos_minimum_os=10.12