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

Fix qml.prod when qfunc contains a single operator #5170

Merged
merged 4 commits into from
Feb 7, 2024

Conversation

albi3ro
Copy link
Contributor

@albi3ro albi3ro commented Feb 7, 2024

Context:

Found internally with the script

@qml.prod
def my_gate():
  qml.Hadamard(wires = 0)
  #qml.Hadamard(wires = 1)

dev = qml.device("default.qubit")

U = my_gate()

@qml.qnode(dev)
def circuit():

  my_gate()

  qml.ctrl(U, control = 2)

  return qml.probs(wires = [0,1,2])

qml.draw_mpl(circuit, wire_order = [0,1,2])()

Basically when a qfunc only has a single operator, it doesn't get turned into a Prod class, so it isn't re-queued.

Description of the Change:

Adds special logic for processing a qfunc with a single operator.

Benefits:

Possible Drawbacks:

Related GitHub Issues:

[sc-56341]

doc/releases/changelog-dev.md Outdated Show resolved Hide resolved
@albi3ro albi3ro requested a review from a team February 7, 2024 14:34
Co-authored-by: Mudit Pandey <mudit.pandey@xanadu.ai>
Copy link
Contributor

@astralcai astralcai 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!

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (c1a813d) 99.68% compared to head (38a0ac1) 99.68%.
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5170      +/-   ##
==========================================
- Coverage   99.68%   99.68%   -0.01%     
==========================================
  Files         394      394              
  Lines       36160    35892     -268     
==========================================
- Hits        36047    35778     -269     
- Misses        113      114       +1     

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

@albi3ro
Copy link
Contributor Author

albi3ro commented Feb 7, 2024

Screenshot 2024-02-07 at 10 31 00 AM

But the difference is one uncovered break statement in merge_rotations, which this PR certainly didn't change. So I'm overriding.

@albi3ro albi3ro merged commit ba0c1ab into master Feb 7, 2024
33 checks passed
@albi3ro albi3ro deleted the prod-single-operator-queueing branch February 7, 2024 15:31
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.

4 participants