Skip to content

Commit b98d142

Browse files
[WIP] Upgrade to tf2.15. (#809)
* [WIP] Upgrade to tf2.15. * format and wheel test fixes. * Version bump again for wheel test. * Back to python3.10 * remove setup.py deps. * more format fixes. * yet more format. * C++ code formats. * Tutorial fix p1. * Tutorial fix p2. * Tutorials p3. * Add updated install instructions and tutorial install versions. * final cleanup * add setup.py --------- Co-authored-by: root <[email protected]>
1 parent f56257b commit b98d142

File tree

86 files changed

+824
-640
lines changed

Some content is hidden

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

86 files changed

+824
-640
lines changed

.bazelversion

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
5.3.0
1+
6.5.0
2+
# NOTE: Update Bazel version in tensorflow/tools/ci_build/release/common.sh.oss

.github/workflows/ci.yaml

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
- uses: actions/checkout@v1
1212
- uses: actions/setup-python@v1
1313
with:
14-
python-version: '3.9'
14+
python-version: '3.10'
1515
architecture: 'x64'
1616
- name: Install Lint tools
1717
run: pip install --upgrade pip setuptools; pip install -r requirements.txt;
@@ -26,7 +26,7 @@ jobs:
2626
- uses: actions/checkout@v1
2727
- uses: actions/setup-python@v1
2828
with:
29-
python-version: '3.9'
29+
python-version: '3.10'
3030
architecture: 'x64'
3131
- name: Install Format tools
3232
run: pip install --upgrade pip setuptools; pip install -r requirements.txt; sudo apt-get install -y clang-format-6.0
@@ -41,7 +41,7 @@ jobs:
4141
- uses: actions/checkout@v1
4242
- uses: actions/setup-python@v1
4343
with:
44-
python-version: '3.9'
44+
python-version: '3.10'
4545
architecture: 'x64'
4646
- name: Install Bazel on CI
4747
run: ./scripts/ci_install.sh
@@ -61,7 +61,7 @@ jobs:
6161
- uses: actions/checkout@v1
6262
- uses: actions/setup-python@v1
6363
with:
64-
python-version: '3.9'
64+
python-version: '3.10'
6565
architecture: 'x64'
6666
- name: Install Bazel on CI
6767
run: ./scripts/ci_install.sh
@@ -79,7 +79,7 @@ jobs:
7979
- uses: actions/checkout@v1
8080
- uses: actions/setup-python@v1
8181
with:
82-
python-version: '3.9'
82+
python-version: '3.10'
8383
architecture: 'x64'
8484
- name: Install Bazel on CI
8585
run: ./scripts/ci_install.sh
@@ -97,7 +97,7 @@ jobs:
9797
- uses: actions/checkout@v1
9898
- uses: actions/setup-python@v1
9999
with:
100-
python-version: '3.9'
100+
python-version: '3.10'
101101
architecture: 'x64'
102102
- name: Install notebook dependencies
103103
run: pip install --upgrade pip seaborn==0.10.0

WORKSPACE

+22-15
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
# This file includes external dependencies that are required to compile the
22
# TensorFlow op.
33

4+
5+
46
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
57

6-
EIGEN_COMMIT = "3bb6a48d8c171cf20b5f8e48bfb4e424fbd4f79e"
7-
EIGEN_SHA256 = "eca9847b3fe6249e0234a342b78f73feec07d29f534e914ba5f920f3e09383a3"
8+
9+
10+
EIGEN_COMMIT = "aa6964bf3a34fd607837dd8123bc42465185c4f8"
811

912

1013
http_archive(
@@ -16,7 +19,6 @@ cc_library(
1619
visibility = ["//visibility:public"],
1720
)
1821
""",
19-
sha256 = EIGEN_SHA256,
2022
strip_prefix = "eigen-{commit}".format(commit = EIGEN_COMMIT),
2123
urls = [
2224
"https://storage.googleapis.com/mirror.tensorflow.org/gitlab.com/libeigen/eigen/-/archive/{commit}/eigen-{commit}.tar.gz".format(commit = EIGEN_COMMIT),
@@ -27,35 +29,41 @@ cc_library(
2729
http_archive(
2830
name = "qsim",
2931
sha256 = "b9c1eba09a885a938b5e73dfc2e02f5231cf3b01d899415caa24769346a731d5",
32+
# patches = [
33+
# "//third_party/tf:qsim.patch",
34+
# ],
3035
strip_prefix = "qsim-0.13.3",
3136
urls = ["https://github.com/quantumlib/qsim/archive/refs/tags/v0.13.3.zip"],
3237
)
3338

3439
http_archive(
3540
name = "org_tensorflow",
36-
sha256 = "e52cda3bae45f0ae0fccd4055e9fa29892b414f70e2df94df9a3a10319c75fff",
37-
strip_prefix = "tensorflow-2.11.0",
41+
patches = [
42+
"//third_party/tf:tf.patch",
43+
],
44+
# sha256 = "e52cda3bae45f0ae0fccd4055e9fa29892b414f70e2df94df9a3a10319c75fff",
45+
strip_prefix = "tensorflow-2.15.0",
3846
urls = [
39-
"https://github.com/tensorflow/tensorflow/archive/refs/tags/v2.11.0.zip",
47+
"https://github.com/tensorflow/tensorflow/archive/refs/tags/v2.15.0.zip",
4048
],
4149
)
4250

4351

44-
load("@org_tensorflow//tensorflow:workspace3.bzl", "workspace")
52+
load("@org_tensorflow//tensorflow:workspace3.bzl", "tf_workspace3")
4553

46-
workspace()
54+
tf_workspace3()
4755

48-
load("@org_tensorflow//tensorflow:workspace2.bzl", "workspace")
56+
load("@org_tensorflow//tensorflow:workspace2.bzl", "tf_workspace2")
4957

50-
workspace()
58+
tf_workspace2()
5159

52-
load("@org_tensorflow//tensorflow:workspace1.bzl", "workspace")
60+
load("@org_tensorflow//tensorflow:workspace1.bzl", "tf_workspace1")
5361

54-
workspace()
62+
tf_workspace1()
5563

56-
load("@org_tensorflow//tensorflow:workspace0.bzl", "workspace")
64+
load("@org_tensorflow//tensorflow:workspace0.bzl", "tf_workspace0")
5765

58-
workspace()
66+
tf_workspace0()
5967

6068
load("//third_party/tf:tf_configure.bzl", "tf_configure")
6169

@@ -72,4 +80,3 @@ bind(
7280
name = "six",
7381
actual = "@six_archive//:six",
7482
)
75-

configure.sh

+15-15
Original file line numberDiff line numberDiff line change
@@ -73,21 +73,21 @@ done
7373

7474

7575
# Check if it's installed
76-
if [[ $(pip show tensorflow) == *tensorflow* ]] || [[ $(pip show tf-nightly) == *tf-nightly* ]]; then
77-
echo 'Using installed tensorflow'
78-
else
79-
# Uninstall CPU version if it is installed.
80-
if [[ $(pip show tensorflow-cpu) == *tensorflow-cpu* ]]; then
81-
echo 'Already have tensorflow non-gpu installed. Uninstalling......\n'
82-
pip uninstall tensorflow
83-
elif [[ $(pip show tf-nightly-cpu) == *tf-nightly-cpu* ]]; then
84-
echo 'Already have tensorflow non-gpu installed. Uninstalling......\n'
85-
pip uninstall tf-nightly
86-
fi
87-
# Install GPU version
88-
echo 'Installing tensorflow .....\n'
89-
pip install tensorflow
90-
fi
76+
# if [[ $(pip show tensorflow) == *tensorflow* ]] || [[ $(pip show tf-nightly) == *tf-nightly* ]]; then
77+
# echo 'Using installed tensorflow'
78+
# else
79+
# # Uninstall CPU version if it is installed.
80+
# if [[ $(pip show tensorflow-cpu) == *tensorflow-cpu* ]]; then
81+
# echo 'Already have tensorflow non-gpu installed. Uninstalling......\n'
82+
# pip uninstall tensorflow
83+
# elif [[ $(pip show tf-nightly-cpu) == *tf-nightly-cpu* ]]; then
84+
# echo 'Already have tensorflow non-gpu installed. Uninstalling......\n'
85+
# pip uninstall tf-nightly
86+
# fi
87+
# # Install GPU version
88+
# echo 'Installing tensorflow .....\n'
89+
# pip install tensorflow
90+
# fi
9191

9292

9393

docs/install.md

+16-17
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ There are a few ways to set up your environment to use TensorFlow Quantum (TFQ):
1010
Python's pip package manager.
1111
* Or build TensorFlow Quantum from source.
1212

13-
TensorFlow Quantum is supported on Python 3.7, 3.8, and 3.9 and depends directly on [Cirq](https://github.com/quantumlib/Cirq).
13+
TensorFlow Quantum is supported on Python 3.9, 3.10, and 3.11 and depends directly on [Cirq](https://github.com/quantumlib/Cirq).
1414

1515
## Pip package
1616

1717
### Requirements
1818

19-
* pip 19.0 or later (requires `manylinux2010` support)
20-
* [TensorFlow == 2.11.0](https://www.tensorflow.org/install/pip)
19+
* pip 19.0 or later (requires `manylinux2014` support)
20+
* [TensorFlow == 2.15.0](https://www.tensorflow.org/install/pip)
2121

2222
See the [TensorFlow install guide](https://www.tensorflow.org/install/pip) to
2323
set up your Python development environment and an (optional) virtual environment.
@@ -27,7 +27,7 @@ Upgrade `pip` and install TensorFlow
2727
<!-- common_typos_disable -->
2828
<pre class="devsite-click-to-copy">
2929
<code class="devsite-terminal">pip3 install --upgrade pip</code>
30-
<code class="devsite-terminal">pip3 install tensorflow==2.11.0</code>
30+
<code class="devsite-terminal">pip3 install tensorflow==2.15.0</code>
3131
</pre>
3232
<!-- common_typos_enable -->
3333

@@ -57,13 +57,13 @@ The following steps are tested for Ubuntu-like systems.
5757

5858
### 1. Set up a Python 3 development environment
5959

60-
First we need the Python 3.8 development tools.
60+
First we need the Python 3.10 development tools.
6161
<!-- common_typos_disable -->
6262
<pre class="devsite-click-to-copy">
6363
<code class="devsite-terminal">sudo apt update</code>
64-
<code class="devsite-terminal">sudo apt-get install pkg-config zip g++ zlib1g-dev unzip python3.8</code>
65-
<code class="devsite-terminal">sudo apt install python3.8 python3.8-dev python3.8-venv python3-pip</code>
66-
<code class="devsite-terminal">python3.8 -m pip install --upgrade pip</code>
64+
<code class="devsite-terminal">sudo apt-get install pkg-config zip g++ zlib1g-dev unzip python3.10</code>
65+
<code class="devsite-terminal">sudo apt install python3.10 python3.10-dev python3.10-venv python3-pip</code>
66+
<code class="devsite-terminal">python3.10 -m pip install --upgrade pip</code>
6767
</pre>
6868
<!-- common_typos_enable -->
6969

@@ -72,7 +72,7 @@ First we need the Python 3.8 development tools.
7272
Go to your workspace directory and make a virtual environment for TFQ development.
7373
<!-- common_typos_disable -->
7474
<pre class="devsite-click-to-copy">
75-
<code class="devsite-terminal">python3.8 -m venv quantum_env</code>
75+
<code class="devsite-terminal">python3.10 -m venv quantum_env</code>
7676
<code class="devsite-terminal">source quantum_env/bin/activate</code>
7777
</pre>
7878
<!-- common_typos_enable -->
@@ -84,21 +84,20 @@ 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.11.0. To ensure compatibility we use `bazel` version 5.3.0. To remove any existing version of Bazel:
88-
87+
Our latest source builds use TensorFlow 2.15.0. To ensure compatibility we use `bazel` version 6.5.0. To remove any existing version of Bazel:
8988
<!-- common_typos_disable -->
9089
<pre class="devsite-click-to-copy">
9190
<code class="devsite-terminal">sudo apt-get remove bazel</code>
9291
</pre>
9392
<!-- common_typos_enable -->
9493

95-
Download and install `bazel` version 5.3.0:
94+
Download and install `bazel` version 6.5.0:
9695

9796
<!-- common_typos_disable -->
9897
<pre class="devsite-click-to-copy">
99-
<code class="devsite-terminal">wget https://github.com/bazelbuild/bazel/releases/download/5.3.0/bazel_5.3.0-linux-x86_64.deb
98+
<code class="devsite-terminal">wget https://github.com/bazelbuild/bazel/releases/download/6.5.0/bazel_6.5.0-linux-x86_64.deb
10099
</code>
101-
<code class="devsite-terminal">sudo dpkg -i bazel_5.3.0-linux-x86_64.deb</code>
100+
<code class="devsite-terminal">sudo dpkg -i bazel_6.5.0-linux-x86_64.deb</code>
102101
</pre>
103102
<!-- common_typos_enable -->
104103

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

124123
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.11.0.
124+
guide, see the link for further details. TensorFlow Quantum is compatible with TensorFlow version&nbsp;2.15.0.
126125

127126
Download the
128127
<a href="https://github.com/tensorflow/tensorflow" class="external">TensorFlow source code</a>:
@@ -131,7 +130,7 @@ Download the
131130
<pre class="devsite-click-to-copy">
132131
<code class="devsite-terminal">git clone https://github.com/tensorflow/tensorflow.git</code>
133132
<code class="devsite-terminal">cd tensorflow</code>
134-
<code class="devsite-terminal">git checkout v2.11.0</code>
133+
<code class="devsite-terminal">git checkout v2.15.0</code>
135134
</pre>
136135

137136
Be sure the virtual environment you created in step 2 is activated. Then, install the TensorFlow dependencies:
@@ -141,7 +140,7 @@ Be sure the virtual environment you created in step 2 is activated. Then, instal
141140
<code class="devsite-terminal">pip install -U pip six numpy wheel setuptools mock 'future>=0.17.1'</code>
142141
<code class="devsite-terminal">pip install -U keras_applications --no-deps</code>
143142
<code class="devsite-terminal">pip install -U keras_preprocessing --no-deps</code>
144-
<code class="devsite-terminal">pip install numpy==1.24.2</code>
143+
<code class="devsite-terminal">pip install numpy==1.23.5</code>
145144
<code class="devsite-terminal">pip install packaging requests</code>
146145
</pre>
147146
<!-- common_typos_enable -->

docs/tutorials/barren_plateaus.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
},
9898
"outputs": [],
9999
"source": [
100-
"!pip install tensorflow==2.7.0"
100+
"!pip install tensorflow==2.15.0"
101101
]
102102
},
103103
{

docs/tutorials/gradients.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
},
100100
"outputs": [],
101101
"source": [
102-
"!pip install tensorflow==2.7.0"
102+
"!pip install tensorflow==2.15.0"
103103
]
104104
},
105105
{

docs/tutorials/hello_many_worlds.ipynb

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
},
104104
"outputs": [],
105105
"source": [
106-
"!pip install tensorflow==2.7.0"
106+
"!pip install tensorflow==2.15.0"
107107
]
108108
},
109109
{
@@ -255,7 +255,7 @@
255255
"# Create a circuit on these qubits using the parameters you created above.\n",
256256
"circuit = cirq.Circuit(\n",
257257
" cirq.rx(a).on(q0),\n",
258-
" cirq.ry(b).on(q1), cirq.CNOT(control=q0, target=q1))\n",
258+
" cirq.ry(b).on(q1), cirq.CNOT(q0, q1))\n",
259259
"\n",
260260
"SVGCircuit(circuit)"
261261
]

docs/tutorials/mnist.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
},
9898
"outputs": [],
9999
"source": [
100-
"!pip install tensorflow==2.7.0"
100+
"!pip install tensorflow==2.15.0"
101101
]
102102
},
103103
{

docs/tutorials/noise.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
},
8484
"outputs": [],
8585
"source": [
86-
"!pip install tensorflow==2.7.0 tensorflow-quantum==0.7.2"
86+
"!pip install tensorflow==2.15.0 tensorflow-quantum==0.7.2"
8787
]
8888
},
8989
{

docs/tutorials/qcnn.ipynb

+2-2
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
},
106106
"outputs": [],
107107
"source": [
108-
"!pip install tensorflow==2.7.0"
108+
"!pip install tensorflow==2.15.0"
109109
]
110110
},
111111
{
@@ -554,7 +554,7 @@
554554
" source_basis_selector = one_qubit_unitary(source_qubit, symbols[3:6])\n",
555555
" pool_circuit.append(sink_basis_selector)\n",
556556
" pool_circuit.append(source_basis_selector)\n",
557-
" pool_circuit.append(cirq.CNOT(control=source_qubit, target=sink_qubit))\n",
557+
" pool_circuit.append(cirq.CNOT(source_qubit, sink_qubit))\n",
558558
" pool_circuit.append(sink_basis_selector**-1)\n",
559559
" return pool_circuit"
560560
]

docs/tutorials/quantum_data.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
}
112112
],
113113
"source": [
114-
"!pip install tensorflow==2.7.0 tensorflow-quantum==0.7.2"
114+
"!pip install tensorflow==2.15.0 tensorflow-quantum==0.7.2"
115115
]
116116
},
117117
{

docs/tutorials/quantum_reinforcement_learning.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
},
124124
"outputs": [],
125125
"source": [
126-
"!pip install tensorflow==2.7.0"
126+
"!pip install tensorflow==2.15.0"
127127
]
128128
},
129129
{

docs/tutorials/research_tools.ipynb

+3-3
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
},
8484
"outputs": [],
8585
"source": [
86-
"!pip install tensorflow==2.7.0 tensorflow-quantum==0.7.2 tensorboard_plugin_profile==2.4.0"
86+
"!pip install tensorflow==2.15.0 tensorflow-quantum==0.7.2 tensorboard_plugin_profile==2.4.0"
8787
]
8888
},
8989
{
@@ -155,8 +155,8 @@
155155
"source": [
156156
"def generate_circuit(qubits):\n",
157157
" \"\"\"Generate a random circuit on qubits.\"\"\"\n",
158-
" random_circuit = cirq.generate_boixo_2018_supremacy_circuits_v2(\n",
159-
" qubits, cz_depth=2, seed=1234)\n",
158+
" random_circuit = cirq.experiments.random_rotations_between_grid_interaction_layers_circuit(\n",
159+
" qubits, depth=2)\n",
160160
" return random_circuit\n",
161161
"\n",
162162
"def generate_data(circuit, n_samples):\n",

0 commit comments

Comments
 (0)