quiche.resources#
Logic for the resource-estimation backend of QUICHE.
Logical costs#
Resource calculations for quantum circuits and routines.
- logical_gate_resources(circuit)#
Calculate estimated logical gate cost of a bloq provided an error budget.
- Return type:
GateCounts
- logical_qubit_resources(circuit)#
Calculate estimated logical gate cost of a bloq provided an error budget.
- Return type:
- logical_rotations_to_tgates(gates, errors, rotation_synthesis)#
Transform rotation gates to T gates according to the error budget.
- Return type:
GateCounts
Bloqs#
Core Qualtran routines (Bloqs) used for resource estimation.
Phase estimation#
Quantum phase estimation routines.
- class NaiveQPE(simulation, mode)#
Naive, single-ancilla phase estimation (Hadamard test).
Uses a controlled application of the propagator U to estimate its expectation value in a provided initial state. Only one ancilla is used during the Hadamard test.
If the measurement mode is “re”, the bloq represents the following circuit:
|0> ------H------•--------H----- meas | |psi> -------------U--------------
and if it is “im”, the bloq represents the following circuit:
|0> ---H---S†----•------- H ---- meas | |psi> -------------U--------------
- Properties:
simulation (Bloq) – Bloq implementing the Hamiltonian simulation.
mode ({‘re’, ‘im’}) – Specifies whether to measure the real or imaginary part of the expectation value.
Resources
The bloq uses simulation qubits and a single ancilla qubit.
- class KitaevQPE(simulation, k, mode)#
Kitaev single-ancilla phase estimation.
For a unitary operator U and an initial state that approximates some eigenstate
|psi>, estimate the phase theta inU|psi> = e^{2 pi i theta} |psi>. The Kitaev QPE estimates the k-th digit of the phase by applying the propagator U^(2^k) for increasing k values. This bloq implements the QPE for a single selection of k. It needs to be called multiple times with different k values to reflect a full phase estimation.If the measurement mode is “re”, the bloq represents the following circuit:
|0> ------H------•--------H----- meas | |psi> -------------U^(2^k)--------
and if it is “im”, the bloq represents the following circuit:
|0> ---H---S†----•------- H ---- meas | |psi> -------------U^(2^k)--------
- Properties:
simulation (Bloq) – Bloq implementing the Hamiltonian simulation.
k (int) – Controls the exponent of the propagator U as described above.
mode ({‘re’, ‘im’}) – Specifies whether to measure the real or imaginary part of the expectation value.
Resources
The bloq uses simulation qubits and a single ancilla qubit.
- class IterativeQPE(simulation, k, mode)#
Iterative phase estimation.
For a unitary operator U and an initial state that approximates some eigenstate
|psi>, estimate the phase theta inU|psi> = e^{2 pi i theta} |psi>. In iterative QPE, a rotation around z is inserted between the controlled propagator and the second Hadamard gate. The rotation angle depends on previous measurements, which we cannot evaluate in Qualtran. Instead we use symbolic angles. This bloq implements the QPE for a single selection of k. It needs to be called multiple times with different k values to reflect a full phase estimation.If the measurement mode is “re”, the bloq represents the following circuit:
|0> ------H------•----Rz----H----- meas | |psi> -------------U^(2^k)----------
and if it is “im”, the bloq represents the following circuit:
|0> ---H---S†----•----Rz---H---- meas | |psi> -------------U^(2^k)----------
- Properties:
simulation (Bloq) – Bloq implementing the Hamiltonian simulation.
k (int) – Controls the exponent of the propagator U as described above.
mode ({‘re’, ‘im’}) – Specifies whether to measure the real or imaginary part of the expectation value.
Resources
The bloq uses simulation qubits and a single ancilla qubit.
- class TextbookQPE(simulation_factory, num_data, num_qpe_ancillas, num_other_ancillas)#
End-to-end QPE routine including state preparation, simulation and QFT.
- property signature: Signature#
Define input and/or output registers of the bloq.
- build_composite_bloq(bb, **soqs)#
Implement bloq decomposition into sub-bloqs.
- class TrotterLadder(index, simulation, num_data, num_qpe_ancillas)#
Routine to construct controlled Trotter evolution operator as needed for QPE.
- property signature: Signature#
Define input and/or output registers of the bloq.
- build_composite_bloq(bb, **soqs)#
Implement bloq decomposition into sub-bloqs.
- class QubitisationLadder(index, walk, num_data, num_qpe_ancillas, num_selection_ancillas)#
Routine to construct controlled Qubitisation operator as needed for QPE.
- property signature: Signature#
Define input and/or output registers of the bloq.
- build_composite_bloq(bb, **soqs)#
Implement bloq decomposition into sub-bloqs.
Hamiltonian simulation#
Hamiltonian simulation routines.
- class SelectPauliLCUWrapper(selection_bitsize, target_bitsize, select_unitaries, control_val=None)#
Wrapper for SelectPauliLCU for resource counting.
- class LCUBlockEncodingWrapper(select, prepare, control_val=None)#
Class that welds the Qualtran to the QUICHE bloq.
- classmethod from_hamiltonian(h, phase_bitsize)#
Process the input arguments and return an LCU block encoding.
- Return type:
Self
- class PauliWordRotation(word, angle, n_qubits, is_controlled=False)#
Routine constructing the Pauli phasor for a given Pauli.
- property signature: Signature#
Define input and/or output registers of the bloq.
- get_ctrl_system(ctrl_spec)#
Override function to get controlled bloq.
- Return type:
tuple[Bloq, AddControlledT]
- build_composite_bloq(bb, **soqs)#
Implement bloq decomposition into sub-bloqs.
- class QDRIFT(h, t, n_terms, seed, is_controlled=False)#
QDRIFT implementation for a given linear combination of Paulis.
- property signature: Signature#
Define input and/or output registers of the bloq.
- get_ctrl_system(ctrl_spec)#
Override function to get controlled bloq.
- Return type:
tuple[Bloq, AddControlledT]
- build_composite_bloq(bb, **soqs)#
Implement bloq decomposition into sub-bloqs.
- class Trotterisation(h, t, n_steps, order, is_controlled=False)#
General Trotter product formulae.
- property signature: Signature#
Define input and/or output registers of the bloq.
- get_ctrl_system(ctrl_spec)#
Override function to get controlled bloq.
- Return type:
tuple[Bloq, AddControlledT]
- get_coeffs_indices(order=None)#
Return the coefficients and indices for the Trotter product.
- Return type:
tuple[NDArray[np.float64], NDArray[np.int_]]
- build_composite_bloq(bb, **soqs)#
Implement the decomposition into sub-bloqs.
State preparation#
State preparation routines.
- class IdentityStatePrep(n_qubits)#
Routine for trivial state preparation.
- property signature: Signature#
Define input and/or output registers of the bloq.
- build_composite_bloq(bb, **_soqs)#
Implement bloq decomposition into sub-bloqs.
- class BitstringStatePrep(bitstring)#
Routine to prepare an arbitrary computational basis state.
- property signature: Signature#
Define input and/or output registers of the bloq.
- build_composite_bloq(bb, **soqs)#
Implement bloq decomposition into sub-bloqs.
- class PrepareFromStatePrep(stateprep, phase_bitsize, select_nqubits)#
PREP routine for a given phase-gradient state preparation bloq.
Implements the action
PREP |0> = \sum_{j=1}^L c_j |j>.- Properties:
stateprep (StatePreparationViaRotations) – State preparation bloq.
phase_bitsize (int) – Number of qubits used for phase gradient.
select_nqubits (int) – Number of qubits on which to prepare the PREP state. Note that L must be equal to
2**select_nqubits.
- build_prepare_circuit()#
Get the state preparation bloq. Required by the PrepareOracle interface.
- Return type:
Bloq
- build_composite_bloq(bb, **soqs)#
Implement decomposition into sub-bloqs using stateprep bloq decomposition.
- build_call_graph(ssa)#
Build call graph for PrepareFromStatePrep.