Skip to content

Commit edea9ba

Browse files
authored
Merge branch 'master' into mh-release-scripts
2 parents 2de8dda + 7dfa7a6 commit edea9ba

File tree

14 files changed

+1906
-210
lines changed

14 files changed

+1906
-210
lines changed

.github/SECURITY.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,9 @@ contributions.
88
Please **do not** use GitHub issues to report security vulnerabilities; GitHub
99
issues are public, and doing so could allow someone to exploit the information
1010
before the problem can be addressed. Instead, please use the *Report a
11-
vulnerability* interface from the *Security* tab at the top of this GitHub
11+
vulnerability* button from the *Security* tab at the top of this GitHub
1212
repository page.
1313

14-
<div align="center">
15-
<img width="75%" alt="Location of the report button on the repository page"
16-
src="/.github/report-vulnerability-button.png">
17-
</div>
18-
1914
Please report security issues in third-party modules to the person or team
2015
maintaining the module rather than this project's stewards, unless you believe
2116
that some action needs to be taken specifically with this project in order to
-37.5 KB
Binary file not shown.

.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: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33

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

6+
local_repository(
7+
name = "pypi_setuptools",
8+
path = "third_party/pypi_setuptools",
9+
)
10+
611
# TensorFlow's .bzl files, loaded later in this file, also load rules_python
712
# but we need a slightly newer version that is still compatible with TF's.
813
http_archive(
@@ -39,11 +44,14 @@ load("@pypi//:requirements.bzl", "install_deps")
3944

4045
install_deps()
4146

42-
EIGEN_COMMIT = "aa6964bf3a34fd607837dd8123bc42465185c4f8"
47+
# Eigen commit used by TensorFlow / TFQ.
48+
# This commit corresponds to Eigen version 3.4.90
49+
# (verified via Eigen/src/Core/util/Macros.h).
50+
EIGEN_COMMIT = "c1d637433e3b3f9012b226c2c9125c494b470ae6"
4351

4452
http_archive(
4553
name = "eigen",
46-
sha256 = "35ba771e30c735a4215ed784d7e032086cf89fe6622dce4d793c45dd74373362",
54+
sha256 = "0992b93a590c39e196a9efdb5b4919fbf3fb485e7e656c6a87b21ddadb7f6ad2",
4755
build_file_content = """
4856
cc_library(
4957
name = "eigen3",
@@ -71,10 +79,9 @@ http_archive(
7179

7280
http_archive(
7381
name = "org_tensorflow",
74-
patches = ["//third_party/tf:tf.patch"],
75-
sha256 = "c8c8936e7b6156e669e08b3c388452bb973c1f41538149fce7ed4a4849c7a012",
76-
strip_prefix = "tensorflow-2.16.2",
77-
urls = ["https://github.com/tensorflow/tensorflow/archive/refs/tags/v2.16.2.zip"],
82+
sha256 = "75d63eab5c4b41a831e39e2e3795e1f9dcc247e8fcca11bf3f3e1a6ac35e55d0",
83+
strip_prefix = "tensorflow-2.17.1",
84+
urls = ["https://github.com/tensorflow/tensorflow/archive/refs/tags/v2.17.1.zip"],
7885
)
7986

8087

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: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,31 +48,29 @@ def finalize_options(self):
4848
REQUIRED_PACKAGES = [
4949
"cirq-core==1.3.0",
5050
"cirq-google==1.3.0",
51-
"numpy<2.0",
52-
"protobuf==4.25.8",
53-
"scipy<=1.12.0",
5451
"sympy==1.14",
55-
"tf-keras~=2.16.0",
56-
52+
"tf-keras~=2.17.0",
5753
# The following are transitive dependencies that need to be constrained to
5854
# avoid incompatible versions or because some (e.g., contourpy 1.3.3)
5955
# require Python 3.11+ and we want to maintain Python 3.10 compatibility.
6056
# TODO: revisit after we reach compatibility with TensorFlow 2.19+.
61-
"contourpy<=1.3.0",
57+
"contourpy<=1.3.2",
6258
"h5py==3.10.0",
6359
"importlib_metadata<5",
64-
"jax<0.4.24",
65-
"jaxlib<0.4.24",
60+
"jax<=0.5",
6661
"matplotlib<3.10",
67-
"networkx<3.3",
68-
"pillow<=11.0",
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",
6967
]
7068

7169
# TF requirement is placed as an extras to avoid overwriting existing nightly TF
7270
# installations. Users can run "pip install tensorflow-quantum[and-tensorflow]"
7371
# to get everything in one go (or "pip install tensorflow tensorflow-quantum").
7472
EXTRA_PACKAGES = {}
75-
EXTRA_PACKAGES["and-tensorflow"] = ["tensorflow>=2.16,<2.17"]
73+
EXTRA_PACKAGES["and-tensorflow"] = ["tensorflow>=2.17,<2.18"]
7674
# "extras" was used before 0.7.4. Prefer "and-tensorflow" in 0.7.4+.
7775
EXTRA_PACKAGES["extras"] = EXTRA_PACKAGES["and-tensorflow"]
7876
# Add an alias in case people type an underscore instead of a dash.
@@ -103,6 +101,7 @@ def has_ext_modules(self):
103101
version=BUILD_VERSION,
104102
description="Library for hybrid quantum-classical machine learning.",
105103
long_description="\n".join(DOCLINES[2:]),
104+
long_description_content_type="text/plain",
106105
author="The TensorFlow Quantum Authors",
107106
author_email="tensorflow-quantum-team@google.com",
108107
url="https://github.com/tensorflow/quantum/",
@@ -122,6 +121,7 @@ def has_ext_modules(self):
122121
"Programming Language :: Python :: 3.10",
123122
"Programming Language :: Python :: 3.11",
124123
"Programming Language :: Python :: 3.12",
124+
"Programming Language :: Python :: 3.13",
125125
"Topic :: Scientific/Engineering",
126126
"Topic :: Scientific/Engineering :: Artificial Intelligence",
127127
"Topic :: Scientific/Engineering :: Mathematics",

requirements.in

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,14 @@
1818
# scripts/generate_requirements.sh.
1919
cirq-core~=1.3.0
2020
cirq-google~=1.3.0
21-
tensorflow>=2.16,<2.17
22-
tf-keras~=2.16.0
21+
tensorflow>=2.17,<2.18
22+
keras==3.12.0
23+
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
2329

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

0 commit comments

Comments
 (0)