Skip to content

Commit ad05884

Browse files
jaeyooMichaelBroughton
authored andcommitted
Upgrade TF version from 2.7 to 2.11 (#749)
* Upgrade bazel version to 5.1.0 for building with TFv2.11.0 * Upgrade to TF v2.11 * Bump up the version of numpy to v1.24.2 * Format * Fix tf.Variable inside tf.while_loop issues inside optimizers * Format optimizers * Upgrade the latest gym for notebook tutorial. * Fix tutorial error * Fix tutorial errors * Upgrade seaborn version to 0.12.0 * Fix typo * Remove debug print * Update ci_install bazel version, removed duplicated code lines.
1 parent f46056d commit ad05884

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1278
-944
lines changed

.bazelversion

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.7.2
1+
5.1.0

WORKSPACE

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
55

6-
EIGEN_COMMIT = "12e8d57108c50d8a63605c6eb0144c838c128337"
7-
EIGEN_SHA256 = "f689246e342c3955af48d26ce74ac34d21b579a00675c341721a735937919b02"
6+
EIGEN_COMMIT = "3bb6a48d8c171cf20b5f8e48bfb4e424fbd4f79e"
7+
EIGEN_SHA256 = "eca9847b3fe6249e0234a342b78f73feec07d29f534e914ba5f920f3e09383a3"
88

99

1010
http_archive(
@@ -33,10 +33,10 @@ http_archive(
3333

3434
http_archive(
3535
name = "org_tensorflow",
36-
sha256 = "249b48ddee927801c7a4f8e5442cf1a3c860f6f46b85a2ff7a78b501507dd561",
37-
strip_prefix = "tensorflow-2.7.0",
36+
sha256 = "e52cda3bae45f0ae0fccd4055e9fa29892b414f70e2df94df9a3a10319c75fff",
37+
strip_prefix = "tensorflow-2.11.0",
3838
urls = [
39-
"https://github.com/tensorflow/tensorflow/archive/refs/tags/v2.7.0.zip",
39+
"https://github.com/tensorflow/tensorflow/archive/refs/tags/v2.11.0.zip",
4040
],
4141
)
4242

benchmarks/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Some notes on benchmark configuration:
2424

2525
For example, to benchmark a dense depth-10 Clifford circuit over 5 qubits call:
2626
```
27-
bazel run -c opt --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0" --cxxopt="-msse2" \
27+
bazel run -c opt --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=1" --cxxopt="-msse2" \
2828
--cxxopt="-msse3" --cxxopt="-msse4" \
2929
benchmarks/scripts:benchmark_clifford_circuit -- \
3030
--n_moments 5 --n_qubits 4 \
@@ -39,7 +39,7 @@ benchmarks/scripts/reports/CliffordBenchmarks.benchmark_clifford_circuit_4_5_1
3939
To benchmark the parameter shift differentiation method on a random depth-10 4-qubit circuit with 10 parameters call, where the circuit will be differentiated
4040
over 50 trials, each time over a batch of 10 circuits.
4141
```
42-
bazel run -c opt --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0" --cxxopt="-msse2" \
42+
bazel run -c opt --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=1" --cxxopt="-msse2" \
4343
--cxxopt="-msse3" --cxxopt="-msse4" \
4444
benchmarks/scripts:benchmark_op_gradients -- \
4545
--n_moments 10 --n_qubits 4 --n_symbols 10 \

configure.sh

+3-4
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,12 @@ if [[ "$PIP_MANYLINUX2010" == "0" ]]; then
9999
write_to_bazelrc "build:cuda --crosstool_top=@local_config_cuda//crosstool:toolchain"
100100
fi
101101

102-
102+
write_to_bazelrc "build --experimental_repo_remote_exec"
103103
write_to_bazelrc "build --spawn_strategy=standalone"
104104
write_to_bazelrc "build --strategy=Genrule=standalone"
105-
write_to_bazelrc "build --experimental_repo_remote_exec"
106105
write_to_bazelrc "build -c opt"
107-
write_to_bazelrc "build --cxxopt=\"-D_GLIBCXX_USE_CXX11_ABI=0\""
108-
write_to_bazelrc "build --cxxopt=\"-std=c++14\""
106+
write_to_bazelrc "build --cxxopt=\"-D_GLIBCXX_USE_CXX11_ABI=1\""
107+
write_to_bazelrc "build --cxxopt=\"-std=c++17\""
109108

110109

111110
if is_windows; then

docs/install.md

+11-10
Original file line numberDiff line numberDiff line change
@@ -84,21 +84,21 @@ As noted in the TensorFlow
8484
guide, the <a href="https://bazel.build/" class="external">Bazel</a>
8585
build system will be required.
8686

87-
Our latest source builds use TensorFlow 2.7.0. To ensure compatibility we use `bazel` version 3.7.2. To remove any existing version of Bazel:
87+
Our latest source builds use TensorFlow 2.11.0. To ensure compatibility we use `bazel` version 5.1.0. To remove any existing version of Bazel:
8888

8989
<!-- common_typos_disable -->
9090
<pre class="devsite-click-to-copy">
9191
<code class="devsite-terminal">sudo apt-get remove bazel</code>
9292
</pre>
9393
<!-- common_typos_enable -->
9494

95-
Download and install `bazel` version 3.7.2:
95+
Download and install `bazel` version 5.1.0:
9696

9797
<!-- common_typos_disable -->
9898
<pre class="devsite-click-to-copy">
99-
<code class="devsite-terminal">wget https://github.com/bazelbuild/bazel/releases/download/3.7.2/bazel_3.7.2-linux-x86_64.deb
99+
<code class="devsite-terminal">wget https://github.com/bazelbuild/bazel/releases/download/5.1.0/bazel_5.1.0-linux-x86_64.deb
100100
</code>
101-
<code class="devsite-terminal">sudo dpkg -i bazel_3.7.2-linux-x86_64.deb</code>
101+
<code class="devsite-terminal">sudo dpkg -i bazel_5.1.0-linux-x86_64.deb</code>
102102
</pre>
103103
<!-- common_typos_enable -->
104104

@@ -122,7 +122,7 @@ Finally, confirm installation of the correct `bazel` version:
122122
### 4. Build TensorFlow from source
123123

124124
Here we adapt instructions from the TensorFlow [build from source](https://www.tensorflow.org/install/source)
125-
guide, see the link for further details. TensorFlow Quantum is compatible with TensorFlow version&nbsp;2.7.0.
125+
guide, see the link for further details. TensorFlow Quantum is compatible with TensorFlow version&nbsp;2.11.0.
126126

127127
Download the
128128
<a href="https://github.com/tensorflow/tensorflow" class="external">TensorFlow source code</a>:
@@ -131,7 +131,7 @@ Download the
131131
<pre class="devsite-click-to-copy">
132132
<code class="devsite-terminal">git clone https://github.com/tensorflow/tensorflow.git</code>
133133
<code class="devsite-terminal">cd tensorflow</code>
134-
<code class="devsite-terminal">git checkout v2.7.0</code>
134+
<code class="devsite-terminal">git checkout v2.11.0</code>
135135
</pre>
136136

137137
Be sure the virtual environment you created in step 2 is activated. Then, install the TensorFlow dependencies:
@@ -141,7 +141,8 @@ Be sure the virtual environment you created in step 2 is activated. Then, instal
141141
<code class="devsite-terminal">pip install -U pip six numpy wheel setuptools mock 'future>=0.17.1'</code>
142142
<code class="devsite-terminal">pip install -U keras_applications --no-deps</code>
143143
<code class="devsite-terminal">pip install -U keras_preprocessing --no-deps</code>
144-
<code class="devsite-terminal">pip install numpy==1.19.5</code>
144+
<code class="devsite-terminal">pip install numpy==1.24.2</code>
145+
<code class="devsite-terminal">pip install packaging requests</code>
145146
</pre>
146147
<!-- common_typos_enable -->
147148

@@ -153,11 +154,11 @@ Configure the TensorFlow build. When asked for the Python interpreter and librar
153154
</pre>
154155
<!-- common_typos_enable -->
155156

156-
Build the TensorFlow package:
157+
Build the TensorFlow package (Since TF v2.8, `_GLIBCXX_USE_CXX11_ABI` is set to 1, and the c++ codes are all compiled with `-std=c++17`):
157158

158159
<!-- common_typos_disable -->
159160
<pre class="devsite-click-to-copy">
160-
<code class="devsite-terminal">bazel build -c opt --cxxopt="-O3" --cxxopt="-march=native" --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0" //tensorflow/tools/pip_package:build_pip_package</code>
161+
<code class="devsite-terminal">bazel build -c opt --cxxopt="-O3" --cxxopt="-march=native" --cxxopt="-std=c++17" --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=1" //tensorflow/tools/pip_package:build_pip_package</code>
161162
</pre>
162163
<!-- common_typos_enable -->
163164

@@ -193,7 +194,7 @@ Build the TensorFlow Quantum pip package and install:
193194
<!-- common_typos_disable -->
194195
<pre class="devsite-click-to-copy">
195196
<code class="devsite-terminal">./configure.sh</code>
196-
<code class="devsite-terminal">bazel build -c opt --cxxopt="-O3" --cxxopt="-march=native" --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0" release:build_pip_package</code>
197+
<code class="devsite-terminal">bazel build -c opt --cxxopt="-O3" --cxxopt="-march=native" --cxxopt="-std=c++17" --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=1" release:build_pip_package</code>
197198
<code class="devsite-terminal">bazel-bin/release/build_pip_package /tmp/tfquantum/</code>
198199
<code class="devsite-terminal">python3 -m pip install /tmp/tfquantum/<var>name_of_generated_wheel</var>.whl</code>
199200
</pre>

docs/tutorials/barren_plateaus.ipynb

+19-10
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
},
1313
{
1414
"cell_type": "code",
15-
"execution_count": 0,
15+
"execution_count": null,
1616
"metadata": {
1717
"cellView": "form",
1818
"colab": {},
@@ -89,7 +89,7 @@
8989
},
9090
{
9191
"cell_type": "code",
92-
"execution_count": 0,
92+
"execution_count": null,
9393
"metadata": {
9494
"colab": {},
9595
"colab_type": "code",
@@ -112,7 +112,7 @@
112112
},
113113
{
114114
"cell_type": "code",
115-
"execution_count": 0,
115+
"execution_count": null,
116116
"metadata": {
117117
"colab": {},
118118
"colab_type": "code",
@@ -125,7 +125,7 @@
125125
},
126126
{
127127
"cell_type": "code",
128-
"execution_count": 0,
128+
"execution_count": null,
129129
"metadata": {
130130
"colab": {},
131131
"colab_type": "code",
@@ -150,7 +150,7 @@
150150
},
151151
{
152152
"cell_type": "code",
153-
"execution_count": 0,
153+
"execution_count": null,
154154
"metadata": {
155155
"colab": {},
156156
"colab_type": "code",
@@ -202,7 +202,7 @@
202202
},
203203
{
204204
"cell_type": "code",
205-
"execution_count": 0,
205+
"execution_count": null,
206206
"metadata": {
207207
"colab": {},
208208
"colab_type": "code",
@@ -278,7 +278,7 @@
278278
},
279279
{
280280
"cell_type": "code",
281-
"execution_count": 0,
281+
"execution_count": null,
282282
"metadata": {
283283
"colab": {},
284284
"colab_type": "code",
@@ -327,7 +327,7 @@
327327
},
328328
{
329329
"cell_type": "code",
330-
"execution_count": 0,
330+
"execution_count": null,
331331
"metadata": {
332332
"colab": {},
333333
"colab_type": "code",
@@ -399,7 +399,7 @@
399399
},
400400
{
401401
"cell_type": "code",
402-
"execution_count": 0,
402+
"execution_count": null,
403403
"metadata": {
404404
"colab": {},
405405
"colab_type": "code",
@@ -455,7 +455,7 @@
455455
},
456456
{
457457
"cell_type": "code",
458-
"execution_count": 0,
458+
"execution_count": null,
459459
"metadata": {
460460
"colab": {},
461461
"colab_type": "code",
@@ -511,6 +511,15 @@
511511
"display_name": "Python 3",
512512
"language": "python",
513513
"name": "python3"
514+
},
515+
"language_info": {
516+
"name": "python",
517+
"version": "3.10.9 (main, Dec 7 2022, 13:47:07) [GCC 12.2.0]"
518+
},
519+
"vscode": {
520+
"interpreter": {
521+
"hash": "916dbcbb3f70747c44a77c7bcd40155683ae19c65e1c03b4aa3499c5328201f1"
522+
}
514523
}
515524
},
516525
"nbformat": 4,

0 commit comments

Comments
 (0)