-
Notifications
You must be signed in to change notification settings - Fork 617
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
[BUG] Torch interface incompatibility with finite-shot mid-circuit measurements #5442
Closed
1 task done
Labels
bug 🐛
Something isn't working
Comments
Related to this forum post. |
CC @vincentmr. |
Different errors, but also fails for jax and tensorflow. |
albi3ro
added a commit
that referenced
this issue
Apr 1, 2024
**Context:** While investigating Issue #5442, I was getting really confused by why my tensorflow execution was giving a torch error. I realized that when the execution fails, we do not properly reset `QNode.interface` back to `"auto"`. **Description of the Change:** Pulls a block of the code to a helper method so that we can wrap it in a `try-finally` block. **Benefits:** We can continue using a qnode after a failure has occured during execution. **Possible Drawbacks:** **Related GitHub Issues:** [sc-60047] --------- Co-authored-by: Astral Cai <[email protected]>
mudit2812
added a commit
that referenced
this issue
May 24, 2024
**Context:** Opened in favour of #5630. Bug fix for #5442. This PR updates `dynamic_one_shot` so that it has better compatibility with the `torch` and `jax` interfaces. **Description of the Change:** * Change casting method from `array.astype()` to `qml.math.cast` in the `apply_operation` dispatch for `MidMeasureMP`. * Update usage of `qml.math` in `dynamic_one_shot`. * When using `qml.counts`, cast results to ints before converting to strings for lists of MCM values and floats for single MCM values. This is needed because jax arrays are not hashable, and the hash of torch tensors seems to be independent of the value(s) stored inside it. Thus, neither can be used as keys for dictionaries. **Benefits:** Better interface support with `dynamic_one_shot`. **Possible Drawbacks:** **Related GitHub Issues:** --------- Co-authored-by: Vincent Michaud-Rioux <[email protected]> Co-authored-by: Vincent Michaud-Rioux <[email protected]> Co-authored-by: Christina Lee <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Astral Cai <[email protected]> Co-authored-by: David Wierichs <[email protected]> Co-authored-by: lillian542 <[email protected]> Co-authored-by: Pietropaolo Frisoni <[email protected]> Co-authored-by: Korbinian Kottmann <[email protected]> Co-authored-by: Jay Soni <[email protected]> Co-authored-by: Guillermo Alonso-Linaje <[email protected]> Co-authored-by: Thomas R. Bromley <[email protected]> Co-authored-by: Isaac De Vlugt <[email protected]> Co-authored-by: Diksha Dhawan <[email protected]> Co-authored-by: Isaac De Vlugt <[email protected]> Co-authored-by: Diego <[email protected]> Co-authored-by: trbromley <[email protected]> Co-authored-by: erick-xanadu <[email protected]> Co-authored-by: David Ittah <[email protected]> Co-authored-by: soranjh <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Expected behavior
Able to execute the following QNode which includes:
Actual behavior
Error when following QNode is executed.
Additional information
No response
Source code
Tracebacks
System information
Existing GitHub issues
The text was updated successfully, but these errors were encountered: