Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate tape and qtape properties on the QNode #6583

Open
wants to merge 26 commits into
base: master
Choose a base branch
from

Conversation

andrijapau
Copy link
Contributor

@andrijapau andrijapau commented Nov 13, 2024

Context:

The QNode currently has QNode.tape and QNode.qtape properties, which track the last tape generated during a construct call. Users can check these to verify what was executed most recently.

Now, we’ve added construct_tape(qnode)(*args, **kwargs) in the workflow module as a preferred method for constructing tapes. This function creates a tape without modifying the QNode, ensuring it doesn’t interfere with other parts of the codebase.

Description of the change

  • Hopefully removed all calls to QNode.tape and QNode.qtape in the PennyLane source code.
  • Since many tests rely on these properties to access tape information, I’ve temporarily suppressed the warnings. This needs to be revisited in the backlog and gradually updated to use the preferred code [sc-78317].

Found references in,

No references in,

  • Lightning
  • Catalyst
  • AQT
  • IONQ
  • Qulacs
  • Cirq

Benefits: Removes problems and confusion with having a mutable tape property.

Possible Drawbacks: None

[sc-76836]

@andrijapau andrijapau marked this pull request as ready for review November 13, 2024 19:28
Copy link

codecov bot commented Nov 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.30%. Comparing base (51c1436) to head (85bfe4c).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6583   +/-   ##
=======================================
  Coverage   99.29%   99.30%           
=======================================
  Files         454      454           
  Lines       43262    43262           
=======================================
+ Hits        42959    42960    +1     
+ Misses        303      302    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

tests/test_qnode.py Outdated Show resolved Hide resolved
tests/test_qnode.py Outdated Show resolved Hide resolved
tests/test_qnode.py Outdated Show resolved Hide resolved
tests/test_qnode.py Outdated Show resolved Hide resolved
andrijapau added a commit to PennyLaneAI/qml that referenced this pull request Nov 15, 2024
…1266)

Summary:

Updating deprecated code that was introduced from a recent deprecation
PennyLaneAI/pennylane#6583.

[sc-76836]
Copy link
Contributor

@albi3ro albi3ro left a comment

Choose a reason for hiding this comment

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

❤️

Copy link
Contributor

@mudit2812 mudit2812 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. There are a couple of comments that are blocking approval from me.

pennylane/workflow/qnode.py Outdated Show resolved Hide resolved

# pylint: disable=unexpected-keyword-arg
def test_no_shots_per_call_if_user_has_shots_qfunc_arg(self):
"""Tests that the per-call shots overwriting is suspended
if user has a shots argument, but a warning is raised."""
dev = qml.device("default.mixed", wires=[0, 1], shots=10)
dev = qml.device("default.qubit", wires=[0, 1], shots=10)
Copy link
Contributor

Choose a reason for hiding this comment

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

This file tests legacy devices, hence why default.mixed is used. Now that default.mixed is being ported over, we might need a different device. Maybe we should use the tests/default_qubit_legacy device? cc @albi3ro

tests/circuit_graph/test_circuit_graph.py Show resolved Hide resolved
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.

3 participants