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

Support Prod as observables #241

Closed
astralcai opened this issue Apr 8, 2024 · 1 comment · Fixed by #244
Closed

Support Prod as observables #241

astralcai opened this issue Apr 8, 2024 · 1 comment · Fixed by #244

Comments

@astralcai
Copy link
Contributor

astralcai commented Apr 8, 2024

Describe the feature you'd like

In the latest version of PennyLane (0.36.0-dev), new opmath is enabled by default. Observables made with @ will now be instances of Prod instead of Tensor. This will not work:

qml.expval(qml.PauliX(0) @ qml.PauliY(1))

because the pennylane-braket plugin currently do not know how to handle Prod.

Solution

In translation.py, add

@_translate_observable.register
def _(t: qml.ops.Prod):
    return reduce(lambda x, y: x @ y, [_translate_observable(factor) for factor in t.operands])

should make it work with new opmath.

@ashlhans
Copy link
Contributor

ashlhans commented Apr 8, 2024

Hi @astralcai - thank you for raising this issue! We will look into this.

@ashlhans ashlhans linked a pull request Apr 25, 2024 that will close this issue
5 tasks
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 a pull request may close this issue.

2 participants