qrunch.quantum.backends.ibm.qiskit_backend

Module with implementation of a state vector calculation in qiskit.

Classes

QiskitBackend

Class for handling Qiskit's State Vector simulator or other qiskit-compatible backends.

QiskitBackendJob

Job class for handling job on Qiskit's backend.

QiskitFakeBackend

Class for handling Qiskit's State Vector simulator.

QiskitRealBackend

Class for handling Qiskit's State Vector simulator.

class QiskitBackend

Bases: object

Class for handling Qiskit’s State Vector simulator or other qiskit-compatible backends.

static __new__(cls, qiskit_provider_backend: BackendV2, *, seed: int | None = None, compiler: Compiler | None = None, translator: Translator[QuantumCircuit] | None = None) QiskitRealBackend
static __new__(cls, qiskit_provider_backend: None = None, *, seed: int | None = None, compiler: Compiler | None = None, translator: Translator[QuantumCircuit] | None = None) QiskitFakeBackend

Initialize a State Vector Backend.

The backend calculates the full state vector of the given circuit, and uses this to find the probabilities for each possible state in the Hilbert space.

Parameters:
  • qiskit_provider_backend (BackendV2 | None) – Qiskit backend to use. If None, the state vector simulator will be used. Defaults to None.

  • seed (int | None) – Default seed for the simulator. Defaults to None

  • compiler (Compiler | None) – Compiler for changing into universal gates. the compiler must implement the to_universal_gates method. Defaults to PerGateCompiler.

  • translator (Translator[QuantumCircuit] | None) – Translator for translating universal gates to Qiskit format. Defaults to QiskitTranslator.

Return type:

QiskitRealBackend | QiskitFakeBackend

class QiskitBackendJob

Bases: BackendJob

Job class for handling job on Qiskit’s backend.

__init__(backend: QiskitRealBackend, job_id: str, qiskit_job: PrimitiveJob[PrimitiveResult[SamplerPubResult]]) None

Initialize a Qiskit job.

Parameters:
  • backend (QiskitRealBackend) – Backend used for the job.

  • job_id (str) – id of the job.

  • qiskit_job (PrimitiveJob[PrimitiveResult[SamplerPubResult]]) – Qiskit job.

Return type:

None

property backend: QiskitRealBackend

Backend used for the job.

cancel() None

Cancel the job.

Return type:

None

property job_id: str

ID of the job.

result() BackendResult

Get the result of the job.

Return type:

BackendResult

status() BackendJobStatus

Get the status of the job.

Return type:

BackendJobStatus

wait_for_final_state(timeout: float | None = None) None

Wait until the job status is in a final state, i.e., DONE, CANCELLED, or FAILED.

Parameters:

timeout (float | None) – Seconds to wait for the job. If None, wait forever.

Raises:

TimeoutError – If the job does not reach a final state before the specified timeout.

Return type:

None

class QiskitFakeBackend

Bases: Backend

Class for handling Qiskit’s State Vector simulator.

__init__(*, seed: int | None = None, compiler: Compiler | None = None, translator: Translator[QuantumCircuit] | None = None) None

Initialize a State Vector Backend.

The backend calculates the full state vector of the given circuit, and uses this to find the probabilities for each possible state in the Hilbert space.

Parameters:
  • seed (int | None) – Default seed for the simulator. Defaults to None

  • compiler (Compiler | None) – Compiler for changing into universal gates. the compiler must implement the to_universal_gates method. Defaults to PerGateCompiler.

  • translator (Translator[QuantumCircuit] | None) – Translator for translating universal gates to Qiskit format. Defaults to QiskitTranslator.

Return type:

None

property name: str

Name of the backend.

run(circuits: Circuit | Sequence[Circuit], shots: int | None) QiskitBackendJob | SimulatedJob

Run circuit on the backend.

Parameters:
  • circuits (Circuit | Sequence[Circuit]) – circuits to run on backend

  • shots (int | None) – number of shots

Return type:

QiskitBackendJob | SimulatedJob

supports_shots_equals_none() bool

Return whether the backend supports shots = None.

Return type:

bool

class QiskitRealBackend

Bases: Backend

Class for handling Qiskit’s State Vector simulator.

__init__(qiskit_provider_backend: BackendV2, *, seed: int | None = None, compiler: Compiler | None = None, translator: Translator[QuantumCircuit] | None = None) None

Initialize a State Vector Backend.

The backend calculates the full state vector of the given circuit, and uses this to find the probabilities for each possible state in the Hilbert space.

Parameters:
  • qiskit_provider_backend (BackendV2) – Qiskit backend to use.

  • seed (int | None) – Default seed for the simulator. Not used in real backends.

  • compiler (Compiler | None) – Compiler for changing into universal gates. the compiler must implement the to_universal_gates method. Defaults to PerGateCompiler.

  • translator (Translator[QuantumCircuit] | None) – Translator for translating universal gates to Qiskit format. Defaults to QiskitTranslator.

Return type:

None

get_device_data() DeviceData

Get device data if available.

Device data is only available if a Qiskit provider backend is used.

Return type:

DeviceData

property name: str

Name of the backend.

run(circuits: Circuit | Sequence[Circuit], shots: int | None) QiskitBackendJob | SimulatedJob

Run circuit on the backend.

Parameters:
  • circuits (Circuit | Sequence[Circuit]) – circuits to run on backend

  • shots (int | None) – number of shots

Return type:

QiskitBackendJob | SimulatedJob

supports_shots_equals_none() bool

Return whether the backend supports shots = None.

Qiskit’s backends requires a positive number of shots.

Return type:

bool