Saturation diagnostics¶
saturation
¶
Compile-time saturation warnings.
Source-keyed warnings for latent steps whose algebra-specific initialization
recipe differs materially from the default Normal(0, 1) initialization.
The check implements the two closed-form conditions documented in the public
analysis guide and returns SaturationWarning objects with source_line and
source_col coordinates. It currently diagnoses:
- Deep chains in a bounded algebra with no user-set init.
ProductFuzzyAlgebraover a depth-10 chain with a defaultNormal(0, 1)initial value will saturate noisy-OR at 1 on every cell; the gradient through the join goes to zero. - Intermediate-axis blowup with a small algebra unit.
LukasiewiczAlgebrasaturates its bounded sum at 1 when the intermediate axis is large; the recipe isp ≈ 1 / kand the warning fires when no init is declared.
The downstream apply_init_spec path consumes the same
ChainShape, so once the user applies the recommendation
the warning goes away.
SaturationWarning
didactic-model
¶
SaturationWarning(*, name: str, source_line: int = 0, source_col: int = 0, algebra_name: str = '', depth: int = 0, intermediate_size: int | None = None, init_spec: InitSpec | None = None)
Bases: Model
One saturation-risk diagnosis at a specific source location.
| ATTRIBUTE | DESCRIPTION |
|---|---|
name |
Latent variable name.
TYPE:
|
source_line, source_col |
Position of the latent declaration in the source.
TYPE:
|
algebra_name |
Governing algebra at the latent's location.
TYPE:
|
depth |
Chain depth of the latent (number of stochastic-bind steps from the program entry, 1-indexed).
TYPE:
|
intermediate_size |
Inferred plate / shared-axis size.
TYPE:
|
init_spec |
The recommended algebra-specific initialization for this latent.
TYPE:
|
message
¶
One-line human-readable diagnosis suitable for surfacing
at qvr check / Compiler warning level.
Source code in src/quivers/analysis/saturation.py
saturation_warnings
¶
saturation_warnings(module: Module) -> tuple[SaturationWarning, ...]
Per-latent saturation diagnoses.
Returns a warning for every latent step in the program at
depth ≥ 2 or with intermediate size > 1 under an algebra whose
algebra-specific recipe differs materially from a default
Normal(0, 1) init. The threshold for "differs materially"
is the absolute distance between the recipe's mean and 0
(Normal default) plus the relative distance between its std
and 1; we surface a warning when either pulls the
recommendation more than 20% away from the default.
Suppressing warnings: declare the latent with an explicit init
via the DSL surface (when available) or apply the recommended
init programmatically via
quivers.analysis.init_spec.apply_init_spec.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The parsed QVR module whose program is analysed.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[SaturationWarning, ...]
|
One warning per latent whose recommended init departs from the default; empty when the module declares no governing algebra. |