monoprop

circuit

Authoring types for Majorana/qubit circuits.

An ExpGate is the exponential of a generator operator -- a MajoranaOperator, PauliOperator, or FermiOperator (converted to Majorana form on construction). A bare term is rejected: only an operator carries the system num_modes / num_qubits, and its type fixes the gate's family and normalization. A Circuit is an ordered sequence of such gates, all of one family, each gate carrying one variational angle. The propagators dispatch on Circuit.family: MajoranaPropagator takes a Majorana/fermionic circuit, PauliPropagator a qubit one.

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 ("gates", "graph layers"), used only in the 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]

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 generators; unused for Majorana.

Returns

list

(majoranas, gen_coeffs, parameter_mapping, gate_indices) for the C++ engine, expanded per monomial. gate_indices[i] is the local 0-based index of the authoring gate, so the engine can recover gate boundaries; a multi-term gate's monomials share one index.