qiu_quantum_computing.phase_propagator.sample_based
¶
Sample-based phase propagators, applying e^(i f(x)) for a signal f of one sign.
The signal is split into its sum alpha and the state |phi> = sqrt(f / alpha) by
sample_based_decomposition, so that f = alpha |phi|^2. Each cycle of the protocol
prepares |phi> in a second register, applies the phase e^(i delta) where both
registers are in the same basis state (partial_phase_circuit), un-prepares |phi>
and measures the second register. On success, i.e. measuring |0...0>, the amplitudes
psi_j of the first register are mapped to psi_j (1 + (e^(i delta) - 1) |phi_j|^2),
which is e^(i delta |phi_j|^2) psi_j up to O(delta^2). Slicing alpha into small
deltas thus applies e^(i alpha |phi|^2) = e^(i f).
Classes:
-
GenericIterativeSampleBasedPhasePropagator–A sample-based phase propagator with one cycle per delta.
-
GenericIterativeSampleBasedPhasePropagatorWithConstantDelta–A sample-based phase propagator repeating one delta in a loop.
-
QuadraticSignalSampleBasedPhasePropagator–The sample-based phase propagator applying
e^(i f(x))for a signalf.
Functions:
-
sample_based_decomposition–Split a real signal of one sign into its sum and a normalized state.
-
slice_alpha_to_deltas_evenly–Slice
alphainto the fewest equal deltas of magnitude at mostmax_delta. -
partial_phase_diagonal–Return the diagonal of the unitary of
partial_phase_circuit. -
partial_phase_circuit–Return the phase
e^(i delta)on the basis states where both registers agree. -
propagator_registers–Return the registers of a propagator:
psi,phiand the success flags.
GenericIterativeSampleBasedPhasePropagator
¶
GenericIterativeSampleBasedPhasePropagator(deltas: NDArray | list[float], U_phi: QuantumCircuit, U_phi_dagger: QuantumCircuit, take_snapshot: bool = False)
Bases: QuantumCircuit
A sample-based phase propagator with one cycle per delta.
Each cycle only runs if all previous ones succeeded, i.e. measured the phi
register in |0...0>. The phi register is reset after each cycle.
Parameters:
-
deltas(NDArray | list[float]) –The phase of each cycle.
-
U_phi(QuantumCircuit) –The circuit preparing
|phi>from|0...0>. -
U_phi_dagger(QuantumCircuit) –The inverse of
U_phi. -
take_snapshot(bool, default:False) –If True, save the statevector after each cycle, labeled by the cycle index (Aer simulators only).
Methods:
-
from_state–Create the propagator for the preparable state
|phi>.
Attributes:
-
num_of_cycles(int) –The number of cycles.
Source code in packages/qiu-quantum-computing/src/qiu_quantum_computing/phase_propagator/sample_based.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | |
from_state
classmethod
¶
from_state(state: PreparableState, deltas: NDArray | list[float]) -> GenericIterativeSampleBasedPhasePropagator
Create the propagator for the preparable state |phi>.
Source code in packages/qiu-quantum-computing/src/qiu_quantum_computing/phase_propagator/sample_based.py
197 198 199 200 201 202 203 204 | |
GenericIterativeSampleBasedPhasePropagatorWithConstantDelta
¶
GenericIterativeSampleBasedPhasePropagatorWithConstantDelta(delta: float, number_of_cycles: int, U_phi: QuantumCircuit, U_phi_dagger: QuantumCircuit)
Bases: QuantumCircuit
A sample-based phase propagator repeating one delta in a loop.
The loop breaks at the first failed cycle, i.e. when the phi register is not
measured in |0...0>.
Parameters:
-
delta(float) –The phase of each cycle.
-
number_of_cycles(int) –The number of cycles.
-
U_phi(QuantumCircuit) –The circuit preparing
|phi>from|0...0>. -
U_phi_dagger(QuantumCircuit) –The inverse of
U_phi.
Methods:
-
from_state–Create the propagator for the preparable state
|phi>.
Attributes:
-
num_of_cycles(int) –The number of cycles.
Source code in packages/qiu-quantum-computing/src/qiu_quantum_computing/phase_propagator/sample_based.py
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 | |
from_state
classmethod
¶
from_state(state: PreparableState, delta: float, number_of_cycles: int) -> GenericIterativeSampleBasedPhasePropagatorWithConstantDelta
Create the propagator for the preparable state |phi>.
Source code in packages/qiu-quantum-computing/src/qiu_quantum_computing/phase_propagator/sample_based.py
249 250 251 252 253 254 255 256 257 258 259 | |
QuadraticSignalSampleBasedPhasePropagator
¶
QuadraticSignalSampleBasedPhasePropagator(signal: SampledSignal, max_delta: float, method: SynthesisMethod = GATE)
Bases: QuantumCircuit
The sample-based phase propagator applying e^(i f(x)) for a signal f.
The signal is decomposed as f = alpha |phi|^2 by sample_based_decomposition,
and alpha is sliced into equal deltas of magnitude at most max_delta.
Parameters:
-
signal(SampledSignal) –The real signal
fof one sign, on an axis of2**nsamples. -
max_delta(float) –The maximum phase per cycle.
-
method(SynthesisMethod, default:GATE) –How the preparation of
|phi>is represented in the circuit.
Attributes:
-
num_of_cycles(int) –The number of cycles.
Source code in packages/qiu-quantum-computing/src/qiu_quantum_computing/phase_propagator/sample_based.py
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 | |
sample_based_decomposition
¶
sample_based_decomposition(signal: SampledSignal) -> tuple[float, Statevector]
Split a real signal of one sign into its sum and a normalized state.
Parameters:
-
signal(SampledSignal) –The signal
f, real and either non-negative or non-positive, on an axis of2**nsamples.
Returns:
-
float–The sum
alphaof the samples and the statesqrt(f / alpha), such that -
Statevector–f = alpha |state|^2.
Raises:
-
ValueError–If the axis does not have
2**nsamples withn >= 1, or if the signal is not real, has samples of both signs, or vanishes.
Source code in packages/qiu-quantum-computing/src/qiu_quantum_computing/phase_propagator/sample_based.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
slice_alpha_to_deltas_evenly
¶
Slice alpha into the fewest equal deltas of magnitude at most max_delta.
Parameters:
-
alpha(float) –The total phase coefficient to slice.
-
max_delta(float) –The positive maximum magnitude of each delta.
Returns:
-
NDArray–The equal deltas summing up to
alpha, none ifalphais 0.
Raises:
-
ValueError–If
max_deltais not positive.
Source code in packages/qiu-quantum-computing/src/qiu_quantum_computing/phase_propagator/sample_based.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | |
partial_phase_diagonal
¶
partial_phase_diagonal(delta: float, num_qubits: int) -> NDArray[complex128]
Return the diagonal of the unitary of partial_phase_circuit.
The entry of |j>|l>, at index l * 2**n + j, is e^(i delta [j == l]).
Parameters:
Returns:
-
NDArray[complex128]–The
4**ndiagonal entries.
Source code in packages/qiu-quantum-computing/src/qiu_quantum_computing/phase_propagator/sample_based.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | |
partial_phase_circuit
¶
partial_phase_circuit(delta: float, num_qubits: int) -> QuantumCircuit
Return the phase e^(i delta) on the basis states where both registers agree.
The circuit acts on the registers psi (qubits 0, ..., n-1) and phi (qubits
n, ..., 2n-1) and maps |j>|l> to e^(i delta [j == l]) |j>|l>.
Parameters:
Returns:
-
QuantumCircuit–The circuit on
2nqubits.
Source code in packages/qiu-quantum-computing/src/qiu_quantum_computing/phase_propagator/sample_based.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | |
propagator_registers
¶
propagator_registers(num_qubits: int) -> tuple[QuantumRegister, QuantumRegister, ClassicalRegister]
Return the registers of a propagator: psi, phi and the success flags.
Source code in packages/qiu-quantum-computing/src/qiu_quantum_computing/phase_propagator/sample_based.py
144 145 146 147 148 149 150 151 152 | |