monoprop

circuit

Authoring types for Majorana/qubit circuits.

The authoring model is four layers: a term (:class:~monoprop.majorana.Majorana / :class:~monoprop.pauli.Pauli) is the atom; an operator (:class:~monoprop.majorana.MajoranaOperator / :class:~monoprop.pauli.PauliOperator) is a weighted sum of terms that also carries the system num_modes / num_qubits; an exponential gate wraps a generator operator that gets exponentiated; and a circuit is an ordered sequence of such gates.

A gate is an explicit exponential of a generator operator -- :class:ExpGate accepts only operator objects (never a bare term), because those carry the system size. There is a single :class:ExpGate gate type; it abstracts over the family the same way :class:Circuit does -- the generator type it is handed decides how it is normalized:

  • a :class:~monoprop.majorana.MajoranaOperator is a native Majorana generator carrying the Hermitian operator (same coefficient convention as an observable: imaginary for a weight-2 monomial, real for weight-4); each term is antihermitian-normalized when the circuit is ingested, dividing out the Hermitian phase to the structural coefficient the engine rotates by;
  • a :class:~monoprop.pauli.PauliOperator is a qubit generator; each term is Jordan-Wigner mapped and antihermitian-normalized when the circuit is ingested;
  • a :class:~monoprop.fermi.FermiOperator is a fermionic generator; it is converted to its (Hermitian) Majorana form in :class:ExpGate.

There is likewise a single :class:Circuit type. The gate objects carry the family, so one circuit can be authored from Majorana/fermionic gates or qubit gates, and the circuit validates that its gates are a single, consistent family (the two cannot be mixed). Each gate is the unit of parameterization: one gate is driven by exactly one variational angle, named by its index (None on every gate => each gate gets its own angle in order; repeat an index to tie gates to a shared angle). A multi-term generator is a single exponential driven by a single angle.

The propagators check the circuit's :attr:Circuit.family: :class:~monoprop.majorana_propagator.MajoranaPropagator consumes a Majorana/fermionic circuit, :class:~monoprop.pauli_propagator.PauliPropagator a qubit circuit.

attributeGateFamily
= Literal['pauli', 'majorana']
attributeCircuitFamily
= Literal['pauli', 'majorana', 'empty']
funcvalidate_parameter_mapping(mapping, expected_len, unit='gates') -> None

Validate that a parameter mapping has the right length and contiguous indices.

parammappingSequence[int]

Per-unit angle indices to validate.

paramexpected_lenint

Number of entries the mapping must have.

paramunitstr
= 'gates'

Noun naming what each entry covers (e.g. "gates" or "graph layers"), used only in the length-mismatch error message.

Returns

None
funcexpand_monomials(gates, mapping, num_qubits=None) -> tuple[list[tuple[int, ...]], list[float], list[int], list[int]]

Flatten gates + an already-resolved per-gate mapping into per-monomial arrays.

paramgatesSequence[ExpGate]

:class:ExpGate gates, in application order.

parammappingSequence[int]

The angle index driving each gate (one entry per gate).

paramnum_qubitsint | None
= None

System qubit count, required to place Pauli-family generators; unused for native Majorana generators.

Returns

list

A tuple (majoranas, gen_coeffs, parameter_mapping, gate_indices) for the C++