qolumbina.utils.backend_execution module#

class ShotBasedBackend(qc, backend, noise_model, shots, if_noisy, random_seed=None)[source]#

Bases: object

Execute QuantumCircuit on a Qiskit backend (Qiskit 2.0 compatible) and return measurement outcomes via multiple shots.

This class supports both ideal and noisy backends. For noisy backends, users can either use the default noise model derived from the fake backend or provide a custom noise model.

Note

Regarding the scenario of quantum software testing, using this backend indicates that the test technique under evaluation is expected to work in a real (future) quantum computers. In this situation, quantum measurements are necessary to extract classical information from quantum states.

Parameters:
  • qc (QuantumCircuit) – The quantum circuit to be executed.

  • backend (str) –

    Backend name for circuit execution. Supported backends include:

    • "ideal" -> ideal AerSimulator

    • "fake_xxx" -> AerSimulator with FakeBackend

    See the complete list of fake backends: Fake Backends.

  • noise_model (NoiseModel | None) – Optional custom NoiseModel

  • shots (int) – The number of quantum measurements per circuit execution.

  • if_noisy (bool) – Whether to enable noise when using fake backend. Ignored for “ideal” backend.

  • random_seed (int | None) – Optional random seed for simulator to ensure reproducibility.

Raises:

TypeError – If backend is not a string.

Note

For “ideal” backend, noise_model is ignored and if_noisy is always False.

property backend#
property noise_model: NoiseModel | None#
property whether_noisy: bool#
class ShotIndependentBackend(qc, backend)[source]#

Bases: object

Execute QuantumCircuit on a Qiskit backend (Qiskit 2.0 compatible) and return exact mathematical objects for analytical / exact quantum simulation.

Therefore, this class is only suitable for ideal simulation scenarios without quantum measurements.

Note

Regarding the scenario of quantum software testing, using this backend indicates that the test technique under evaluation is expected to merely work in classical computers but not necessarily in real quantum computers. This holds true in current NISQ era where quantum noise is inevitable and the accessiblity to real quantum hardware is limited. To this end, this class provides a convenient way to check the correctness of quantum software in an ideal setting, which can be easily achieved by classical simulation.

Parameters:
  • qc (QuantumCircuit) – The QuantumCircuit to be executed.

  • backend (str) –

    Backend name for circuit execution. Supported backends:

    • "statevector"

    • "unitary"

    • "density_matrix"

Raises:

TypeError – If backend is not a string.

property backend: AerSimulator | None#