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

Catalyst support for qml.CosineWindow #6318

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

Conversation

willjmax
Copy link
Contributor

@willjmax willjmax commented Oct 1, 2024

Compiling a circuit with QJIT that begins with a CosineWindow state preparation results in a compiler error. This is because Catalyst has optimizations for when the first operation is a state preparation, but these optimizations are not supported for CosineWindow. A workaround is to only perform the state preparation optimizations on the StatePrep and BasisState classes, rather than the more general StatePrepBase class.

This workaround requires additional changes to Catalyst (PR #1166) and PennyLane lightning (PR #929).

Copy link
Contributor

github-actions bot commented Oct 1, 2024

Hello. You may have forgotten to update the changelog!
Please edit doc/releases/changelog-dev.md with:

  • A one-to-two sentence description of the change. You may include a small working example for new features.
  • A link back to this PR.
  • Your name (or GitHub username) in the contributors section.

Copy link

codecov bot commented Oct 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.70%. Comparing base (d9e833a) to head (27f2ca7).
Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6318   +/-   ##
=======================================
  Coverage   99.70%   99.70%           
=======================================
  Files         445      445           
  Lines       42260    42264    +4     
=======================================
+ Hits        42137    42141    +4     
  Misses        123      123           

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

Comment on lines -360 to +361
if tape.operations and isinstance(tape[0], StatePrepBase) and skip_initial_state_prep:
if tape.operations and isinstance(tape[0], (StatePrep, BasisState)) and skip_initial_state_prep:
Copy link
Contributor

Choose a reason for hiding this comment

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

It is better to update Catalyst to target the more general base class StatePrepBase instead of changing this here. Alternatively, we might include all 3 state prep classes in this condition.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Including all three state prep classes would reintroduce the bug. The issue is that CosineWindow inherits from StatePrepBase, so Catalyst will attempt to optimize it.

Copy link
Contributor

Choose a reason for hiding this comment

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

What if CosineWindow inherits from StatePrep? Does it solve the problem?

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