Skip to content

Add support for TensorFlow 2.19#1051

Open
psamanoelton wants to merge 1 commit intotensorflow:masterfrom
psamanoelton:tf219_support
Open

Add support for TensorFlow 2.19#1051
psamanoelton wants to merge 1 commit intotensorflow:masterfrom
psamanoelton:tf219_support

Conversation

@psamanoelton
Copy link
Copy Markdown
Collaborator

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

  • update install docs and tutorial notebook snippets to use TensorFlow 2.19.1
  • 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 April 17, 2026 18:13
@review-notebook-app
Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Copy link
Copy Markdown

@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 the Bazel workspace for multi-version Python support, adjusting dependency constraints in setup.py and requirements.in, and updating documentation to include the TF_USE_LEGACY_KERAS=1 environment variable. Additionally, the requirements generation script was refactored, and redundant mutex initializations in the C++ ops were removed. Feedback suggests restoring the pyyaml exclusion in generate_requirements.sh to prevent installation conflicts and explicitly setting the legacy Keras environment variable within the tutorial notebooks to ensure compatibility.

Comment thread scripts/generate_requirements.sh
Comment thread docs/tutorials/mnist.ipynb
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.

1 participant