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

Merged
merged 33 commits into from
Nov 18, 2024

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]

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@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.45%. Comparing base (8df1025) to head (8d421d2).
Report is 311 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6583   +/-   ##
=======================================
  Coverage   99.44%   99.45%           
=======================================
  Files         450      450           
  Lines       42088    42088           
=======================================
+ Hits        41856    41857    +1     
+ Misses        232      231    -1     

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

andrijapau and others added 7 commits November 14, 2024 11:53
Co-authored-by: Christina Lee <christina@xanadu.ai>
Co-authored-by: Christina Lee <christina@xanadu.ai>
Co-authored-by: Christina Lee <christina@xanadu.ai>
Co-authored-by: Christina Lee <christina@xanadu.ai>
Co-authored-by: Christina Lee <christina@xanadu.ai>
Co-authored-by: Christina Lee <christina@xanadu.ai>
Co-authored-by: Christina Lee <christina@xanadu.ai>
@andrijapau andrijapau requested a review from albi3ro November 14, 2024 21:34
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.

❤️

Co-authored-by: Mudit Pandey <mudit.pandey@xanadu.ai>
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.

Co-authored-by: Mudit Pandey <mudit.pandey@xanadu.ai>
@andrijapau andrijapau requested a review from mudit2812 November 18, 2024 15:03
@andrijapau andrijapau enabled auto-merge (squash) November 18, 2024 18:11
@andrijapau andrijapau disabled auto-merge November 18, 2024 18:25
@andrijapau andrijapau merged commit 9a3dbdd into master Nov 18, 2024
46 checks passed
@andrijapau andrijapau deleted the deprecate-tape-properties branch November 18, 2024 19:51
andrijapau added a commit that referenced this pull request Dec 18, 2024
**Context:**

Many tests incorrectly rely on the `tape` and `qtape` properties to
access information during tests. With these properties deprecated in
#6583, deprecation warnings in the affected test files have been
suppressed. This PR aims to replace all instances of deprecated code
with the correct code.

**Description of the Change:** 

Tests should construct the tape dynamically using `construct_tape`
rather than use the deprecated properties.

**Benefits:** Better testing and code maintainability.

**Possible Drawbacks:** 

I’m still a bit unsure about the changes in
tests/workflow/interfaces/qnode/. The lines I deleted were originally a
workaround to further verify QNode interfacing. However, the primary
goal of the tests in this folder isn’t to check gradient accuracy but
rather to ensure proper interfacing with the QNode architecture (e.g.,
verifying data types and result shapes). Since the property being used
should now be considered private, relying on it in tests isn’t best
practice—hence the deletion.

[sc-78317]

---------

Co-authored-by: Pietropaolo Frisoni <pietropaolo.frisoni@xanadu.ai>
willjmax pushed a commit that referenced this pull request Feb 4, 2025
**Context:**

Many tests incorrectly rely on the `tape` and `qtape` properties to
access information during tests. With these properties deprecated in
#6583, deprecation warnings in the affected test files have been
suppressed. This PR aims to replace all instances of deprecated code
with the correct code.

**Description of the Change:** 

Tests should construct the tape dynamically using `construct_tape`
rather than use the deprecated properties.

**Benefits:** Better testing and code maintainability.

**Possible Drawbacks:** 

I’m still a bit unsure about the changes in
tests/workflow/interfaces/qnode/. The lines I deleted were originally a
workaround to further verify QNode interfacing. However, the primary
goal of the tests in this folder isn’t to check gradient accuracy but
rather to ensure proper interfacing with the QNode architecture (e.g.,
verifying data types and result shapes). Since the property being used
should now be considered private, relying on it in tests isn’t best
practice—hence the deletion.

[sc-78317]

---------

Co-authored-by: Pietropaolo Frisoni <pietropaolo.frisoni@xanadu.ai>
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.

None yet

3 participants