Families¶
The distribution family registry fixes, for each family, its parameters, its support, and its density, which every runtime and transpiler implements in its own parameterization. The support table lists which families each target accepts.
FamilyShapeSignature binds local Nat indices and relates each parameter's
intrinsic dimensions to the sample event shape. Leading plate dimensions
remain separate. Source elaboration and kernel checking instantiate this
same contract, including ordinary define computations that construct a
family value. Typed and literal arguments contribute equations jointly,
so coupled extent inference does not depend on parameter order. The
concrete-dimension helper uses the shared exact Nat solver.
Legacy event-dimension metadata is translated into this representation once.
It does not introduce another checking path.
For instance, the additive log-ratio normal binds a coordinate extent d,
takes location shape [d] and Cholesky shape [d, d], and samples a
simplex of shape [nat_add(d, 1)]. Structural dimensions can also relate
parameters when the sample is scalar. FamilyParameter.scalar_broadcast
distinguishes ordinary plated broadcasting from a structural table that
requires its own dimensions.
families
¶
The semantic registry of distribution families.
One record per family says what a distribution is, independently of any
host library: its parameters with their constraints and ranks, the type and
event rank of a sample, its support, whether it is discrete, whether a
sample is reparameterizable, and the spelling each transpile target uses.
The compiler, the reference runtime, and every renderer read this table;
host-specific metadata such as the torch.distributions class is kept
beside it in the layers that need it and checked against it in tests, so a
family cannot mean one thing to the checker and another to a backend.
Four families form the measure algebra a program's operator forms lower
to. Restrict(base, low, high) is the restriction of a base to an
interval, a sub-probability measure whose density is the base's inside the
interval and whose mass is the base's mass there; Mixture(weights,
component) is the weighted sum of measures, with raw weights, whose mass
is the weighted sum of the components' masses and whose component is
either one sampleable plated over the mixture axis or a tensor of
sampleables, one per component; Normalize(base) rescales a measure to
a probability measure; PointMass(value) is the Dirac measure. A
sample or observe step normalizes the measure it draws from, so
Restrict at a step is the truncated family and a mixture of restricted
components weighs each by its mass.
FAMILIES
module-attribute
¶
FAMILIES: Mapping[str, DistributionFamily] = MappingProxyType({item.name: item for item in _FAMILIES})
Every family by source name.
The mapping is closed: a name absent here is not a distribution family, and no backend may invent one.
ParameterConstraint
¶
A symbolic constraint on a parameter value, such as "positive",
"unit_interval", "simplex", "positive_definite", or
"dependent" when the admissible values depend on other parameters. A
compositional family's parameters use "sampleable" for a distribution
it is built from and "transform" for a named bijector chain; an atom's
"numeric" value is an integer or a real, and fixes which the atom
samples.
SupportKind
¶
A symbolic description of where samples live, in the same vocabulary as the parameter constraints.
FamilyParameter
didactic-model
¶
FamilyParameter(*, name: str, constraint: ParameterConstraint, rank: int, event_dims: tuple[int | None, ...] = (), scalar_broadcast: bool = True)
Bases: Model
One parameter of a distribution family.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The parameter's name, as the source spells it by keyword.
TYPE:
|
constraint
|
The symbolic constraint on admissible values.
TYPE:
|
rank
|
The tensor rank of one parameter value: 0 for a scalar, 1 for a vector, 2 for a matrix.
TYPE:
|
event_dims
|
For each of the value's own dimensions, the dimension of the
family's sample it has the extent of, or
TYPE:
|
scalar_broadcast
|
Whether a scalar may broadcast over a plated tensor parameter. False for structural tables whose dimensions must be supplied explicitly.
TYPE:
|
DistributionFamily
didactic-model
¶
DistributionFamily(*, name: str, parameters: tuple[FamilyParameter, ...] = field(opaque=True, extras=OPAQUE_BY_VALUE), support: SupportKind, element: TypeExpr = field(opaque=True, extras=OPAQUE_BY_VALUE), event_rank: int, event_sources: tuple[str, ...], discrete: bool, reparameterizable: bool, compositional: bool, targets: Mapping[str, str] = field(default_factory=dict, opaque=True, extras=OPAQUE_BY_VALUE), finite_support: tuple[LiteralData, ...] | None = field(default=None, opaque=True, extras=OPAQUE_BY_VALUE), event_offsets: tuple[int, ...] = (), shape_signature: FamilyShapeSignature | None = field(default=None, opaque=True, extras=OPAQUE_BY_VALUE), atom_locations: tuple[float, ...] | None = field(default=(), opaque=True, extras=OPAQUE_BY_VALUE))
Bases: ValueModel
The semantic record of one distribution family.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The family's source name, such as
TYPE:
|
parameters
|
The parameters, in the order a positional application supplies
them. Alternative parameterizations, such as
TYPE:
|
support
|
Where samples live.
TYPE:
|
element
|
The scalar type of one sample element.
TYPE:
|
event_rank
|
The rank of one sample: 0 for a scalar family, 1 for a vector family, 2 for a matrix family.
TYPE:
|
event_sources
|
The parameters whose trailing
TYPE:
|
discrete
|
Whether samples are discrete.
TYPE:
|
reparameterizable
|
Whether a sample can be drawn as a differentiable function of the parameters.
TYPE:
|
compositional
|
Whether the family is built from other distributions or morphisms rather than from tensor parameters alone.
TYPE:
|
targets
|
The spelling each transpile target uses for the family.
TYPE:
|
event_offsets
|
Nonnegative offsets from parameter event dimensions to sample dimensions, or empty for identity extents. An additive log-ratio normal has one more simplex component than Gaussian coordinates.
TYPE:
|
finite_support
|
The finite set of values a sample ranges over, when the family has one independent of its parameters.
TYPE:
|
shape_signature
|
Explicit dependent parameter/event shape contract. Legacy event-shape fields are otherwise translated to the same representation.
TYPE:
|
atom_locations
class-attribute
instance-attribute
¶
atom_locations: tuple[float, ...] | None = dx.field(default=(), opaque=True, extras=OPAQUE_BY_VALUE)
Fixed scalar atom carrier; None means a constructor-dependent carrier.
Empty locations declare an atomless non-discrete, noncompositional law. Integer laws use the global integer counting reference, including cells with zero mass. Compositions derive carriers from their components.
effective_atomicity
property
¶
Classify the family's reference measure from its semantic contract.
| RETURNS | DESCRIPTION |
|---|---|
str
|
Discrete, composite, mixed, or atomless reference category. |
effective_shape_signature
property
¶
effective_shape_signature: FamilyShapeSignature
Return the dependent contract, translating legacy shorthand once.
| RETURNS | DESCRIPTION |
|---|---|
FamilyShapeSignature
|
Intrinsic parameter and native event dimensions under local Nat binders. Every checking path consumes this contract. |
id
property
¶
id: DistributionId
The family's stable identity.
| RETURNS | DESCRIPTION |
|---|---|
DistributionId
|
An identity derived from the |
parameter_names
property
¶
The parameter names in positional order.
| RETURNS | DESCRIPTION |
|---|---|
tuple[str, ...]
|
The names. |
parameter
¶
parameter(name: str) -> FamilyParameter
Look up a parameter by name.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The parameter's name.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
FamilyParameter
|
The parameter. |
| RAISES | DESCRIPTION |
|---|---|
KeyError
|
If the family has no such parameter. |
Source code in src/quivers/qiec/families.py
event_argument
¶
The supplied argument that fixes the sample's event shape.
| PARAMETER | DESCRIPTION |
|---|---|
arguments
|
An application's named arguments.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[str, V] | None
|
The first argument filling one of |
Source code in src/quivers/qiec/families.py
family
¶
family(name: str) -> DistributionFamily
Look up a distribution family by source name.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The family's source name.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
DistributionFamily
|
The family's semantic record. |
| RAISES | DESCRIPTION |
|---|---|
KeyError
|
If no family has the name. |
Source code in src/quivers/qiec/families.py
family_shapes
¶
Dependent shape signatures shared by distribution checking and elaboration.
FamilyShapeSignature
didactic-model
¶
FamilyShapeSignature(*, telescope: tuple[IndexBinder, ...] = field(opaque=True, extras=OPAQUE_BY_VALUE), parameter_shapes: tuple[tuple[str, tuple[IndexTerm, ...]], ...] = field(opaque=True, extras=OPAQUE_BY_VALUE), event_shape: tuple[IndexTerm, ...] = field(opaque=True, extras=OPAQUE_BY_VALUE))
Bases: ValueModel
A Nat telescope relating parameter dimensions and one sample event.
| PARAMETER | DESCRIPTION |
|---|---|
telescope
|
Local Nat variables, freshened for every distribution application.
TYPE:
|
parameter_shapes
|
Each parameter's own dimensions, excluding leading plate batch axes.
TYPE:
|
event_shape
|
One sample's event dimensions. An empty tuple denotes a scalar event.
TYPE:
|
Notes
All dimension dependencies use the ordinary checked Nat language. Scheme variables are local to this signature; they cannot bind a caller's rigid indices or identify unrelated caller axes by coincident cardinality.
parameter_shape
¶
parameter_shape(name: str) -> tuple[IndexTerm, ...]
Return one parameter's intrinsic dimension pattern.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
Parameter name.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[IndexTerm, ...]
|
Its dimensions under this signature's telescope. |
| RAISES | DESCRIPTION |
|---|---|
KeyError
|
If the signature contains no parameter of this name. |
Source code in src/quivers/qiec/family_shapes.py
legacy_family_shape_signature
¶
legacy_family_shape_signature(parameters: Sequence[tuple[str, int, tuple[int | None, ...]]], event_rank: int, event_sources: Sequence[str], event_offsets: tuple[int, ...] = ()) -> FamilyShapeSignature
Translate existing event-dimension shorthand into one dependent contract.
| PARAMETER | DESCRIPTION |
|---|---|
parameters
|
Parameter name, rank, and legacy event-dimension correspondence.
TYPE:
|
event_rank
|
Native sample event rank.
TYPE:
|
event_sources
|
Alternative parameters fixing the sample's trailing native dimensions.
TYPE:
|
event_offsets
|
Existing nonnegative parameter-to-sample offsets.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
FamilyShapeSignature
|
A canonical contract consumed by the same checking path as explicitly authored shape signatures. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If legacy ranks, sources, or event-dimension correspondences conflict. |
Source code in src/quivers/qiec/family_shapes.py
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 | |
instantiate_family_shapes
¶
instantiate_family_shapes(signature: FamilyShapeSignature, indices: Mapping[str, IndexTerm]) -> tuple[dict[str, tuple[IndexTerm, ...]], tuple[IndexTerm, ...]]
Instantiate shape patterns using the ordinary capture-safe substitution.
| PARAMETER | DESCRIPTION |
|---|---|
signature
|
The local dependent shape contract.
TYPE:
|
indices
|
One replacement for every local Nat binder.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[dict[str, tuple[IndexTerm, ...]], tuple[IndexTerm, ...]]
|
Parameter patterns and sample event pattern after substitution. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If substitutions do not supply exactly the local telescope. |
Source code in src/quivers/qiec/family_shapes.py
family_shape_equations
¶
family_shape_equations(parameter_shapes: Mapping[str, tuple[IndexTerm, ...]], event_shape: tuple[IndexTerm, ...], actual_shapes: Mapping[str, tuple[IndexTerm, ...]], event: tuple[IndexTerm, ...] | None = None) -> tuple[tuple[IndexTerm, IndexTerm], ...]
Collect the same exact dimension equations for every checking frontend.
| PARAMETER | DESCRIPTION |
|---|---|
parameter_shapes
|
Instantiated intrinsic shape patterns.
TYPE:
|
event_shape
|
Instantiated sample event pattern.
TYPE:
|
actual_shapes
|
Supplied intrinsic parameter dimensions; scalar broadcasts omit shape evidence rather than inventing dimensions.
TYPE:
|
event
|
Declared native event dimensions, when available.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[tuple[IndexTerm, IndexTerm], ...]
|
Pattern/actual equations, without mutating either scope. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If a supplied intrinsic parameter or event has the wrong rank. |
Source code in src/quivers/qiec/family_shapes.py
match_family_shapes
¶
match_family_shapes(signature: FamilyShapeSignature, actual_shapes: Mapping[str, tuple[IndexTerm, ...]], event: tuple[IndexTerm, ...] | None = None) -> tuple[IndexTerm, ...]
Check symbolic shapes by solving only freshly scoped scheme variables.
| PARAMETER | DESCRIPTION |
|---|---|
signature
|
Dependent family contract.
TYPE:
|
actual_shapes
|
Intrinsic supplied parameter shapes.
TYPE:
|
event
|
Native event dimensions supplied by a plate or result type.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[IndexTerm, ...]
|
The uniquely instantiated native event shape. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If exact shape equations disagree or cannot determine the event. |
Source code in src/quivers/qiec/family_shapes.py
314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 | |
validate_family_shape_dimensions
¶
validate_family_shape_dimensions(signature: FamilyShapeSignature, shapes: Mapping[str, Sequence[int]]) -> dict[str, int]
Validate concrete host dimensions with the shared exact Nat solver.
| PARAMETER | DESCRIPTION |
|---|---|
signature
|
The same contract used by source and kernel checking.
TYPE:
|
shapes
|
Supplied intrinsic tensor dimensions.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, int]
|
Uniquely inferred scheme extents. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If a parameter has the wrong rank or exact shape evidence conflicts. |