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 consistency of QNode results processing #6568

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

Conversation

andrijapau
Copy link
Contributor

Context:

The output of QNode execution was not consistent based on the type of the qfunc output,

@qml.qnode(qml.device('default.qubit'))
def circuit(t):
    return t([qml.expval(qml.Z(0))])
>>> circuit(tuple)
1.0
>>> circuit(list)
[1.0]

Description of the Change:

Update how the results of the execution get type converted based on the qfunc output type.

After this fix we get consistency,

@qml.qnode(qml.device('default.qubit'))
def circuit(t):
    return t([qml.expval(qml.Z(0))])
>>> circuit(tuple)
(1.0,)
>>> circuit(list)
[1.0]

Benefits: Consistency

Possible Drawbacks: Output of QNode execution may look different than people are used to.

[sc-77682]

@andrijapau andrijapau marked this pull request as ready for review November 11, 2024 20:34
Copy link
Contributor

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.

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.

1 participant