propaq.truncation¶
Composable truncation operators, applied together after every gate by both the numerical and the surrogate propagators.
See the truncation guide.
truncation
¶
Composable truncation operators shared by the numerical and surrogate propagators.
Classes:
| Name | Description |
|---|---|
WeightTruncator |
Drop whole Pauli/Majorana terms whose operator weight exceeds |
CoefficientTruncator |
Drop contributions with coefficient magnitude below |
TermBudget |
Live-term floor: below |
FrequencyTruncator |
Drop monomials whose frequency (trig-factor count) exceeds |
Simplify |
Real (lossless) algebraic simplification, surrogate-only. |
NativeTruncator |
Truncation policy backed by a dynamically loaded C, Rust, or |
Truncator |
Abstract base class for composable truncation operators. |
TruncationPolicy |
Controls when and how terms are discarded during propagation. |
FrequencyTruncationPolicy |
|
ResolvedTruncation |
A truncator pipeline collapsed to the values the emit gate compares against. |
Functions:
| Name | Description |
|---|---|
resolve_truncation |
Normalize the flexible |
WeightTruncator
¶
Bases: WeightTruncator
Drop whole Pauli/Majorana terms whose operator weight exceeds weight.
Applies to both propagators.
A term with weight w is exponentially unlikely in w to contribute to
the final state, which is why this is a useful truncation criterion for
larger circuits.
Attributes:
| Name | Type | Description |
|---|---|---|
weight |
int | None
|
|
CoefficientTruncator
¶
Bases: CoefficientTruncator
Drop contributions with coefficient magnitude below coefficient.
Attributes:
| Name | Type | Description |
|---|---|---|
coefficient |
float | None
|
|
TermBudget
¶
Bases: TermBudget
Live-term floor: below min_terms terms, all other lossy truncators
(WeightTruncator/CoefficientTruncator/NativeTruncator) are
suppressed, keeping propagation exact until the operator has had room to
grow. None disables the floor.
Attributes:
| Name | Type | Description |
|---|---|---|
min_terms |
int | None
|
|
FrequencyTruncator
¶
Simplify
¶
NativeTruncator
¶
Bases: NativeTruncator
Truncation policy backed by a dynamically loaded C, Rust, or AOT-compiled Julia shared library
Methods:
| Name | Description |
|---|---|
keep_term |
Delegate to the plugin's |
Attributes:
| Name | Type | Description |
|---|---|---|
abi_version |
int
|
The ABI version the loaded plugin declared. |
depends |
int
|
The dependency bitmask the plugin declared: 1 = reads the term's key, |
depends
property
¶
The dependency bitmask the plugin declared: 1 = reads the term's key, 2 = reads the layer index. 0 means weight and magnitude alone.
keep_term
method descriptor
¶
keep_term(basis_kind: int, words: Sequence[int], n_units: int, weight: int, coeff_magnitude: float, layer_index: int = 0, n_layers: int = 0) -> bool
Delegate to the plugin's propaq_truncator_keep.
Exposed so a plugin can be exercised from Python without running a circuit; propagation calls the same entry point directly from the pool.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
basis_kind
|
int
|
0 for Pauli, 1 for Majorana. |
required |
words
|
Sequence[int]
|
The term's raw basis-string words, two bits per unit. Ignored (and passed as NULL) unless the plugin declared it reads keys. |
required |
n_units
|
int
|
Qubits (Pauli) or modes (Majorana) of the register. |
required |
weight
|
int
|
The term's weight. |
required |
coeff_magnitude
|
float
|
The term's coefficient magnitude. |
required |
layer_index
|
int
|
Zero-based circuit layer. |
0
|
n_layers
|
int
|
Layers in the circuit. |
0
|
Truncator
¶
Bases: ABC
Abstract base class for composable truncation operators.
TruncationPolicy
¶
Controls when and how terms are discarded during propagation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
weight_cutoff
|
Discard terms with Pauli weight strictly greater than this value. None disables weight-based truncation. |
required | |
coeff_cutoff
|
Discard terms with |coefficient| strictly less than this value. |
required | |
min_terms
|
Live-term floor below which truncation is suppressed. |
required |
Methods:
| Name | Description |
|---|---|
should_truncate |
Return True if a term with weight and |coefficient| abs_coeff should be discarded. |
Attributes:
| Name | Type | Description |
|---|---|---|
coeff_cutoff |
float
|
|
min_terms |
int | None
|
|
weight_cutoff |
int | None
|
|
should_truncate
method descriptor
¶
Return True if a term with weight and |coefficient| abs_coeff should be discarded.
FrequencyTruncationPolicy
¶
Attributes:
| Name | Type | Description |
|---|---|---|
max_frequency |
int | None
|
Drop monomials with more than this many trig factors (None = no limit). |
min_terms |
int | None
|
Live-term floor below which truncation is suppressed entirely. |
weight_cutoff |
int | None
|
Drop Pauli/Majorana terms with weight exceeding this value (None = no limit). |
ResolvedTruncation
dataclass
¶
ResolvedTruncation(weight_cutoff: int | None = None, coeff_cutoff: float | None = None, min_terms: int | None = None)
A truncator pipeline collapsed to the values the emit gate compares against.
Methods:
| Name | Description |
|---|---|
from_truncators |
Collapse a truncator list into one |
at_size |
The cutoff to use when emitting children of a term sum with |
admits |
True if a term of this weight and coefficient belongs in the store. |
from_truncators
classmethod
¶
from_truncators(truncators: Sequence[_Truncator]) -> ResolvedTruncation
Collapse a truncator list into one ResolvedTruncation, last-wins per type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
truncators
|
Sequence[_Truncator]
|
The truncators, as returned by |
required |
at_size
¶
at_size(n_live: int) -> ResolvedTruncation
The cutoff to use when emitting children of a term sum with n_live live terms.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_live
|
int
|
The number of terms live before this emission. |
required |
Returns:
| Type | Description |
|---|---|
ResolvedTruncation
|
|
ResolvedTruncation
|
below it, in which case |
ResolvedTruncation
|
suppressed (returned as |
admits
¶
True if a term of this weight and coefficient belongs in the store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
weight
|
int
|
The term's weight. |
required |
coeff
|
complex
|
The term's coefficient. |
required |
resolve_truncation
¶
resolve_truncation(truncation: object | Sequence[object] | TruncationPolicy | None = None) -> list[_Truncator]
Normalize the flexible truncation argument into a truncator list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
truncation
|
object | Sequence[object] | TruncationPolicy | None
|
The pipeline, in any of the accepted forms. |
None
|
Returns:
| Type | Description |
|---|---|
list[_Truncator]
|
The truncators, in application order. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |