API reference

Everything below imports from qiskit_maestro. The Guide explains the options in more detail.

Backend

class MaestroBackend(*, name='maestro_simulator', service=None, **options)

Run Qiskit circuits on the Maestro simulator.

A drop-in for AerSimulator. Options use Aer’s names where the concept is the same, and Aer’s longer MPS option names are accepted as aliases.

Parameters:
  • method – "statevector" (default), "matrix_product_state" (or "mps"), "stabilizer", "extended_stabilizer", "density_matrix", "tensor_network", "pauli_propagation" or "automatic", which picks the density matrix for small noisy circuits as Aer does, and the statevector otherwise.

  • device – "CPU" (default) or "GPU". A GPU run needs Maestro’s GPU plugin and licence, and raises rather than falling back to the CPU.

  • precision – "double" (default) or "single".

  • seed_simulator – Seed for reproducible sampling.

  • max_bond_dimension – Cap on the MPS bond dimension. Aer’s name, matrix_product_state_max_bond_dimension, also works.

  • truncation_threshold – MPS truncation threshold, as discarded weight. Aer’s name, matrix_product_state_truncation_threshold, also works.

  • max_parallel_experiments – Threads for running circuits side by side. 0 (default) picks a number, 1 runs them one at a time.

  • maestro_options – Other maestro.SimulatorConfig fields, passed through unchanged.

  • noise_model – A qiskit_aer.noise.NoiseModel. Its errors are applied where Aer applies them, and the target then uses its basis gates, as AerSimulator(noise_model=...)’s does. An error Maestro can’t reproduce exactly raises UnsupportedNoiseError.

  • shots – Default shots for run() (1024).

  • memory – Whether run() returns per-shot results by default (False).

  • service – A divi.backends.QoroService to run on the Qoro cloud. run() then submits one cloud job and returns a QoroCloudJob at once. None (default) runs locally. On the cloud, circuits can’t have classical control, save instructions or a noise model yet.

property service

The QoroService the backend runs on, or None when it runs locally.

set_options(**fields)

Change options, as on AerSimulator.

Parameters:

fields – shots, memory or any option the constructor takes. Setting noise_model also changes the target’s basis gates.

Raises:
  • ValueError – for an unknown option, or a value the option can’t take.

  • MaestroGpuError – if device="GPU" can’t be used.

  • QoroCloudError – for a noise model on a backend that runs on the cloud.

simulator_options()

The current simulator options, in the form the primitives take them.

Return type:

dict[str, Any]

run(run_input, **run_options)

Sample circuits and return a finished job, or a submitted one on the Qoro cloud.

Parameters:
  • run_input (QuantumCircuit | Sequence[QuantumCircuit]) – A circuit or a list of circuits, with every parameter bound.

  • run_options – shots, memory or any simulator option, for this run only.

Raises:
Return type:

MaestroJob | QoroCloudJob

class MaestroJob(backend, job_id, result)

A finished Maestro run.

MaestroBackend.run() simulates before it returns, as Qiskit’s BasicSimulator does, so the job is already done when you get it.

result(timeout=None)

Return the results of the job.

Return type:

Result

status()

Return the status of the job, among the values of JobStatus.

Return type:

JobStatus

Primitives

class MaestroSampler(*, default_shots=1024, seed=None, options=None, service=None, **simulator_options)

Sample circuits on Maestro, a drop-in for StatevectorSampler and Aer’s SamplerV2.

Each PUB’s circuit is converted once; its parameter sets then run in parallel. Results have one BitArray per classical register, shaped as StatevectorSampler shapes them, in Qiskit’s bit order.

Parameters:
  • default_shots (int) – Shots for PUBs that don’t set their own.

  • seed (int | None) – Seed for reproducible results.

  • options (Mapping[str, Any] | None) – Aer’s form, {"backend_options": {...}, "run_options": {...}}, for code moving from qiskit_aer.primitives.SamplerV2.

  • service – A divi.backends.QoroService to run on the Qoro cloud, one cloud job per run(). None (default) runs locally. On the cloud, circuits can’t have classical control or a noise model yet.

  • **simulator_options – Any MaestroBackend option, such as method="matrix_product_state", device="GPU" or noise_model.

classmethod from_backend(backend, **kwargs)

A sampler with the simulator options and service of a MaestroBackend.

Return type:

MaestroSampler

property options: dict[str, Any]

The simulator options in use.

property service

The QoroService the sampler runs on, or None when it runs locally.

run(pubs, *, shots=None)

Sample the PUBs.

Locally, the job runs in the background. With a service, the PUBs’ circuits are submitted to the Qoro cloud as one job before this returns, and the returned QoroCloudPrimitiveJob has the cloud’s job ID.

Return type:

PrimitiveJob[PrimitiveResult[SamplerPubResult]]

class MaestroEstimator(*, default_precision=0.0, seed=None, options=None, incremental_evolution=True, service=None, **simulator_options)

Expectation values on Maestro, a drop-in for StatevectorEstimator and Aer’s EstimatorV2.

Values are computed from the simulated state (statevector, MPS, stabilizer tableau, density matrix, tensor network or Pauli propagation), never from shots. With precision > 0, Gaussian noise of that standard deviation is added, as StatevectorEstimator does, and stds reports it.

Time evolution runs on one persistent simulator. When the PUBs of a call are an initial circuit followed by 0, 1, 2, … repetitions of the same step, as when each time point of a Trotter evolution is its own circuit, the estimator simulates the longest one once and reads every time point’s values on the way. run_evolution() does the same when you give it the initial circuit and the step yourself.

Parameters:
  • default_precision (float) – Precision for PUBs that don’t set their own. 0 (default) returns exact values.

  • seed (int | None) – Seed for the precision noise and for any mid-circuit resets.

  • options (Mapping[str, Any] | None) – Aer’s form, {"default_precision": ..., "backend_options": {...}, "run_options": {...}}, for code moving from qiskit_aer.primitives.EstimatorV2.

  • incremental_evolution (bool) – Recognise time-evolution PUBs in run() (default True). Set False to simulate every circuit from the start.

  • **simulator_options – Any MaestroBackend option, such as method="matrix_product_state", device="GPU" or noise_model. With a noise model, method="density_matrix" gives exact noisy values; pure-state methods average 1,024 noise trajectories, as Aer’s EstimatorV2 does on its statevector method.

  • service – A divi.backends.QoroService to run on the Qoro cloud, one expectation-value job per run(). None (default) runs locally. On the cloud, circuits can’t have resets or a noise model yet, and run_evolution() isn’t available.

classmethod from_backend(backend, **kwargs)

An estimator with the simulator options and service of a MaestroBackend.

Return type:

MaestroEstimator

property options: dict[str, Any]

The simulator options in use.

property service

The QoroService the estimator runs on, or None when it runs locally.

run(pubs, *, precision=None)

Estimate the PUBs.

Locally, the job runs in the background. With a service, the PUBs’ circuits are submitted to the Qoro cloud as one expectation-value job before this returns, and the returned QoroCloudPrimitiveJob has the cloud’s job ID.

Return type:

PrimitiveJob[PrimitiveResult[PubResult]]

run_evolution(initial_state, step, observables, steps, *, precision=None)

Expectation values after repeating step on initial_state.

Uses one simulator for the whole evolution: initial_state runs once, then step is applied again and again, and the observables are evaluated on the live state after each count in steps. That costs one pass to the largest count, where a circuit per time point costs a pass per point.

Parameters:
  • initial_state (QuantumCircuit) – The circuit that prepares the state, with bound parameters. Can be empty.

  • step (QuantumCircuit) – One time step, such as one Trotter step, with bound parameters.

  • observables – Anything a PUB takes as observables: a SparsePauliOp, a label, or an array of them.

  • steps (Sequence[int]) – Step counts to evaluate at, in any order; 0 is the initial state.

  • precision (float | None) – As in run().

Returns:

A job whose result holds one PubResult with evs of shape (len(steps), *observables.shape).

Raises:
  • UnsupportedInstructionError – if a circuit holds a reset, which Maestro’s incremental evolution doesn’t apply correctly yet.

  • QoroCloudError – if the estimator runs on the Qoro cloud, which doesn’t offer incremental evolution yet.

Return type:

PrimitiveJob[PrimitiveResult[PubResult]]

Qoro cloud jobs

With service=, run() returns one of these as soon as the job is submitted. The guide’s GPU and Qoro cloud page lists what runs there.

class QoroCloudJob(backend, run, build)

A run() on the Qoro cloud.

job_id() is the cloud’s job ID. result() waits for the job.

result(timeout=None)

Wait for the job and return its Result.

Raises:
  • JobTimeoutError – if timeout seconds pass first. The job keeps running.

  • QoroCloudError – if the job fails, is cancelled, or runs out of credits.

status()

Return the status of the job, among the values of JobStatus.

Return type:

JobStatus

cancel()

Attempt to cancel the job.

Return type:

bool

job_id()

Return a unique id identifying the job.

Return type:

str

class QoroCloudPrimitiveJob(run, build)

A primitive’s run on the Qoro cloud. job_id() is the cloud’s job ID.

result()

Wait for the job and return its result.

Raises:

QoroCloudError – if the job fails, is cancelled, or runs out of credits.

Return type:

T

status()

Return the status of the job.

Return type:

JobStatus

job_id()

Return a unique id identifying the job.

Return type:

str

cancel()

Attempt to cancel the job.

Return type:

bool

Exceptions

exception MaestroError(*message)

Base class for errors raised by qiskit-maestro.

exception UnsupportedInstructionError(instruction, reason)

A circuit holds an instruction Maestro can’t run.

exception UnsupportedNoiseError(instruction, reason, qubits=None)

A noise model holds an error Maestro can’t reproduce exactly.

instruction names the instruction the error is attached to, and qubits its qubits when the error is on particular ones.

exception MaestroGpuError(reason)

device="GPU" was requested but Maestro’s GPU backend can’t be used.

exception QoroCloudError(message, job_id=None)

A run can’t be sent to the Qoro cloud, or the cloud job didn’t succeed.

job_id is the cloud job’s identifier when the job was submitted.