Skip to content

Add support for TensorFlow 2.19#1077

Merged
mhucka merged 9 commits into
masterfrom
tf-219
May 22, 2026
Merged

Add support for TensorFlow 2.19#1077
mhucka merged 9 commits into
masterfrom
tf-219

Conversation

@psamanoelton
Copy link
Copy Markdown
Collaborator

@psamanoelton psamanoelton commented May 22, 2026

Summary

Update TensorFlow Quantum build to support TensorFlow 2.19.1.

Keep TFQ aligned with TensorFlow 2.19.1’s Bazel and Python repository expectations, confirm Eigen remains on TensorFlow’s pinned revision, and regenerate Python dependencies from requirements.in.

Key changes

WORKSPACE

  • bump @org_tensorflow to 2.19.1
  • add python_version_repo to satisfy TensorFlow 2.19’s expected Python version repository layout
  • add lightweight wrapper lockfiles (requirements_lock_3_10.txt, requirements_lock_3_11.txt, requirements_lock_3_12.txt) so the same compiled requirements can be reused across the supported Python versions
  • confirm Eigen remains aligned with TensorFlow 2.19.1’s pinned revision

requirements.in / requirements.txt

  • update TensorFlow requirement to 2.19.1
  • update tf-keras requirement to 2.19.x
  • regenerate requirements.txt from requirements.in with pip-compile under Python 3.10
  • keep the dependency set compatible with Python 3.10, 3.11, and 3.12

TFQ source compatibility

  • update noisy expectation ops to avoid copy-constructing tensorflow::mutex, which fails with TensorFlow 2.19
  • keep the rest of the TensorFlow Quantum codepath unchanged as much as possible

Docs / install flow

  • document tf-keras==2.19.0 and TF_USE_LEGACY_KERAS=1 as part of the supported install path

Testing

Linux/Ubuntu 22.04 (Docker), Python 3.10, 3.11, and 3.12, Bazelisk → Bazel 6.5.0

  • bazel build ... release:build_pip_package succeeds
  • unit tests (./scripts/test_all.sh and ./scripts/ci_validate_tutorials.sh) pass
  • wheel builds, installs, and imports successfully
  • validated with TensorFlow 2.19.1 + tf-keras 2.19.0, Cirq 1.5.0, and NumPy 2.1.3

Notes

  • This keeps TFQ on the Keras 2 path; Keras 3 migration can be handled in a future PR
  • TensorFlow 2.19.1 keeps the same Eigen pin already used by TFQ
  • this change should help with the incoming upgrades to 2.20
  • Updating Bazel to 7.4.1 might be useful when upgrading to 2.20

@psamanoelton psamanoelton requested a review from mhucka May 22, 2026 20:28
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates TensorFlow Quantum to support TensorFlow 2.19.1 and TF-Keras 2.19.0, adjusting build configurations, documentation, and dependency management accordingly. Key changes include the enforcement of Python 3.10 for requirement generation and a migration from tensorflow::mutex to absl::Mutex in C++ core operations. Review feedback points out missing absl/synchronization/mutex.h headers and identifies a technical issue where absl::Mutex is stored in a std::vector, which is invalid due to its non-copyable and non-movable nature; a transition to std::unique_ptr is recommended.

Comment thread tensorflow_quantum/core/ops/parse_context.h
Comment thread tensorflow_quantum/core/ops/noise/tfq_noisy_expectation.cc Outdated
Comment thread tensorflow_quantum/core/ops/noise/tfq_noisy_sampled_expectation.cc Outdated
Copy link
Copy Markdown
Member

@mhucka mhucka left a comment

Choose a reason for hiding this comment

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

Looks good.

@mhucka mhucka enabled auto-merge May 22, 2026 20:42
@mhucka mhucka disabled auto-merge May 22, 2026 20:43
@mhucka
Copy link
Copy Markdown
Member

mhucka commented May 22, 2026

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the project to support TensorFlow 2.19.1 and TF-Keras 2.19.0. Key changes include updating dependency versions across README.md, WORKSPACE, setup.py, and requirement files, as well as updating installation documentation to include the TF_USE_LEGACY_KERAS=1 environment variable. In the C++ source, tensorflow::mutex has been replaced with absl::Mutex across multiple operation kernels. Furthermore, the generate_requirements.sh script now enforces Python 3.10 and utilizes updated pip-compile flags including hash generation. I have no feedback to provide as there were no review comments.

@mhucka mhucka added this pull request to the merge queue May 22, 2026
Merged via the queue into master with commit 1bd3915 May 22, 2026
12 checks passed
@mhucka mhucka deleted the tf-219 branch May 22, 2026 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants