Family Registry¶
Every distribution family is described once by a
FamilySpec and registered
in FAMILY_REGISTRY.
The inline builders and conditional families dispatch on the registered
specification, so registering a family through
register_family
(and refreshing the inline tables with
reload_inline_registry)
makes it available to programs.
family_spec
¶
Single source of truth for every parametric distribution family the quivers stack supports.
A FamilySpec carries everything the three call paths need:
- the conditional path
(
quivers.continuous.families._IndependentConditional) consumesparamsto know how to transform unbounded MLP outputs and how to instantiate atorch.distributionsobject; - the fixed inline path
(
quivers.continuous.inline.FixedDistribution) consumesparamsandsupportto construct a distribution from literal compile-time floats; - the mixed inline path
(
quivers.continuous.inline.MixedInlineDistribution) consumes the same spec to build a distribution whose parameters are stacked runtime tensors.
Every family registers itself exactly once via register; the
inline and conditional generators read from the same record. This
is the architectural seam that keeps the family catalog from
duplicating itself across three modules.
FAMILY_REGISTRY
module-attribute
¶
FAMILY_REGISTRY: dict[str, FamilySpec] = {}
Every registered family specification, keyed by its DSL name.
ParamKind
¶
Per-parameter shape contract on the inline call side.
"scalar"— broadcasts across the codomain's last axis (one parameter value per per-codomain dimension, as inNormal(loc, scale))."vector"— a single vector parameter for the whole sample (used byDirichletwhose concentration is the full simplex-dimensional vector, not a per-component scalar)."integer"— a count-typed parameter (total_countforBinomial/NegativeBinomial/Multinomial); the fixed-factory accepts a Pythonint.
OutputKind
¶
How the distribution's output relates to the codomain.
The conditional path reads output_kind to decide whether to use
the generic per-dim _IndependentConditional or a hand-written
class. The inline path reads it to pick the matching codomain
inference rule.
ParamSpec
dataclass
¶
Spec for a single parameter of a distribution family.
A plain frozen dataclass rather than a
dx.Model because transform accepts a
Bijector instance,
and the didactic model surface admits only registered scalar
types in a union field. String-typed transforms retain a stable
identity for panproto-side introspection via transform_name.
| ATTRIBUTE | DESCRIPTION |
|---|---|
name |
Keyword argument expected by the underlying torch
TYPE:
|
transform |
Either a string key registered in
TYPE:
|
kind |
Per-parameter shape contract on the inline call side.
TYPE:
|
bijector
property
¶
bijector: Bijector
The resolved Bijector
for this parameter.
For a string-typed transform, looks the key up in
TRANSFORM_TO_BIJECTOR;
for a Bijector-typed transform, returns it unchanged.
raw_transform
property
¶
The bijector's forward map, exposed as a plain callable.
For callers that treat the transform as
Callable[[Tensor], Tensor].
inline_clamp
property
¶
Inline safety-clamp callable for user-supplied literal
or runtime parameters, sourced from
resolve_inline_clamp.
transform_name
property
¶
A stable string identifier for the transform.
Returns the registered key when transform is a string;
returns a synthesised name based on the bijector class for
Bijector-typed transforms.
FamilySpec
dataclass
¶
FamilySpec(name: str, dist_class: type, params: tuple[ParamSpec, ...], support: Constraint, discrete: bool = False, output_kind: OutputKind = 'independent', docstring: str = '', fixed_factory_override: Callable | None = None, mixed_builder_override: Callable | None = None, conditional_class_override: type | None = None)
Single source of truth for a distribution family.
Implemented as a plain @dataclass(frozen=True) rather than
a didactic.api.Model because several fields are
Python callables (fixed_factory_override,
mixed_builder_override) or class objects
(conditional_class_override) that don't translate to a
panproto sort. ParamSpec is similarly a plain frozen
dataclass since its transform field accepts a Bijector
instance that has no didactic scalar registration.
Used by:
quivers.continuous.families._IndependentConditionaland the standaloneConditionalXclasses for the learnable-parameter path;quivers.continuous.inline.FixedDistributionandquivers.continuous.inline.MixedInlineDistributionfor the DSL inline call surface.
params
instance-attribute
¶
params: tuple[ParamSpec, ...]
Ordered parameter specs, matching the dist's positional / keyword API.
support
instance-attribute
¶
support: Constraint
Output support, used by variational guides to pick a bijector.
discrete
class-attribute
instance-attribute
¶
True for integer / categorical outputs.
output_kind
class-attribute
instance-attribute
¶
output_kind: OutputKind = 'independent'
How the distribution's output relates to the codomain shape.
docstring
class-attribute
instance-attribute
¶
Used as the generated ConditionalX class docstring.
fixed_factory_override
class-attribute
instance-attribute
¶
Override for the all-literal FixedDistribution factory.
mixed_builder_override
class-attribute
instance-attribute
¶
Override for the mixed-mode dist builder
(list[Tensor]) -> Distribution.
conditional_class_override
class-attribute
instance-attribute
¶
Override for the conditional class (used by Categorical, Bernoulli, MultivariateNormal, etc.).
register_family
¶
register_family(spec: FamilySpec) -> FamilySpec
Register a FamilySpec under its name; idempotent on
re-registration of the same name to support hot-reload during
development.
Source code in src/quivers/continuous/family_spec.py
get_family_spec
¶
get_family_spec(name: str) -> FamilySpec | None
family_names
¶
build_torch_distribution
¶
build_torch_distribution(spec: FamilySpec, params: list[Tensor] | dict[str, Tensor]) -> Distribution
Instantiate the underlying torch distribution from a list / dict of parameter tensors that have already been clamped to the family's constraints.
Source code in src/quivers/continuous/family_spec.py
clamp_param
¶
clamp_param(spec: FamilySpec, name: str, value: Tensor) -> Tensor
Apply the inline safety clamp for the named parameter of
spec.