qbench.schemes
package#
qbench.scheme.postselection
module#
Module implementing postselection experiment.
- qbench.schemes.postselection.assemble_postselection_circuits(target, ancilla, state_preparation, u_dag, v0_dag, v1_dag)#
Assemble circuits required for running Fourier discrimination experiment using postselection.
- Parameters:
target (int) – index of qubit measured either in Z-basis or the alternative one.
ancilla (int) – index of auxiliary qubit.
state_preparation (Instruction) – instruction preparing the initial state of both qubits.
u_dag (Instruction) – hermitian adjoint of matrix U s.t. i-th column corresponds to i-th effect of alternative measurement. Can be viewed as matrix for a change of basis in which measurement is being performed.
v0_dag (Instruction) – hermitian adjoint of positive part of Holevo-Helstrom measurement.
v1_dag (Instruction) – hermitian adjoint of negative part of Holevo-Helstrom measurement.
- Returns:
dictionary with keys “id_v0”, “id_v1”, “u_v0”, “u_v1” mapped to corresponding circuits. (e.g. id_v0 maps to a circuit with identity measurement followed by v0 measurement on ancilla)
- Return type:
Dict[str, QuantumCircuit]
- qbench.schemes.postselection.benchmark_using_postselection(backend, target, ancilla, state_preparation, u_dag, v0_dag, v1_dag, num_shots_per_measurement)#
Estimate prob. of distinguishing between measurements in computational and other basis.
- Parameters:
backend (Union[BackendV1, BackendV2]) – backend to use for sampling.
target (int) – index of qubit measured either in Z-basis or the alternative one.
ancilla (int) – index of auxiliary qubit.
state_preparation (Instruction) – instruction preparing the initial state of both qubits.
u_dag (Instruction) – hermitian adjoint of matrix U s.t. i-th column corresponds to i-th effect of alternative measurement. Can be viewed as matrix for a change of basis in which measurement is being performed.
v0_dag (Instruction) – hermitian adjoint of positive part of Holevo-Helstrom measurement.
v1_dag (Instruction) – hermitian adjoint of negative part of Holevo-Helstrom measurement.
num_shots_per_measurement (int) – number of shots to be performed for Z-basis and alternative measurement. Since each measurement on target qubit is combined with each measurement on ancilla qubit, the total number of shots done in the experiment is 4 * num_shots_per_measurement.
- Returns:
estimated probability of distinguishing between computational basis and alternative measurement.
- Return type:
float
Note
The circuits used for sampling have the form::
┌────────────────────┐ ┌─────┐ target: ┤0 ├─┤ Mi† ├ │ state_preparation │ ├─────┤ ancilla: ┤1 ├─┤ Vj† ├ └────────────────────┘ └─────┘
for i=0,1, j=0,1 where M0 = U, M1 = identity. Refer to the paper for details how the terminal measurements are interpreted.
- qbench.schemes.postselection.compute_probabilities_from_postselection_measurements(id_v0_counts, id_v1_counts, u_v0_counts, u_v1_counts)#
Convert measurements obtained from postselection Fourier discrimination experiment to probabilities.
- Parameters:
id_v0_counts (Dict[str, int]) – measurements for circuit with identity measurement on target and v0 measurement on ancilla.
id_v1_counts (Dict[str, int]) – measurements for circuit with identity measurement on target and v1 measurement on ancilla.
u_v0_counts (Dict[str, int]) – measurements for circuit with U measurement on target and v0 measurement on ancilla.
u_v1_counts (Dict[str, int]) – measurements for circuit with U measurement on target and v1 measurement on ancilla.
- Returns:
probability of distinguishing between u and identity measurements.
- Return type:
float
qbench.scheme.direct_sum
module#
Module implementing experiment using direct sum of V0† ⊕ V1†.
- qbench.schemes.direct_sum.assemble_direct_sum_circuits(target, ancilla, state_preparation, u_dag, v0_v1_direct_sum_dag)#
Assemble circuits required for running Fourier discrimination experiment using direct-sum.
- Parameters:
target (int) – index of qubit measured either in Z-basis or the alternative one.
ancilla (int) – index of auxiliary qubit.
state_preparation (Instruction) – instruction preparing the initial state of both qubits.
u_dag (Instruction) – hermitian adjoint of matrix U s.t. i-th column corresponds to i-th effect of alternative measurement. Can be viewed as matrix for a change of basis in which measurement is being performed.
v0_v1_direct_sum_dag (Instruction) – block-diagonal operator comprising hermitian adjoints of both parts of Holevo-Helstrom measurement.
- Returns:
dictionary with keys “id”, “u”mapped to corresponding circuits. The “u” key corresponds to a circuit for which U measurement has been performed, while “id” key corresponds to a circuit for which identity measurement has been performed.
- Return type:
Dict[str, QuantumCircuit]
- qbench.schemes.direct_sum.benchmark_using_direct_sum(backend, target, ancilla, state_preparation, u_dag, v0_v1_direct_sum_dag, num_shots_per_measurement)#
Estimate prob. of distinguishing between measurements in computational and other basis.
- Parameters:
backend (Union[BackendV1, BackendV2]) – backend to be used for sampling.
target (int) – index of qubit measured either in computational basis or the alternative one.
ancilla (int) – index of auxiliary qubit.
state_preparation (Instruction) – instruction preparing the initial state of both qubits.
u_dag (Instruction) – hermitian adjoint of matrix U s.t. i-th column corresponds to i-th effect of alternative measurement. Can be viewed as matrix for a change of basis in which measurement is being performed.
v0_v1_direct_sum_dag (Instruction) – block-diagonal operator comprising hermitian adjoints of both parts of Holevo-Helstrom measurement.
num_shots_per_measurement (int) – number of shots to be performed for computational basis and alternative measurement. The total number of shots done in the experiment is therefore 2 * num_shots_per_measurement.
- Returns:
estimated probability of distinguishing between computational basis and alternative measurement.
- Return type:
float
Note
The circuits used for sampling have the form:
┌────────────────────┐┌────┐┌────────────┐ target: ┤0 ├┤ M† ├┤0 ├─ │ state_preparation │└────┘│ V0† ⊕ V1† │ ancilla: ┤1 ├──────┤1 ├─ └────────────────────┘ └────────────┘
where M defines the measurement to be performed (M=identity or M=U†). Refer to the paper for details how the final measurements are interpreted.
- qbench.schemes.direct_sum.compute_probabilities_from_direct_sum_measurements(id_counts, u_counts)#
Convert measurements obtained from direct_sum Fourier experiment to probabilities.
- Parameters:
id_counts (Dict[str, int]) – measurements for circuit with identity measurement on target qubit.
u_counts (Dict[str, int]) – measurements for circuit with U measurement on target qubit.
- Returns:
probability of distinguishing between u and identity measurements.
- Return type:
float