Skip to content

Commit 3e9c7a7

Browse files
authored
Merge branch 'master' into replace-gym-to-gymnasium
2 parents 46a9832 + 66e4479 commit 3e9c7a7

File tree

10 files changed

+357
-1704
lines changed

10 files changed

+357
-1704
lines changed

.github/workflows/ci-build-checks.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
name: Library tests
5555
runs-on: linux-x86-n2-32
5656
container:
57-
image: us-docker.pkg.dev/ml-oss-artifacts-published/ml-public-container/ml-build:latest
57+
image: us-docker.pkg.dev/ml-oss-artifacts-published/ml-public-container/ml-build:infrastructure-public-image-82c7ac59ba4b
5858
timeout-minutes: 60
5959

6060
steps:
@@ -103,7 +103,7 @@ jobs:
103103
name: Tutorial tests
104104
runs-on: linux-x86-n2-32
105105
container:
106-
image: us-docker.pkg.dev/ml-oss-artifacts-published/ml-public-container/ml-build:latest
106+
image: us-docker.pkg.dev/ml-oss-artifacts-published/ml-public-container/ml-build:infrastructure-public-image-82c7ac59ba4b
107107
timeout-minutes: 60
108108

109109
steps:

.github/workflows/ci-nightly-build-test.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ jobs:
9393
if: needs.Decision.outputs.run == 'true'
9494
name: Build and test
9595
needs: Decision
96-
runs-on: ubuntu-22.04
96+
container:
97+
image: us-docker.pkg.dev/ml-oss-artifacts-published/ml-public-container/ml-build:infrastructure-public-image-82c7ac59ba4b
98+
runs-on: linux-x86-n2-32
9799
steps:
98100
- name: Check out a copy of the TFQ git repository
99101
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4

WORKSPACE

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ cc_library(
6868

6969
http_archive(
7070
name = "qsim",
71-
sha256 = "b9c1eba09a885a938b5e73dfc2e02f5231cf3b01d899415caa24769346a731d5",
71+
sha256 = "720eeb97298819e00bbb218b8b58fcebbbc1e1708233598fdffeef0b97339617",
7272
# patches = [
7373
# "//third_party/tf:qsim.patch",
7474
# ],
75-
strip_prefix = "qsim-0.13.3",
76-
urls = ["https://github.com/quantumlib/qsim/archive/refs/tags/v0.13.3.zip"],
75+
strip_prefix = "qsim-0.21.0",
76+
urls = ["https://github.com/quantumlib/qsim/archive/refs/tags/v0.21.0.zip"],
7777
)
7878

7979

release/docker/Dockerfile

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Copyright 2025 The TensorFlow Quantum Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# =============================================================================
15+
16+
# Summary: build file for making isolated Docker environments for testing.
17+
# This accepts 2 optional build arguments to set the Ubuntu & Python versions.
18+
# Usage example:
19+
#
20+
# docker build --no-cache --build-arg PYTHON_VERSION=3.10 \
21+
# --build-arg UBUNTU_VERSION=24.04 -t my-image:latest .
22+
#
23+
# Note that the name and tag ("my-image" and "latest" in the example above) are
24+
# yours to choose. They're not set using the arguments or linked to their values.
25+
26+
# Default values for build arguments:
27+
ARG PYTHON_VERSION=3.10
28+
ARG UBUNTU_VERSION=22.04
29+
30+
FROM ubuntu:${UBUNTU_VERSION}
31+
32+
# Make the Python version argument visible to the rest of this file after FROM.
33+
ARG PYTHON_VERSION
34+
ENV PYTHON_VERSION=${PYTHON_VERSION}
35+
36+
ENV LANG=C.UTF-8
37+
ENV LC_ALL=C.UTF-8
38+
ENV DEBIAN_FRONTEND=noninteractive
39+
40+
# Ensure the shell is Bash.
41+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
42+
43+
# Tell the Dockerfile linter not to warn about how we use apt.
44+
# hadolint global ignore=DL3008,DL3009
45+
46+
RUN apt-get -q update -q && \
47+
apt-get install -y --no-install-recommends ca-certificates \
48+
pkg-config gnupg curl lsb-release git zip unzip
49+
50+
# We avoid the use of "add-apt-repository" because it is only available from the
51+
# "software-properties-common" package, and installing that package brings in a
52+
# lot of other unrelated unnecessary packages. Instead, we fetch the GPG key for
53+
# the deadsnakes package archive and install it where apt can find it.
54+
ENV ID=0xF23C5A6CF475977595C89F51BA6932366A755776
55+
ENV GPG_FILE="/etc/apt/trusted.gpg.d/deadsnakes.gpg"
56+
RUN curl -sSL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=${ID}" | \
57+
gpg --dearmor -o ${GPG_FILE}
58+
59+
ENV PPA_URL="https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu"
60+
ENV APT_FILE="/etc/apt/sources.list.d/deadsnakes.list"
61+
RUN echo "deb [signed-by=${GPG_FILE}] ${PPA_URL} $(lsb_release -cs) main" > "${APT_FILE}"
62+
63+
RUN apt-get -q update -q && \
64+
apt-get install -yq --no-install-recommends make clang g++ zlib1g-dev \
65+
python${PYTHON_VERSION} python${PYTHON_VERSION}-dev \
66+
python${PYTHON_VERSION}-venv python-is-python3
67+
68+
# Use update-alternatives to make the desired version be the default.
69+
# hadolint ignore=SC3010
70+
RUN python_path="" bin="/usr/bin" && \
71+
case "$(lsb_release -rs)" in \
72+
"24.04") python_path="${bin}/python3.12" ;; \
73+
"22.04") python_path="${bin}/python3.10" ;; \
74+
"20.04") python_path="${bin}/python3.8" ;; \
75+
*) python_path=$(readlink -f ${bin}/python3) ;; \
76+
esac && \
77+
update-alternatives --install ${bin}/python3 python3 "${python_path}" 1 && \
78+
update-alternatives --install ${bin}/python3 python3 "${bin}/python${PYTHON_VERSION}" 2
79+
80+
# Install pip, trying ensurepip first and falling back to get-pip.py.
81+
RUN export PIP_BREAK_SYSTEM_PACKAGES=1 PIP_ROOT_USER_ACTION=ignore && \
82+
(python3 -m ensurepip --upgrade --default-pip || \
83+
(curl -sS https://bootstrap.pypa.io/get-pip.py | python3)) && \
84+
python3 -m pip install --no-cache-dir --upgrade 'pip>19'
85+
86+
# Clean up before finishing.
87+
RUN apt-get clean
88+
89+
CMD ["/bin/bash"]

release/docker/README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Docker images for basic testing
2+
3+
This directory contains a [`Dockerfile`](Dockerfile) for creating Ubuntu
4+
containers with Python installed and very little else compared to the stock
5+
Ubuntu images from https://hub.docker.com/_/ubuntu/. These can be used for
6+
testing TensorFlow Quantum builds and tutorials in relatively isolated
7+
environments.
8+
9+
The script [`create_docker_images.sh`](create_docker_images.sh) creates separate
10+
images with a range of Python versions installed in Ubuntu 22.04 and 24.04. The
11+
result is a set of images with names like `ubuntu22-cp310`, `ubuntu22-cp311`,
12+
etc. The script `create_docker_images.sh` is meant to be run simply like this:
13+
14+
```shell
15+
./create_docker_images.sh
16+
```
17+
18+
The configuration in `Dockerfile` runs a Bash shell as the last step if a
19+
container is not started with any other command to run. When combined with
20+
Docker's `-v` argument, you can easily run commands inside the container
21+
environment while accessing your TensorFlow Quantum source files. For example:
22+
23+
```shell
24+
# The next cd command moves to the root of the source tree.
25+
cd $(git rev-parse --show-toplevel)
26+
docker run -it --rm --network host -v .:/tfq ubuntu24-cp312
27+
```
28+
29+
will leave you with a shell prompt inside a basic Ubuntu 24.04 environment with
30+
Python 3.12 preinstalled and your local TensorFlow Quantum source directory
31+
accessible at `/tfq` from inside the container.
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/bin/bash
2+
# Copyright 2025 The TensorFlow Quantum Authors
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# https://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
# =============================================================================
16+
17+
# Summary: create a set of Docker images for testing TFQ distributions.
18+
# This loops over a set of Ubuntu versions and Python versions, and builds
19+
# Docker images using the Dockerfile in this directory.
20+
#
21+
# Example of how the resulting images can be run
22+
# docker run -it --rm --network host -v .:/tfq ubuntu22-cp310
23+
24+
set -e
25+
26+
declare -a ubuntu_versions=()
27+
declare -a python_versions=()
28+
29+
ubuntu_versions+=( "22.04" "24.04" )
30+
python_versions+=( "3.10" "3.11" "3.12" "3.13" )
31+
32+
usage="Usage: ${0} [OPTIONS]
33+
34+
Build a set of basic Ubuntu Linux x86_64 Docker images with
35+
Python preinstalled.
36+
37+
General options:
38+
-h Show this help message and exit
39+
-v Run Docker build with verbose progress output"
40+
41+
while getopts "hv" opt; do
42+
case "${opt}" in
43+
h) echo "${usage}"; exit 0 ;;
44+
v) export BUILDKIT_PROGRESS=plain ;;
45+
?) echo "${usage}"; exit 1 ;;
46+
esac
47+
done
48+
49+
total_items=$(( ${#ubuntu_versions[@]} * ${#python_versions[@]}))
50+
echo "Building a total of ${total_items} Docker images."
51+
52+
start_time="$(date +"%Y-%m-%d-%H%M")"
53+
for os_version in "${ubuntu_versions[@]}"; do
54+
for py_version in "${python_versions[@]}"; do
55+
echo
56+
echo "~~~~ Python ${py_version} on Ubuntu ${os_version}"
57+
# shellcheck disable=SC2086 # Lack of quotes around vars is ok here.
58+
docker build --no-cache --label "build-datetime=${start_time}" \
59+
--build-arg PYTHON_VERSION="${py_version}" \
60+
--build-arg UBUNTU_VERSION="${os_version}" \
61+
-t ubuntu${os_version%%.*}-cp${py_version//./}:latest .
62+
done
63+
done
64+
65+
echo
66+
echo "~~~~ Done. The following Docker images were created:"
67+
echo
68+
docker images --filter "label=build-datetime=${start_time}"

release/setup.py

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -48,22 +48,17 @@ def finalize_options(self):
4848
REQUIRED_PACKAGES = [
4949
"cirq-core==1.3.0",
5050
"cirq-google==1.3.0",
51+
"numpy<2.0",
52+
"scipy~=1.15.3",
5153
"sympy==1.14",
5254
"tf-keras~=2.17.0",
53-
# The following are transitive dependencies that need to be constrained to
54-
# avoid incompatible versions or because some (e.g., contourpy 1.3.3)
55-
# require Python 3.11+ and we want to maintain Python 3.9 compatibility.
56-
# TODO: revisit after we reach compatibility with TensorFlow 2.19+.
57-
"contourpy<=1.3.2",
58-
"h5py==3.10.0",
59-
"importlib_metadata<5",
60-
"jax<=0.5",
61-
"matplotlib<3.10",
62-
"numpy<2.0",
63-
"scipy<=1.12.0",
64-
# The following makes it easier to get the right version on Colab. Once
65-
# TFQ works with the latest version of TF, this may become unnecessary.
66-
"protobuf==4.25.8",
55+
56+
# The reset of these constraints are on transitive dependencies to avoid
57+
# installation conflicts, which can happen if pip finds a newer version of a
58+
# package & that newer version requires, e.g., NumPy 2.x or Python 3.11+.
59+
# Ideally these can be removed once TFQ is compatible with recent TFs.
60+
"jax<0.5",
61+
"contourpy<1.3.3",
6762
]
6863

6964
# TF requirement is placed as an extras to avoid overwriting existing nightly TF
@@ -73,8 +68,6 @@ def finalize_options(self):
7368
EXTRA_PACKAGES["and-tensorflow"] = ["tensorflow>=2.17,<2.18"]
7469
# "extras" was used before 0.7.4. Prefer "and-tensorflow" in 0.7.4+.
7570
EXTRA_PACKAGES["extras"] = EXTRA_PACKAGES["and-tensorflow"]
76-
# Add an alias in case people type an underscore instead of a dash.
77-
EXTRA_PACKAGES["and_tensorflow"] = EXTRA_PACKAGES["and-tensorflow"]
7871

7972

8073
class BinaryDistribution(Distribution):
@@ -106,7 +99,7 @@ def has_ext_modules(self):
10699
author_email="tensorflow-quantum-team@google.com",
107100
url="https://github.com/tensorflow/quantum/",
108101
packages=find_packages(),
109-
python_requires='>=3.9',
102+
python_requires='>=3.10',
110103
install_requires=REQUIRED_PACKAGES,
111104
extras_require=EXTRA_PACKAGES,
112105
include_package_data=True,

requirements.in

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,15 @@
1616
# Core development requirements for TensorFlow Quantum. This file is processed
1717
# by pip-compile (from pip-tools) to produce requirements.txt using the script
1818
# scripts/generate_requirements.sh.
19+
1920
cirq-core~=1.3.0
2021
cirq-google~=1.3.0
22+
jax<0.5
23+
numpy<2.0
24+
scipy~=1.15.3
25+
sympy==1.14
2126
tensorflow>=2.17,<2.18
22-
keras==3.12.0
2327
tf-keras~=2.17.0
24-
setuptools==75.0.0
25-
wheel==0.46.2
26-
contourpy<=1.3.2
27-
networkx<=3.4.2
28-
scipy==1.15.3
2928

3029
# TODO: the next ones are not truly core requirements. A better place should be
3130
# found for them (long with others needed by scripts/*). They're here as a

0 commit comments

Comments
 (0)