qml.iterative_qpe¶
- iterative_qpe(base, aux_wire='unset', iters='unset', ancilla='unset')[source]¶
Performs the iterative quantum phase estimation circuit.
Given a unitary \(U\), this function applies the circuit for iterative quantum phase estimation and returns a list of mid-circuit measurements with qubit reset.
Warning
The
ancilla
argument below is deprecated and will be removed in v0.40. Theaux_wire
argument should be used instead. If both arguments are provided,aux_wire
will be used andancilla
will be ignored.- Parameters
base (Operator) – the phase estimation unitary, specified as an
Operator
aux_wire (Union[Wires, int, str]) – the wire to be used for the estimation
iters (int) – the number of measurements to be performed
ancilla (Union[Wires, int, str]) – The wire to be used for the estimation. This argument is deprecated.
- Returns
the list of measurements performed
- Return type
list[MidMeasureMP]
See also
Example
dev = qml.device("default.qubit", shots=5) @qml.qnode(dev) def circuit(): # Initial state qml.X(0) # Iterative QPE measurements = qml.iterative_qpe(qml.RZ(2.0, wires=[0]), aux_wire=1, iters=3) return qml.sample(measurements)
>>> print(circuit()) [[0 0 1] [0 0 1] [0 0 1] [1 1 1] [0 0 1]]
The output is an array of size
(number of shots, number of iterations)
.>>> print(qml.draw(circuit, max_length=150)()) 0: ──X─╭RZ(2.00)⁴─────────────────╭RZ(2.00)²────────────────────────────╭RZ(2.00)¹────────────────────────────────────┤ 1: ──H─╰●──────────H──┤↗│ │0⟩──H─╰●──────────Rϕ(-1.57)──H──┤↗│ │0⟩──H─╰●──────────Rϕ(-1.57)──Rϕ(-0.79)──H──┤↗│ │0⟩─┤ ╚══════════════════════╩══════════════║══════════════════════║══════════╩══════════════║═══════╡ ╭Sample[MCM] ╚══════════════════════╩═════════════════════════║═══════╡ ├Sample[MCM] ╚═══════╡ ╰Sample[MCM]