Skip to content

Qiskit Backend ​

menos.qiskit.MENOSBackend, a Qiskit BackendV2.

python
from menos.qiskit import MENOSBackend

Class ​

text
class MENOSBackend(BackendV2)
MENOSBackend(provider=None, **fields)

**fields override the default options: MENOSBackend(shots=2048, seed_simulator=7) sets new defaults for every call. A field that is not a valid option raises AttributeError.

Properties ​

PropertyValue
name"menos"
description"MENOS dense-engine simulator". A fixed label; the backend uses every engine, not only dense
backend_versionThe installed menos package version
max_circuits1
num_qubitsNone: no fixed size; memory is the limit
targetA Target advertising exactly the supported gates plus measure and unitary
providerNone (there is no provider class)
optionsSee below

Options ​

OptionDefaultMeaning
shots1024Number of samples
seed_simulatorNoneSampling seed; None draws a fresh one
want_statevectorFalseAlso return the exact statevector
noise_modelNoneA qiskit_aer.noise.NoiseModel, simulated exactly by default. See Noise Models
noise_method"exact""exact": a noisy circuit runs on the exact density matrix. "auto": the planner may also sample it with trajectories when that is cheaper or the only plan that fits. Any other value raises ValueError
time_budget_secondsNoneWall-clock seconds one execution attempt may take. None: no budget. A run that overruns is replanned; with no plan left, run raises ResourceExceededError. Abandoned attempts appear in result.results[0].metadata["menos_replans"]. Must be finite and > 0, otherwise InvalidCircuitError. See Time Budgets
backendNoneNone: the planner chooses CPU or CUDA. "cpu" or "cuda" forces one (see Forcing a backend). "cuda" raises UnsupportedFeatureError when CUDA cannot be used, and never falls back to the CPU. Any other value raises ValueError

backend.set_options(shots=…) changes defaults after construction.

run ​

text
MENOSBackend.run(run_input, **options) -> MENOSJob
ParameterMeaning
run_inputOne QuantumCircuit (a one-element list is also accepted)
**optionsOverrides for shots, seed_simulator, want_statevector, noise_model, noise_method, time_budget_seconds, backend for this call
RaisesWhen
TypeErrorrun_input is not a QuantumCircuit, or noise_model is not an Aer NoiseModel
ValueErrorrun_input is a list of more than one circuit, noise_method is not "exact" or "auto", or backend is not None, "cpu" or "cuda"
AttributeErrorAn option name is not valid
InvalidCircuitErrorUnbound parameters, nothing to produce, shots > 0 with no measurement, malformed circuit, a time_budget_seconds that is not finite and > 0
UnsupportedFeatureErrorA gate or feature MENOS cannot represent, or backend="cuda" when this build has no CUDA support, no device is usable, or the circuit is noisy
ResourceExceededErrorNo plan fits the memory budget, or the time budget (at plan time, or after an overrun with no plan left)

The call is synchronous and returns a finished MENOSJob.

Verification ​

python
import inspect

from menos.qiskit import MENOSBackend

assert str(inspect.signature(MENOSBackend.__init__)) == "(self, provider=None, **fields) -> 'None'"
assert str(inspect.signature(MENOSBackend.run)) == "(self, run_input, **options) -> 'MENOSJob'"

backend = MENOSBackend(shots=64, seed_simulator=5)
assert dict(backend.options.items()) == {
    "shots": 64,
    "seed_simulator": 5,
    "want_statevector": False,
    "noise_model": None,
    "noise_method": "exact",
    "time_budget_seconds": None,
    "backend": None,
}
assert backend.name == "menos"
assert backend.max_circuits == 1
assert backend.num_qubits is None
assert backend.provider is None
assert backend.description == "MENOS dense-engine simulator"

MENOSBackend guide · Running Jobs · Qiskit Integration

Released under the Apache-2.0 license. GitHub · PyPI