Note

This is the documentation for the current state of the development branch of Qiskit Experiments. The documentation or APIs here can change prior to being released.

MockIQParallelExperimentHelper

class MockIQParallelExperimentHelper(exp_list, exp_helper_list)[source]

Helper for Parallel experiment.

Parallel Experiment Helper initializer. The class assumes exp_helper_list is ordered to match the corresponding experiment in exp_list.

Note that __init__() does not have iq_cluster_centers and iq_cluster_width as in MockIQExperimentHelper.__init__(). This is because the centers and widths for MockIQParallelBackend are stored in multiple experiment helpers in the list exp_helper_list.

Parameters:
  • exp_list (List) – List of experiments.

  • exp_helper_list (List) – Ordered list of MockIQExperimentHelper corresponding to the experiments in exp_list. Nested parallel experiment aren’t supported currently.

Raises:
  • ValueError – Raised if the list are empty or if they don’t have the same length.

  • QiskitError – Raised if exp_helper_list contains an object of type MockIQParallelExperimentHelper, because the parallel mock backend currently does not support parallel sub-experiments.`.

Examples

Parallel experiment for Resonator Spectroscopy

To run a parallel experiment of Resonator Spectroscopy on two qubits we will create two instances of SpectroscopyHelper objects (for each experiment) and an instance of ParallelExperimentHelper with them.

iq_cluster_centers = [
    ((-1.0, 0.0), (1.0, 0.0)),
    ((0.0, -1.0), (0.0, 1.0)),
    ((3.0, 0.0), (5.0, 0.0)),
    ]

parallel_backend = MockIQParallelBackend(
    experiment_helper=None,
    rng_seed=0,
)
parallel_backend._configuration.basis_gates = ["x"]
parallel_backend._configuration.timing_constraints = {"granularity": 16}

# experiment parameters
qubit1 = 0
qubit2 = 1
freq01 = parallel_backend.defaults().qubit_freq_est[qubit1]
freq02 = parallel_backend.defaults().qubit_freq_est[qubit2]

# experiments initialization
frequencies1 = np.linspace(freq01 - 10.0e6, freq01 + 10.0e6, 23)
frequencies2 = np.linspace(freq02 - 10.0e6, freq02 + 10.0e6, 21)

exp_list = [
    QubitSpectroscopy(qubit1, frequencies1),
    QubitSpectroscopy(qubit2, frequencies2),
]

exp_helper_list = [
    SpectroscopyHelper(iq_cluster_centers=iq_cluster_centers,),
    SpectroscopyHelper(iq_cluster_centers=iq_cluster_centers,),
]
parallel_helper = ParallelExperimentHelper(exp_list, exp_helper_list)

parallel_backend.experiment_helper = parallel_helper

# initializing the parallel experiment
par_experiment = ParallelExperiment(exp_list, backend=parallel_backend)
par_experiment.set_run_options(meas_level=MeasLevel.KERNELED, meas_return="single")

par_data = par_experiment.run().block_for_results()

Attributes

iq_cluster_centers

The base cluster centers in the IQ plane.

iq_cluster_width

The base cluster widths in the IQ plane.

Methods

compute_probabilities(circuits)[source]

Run the compute_probabilities for each helper.

Parameters:

circuits (List[QuantumCircuit]) – The quantum circuits for which the probabilities should be computed.

Returns:

A list of dictionaries containing computed probabilities and data for the given

circuits.

Return type:

List

iq_clusters(circuits)

Returns circuit-specific IQ cluster centers and widths in the IQ plane.

Subclasses can override this function to modify the centers and widths of IQ clusters based on the circuits being simulated by a MockIQBackend. The base centers and widths are stored internally within the helper object, and can be set in __init__() or by modifying iq_cluster_centers and iq_cluster_width. The default behavior for iq_clusters() is to return the centers and widths unmodified for each circuit in circuits. Subclasses may return different centers and widths based on the circuits provided.

The returned list contains a tuple per circuit. Each tuple contains the IQ centers and widths in the same format as iq_cluster_centers and iq_cluster_width, passed as arguments to __init__(). The format of the centers and widths lists, in the argument list and in the returned tuples, must match the format of iq_cluster_centers and iq_cluster_width in qiskit_experiments.test.MockIQExperimentHelper.__init__().

Parameters:

circuits (List[QuantumCircuit]) – The quantum circuits for which the clusters should be modified.

Returns:

A list of tuples containing the circuit-specific IQ centers and widths for the

provided circuits.

Return type:

List

iq_phase(circuits)

Sub-classes can override this method to introduce a phase in the IQ plane.

This is needed, to test the resonator spectroscopy where the point in the IQ plane has a frequency-dependent phase rotation.

Return type:

List[float]