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,1runs them one at a time.maestro_options – Other
maestro.SimulatorConfigfields, 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, asAerSimulator(noise_model=...)’s does. An error Maestro can’t reproduce exactly raisesUnsupportedNoiseError.shots – Default shots for
run()(1024).memory – Whether
run()returns per-shot results by default (False).service – A
divi.backends.QoroServiceto run on the Qoro cloud.run()then submits one cloud job and returns aQoroCloudJobat once.None(default) runs locally. On the cloud, circuits can’t have classical control, save instructions or a noise model yet.
- property service¶
The
QoroServicethe backend runs on, orNonewhen it runs locally.
- set_options(**fields)¶
Change options, as on
AerSimulator.- Parameters:
fields –
shots,memoryor any option the constructor takes. Settingnoise_modelalso 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.
- 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,memoryor any simulator option, for this run only.
- Raises:
UnsupportedInstructionError – if a circuit holds an instruction Maestro can’t run.
UnsupportedNoiseError – if the noise model has an error, on an instruction a circuit uses, that Maestro can’t reproduce exactly.
MaestroGpuError – if
device="GPU"and the GPU can’t be used.QoroCloudError – with a
service, for an option the cloud can’t honour.
- Return type:
- class MaestroJob(backend, job_id, result)¶
A finished Maestro run.
MaestroBackend.run()simulates before it returns, as Qiskit’sBasicSimulatordoes, so the job is already done when you get it.
Primitives¶
- class MaestroSampler(*, default_shots=1024, seed=None, options=None, service=None, **simulator_options)¶
Sample circuits on Maestro, a drop-in for
StatevectorSamplerand Aer’sSamplerV2.Each PUB’s circuit is converted once; its parameter sets then run in parallel. Results have one
BitArrayper classical register, shaped asStatevectorSamplershapes 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 fromqiskit_aer.primitives.SamplerV2.service – A
divi.backends.QoroServiceto run on the Qoro cloud, one cloud job perrun().None(default) runs locally. On the cloud, circuits can’t have classical control or a noise model yet.**simulator_options – Any
MaestroBackendoption, such asmethod="matrix_product_state",device="GPU"ornoise_model.
- classmethod from_backend(backend, **kwargs)¶
A sampler with the simulator options and service of a
MaestroBackend.- Return type:
- property service¶
The
QoroServicethe sampler runs on, orNonewhen 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 returnedQoroCloudPrimitiveJobhas the cloud’s job ID.- Return type:
- 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
StatevectorEstimatorand Aer’sEstimatorV2.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, asStatevectorEstimatordoes, andstdsreports 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 fromqiskit_aer.primitives.EstimatorV2.incremental_evolution (bool) – Recognise time-evolution PUBs in
run()(defaultTrue). SetFalseto simulate every circuit from the start.**simulator_options – Any
MaestroBackendoption, such asmethod="matrix_product_state",device="GPU"ornoise_model. With a noise model,method="density_matrix"gives exact noisy values; pure-state methods average 1,024 noise trajectories, as Aer’sEstimatorV2does on its statevector method.service – A
divi.backends.QoroServiceto run on the Qoro cloud, one expectation-value job perrun().None(default) runs locally. On the cloud, circuits can’t have resets or a noise model yet, andrun_evolution()isn’t available.
- classmethod from_backend(backend, **kwargs)¶
An estimator with the simulator options and service of a
MaestroBackend.- Return type:
- property service¶
The
QoroServicethe estimator runs on, orNonewhen 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 returnedQoroCloudPrimitiveJobhas the cloud’s job ID.- Return type:
- run_evolution(initial_state, step, observables, steps, *, precision=None)¶
Expectation values after repeating
steponinitial_state.Uses one simulator for the whole evolution:
initial_stateruns once, thenstepis applied again and again, and the observables are evaluated on the live state after each count insteps. 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;
0is the initial state.
- Returns:
A job whose result holds one
PubResultwithevsof 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:
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
timeoutseconds pass first. The job keeps running.QoroCloudError – if the job fails, is cancelled, or runs out of credits.
- 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
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.
instructionnames the instruction the error is attached to, andqubitsits 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_idis the cloud job’s identifier when the job was submitted.