qml.debug_probs¶
- debug_probs(wires=None, op=None)[source]¶
Compute the probability distribution for the state at the current point in the quantum circuit.
Debugging measurements do not alter the state, it remains the same until the next operation in the circuit.
- Parameters
wires (Union[Iterable, int, str, list]) – the wires the operation acts on
op (Union[Observable, MeasurementValue]) – observable (with a
diagonalizing_gates
attribute) that rotates the computational basis, or aMeasurementValue
corresponding to mid-circuit measurements.
- Returns
the probability distribution of the bitstrings for the wires
- Return type
Array(float)
Example
While in a “debugging context”, we can query the probability distribution as we would at the end of a circuit.
dev = qml.device("default.qubit", wires=2) @qml.qnode(dev) def circuit(x): qml.RX(x, wires=0) qml.Hadamard(wires=1) qml.breakpoint() qml.CNOT(wires=[0, 1]) return qml.state() circuit(1.23)
Running the above python script opens up the interactive
[pldb]
prompt in the terminal. We can query the probability distribution:[pldb] longlist 4 @qml.qnode(dev) 5 def circuit(x): 6 qml.RX(x, wires=0) 7 qml.Hadamard(wires=1) 8 9 qml.breakpoint() 10 11 -> qml.CNOT(wires=[0, 1]) 12 return qml.state() [pldb] qml.debug_probs() array([0.33355943, 0.33355943, 0.16644057, 0.16644057])