mimiqcircuits.backends.capabilities¶
Capability vocabulary, numeric limits, topology, and admission types.
A backend’s Backend.capabilities() returns a set of capability
tokens drawn from CAPABILITY_VOCABULARY.
A backend’s Backend.limits() returns a Limits
instance, and Backend.topology() returns one of the
Topology subclasses (AllToAll,
CouplingMap, LinearChain).
Backend.can_handle() returns an AdmissionResult
(Admissible, Marginal, or Inadmissible).
Module Attributes
Type of a capability token: a string such as |
|
Capability tokens a backend may declare in |
|
Registry of probe-circuit factories keyed by capability, used by the conformance tests to check that a backend rejects what it does not declare. |
Functions
|
Return whether an admission result accepts the circuit. |
|
Register a probe-circuit factory for |
Classes
The backend can execute the circuit. |
|
Base class for the results of |
|
|
Every pair of qubits can interact. |
|
Connectivity given as a list of edges. |
|
The backend cannot execute the circuit. |
|
Numeric limits a backend declares in |
|
Linear chain of |
|
The backend can execute the circuit, but it is near a limit (memory, bond dimension, runtime). |
|
Base class for the qubit connectivity a backend declares in |
Exceptions
|
Error for a feature the backend does not declare in |
- Capability¶
Type of a capability token: a string such as
"noise".
- CAPABILITY_VOCABULARY: frozenset[str] = frozenset({'amplitude', 'batch', 'bond_dim', 'calibrated_noise', 'classical_bits', 'expectation_1q', 'expectation_2q', 'expectation_paulistring', 'expectation_state', 'feed_forward', 'final_measure_only', 'loss', 'midcircuit_measure', 'midcircuit_reset', 'noise', 'parametric', 'parametric_batch', 'pass_order_honored', 'reset_after_measure', 'sampling', 'schmidt_rank', 'shared_prefix_batch', 'streaming', 'while_statement', 'zvars'})¶
Capability tokens a backend may declare in
Backend.capabilities(). Informational: backends may declare tokens outside this set; conformance tests warn but never fail on extras.
- class Limits(max_qubits=None, max_bond_dim=None, max_classical_bits=None, max_zvars=None, max_samples=None, max_circuit_depth=None)[source]¶
Bases:
objectNumeric limits a backend declares in
Backend.limits().Nonefor a field means unbounded, or not applicable (such asmax_bond_dimon a state-vector simulator). The defaultBackend.can_handle()checksmax_qubits,max_classical_bitsandmax_zvars; the other fields are informational.Examples
>>> from mimiqcircuits import * >>> from mimiqcircuits.backends import Limits >>> lim = Limits(max_qubits=30) >>> lim.max_qubits, lim.max_samples (30, None)
- class Topology[source]¶
Bases:
objectBase class for the qubit connectivity a backend declares in
Backend.topology().
- class AllToAll[source]¶
Bases:
TopologyEvery pair of qubits can interact. The default for simulators.
- class CouplingMap(edges)[source]¶
Bases:
TopologyConnectivity given as a list of edges.
Each edge
(i, j)means qubitsiandjcan interact directly. Indices are 1-based.
- class LinearChain(n)[source]¶
Bases:
TopologyLinear chain of
nqubits, each coupled to its neighbours.
- class Admissible[source]¶
Bases:
AdmissionResultThe backend can execute the circuit.
- class Marginal(warning)[source]¶
Bases:
AdmissionResultThe backend can execute the circuit, but it is near a limit (memory, bond dimension, runtime).
is_admissible()treats it as admissible.
- class Inadmissible(reason)[source]¶
Bases:
AdmissionResultThe backend cannot execute the circuit.
- is_admissible(result)[source]¶
Return whether an admission result accepts the circuit.
- Parameters:
result (AdmissionResult) – The result of
Backend.can_handle().- Returns:
TrueforAdmissibleandMarginal,Falseotherwise.- Return type:
Examples
>>> from mimiqcircuits import * >>> from mimiqcircuits.backends import ( ... Admissible, Inadmissible, Marginal, is_admissible) >>> is_admissible(Admissible()) True >>> is_admissible(Marginal(warning="close to the memory limit")) True >>> is_admissible(Inadmissible(reason="too many qubits")) False
- exception UnsupportedCapabilityError(backend_name, capability, detail='')[source]¶
Bases:
ExceptionError for a feature the backend does not declare in
Backend.capabilities().Backends raise it when asked to run such a feature, instead of running something else in its place.
- CAP_PROBES: dict[str, Callable] = {'feed_forward': <function _probe_feed_forward>, 'loss': <function _probe_loss>, 'midcircuit_measure': <function _probe_midcircuit_measure>, 'midcircuit_reset': <function _probe_midcircuit_reset>, 'noise': <function _probe_noise>, 'parametric': <function _probe_parametric>, 'reset_after_measure': <function _probe_reset_after_measure>}¶
Registry of probe-circuit factories keyed by capability, used by the conformance tests to check that a backend rejects what it does not declare. Importing
mimiqcircuits.backendsregisters the default probes;register_cap_probe()adds more.
- register_cap_probe(capability, factory)[source]¶
Register a probe-circuit factory for
capabilityinCAP_PROBES.Conformance tests run each probe on every backend that does not declare its capability, and check that the backend rejects it. A factory registered for a capability that already has one replaces it.