Skip to content

Commit 07608a3

Browse files
andrijapauPietropaoloFrisonimudit2812isaacdevlugt
authored
chore: deprecate tensorflow maintenance support (#7989)
**Context:** We are deprecating `tensorflow` maintenance support and promoting user migration to `jax` and `torch` interfaces. **Description of the Change:** - Add deprecation warning to `QNode` execution. This will capture majority of user workflows and ensure deprecation visibility. - Add deprecation warning to https://docs.pennylane.ai/en/stable/introduction/interfaces/tf.html - Add deprecation warning in changelog (which will be promoted to release notes). - Cleaned up necessary tests to un-block work (this involved deleting TF specific `all_interfaces` tests). - Add no cover to TF logic branches Here's an example, ```python import pennylane as qml import tensorflow as tf dev = qml.device("default.qubit", wires=1) params = tf.Variable(0.1) @qml.qnode(dev) def circuit(x): qml.RX(x, wires=0) return qml.expval(qml.PauliZ(0)) circuit(params) ``` ``` PennyLaneDeprecationWarning: Support for the TensorFlow interface is deprecated and will be removed in v0.44. Future versions of PennyLane are not guaranteed to work with TensorFlow. Please migrate your workflows to JAX or torch to benefit from enhanced support and features. circuit(params) <tf.Tensor: shape=(), dtype=float64, numpy=0.9950041833264242> ``` **Benefits:** No longer have to deal with maintaining TF. **Possible Drawbacks:** This could have impact on our eco-system: Catalyst: N/A Lightning: PennyLaneAI/pennylane-lightning#1225 QML: Some [demos](https://github.com/search?q=repo%3APennyLaneAI%2Fqml%20import%20tensorflow&type=code) need changes. Being taken care of by product here PennyLaneAI/qml/pull/1505. Plug-ins: N/A [sc-92521] --------- Co-authored-by: Pietropaolo Frisoni <[email protected]> Co-authored-by: Mudit Pandey <[email protected]> Co-authored-by: Isaac De Vlugt <[email protected]> Co-authored-by: Isaac De Vlugt <[email protected]>
1 parent 46734c9 commit 07608a3

File tree

122 files changed

+640
-10910
lines changed

Some content is hidden

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

122 files changed

+640
-10910
lines changed

.coveragerc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@ omit =
55
pennylane/devices/tests*
66
pennylane/labs/*
77
pennylane/compiler/python_compiler/*
8+
pennylane/workflow/interfaces/tensorflow.py
9+
pennylane/workflow/interfaces/tensorflow_autograph.py
810

911
[report]
1012
# Regexes for lines to exclude from consideration
1113
exclude_lines =
1214
# Have to re-enable the standard pragma
1315
pragma: no cover
16+
17+
pragma: no cover (TensorFlow tests were disabled during deprecation)
1418

1519
# Ignore type checking
1620
if TYPE_CHECKING:
@@ -33,7 +37,6 @@ exclude_lines =
3337
# Ignore overload stubs
3438
@overload
3539

36-
3740
ignore_errors = True
3841

3942
[html]

.github/durations/tf_tests_durations.json

Lines changed: 0 additions & 4557 deletions
This file was deleted.

.github/stable/tf.txt

Lines changed: 0 additions & 112 deletions
This file was deleted.

.github/workflows/interface-dependency-versions.yml

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@ on:
2222
required: false
2323
type: string
2424
default: '0.6.2'
25-
tensorflow_version:
26-
description: The version of TensorFlow to use for testing
27-
required: false
28-
type: string
29-
default: '2.19.0'
3025
torch_version:
3126
description: The version of PyTorch to use for testing
3227
required: false
@@ -39,9 +34,6 @@ on:
3934
catalyst-jax-version:
4035
description: The version of JAX to use along with Catalyst
4136
value: ${{ jobs.default-dependency-versions.outputs.catalyst-jax-version }}
42-
tensorflow-version:
43-
description: The version of TensorFlow to use
44-
value: ${{ jobs.default-dependency-versions.outputs.tensorflow-version }}
4537
pytorch-version:
4638
description: The version of PyTorch to use
4739
value: ${{ jobs.default-dependency-versions.outputs.pytorch-version }}
@@ -65,10 +57,6 @@ jobs:
6557
id: catalyst-jax
6658
run: echo "version=${{ inputs.catalyst_jax_version }}" >> $GITHUB_OUTPUT
6759

68-
- name: Default Tensorflow Version
69-
id: tensorflow
70-
run: echo "version=${{ inputs.tensorflow_version }}" >> $GITHUB_OUTPUT
71-
7260
- name: Default PyTorch Version
7361
id: pytorch
7462
run: echo "version=${{ inputs.torch_version }}" >> $GITHUB_OUTPUT
@@ -84,7 +72,6 @@ jobs:
8472
outputs:
8573
catalyst-jax-version: jax==${{ steps.catalyst-jax.outputs.version }} jaxlib==${{ steps.catalyst-jax.outputs.version }}
8674
jax-version: jax==${{ steps.jax.outputs.version }} jaxlib==${{ steps.jax.outputs.version }}
87-
tensorflow-version: tensorflow~=${{ steps.tensorflow.outputs.version }} tf-keras~=${{ steps.tensorflow.outputs.version }}
8875
pytorch-version: torch~=${{ steps.pytorch.outputs.version }}
8976
catalyst-nightly: ${{ steps.catalyst.outputs.nightly }}
9077
pennylane-lightning-latest: ${{ steps.pennylane-lightning.outputs.latest }}

.github/workflows/interface-unit-tests.yml

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ jobs:
155155
{
156156
"default": ["3.11", "3.12", "3.13"],
157157
"torch-tests": ["3.11", "3.13"],
158-
"tf-tests": ["3.11", "3.12"],
159158
"jax-tests": ["3.11", "3.13"],
160159
"capture-jax-tests": ["3.11", "3.13"],
161160
"all-interfaces-tests": ["3.11"],
@@ -183,7 +182,6 @@ jobs:
183182
"core-tests": 6,
184183
"gradients-tests": 2,
185184
"jax-tests": 4,
186-
"tf-tests": 3,
187185
"device-tests": 1
188186
}
189187
EOF
@@ -193,7 +191,6 @@ jobs:
193191
"default": 1,
194192
"core-tests": 6,
195193
"jax-tests": 8,
196-
"tf-tests": 6,
197194
"torch-tests": 2,
198195
"device-tests": 1
199196
}
@@ -303,46 +300,6 @@ jobs:
303300
pytest_xml_file_path: '${{ inputs.job_name_prefix }}autograd-tests (${{ matrix.python-version }})${{ inputs.job_name_suffix }}.xml'
304301
pytest_markers: autograd and not qcut and not finite-diff and not param-shift
305302

306-
307-
tf-tests:
308-
needs:
309-
- setup-ci-load
310-
- determine_runner
311-
- default-dependency-versions
312-
- warnings-as-errors-setup
313-
strategy:
314-
fail-fast: ${{ needs.warnings-as-errors-setup.outputs.fail_fast == 'default' }}
315-
max-parallel: >-
316-
${{
317-
fromJSON(needs.setup-ci-load.outputs.matrix-max-parallel).tf-tests
318-
|| fromJSON(needs.setup-ci-load.outputs.matrix-max-parallel).default
319-
}}
320-
matrix:
321-
group: [1, 2, 3]
322-
python-version: >-
323-
${{
324-
fromJSON(needs.setup-ci-load.outputs.python-version).tf-tests
325-
|| fromJSON(needs.setup-ci-load.outputs.python-version).default
326-
}}
327-
if: ${{ !contains(fromJSON(needs.setup-ci-load.outputs.jobs-to-skip), 'tf-tests') }}
328-
uses: ./.github/workflows/unit-test.yml
329-
with:
330-
job_runner_name: ${{ needs.determine_runner.outputs.runner_group }}
331-
job_name: ${{ inputs.job_name_prefix }}tf-tests (${{ matrix.group }}, ${{ matrix.python-version }})${{ inputs.job_name_suffix }}
332-
branch: ${{ inputs.branch }}
333-
coverage_artifact_name: core-interfaces-coverage-tf-${{ matrix.python-version }}-${{ matrix.group }}
334-
python_version: ${{ matrix.python-version }}
335-
additional_pip_packages: |
336-
${{ needs.default-dependency-versions.outputs.tensorflow-version }}
337-
${{ inputs.additional_python_packages }}
338-
additional_pip_packages_post: ${{ needs.default-dependency-versions.outputs.pennylane-lightning-latest }}
339-
pytest_coverage_flags: ${{ inputs.pytest_coverage_flags }}
340-
pytest_markers: tf and not qcut and not finite-diff and not param-shift
341-
pytest_additional_args: --splits 3 --group ${{ matrix.group }} ${{ needs.warnings-as-errors-setup.outputs.pytest_warning_args }}
342-
pytest_durations_file_path: '.github/durations/tf_tests_durations.json'
343-
pytest_xml_file_path: '${{ inputs.job_name_prefix }}tf-tests (${{ matrix.group }}, ${{ matrix.python-version }})${{ inputs.job_name_suffix }}.xml'
344-
requirements_file: ${{ github.event_name == 'schedule' && strategy.job-index == 0 && 'tf.txt' || '' }}
345-
346303
jax-tests:
347304
needs:
348305
- setup-ci-load
@@ -490,7 +447,6 @@ jobs:
490447
python_version: ${{ matrix.python-version }}
491448
additional_pip_packages: |
492449
${{ needs.default-dependency-versions.outputs.jax-version }}
493-
${{ needs.default-dependency-versions.outputs.tensorflow-version }}
494450
${{ needs.default-dependency-versions.outputs.pytorch-version }}
495451
${{ inputs.additional_python_packages }}
496452
additional_pip_packages_post: ${{ needs.default-dependency-versions.outputs.pennylane-lightning-latest }}
@@ -536,7 +492,6 @@ jobs:
536492
pyzx matplotlib stim quimb mitiq ply optax scipy-openblas32>=0.3.26 qualtran openqasm3 antlr4_python3_runtime xdsl==0.46 filecheck
537493
${{ needs.default-dependency-versions.outputs.jax-version }}
538494
git+https://github.com/PennyLaneAI/pennylane-qiskit.git@master
539-
${{ needs.default-dependency-versions.outputs.tensorflow-version }}
540495
${{ needs.default-dependency-versions.outputs.catalyst-nightly }}
541496
${{ inputs.additional_python_packages }}
542497
@@ -578,7 +533,6 @@ jobs:
578533
kahypar==1.3.5
579534
opt_einsum
580535
${{ needs.default-dependency-versions.outputs.jax-version }}
581-
${{ needs.default-dependency-versions.outputs.tensorflow-version }}
582536
${{ needs.default-dependency-versions.outputs.pytorch-version }}
583537
${{ inputs.additional_python_packages }}
584538
additional_pip_packages_post: ${{ needs.default-dependency-versions.outputs.pennylane-lightning-latest }}
@@ -654,7 +608,6 @@ jobs:
654608
pytest_xml_file_path: '${{ inputs.job_name_prefix }}gradients-tests (${{ matrix.config.suite }}, ${{ matrix.python-version }})${{ inputs.job_name_suffix }}.xml'
655609
additional_pip_packages: |
656610
${{ needs.default-dependency-versions.outputs.jax-version }}
657-
${{ needs.default-dependency-versions.outputs.tensorflow-version }}
658611
${{ needs.default-dependency-versions.outputs.pytorch-version }}
659612
${{ inputs.additional_python_packages }}
660613
additional_pip_packages_post: ${{ needs.default-dependency-versions.outputs.pennylane-lightning-latest }}
@@ -735,7 +688,6 @@ jobs:
735688
python_version: ${{ matrix.python-version }}
736689
additional_pip_packages: |
737690
${{ !contains(matrix.config.skip_interface, 'jax') && needs.default-dependency-versions.outputs.jax-version || '' }}
738-
${{ !contains(matrix.config.skip_interface, 'tf') && needs.default-dependency-versions.outputs.tensorflow-version || '' }}
739691
${{ !contains(matrix.config.skip_interface, 'torch') && needs.default-dependency-versions.outputs.pytorch-version || '' }}
740692
${{ inputs.additional_python_packages }}
741693
additional_pip_packages_post: ${{ needs.default-dependency-versions.outputs.pennylane-lightning-latest }}
@@ -749,7 +701,6 @@ jobs:
749701
needs:
750702
- torch-tests
751703
- autograd-tests
752-
- tf-tests
753704
- jax-tests
754705
- capture-jax-tests
755706
- core-tests
@@ -808,7 +759,6 @@ jobs:
808759
- determine_runner
809760
- torch-tests
810761
- autograd-tests
811-
- tf-tests
812762
- jax-tests
813763
- capture-jax-tests
814764
- core-tests

.github/workflows/package_warnings_as_errors.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ jobs:
2222
python_warning_level: 'error'
2323
run_lightened_ci: false
2424
skip_ci_test_jobs: |
25-
tf-tests
2625
all-interfaces-tests
2726
external-libraries-tests
2827
qcut-tests

.github/workflows/test_numpy_1_compat.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ jobs:
2424
additional_python_packages: 'numpy~=1.26.0'
2525
upload_to_codecov: false
2626
skip_ci_test_jobs: |
27-
tf-tests
2827
all-interfaces-tests
2928
external-libraries-tests
3029
qcut-tests

.github/workflows/update-durations.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ jobs:
3939
mkdir durations
4040
jq -s 'add' durations-core-*/*.json > durations/core_tests_durations.json
4141
jq -s 'add' durations-jax-*/*.json > durations/jax_tests_durations.json
42-
jq -s 'add' durations-tf-*/*.json > durations/tf_tests_durations.json
4342
4443
- name: Upload combined durations artifacts
4544
uses: actions/upload-artifact@v4

.pylintrc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22
# A comma-separated list of package or module names from where C extensions may
33
# be loaded. Extensions are loading into the active Python interpreter and may
44
# run arbitrary code
5-
extension-pkg-whitelist=numpy,scipy,autograd,toml,appdir,autograd.numpy,autograd.numpy.linalg,autograd.numpy.builtins,packaging,torch,tensorflow,tensorflow.contrib,tensorflow.contrib.eager,LazyLoader,networkx,networkx.dag
5+
extension-pkg-whitelist=numpy,scipy,autograd,toml,appdir,autograd.numpy,autograd.numpy.linalg,autograd.numpy.builtins,packaging,torch,LazyLoader,networkx,networkx.dag
66

77
[TYPECHECK]
88

99
# List of module names for which member attributes should not be checked
1010
# (useful for modules/projects where namespaces are manipulated during runtime
1111
# and thus existing member attributes cannot be deduced by static analysis. It
1212
# supports qualified module names, as well as Unix pattern matching.
13-
ignored-modules=jax,numpy,scipy,autograd,toml,appdir,autograd.numpy,autograd.numpy.linalg,autograd.numpy.builtins,packaging,torch,tensorflow,tensorflow.contrib,tensorflow.contrib.eager,LazyLoader,networkx,networkx.dag,math,pennylane.numpy
13+
ignored-modules=jax,numpy,scipy,autograd,toml,appdir,autograd.numpy,autograd.numpy.linalg,autograd.numpy.builtins,packaging,torch,LazyLoader,networkx,networkx.dag,math,pennylane.numpy
1414

1515
# List of classes names for which member attributes should not be checked
1616
# (useful for classes with attributes dynamically set). This supports can work
1717
# with qualified names.
18-
ignored-classes=jax,numpy,scipy,autograd,toml,appdir,autograd.numpy,autograd.numpy.linalg,autograd.numpy.builtins,packaging,torch,tensorflow,tensorflow.contrib,tensorflow.contrib.eager,LazyLoader,networkx,networkx.dag,math,pennylane.numpy,pennylane.numpy.random,pennylane.numpy.linalg,pennylane.numpy.builtins,pennylane.operation,rustworkx,kahypar
18+
ignored-classes=jax,numpy,scipy,autograd,toml,appdir,autograd.numpy,autograd.numpy.linalg,autograd.numpy.builtins,packaging,torch,LazyLoader,networkx,networkx.dag,math,pennylane.numpy,pennylane.numpy.random,pennylane.numpy.linalg,pennylane.numpy.builtins,pennylane.operation,rustworkx,kahypar
1919

2020
[MESSAGES CONTROL]
2121

doc/development/deprecations.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ deprecations are listed below.
99
Pending deprecations
1010
--------------------
1111

12+
* Maintenance support for the ``tensorflow`` interface has been deprecated and will be dropped in PennyLane v0.44.
13+
Future versions of PennyLane are not guaranteed to work with TensorFlow.
14+
Instead, we recommend using the :doc:`jax </introduction/interfaces/jax>` or :doc:`torch </introduction/interfaces/torch>` interface for
15+
machine learning applications to benefit from enhanced support and features.
16+
17+
- Deprecated in v0.43
18+
- Will be removed in v0.44
19+
1220
* ``pennylane.devices.DefaultExecutionConfig`` is deprecated and will be removed in v0.44.
1321
Instead, use ``qml.devices.ExecutionConfig()`` to create a default execution configuration.
1422

0 commit comments

Comments
 (0)