You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a circuit containing mid-circuit measurements with post-selection is executed with finite shots, there is always a possibility that none of the shots produced the measurement outcome that we are post-selecting on. The way we handle this scenario should be
Consistent across different error methods.
Clear to the user what is causing the error and/or invalid results.
astralcai
changed the title
[BUG] Confusing errors raised when post-selection produces no valid shots.
[BUG] Confusing errors when post-selection produces no valid shots.
Nov 1, 2024
Expected behavior
When a circuit containing mid-circuit measurements with post-selection is executed with finite shots, there is always a possibility that none of the shots produced the measurement outcome that we are post-selecting on. The way we handle this scenario should be
Actual behavior
Consider the following circuit:
When we use dynamic one-shot, the circuit executes to completion and returns
nan
:With tree-traversal, we now get an error:
With deferred measurement, we get a different error:
This can be difficult to debug for a user with complex circuits.
Additional information
No response
Source code
No response
Tracebacks
No response
System information
Name: PennyLane Version: 0.39.0.dev31 Summary: PennyLane is a cross-platform Python library for quantum computing, quantum machine learning, and quantum chemistry. Train a quantum computer the same way as a neural network. Home-page: https://github.com/PennyLaneAI/pennylane Author: Author-email: License: Apache License 2.0 Location: /Users/astral.cai/Workspace/pennylane Requires: appdirs, autograd, autoray, cachetools, networkx, numpy, packaging, pennylane-lightning, requests, rustworkx, scipy, toml, typing_extensions Required-by: PennyLane-Catalyst, PennyLane_Lightning, PennyLane_Lightning_Kokkos Platform info: macOS-15.1-arm64-arm-64bit Python version: 3.10.14 Numpy version: 1.26.4 Scipy version: 1.12.0 Installed devices: - default.clifford (PennyLane-0.39.0.dev31) - default.gaussian (PennyLane-0.39.0.dev31) - default.mixed (PennyLane-0.39.0.dev31) - default.qubit (PennyLane-0.39.0.dev31) - default.qutrit (PennyLane-0.39.0.dev31) - default.qutrit.mixed (PennyLane-0.39.0.dev31) - default.tensor (PennyLane-0.39.0.dev31) - null.qubit (PennyLane-0.39.0.dev31) - reference.qubit (PennyLane-0.39.0.dev31) - lightning.qubit (PennyLane_Lightning-0.39.0.dev48) - nvidia.custatevec (PennyLane-Catalyst-0.9.0.dev41) - nvidia.cutensornet (PennyLane-Catalyst-0.9.0.dev41) - oqc.cloud (PennyLane-Catalyst-0.9.0.dev41) - softwareq.qpp (PennyLane-Catalyst-0.9.0.dev41) - lightning.kokkos (PennyLane_Lightning_Kokkos-0.39.0.dev38)
Existing GitHub issues
The text was updated successfully, but these errors were encountered: