Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable TF XLA, add tensorflow-xla-runtime. #9005

Merged
Merged
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
1 change: 1 addition & 0 deletions cmssw-tool-conf.spec
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ Requires: hls
Requires: opencv
Requires: grpc
Requires: onnxruntime
Requires: tensorflow-xla-runtime
Requires: TOoLLiP
Requires: triton-inference-client
Requires: hdf5
Expand Down
2 changes: 1 addition & 1 deletion pip/cmsml.file
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Requires: py3-six
Requires: py3-six py3-tabulate py3-pytest py3-pytest-xdist
1 change: 1 addition & 0 deletions pip/execnet.file
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
BuildRequires: py3-hatchling py3-hatch-vcs
1 change: 1 addition & 0 deletions pip/pytest-xdist.file
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Requires: py3-pytest py3-execnet
14 changes: 9 additions & 5 deletions pip/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ charset-normalizer==3.1.0
cleo==2.0.1
click==8.1.3
clikit==0.6.2
cmsml==0.1.2
cmsml==0.2.2
contourpy==1.0.7
correctionlib==2.2.2
crashtest==0.4.1
Expand Down Expand Up @@ -94,6 +94,7 @@ docutils==0.19
dulwich==0.21.3
editables==0.3
entrypoints==0.4
execnet==2.0.2
executing==1.2.0
exceptiongroup==1.1.1
fasteners==0.18
Expand Down Expand Up @@ -170,13 +171,13 @@ keras-preprocessing==1.1.2
keras2onnx==1.7.0
keyring==23.13.1
kiwisolver==1.4.4
law==0.1.12
law==0.1.18
lazy-object-proxy==1.9.0
lizard==1.17.10
#llvmlite==v0.41.0dev0
locket==1.0.0
lockfile==0.12.2
luigi==3.2.1
luigi==3.5.0
lxml==4.9.2
lz4==4.3.2
make==0.1.6.post2
Expand Down Expand Up @@ -284,6 +285,7 @@ pysqlite3==0.5.0
pytest==7.4.0
pytest-cov==4.0.0
pytest-runner==6.0.0
pytest-xdist==3.5.0
python-daemon==3.0.1
python-dateutil==2.8.2
python-json-logger==2.0.7
Expand Down Expand Up @@ -313,7 +315,7 @@ schema==0.7.5
scikit-build==0.16.7
scikit-build-core==0.3.0
scikit-learn==1.2.2
scinum==1.4.6
scinum==2.0.2
scipy==1.10.1
secretstorage==3.3.3
semantic-version==2.10.0
Expand All @@ -337,6 +339,7 @@ stevedore==5.0.0
subprocess32==3.5.4
sympy==1.11.1
tables==3.8.0
tabulate==0.9.0
tenacity==8.2.2
#NO_AUTO_UPDATE:1: Force to use tensorflow 2.6.4; this should match the version in tensorflow-sources.spec
tensorflow==2.12.0
Expand Down Expand Up @@ -379,7 +382,8 @@ Werkzeug==3.0.1
#NO_AUTO_UPDATE:1: you need wheel to build wheel
wheel==0.40.0
widgetsnbextension==4.0.7
wrapt==1.15.0
#NO_AUTO_UPDATE: wrapt >=1.15.0 breaks tensorflow saved model, https://github.com/GrahamDumpleton/wrapt/issues/231
wrapt==1.14.1
xgboost==1.7.5
yarl==1.8.2
zipp==3.15.0
1 change: 1 addition & 0 deletions pip/tabulate.file
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
BuildRequires: py3-hatchling py3-hatch-vcs
3 changes: 2 additions & 1 deletion pip/tensorflow.file
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ Requires: llvm
%define PipPostInstall \
for f in %{RelocateFiles} ; do \
[ ! -f %{i}/$f ] || sed -i -e 's|/[^ ]*/%{cmsplatf}/external/|%{cmsroot}/%{cmsplatf}/external/|' %{i}/$f \
done
done ; \
sed -i 's/assert((arg_size(index)/assert(((size_t)arg_size(index)/' %{i}/lib/python%{cms_python3_major_minor_version}/site-packages/tensorflow/include/tensorflow/compiler/tf2xla/xla_compiled_cpu_function.h

%define PipPostPost \
for f in %{RelocateFiles} ; do \
Expand Down
1 change: 1 addition & 0 deletions python_tools.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Requires: py3-law
Requires: py3-protobuf

Requires: py3-tables
Requires: py3-tabulate
Requires: py3-numexpr
Requires: py3-histogrammar
Requires: py3-pandas
Expand Down
6 changes: 6 additions & 0 deletions scram-tools.file/tools/py3-tensorflow/py3-tensorflow.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<tool name="py3-tensorflow" version="@TOOL_VERSION@">
<client>
<environment name="PY3_TENSORFLOW_BASE" default="@TOOL_ROOT@"/>
</client>
<runtime name="PATH" value="$PY3_TENSORFLOW_BASE/bin" type="path"/>
</tool>
6 changes: 6 additions & 0 deletions scram-tools.file/tools/py3-tensorflow/tensorflow-includes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<tool name="tensorflow-includes" version="@TOOL_VERSION@">
<client>
<environment name="TENSORFLOW_INCLUDES_BASE" default="@TOOL_ROOT@"/>
<environment name="INCLUDE" default="$TENSORFLOW_INCLUDES_BASE/@PYTHON3_LIB_SITE_PACKAGES@/tensorflow/include"/>
</client>
</tool>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<tool name="tensorflow-xla-runtime" version="@TOOL_VERSION@">
<client>
<environment name="TENSORFLOW_XLA_RUNTIME_BASE" default="@TOOL_ROOT@"/>
<environment name="LIBDIR" default="$TENSORFLOW_XLA_RUNTIME_BASE/lib/archive"/>
</client>
<lib name="tf_xla_runtime-static"/>
<use name="eigen"/>
<use name="tensorflow-includes"/>
</tool>
5 changes: 5 additions & 0 deletions scram-tools.file/tools/tensorflow-xla-runtime/vectorized.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<tool name="tensorflow-xla-runtime_@TOOL_VECTORIZATION@" version="@TOOL_VERSION@">
<client>
<environment name="@TOOL_VECTORIZATION_KEY@_LIBDIR" default="@TOOL_ROOT@/lib"/>
</client>
</tool>
6 changes: 4 additions & 2 deletions tensorflow-sources.file
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export TF_NEED_CUDA=%{enable_gpu}
export TF_NEED_JEMALLOC=0
export TF_NEED_HDFS=0
export TF_NEED_GCP=0
export TF_ENABLE_XLA=0
export TF_ENABLE_XLA=1
export TF_NEED_OPENCL=0
export TF_NEED_VERBS=0
export TF_NEED_MKL=0
Expand Down Expand Up @@ -150,6 +150,7 @@ bazel $BAZEL_OPTS //tensorflow/compiler/tf2xla:xla_compiled_cpu_function
#bazel $BAZEL_OPTS //tensorflow/compiler/aot:tfcompile
bazel $BAZEL_OPTS //tensorflow/core/profiler
bazel $BAZEL_OPTS //tensorflow:install_headers
bazel $BAZEL_OPTS //tensorflow/compiler/tf2xla:tf2xla_supported_ops

# rebuild *.pb.{h|cc} files using the external protobuf compiler
chmod -R a+rwX $PWD/bazel-bin/tensorflow/include
Expand Down Expand Up @@ -192,8 +193,9 @@ for l in tensorflow_cc tensorflow_framework tensorflow ; do
done

#cp -p $srcdir/compiler/aot/tfcompile $bindir
cp -p $srcdir/compiler/tf2xla/tf2xla_supported_ops $bindir
for name in tensorflow absl re2 third_party ; do
cp -r -p $srcdir/include/$name $incdir
cp -r -p $srcdir/include/$name $incdir
done

# copy headers from downloaded dependencies
Expand Down
23 changes: 23 additions & 0 deletions tensorflow-xla-runtime.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
### RPM external tensorflow-xla-runtime 2.12.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@riga, we need tensorflow-xla-runtime to be part of cmssw dependency chain, so please add it in https://github.com/cms-sw/cmsdist/blob/IB/CMSSW_14_1_X/master/cmssw-tool-conf.spec

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added 👍

## INCLUDE cpp-standard

Requires: eigen py3-tensorflow
BuildRequires: cmake

%prep

cp -r ${PY3_TENSORFLOW_ROOT}/lib/python%{cms_python3_major_minor_version}/site-packages/tensorflow .

%build

export CPATH="${CPATH}:${EIGEN_ROOT}/include/eigen3"

pushd tensorflow/xla_aot_runtime_src
cmake . -DCMAKE_CXX_FLAGS="-fPIC -msse3" -DCMAKE_CXX_STANDARD=%{cms_cxx_standard} -DBUILD_SHARED_LIBS=OFF
make %{makeprocesses}
popd

%install

mkdir -p %{i}/lib/archive
mv tensorflow/xla_aot_runtime_src/libtf_xla_runtime.a %{i}/lib/archive/libtf_xla_runtime-static.a
1 change: 1 addition & 0 deletions vectorization/cmsdist_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"fastjet",
"tensorflow-sources",
"tensorflow",
"tensorflow-xla-runtime",
"OpenBLAS",
"rivet",
"gbl",
Expand Down