Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
157 changes: 157 additions & 0 deletions easybuild/easyconfigs/t/TensorFlow/TensorFlow-2.21.0-foss-2025b.eb
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
easyblock = 'PythonBundle'

name = 'TensorFlow'
version = '2.21.0'

homepage = 'https://www.tensorflow.org/'
description = "An open-source software library for Machine Intelligence"

toolchain = {'name': 'foss', 'version': '2025b'}
toolchainopts = {'pic': True}

builddependencies = [
('hatchling', '1.27.0'),
('Bazel', '7.7.0', '-Java-21'),
# git 2.x required, see also https://github.com/tensorflow/tensorflow/issues/29053
('git', '2.50.1'),
('UnZip', '6.0'),
('NASM', '2.16.03'),
# Required to build some of the extensions
('poetry', '2.1.3'),
('Cython', '3.2.4'),
]

dependencies = [
('Python', '3.13.5'),
('Python-bundle-PyPI', '2025.07'),
('SciPy-bundle', '2025.07'),
('h5py', '3.14.0'),
('dill', '0.4.1'),
('flatbuffers-python', '25.2.10'),
('ml_dtypes', '0.5.3'),
('patchelf', '0.18.0'),
('protobuf-python', '6.31.1'),
('grpcio', '1.81.0'),
('wrapt', '1.17.3'),
('Markdown', '3.8.2'),
('absl-py', '2.3.1'),
('tensorboard', '2.20.0'),
('opt-einsum', '3.4.0'),
('optree', '0.18.0'),
('typing-extensions', '4.14.1'),
('cURL', '8.14.1'),
]

exts_list = [
('astor', '0.8.1', {
'checksums': ['6a6effda93f4e1ce9f618779b2dd1d9d84f1e32812c23a29b3fff6fd7f63fa5e'],
}),
('termcolor', '2.5.0', {
'checksums': ['998d8d27da6d48442e8e1f016119076b690d962507531df4890fcd2db2ef8a6f'],
}),
('Werkzeug', '3.1.3', {
'source_tmpl': '%(namelower)s-%(version)s.tar.gz',
'checksums': ['60723ce945c19328679790e3282cc758aa4a6040e4bb330f53d30fa546d44746'],
}),
('namex', '0.0.8', {
'checksums': ['32a50f6c565c0bb10aa76298c959507abdc0e850efe085dc38f3440fcb3aa90b'],
}),
('keras', '3.13.2', {
'checksums': ['62f0123488ac87c929c988617e14f293f7bc993811837d08bb37eff77adc85a9'],
}),
('google-pasta', '0.2.0', {
'modulename': 'pasta',
'checksums': ['c9f2c8dfc8f96d0d5808299920721be30c9eec37f2389f28904f454565c8a16e'],
}),
('astunparse', '1.6.3', {
'checksums': ['5ad93a8456f0d084c3456d059fd9a92cce667963232cbf763eac3bc5b7940872'],
}),
('tblib', '3.0.0', {
'checksums': ['93622790a0a29e04f0346458face1e144dc4d32f493714c6c3dff82a4adb77e6'],
}),
(name, version, {
'patches': [
'TensorFlow-2.4.0_dont-use-var-lock.patch',
'TensorFlow-2.18.1_fix-xnnpack.patch',
'TensorFlow-2.18.1_fixedpoint.patch',
'TensorFlow-2.21.0_add-missing-namespaces.patch',
'TensorFlow-2.21.0_disable-tf32-in-fused-matmul-tests.patch',
'TensorFlow-2.21.0_fix-AVX512-eigen-compilation.patch',
'TensorFlow-2.21.0_fix-GCC-compat.patch',
'TensorFlow-2.21.0_fix-openssl-linking.patch',
'TensorFlow-2.21.0_fix-shell-env-for-grpc.patch',
'TensorFlow-2.21.0_fix-shell-env-for-protobuf.patch',
'TensorFlow-2.21.0_readd-system-absl_py.patch',
'TensorFlow-2.21.0_relax-flatbuffers-requirement.patch',
'TensorFlow-2.21.0_remove-libclang-dep.patch',
'TensorFlow-2.21.0_remove-llvm-flag.patch',
],
'source_tmpl': 'v%(version)s.tar.gz',
'source_urls': ['https://github.com/tensorflow/tensorflow/archive/'],
'test_script': 'TensorFlow-2.x_mnist-test.py',
'test_tag_filters_cpu': '-gpu,-tpu,-no_cuda_on_cpu_tap,-no_pip,-no_oss,-oss_serial,-benchmark-test,-v1only',
'test_tag_filters_gpu': (
'gpu,-no_gpu,-nogpu,-gpu_cupti,-no_cuda11,'
'-no_pip,-no_oss,-oss_serial,-benchmark-test,-v1only'
),
'test_targets': [
'//tensorflow/core/...',
'-//tensorflow/core:example_java_proto',
'//tensorflow/cc/...',
'//tensorflow/c/...',
'//tensorflow/python/...',
'-//tensorflow/c/eager:c_api_test_gpu',
'-//tensorflow/c/eager:c_api_distributed_test',
'-//tensorflow/c/eager:c_api_distributed_test_gpu',
'-//tensorflow/c/eager:c_api_cluster_test_gpu',
'-//tensorflow/c/eager:c_api_remote_function_test_gpu',
'-//tensorflow/c/eager:c_api_remote_test_gpu',
'-//tensorflow/core/common_runtime:collective_param_resolver_local_test',
'-//tensorflow/core/kernels/mkl:mkl_fused_ops_test',
'-//tensorflow/core/kernels/mkl:mkl_fused_batch_norm_op_test',
'-//tensorflow/core/ir/importexport/tests/roundtrip/...',
],
'testopts': (
'--test_size_filters=small '
),
'testopts_gpu': (
'--test_size_filters=small '
'--run_under=//tensorflow/tools/ci_build/gpu_build:parallel_gpu_execute '
),
'checksums': [
{'v2.21.0.tar.gz': 'ef3568bb4865d6c1b2564fb5689c19b6b9a5311572cd1f2ff9198636a8520921'},
{'TensorFlow-2.4.0_dont-use-var-lock.patch':
'b14f2493fd2edf79abd1c4f2dde6c98a3e7d5cb9c25ab9386df874d5f072d6b5'},
{'TensorFlow-2.18.1_fix-xnnpack.patch': 'baf81d7b2b61b5a923cf1f171d5e2400df6b8bd9073d3afa7a356e3bbe11984c'},
{'TensorFlow-2.18.1_fixedpoint.patch': '5ea1eb3b32e7df5f9ae711a71778b4cae544b3380f18882186eea035873fb640'},
{'TensorFlow-2.21.0_add-missing-namespaces.patch':
'0ddf31351c6f2eaee308f6ff11b0e1956e70f422f199d8c92909339fd3c822a3'},
{'TensorFlow-2.21.0_disable-tf32-in-fused-matmul-tests.patch':
'2f605322c9694ccf6e013f06f403496320445a093ceca6625fec616343f5fd32'},
{'TensorFlow-2.21.0_fix-AVX512-eigen-compilation.patch':
'5b40296ac4dd76f950d44497e3a81d885a48dc541544cf74e576f6851a95a2eb'},
{'TensorFlow-2.21.0_fix-GCC-compat.patch':
'35c5c88bb07a8a5f2d72770a7c47b47f7c2e0f86f77762080c0823c382b828c1'},
{'TensorFlow-2.21.0_fix-openssl-linking.patch':
'2b327f949f975d8f15fab30ee6c85b3218e03327fc848a5470aa51253971e475'},
{'TensorFlow-2.21.0_fix-shell-env-for-grpc.patch':
'be390a96472b9b91723bf27a4b59a362ab89cd24dfc873a81161ade0bbbd569e'},
{'TensorFlow-2.21.0_fix-shell-env-for-protobuf.patch':
'9910e0df3e225976873a36aa1f7d3ed9b1e29afc5bd8505d6985b93dce8b9853'},
{'TensorFlow-2.21.0_readd-system-absl_py.patch':
'de3ebde1a72612875661a1b8a07251b248a1242ac0a982f3fa4cc26f6fc77c93'},
{'TensorFlow-2.21.0_relax-flatbuffers-requirement.patch':
'c500796a1fe1f3de8322b1a1abeefbd3714fb255e6600d65e3815e20484c45ee'},
{'TensorFlow-2.21.0_remove-libclang-dep.patch':
'4ee3773d07991c7f75d6dd4033ccf1bb9b017de478b39b4ffb6563a6bd66b981'},
{'TensorFlow-2.21.0_remove-llvm-flag.patch':
'5909f2ba3dc8049ce65de771068fdc96330f25d113f8c20463eea831bfefa078'},
],
}),
]

postinstallcmds = [
'mkdir -p %(installdir)s/bin && ln -sf "$EBROOTTENSORBOARD/bin/tensorboard" %(installdir)s/bin/tensorboard',
]

moduleclass = 'lib'
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
diff --git a/tensorflow/dtensor/mlir/spmd_expansion.cc b/tensorflow/dtensor/mlir/spmd_expansion.cc
--- a/tensorflow/dtensor/mlir/spmd_expansion.cc
+++ b/tensorflow/dtensor/mlir/spmd_expansion.cc
@@ -188,7 +188,7 @@ bool GetResourceArgIndexIfUsedInAssignmentOp(
GetForwardedDTensorLayoutInput(assign_variable_op.getResource());
if (llvm::isa<mlir::BlockArgument>(resource)) {
*resource_argument_index_for_assign_variable =
- cast<mlir::BlockArgument>(resource).getArgNumber();
+ mlir::cast<mlir::BlockArgument>(resource).getArgNumber();
return true;
}
}
@@ -221,7 +221,7 @@ mlir::LogicalResult UpdateFunctionArgsUsingLayout(mlir::func::FuncOp function) {

// If argument is a resource type update the subtype shape information
// to reflect local shape of resources.
- if (isa<mlir::TF::ResourceType>(arg_type)) {
+ if (mlir::isa<mlir::TF::ResourceType>(arg_type)) {
if (mlir::failed(UpdateResourceArgumentType(argument_index, function)))
return mlir::failure();
continue;
diff --git a/tensorflow/dtensor/mlir/shape_utils.cc b/tensorflow/dtensor/mlir/shape_utils.cc
--- a/tensorflow/dtensor/mlir/shape_utils.cc
+++ b/tensorflow/dtensor/mlir/shape_utils.cc
@@ -73,7 +73,7 @@ StatusOr<llvm::ArrayRef<int64_t>> ExtractGlobalInputShape(
return absl::InternalError("global_shape does not have static rank");
return *global_shape;
}
- return ExtractGlobalOutputShape(cast<mlir::OpResult>(input_value.get()));
+ return ExtractGlobalOutputShape(mlir::cast<mlir::OpResult>(input_value.get()));
}

// If we reach this point, we're working with a function argument.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
Fixes failing FusedMatMul test on certain GPU models
--- tensorflow/core/kernels/matmul_op_test.cc.orig 2026-06-29 00:00:00.000000000 +0200
+++ tensorflow/core/kernels/matmul_op_test.cc 2026-06-29 00:00:00.000000000 +0200
@@ -24,7 +24,8 @@
#include "tensorflow/core/framework/tensor.h"
#include "tensorflow/core/framework/types.h"
#include "tensorflow/core/kernels/ops_testutil.h"
#include "tensorflow/core/lib/core/status_test_util.h"
+#include "tensorflow/core/platform/tensor_float_32_utils.h"
#include "tensorflow/core/platform/test.h"
#include "tensorflow/core/platform/test_benchmark.h"
#include "tensorflow/core/protobuf/rewriter_config.pb.h"
@@ -334,6 +335,7 @@
// -------------------------------------------------------------------------- //

TYPED_TEST_P(FusedMatMulWithBiasOpTest, MatMul256x128x64) {
+ tensorflow::enable_tensor_float_32_execution(false);
this->VerifyMatMulWithBias(256, 128, 64, false, false);
this->VerifyMatMulWithBias(256, 128, 64, true, false);
this->VerifyMatMulWithBias(256, 128, 64, false, true);
@@ -341,6 +343,7 @@
}

TYPED_TEST_P(FusedMatMulWithBiasOpTest, MatMul1x256x256) {
+ tensorflow::enable_tensor_float_32_execution(false);
this->VerifyMatMulWithBias(1, 256, 256, false, false);
this->VerifyMatMulWithBias(1, 256, 256, true, false);
this->VerifyMatMulWithBias(1, 256, 256, false, true);
@@ -348,6 +351,7 @@
}

TYPED_TEST_P(FusedMatMulWithBiasOpTest, MatMul256x256x1) {
+ tensorflow::enable_tensor_float_32_execution(false);
this->VerifyMatMulWithBias(256, 256, 1, false, false);
this->VerifyMatMulWithBias(256, 256, 1, true, false);
this->VerifyMatMulWithBias(256, 256, 1, false, true);
@@ -371,6 +375,7 @@
}

TYPED_TEST_P(FusedMatMulWithBiasOpTest, MatMul256x128x64WithActivation) {
+ tensorflow::enable_tensor_float_32_execution(false);
for (const std::string& activation : GetActivations(this->kTValueType)) {
this->VerifyConv2DWithBiasAndActivation(256, 128, 64, false, false,
activation);
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
Fix a compilation error for CPUs with AVX512 features where an issue in Eigen leads to
> external/eigen_archive/Eigen/src/Core/arch/AVX512/PacketMathFP16.h:740:49: error: expected initializer before '<' token
> 740 | EIGEN_STRONG_INLINE Packet16h predux_half_dowto4<Packet32h>(const Packet32h& a) {
> | ^

Taken from https://gitlab.com/libeigen/eigen/-/merge_requests/2100

Author: Alexander Grund (TU Dresden)

diff --git a/third_party/xla/third_party/eigen3/fix-avx512.patch b/third_party/xla/third_party/eigen3/fix-avx512.patch
new file mode 100644
index 00000000000..0650d52a0c9
+--- /dev/null
++++ b/third_party/xla/third_party/eigen3/fix-avx512.patch
+ Eigen/src/Core/arch/AVX512/PacketMathFP16.h | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/Eigen/src/Core/arch/AVX512/PacketMathFP16.h b/Eigen/src/Core/arch/AVX512/PacketMathFP16.h
+index e6b8d995c8..370fb83364 100644
+--- a/Eigen/src/Core/arch/AVX512/PacketMathFP16.h
++++ b/Eigen/src/Core/arch/AVX512/PacketMathFP16.h
+@@ -735,9 +735,9 @@ EIGEN_STRONG_INLINE half predux<Packet8h>(const Packet8h& a) {
+ return half(_mm_reduce_add_ph(a));
+ }
+
+-// predux_half_dowto4
++// predux_half
+ template <>
+-EIGEN_STRONG_INLINE Packet16h predux_half_dowto4<Packet32h>(const Packet32h& a) {
++EIGEN_STRONG_INLINE Packet16h predux_half<Packet32h>(const Packet32h& a) {
+ const __m512i bits = _mm512_castph_si512(a);
+ Packet16h lo = _mm256_castsi256_ph(_mm512_castsi512_si256(bits));
+ Packet16h hi = _mm256_castsi256_ph(_mm512_extracti64x4_epi64(bits, 1));
+@@ -745,7 +745,7 @@ EIGEN_STRONG_INLINE Packet16h predux_half_dowto4<Packet32h>(const Packet32h& a)
+ }
+
+ template <>
+-EIGEN_STRONG_INLINE Packet8h predux_half_dowto4<Packet16h>(const Packet16h& a) {
++EIGEN_STRONG_INLINE Packet8h predux_half<Packet16h>(const Packet16h& a) {
+ Packet8h lo = _mm_castsi128_ph(_mm256_castsi256_si128(_mm256_castph_si256(a)));
+ Packet8h hi = _mm_castps_ph(_mm256_extractf128_ps(_mm256_castph_ps(a), 1));
+ return padd(lo, hi);
diff --git a/third_party/xla/third_party/eigen3/workspace.bzl b/third_party/xla/third_party/eigen3/workspace.bzl
index d1d8d4ac486..da549e37432 100644
--- a/third_party/xla/third_party/eigen3/workspace.bzl
+++ b/third_party/xla/third_party/eigen3/workspace.bzl
@@ -14,6 +14,7 @@ def repo():
tf_http_archive(
name = "eigen_archive",
build_file = "//third_party/eigen3:eigen_archive.BUILD",
+ patch_file = ["//third_party/eigen3:fix-avx512.patch"],
sha256 = EIGEN_SHA256,
strip_prefix = "eigen-{commit}".format(commit = EIGEN_COMMIT),
urls = tf_mirror_urls("https://gitlab.com/libeigen/eigen/-/archive/{commit}/eigen-{commit}.tar.gz".format(commit = EIGEN_COMMIT)),
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
Fix for
> external/xla/xla/hlo/utils/hlo_sharding_util.h:356:59: error: call of overloaded 'TileAssignment(<brace-enclosed initializer list>)' is ambiguous

from https://github.com/tensorflow/tensorflow/pull/110851
Second change is similar but for
> external/xla/xla/codegen/emitters/transforms/expand_integer_power.cc:51:66: error: conversion from '<brace-enclosed initializer list>' to 'mlir::mhlo::PowOp::Adaptor' {aka 'mlir::mhlo::PowOpAdaptor'} is ambiguous

author: Alexander Grund (TU Dresden)

From f2c84f1bb34fa43d6a77f1e51b838cdd2fc2effd Mon Sep 17 00:00:00 2001
From: "William S. Moses" <wmoses@google.com>
Date: Mon, 23 Feb 2026 10:55:56 -0800
Subject: [PATCH] TileAssignment: Fix build with gcc

PiperOrigin-RevId: 874157330
---
third_party/xla/xla/hlo/utils/hlo_sharding_util.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/third_party/xla/xla/hlo/utils/hlo_sharding_util.h b/third_party/xla/xla/hlo/utils/hlo_sharding_util.h
--- a/third_party/xla/xla/hlo/utils/hlo_sharding_util.h
+++ b/third_party/xla/xla/hlo/utils/hlo_sharding_util.h
@@ -372,7 +372,8 @@ class DeviceGroupTileAssignment : public TileAssignment {
public:
explicit DeviceGroupTileAssignment(int64_t num_groups,
int64_t num_devices_per_group)
- : TileAssignment({num_groups, num_devices_per_group}) {}
+ : TileAssignment(
+ absl::Span<const int64_t>{num_groups, num_devices_per_group}) {}
explicit DeviceGroupTileAssignment(int64_t num_groups,
int64_t num_devices_per_group,
absl::Span<const int64_t> reshape_dims,


diff --git a/third_party/xla/xla/codegen/emitters/transforms/expand_integer_power.cc b/third_party/xla/xla/codegen/emitters/transforms/expand_integer_power.cc
--- a/third_party/xla/xla/codegen/emitters/transforms/expand_integer_power.cc
+++ b/third_party/xla/xla/codegen/emitters/transforms/expand_integer_power.cc
@@ -49,7 +49,7 @@ mlir::LogicalResult ExpandIntegerPower(mlir::math::IPowIOp op,
llvm::SmallVector<mlir::Type> arg_types(op->getOperandTypes());
mlir::Value result =
mlir::mhlo::impl::mapMhloOpToStdScalarOp<mlir::mhlo::PowOp>(
- op.getLoc(), result_types, arg_types, {op->getOperands()},
+ op.getLoc(), result_types, arg_types, mlir::mhlo::PowOp::Adaptor(op->getOperands()),
op->getAttrs(), &rewriter);

rewriter.replaceOp(op, result);

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
When linking libtensorflow_cc.so.2 fails with many undefined references originating in grpc, e.g.:

bazel-out/k8-opt/bin/external/com_github_grpc_grpc/libtsi_ssl_credentials.pic.a(ssl_transport_security.pic.o):ssl_transport_security.cc:function populate_ssl_context(ssl_ctx_st*, tsi_ssl_pem_key_cert_pair const*, char const*): error: undefined reference to 'PEM_read_bio_PrivateKey'
bazel-out/k8-opt/bin/external/com_github_grpc_grpc/libtsi_ssl_credentials.pic.a(ssl_transport_security.pic.o):ssl_transport_security.cc:function populate_ssl_context(ssl_ctx_st*, tsi_ssl_pem_key_cert_pair const*, char const*): error: undefined reference to 'EVP_PKEY_free'

Fix by explicitely linking the dep that gets now ignored due to a change from 2.19, enabled by default in 2.20.

See https://github.com/tensorflow/tensorflow/pull/125250

Author: Alexander Grund (TU Dresden)

diff --git a/third_party/systemlibs/boringssl.BUILD b/third_party/systemlibs/boringssl.BUILD
--- a/third_party/systemlibs/boringssl.BUILD
+++ b/third_party/systemlibs/boringssl.BUILD
@@ -13,7 +13,7 @@ cc_library(

cc_library(
name = "ssl",
- linkopts = ["-lssl"],
+ linkopts = ["-lssl", "-lcrypto"],
visibility = ["//visibility:public"],
deps = [
":crypto",
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Make sure protobuf tools use by grpc use the same environment they were built in to avoid picking up e.g. the (possibly too old) system libcxx.

> ERROR: /dev/shm/TensorFlow/2.21.0/foss-2025b/TensorFlow/tensorflow-2.21.0/tensorflow/distribute/experimental/rpc/proto/BUILD:17:17: ProtocInvocation tensorflow/distribute/experimental/rpc/proto/tf_rpc_service_pb2_grpc.py failed: (Exit 1): protoc failed: error executing ProtocInvocation command (from target //tensorflow/distribute/experimental/rpc/proto:tf_rpc_service_proto_py_grpc_proto)


Author: Alexander Grund (TU Dresden)

diff --git a/third_party/xla/third_party/grpc/grpc.patch b/third_party/xla/third_party/grpc/grpc.patch
--- a/third_party/xla/third_party/grpc/grpc.patch
+++ b/third_party/xla/third_party/grpc/grpc.patch
@@ -53,3 +53,22 @@ diff --git a/src/python/grpcio/grpc/BUILD.bazel b/src/python/grpcio/grpc/BUILD.b
imports = ["../"],
deps = [
":_observability",
+diff -ur a/bazel/python_rules.bzl .b/bazel/python_rules.bzl
+--- b/bazel/python_rules.bzl
++++ a/bazel/python_rules.bzl
+@@ -84,6 +84,7 @@
+ arguments += get_proto_arguments(protos, context.genfiles_dir.path)
+
+ context.actions.run(
++ use_default_shell_env = True,
+ inputs = protos + includes.to_list(),
+ tools = tools,
+ outputs = out_files,
+@@ -228,6 +229,7 @@
+ arguments.append("--proto_path={}".format(context.genfiles_dir.path))
+ arguments += get_proto_arguments(protos, context.genfiles_dir.path)
+ context.actions.run(
++ use_default_shell_env = True,
+ inputs = protos + includes,
+ tools = tools,
+ outputs = out_files,
Loading
Loading