Skip to content

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

ParameterConstraint = str

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

SupportKind = str

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: str

constraint

The symbolic constraint on admissible values.

TYPE: ParameterConstraint

rank

The tensor rank of one parameter value: 0 for a scalar, 1 for a vector, 2 for a matrix.

TYPE: int

event_dims

For each of the value's own dimensions, the dimension of the family's sample it has the extent of, or None when the sample's shape does not fix it; empty when no dimension is tied to the sample. A multivariate normal's scale_tril is (0, 0): a square matrix over the sample's one axis.

TYPE: tuple[int | None, ...] DEFAULT: ()

scalar_broadcast

Whether a scalar may broadcast over a plated tensor parameter. False for structural tables whose dimensions must be supplied explicitly.

TYPE: bool DEFAULT: True

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 "Normal".

TYPE: str

parameters

The parameters, in the order a positional application supplies them. Alternative parameterizations, such as probs and logits, are both listed; an application supplies one.

TYPE: tuple[FamilyParameter, ...] DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

support

Where samples live.

TYPE: SupportKind

element

The scalar type of one sample element.

TYPE: TypeExpr DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

event_rank

The rank of one sample: 0 for a scalar family, 1 for a vector family, 2 for a matrix family.

TYPE: int

event_sources

The parameters whose trailing event_rank dimensions fix the sample's event shape, one per alternative parameterization (an application supplies at most one of them), or empty when the family is scalar or the shape comes from elsewhere.

TYPE: tuple[str, ...]

discrete

Whether samples are discrete.

TYPE: bool

reparameterizable

Whether a sample can be drawn as a differentiable function of the parameters.

TYPE: bool

compositional

Whether the family is built from other distributions or morphisms rather than from tensor parameters alone.

TYPE: bool

targets

The spelling each transpile target uses for the family.

TYPE: Mapping[str, str] DEFAULT: field(default_factory=dict, opaque=True, extras=OPAQUE_BY_VALUE)

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: tuple[int, ...] DEFAULT: ()

finite_support

The finite set of values a sample ranges over, when the family has one independent of its parameters.

TYPE: tuple[LiteralData, ...] | None DEFAULT: field(default=None, opaque=True, extras=OPAQUE_BY_VALUE)

shape_signature

Explicit dependent parameter/event shape contract. Legacy event-shape fields are otherwise translated to the same representation.

TYPE: FamilyShapeSignature | None DEFAULT: field(default=None, opaque=True, extras=OPAQUE_BY_VALUE)

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

effective_atomicity: str

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

The family's stable identity.

RETURNS DESCRIPTION
DistributionId

An identity derived from the builtin namespace and the name, the same in every module.

parameter_names property

parameter_names: tuple[str, ...]

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: str

RETURNS DESCRIPTION
FamilyParameter

The parameter.

RAISES DESCRIPTION
KeyError

If the family has no such parameter.

Source code in src/quivers/qiec/families.py
def parameter(self, name: str) -> FamilyParameter:
    """Look up a parameter by name.

    Parameters
    ----------
    name : str
        The parameter's name.

    Returns
    -------
    FamilyParameter
        The parameter.

    Raises
    ------
    KeyError
        If the family has no such parameter.
    """
    for parameter in self.parameters:
        if parameter.name == name:
            return parameter
    raise KeyError(f"family {self.name!r} has no parameter {name!r}")

event_argument

event_argument(arguments: Iterable[tuple[str, V]]) -> tuple[str, V] | None

The supplied argument that fixes the sample's event shape.

PARAMETER DESCRIPTION
arguments

An application's named arguments.

TYPE: Iterable[tuple[str, V]]

RETURNS DESCRIPTION
tuple[str, V] | None

The first argument filling one of event_sources, as its name and value, or None when the application supplies none of them.

Source code in src/quivers/qiec/families.py
def event_argument[V](
    self, arguments: Iterable[tuple[str, V]]
) -> tuple[str, V] | None:
    """The supplied argument that fixes the sample's event shape.

    Parameters
    ----------
    arguments : Iterable[tuple[str, V]]
        An application's named arguments.

    Returns
    -------
    tuple[str, V] | None
        The first argument filling one of `event_sources`, as its
        name and value, or ``None`` when the application supplies
        none of them.
    """
    for name, value in arguments:
        if name in self.event_sources:
            return (name, value)
    return None

family

family(name: str) -> DistributionFamily

Look up a distribution family by source name.

PARAMETER DESCRIPTION
name

The family's source name.

TYPE: str

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
def family(name: str) -> DistributionFamily:
    """Look up a distribution family by source name.

    Parameters
    ----------
    name : str
        The family's source name.

    Returns
    -------
    DistributionFamily
        The family's semantic record.

    Raises
    ------
    KeyError
        If no family has the name.
    """
    try:
        return FAMILIES[name]
    except KeyError as error:
        raise KeyError(f"unknown distribution family {name!r}") from error

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: tuple[IndexBinder, ...] DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

parameter_shapes

Each parameter's own dimensions, excluding leading plate batch axes.

TYPE: tuple[tuple[str, tuple[IndexTerm, ...]], ...] DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

event_shape

One sample's event dimensions. An empty tuple denotes a scalar event.

TYPE: tuple[IndexTerm, ...] DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

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: str

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
def parameter_shape(self, name: str) -> tuple[IndexTerm, ...]:
    """Return one parameter's intrinsic dimension pattern.

    Parameters
    ----------
    name : str
        Parameter name.

    Returns
    -------
    tuple[IndexTerm, ...]
        Its dimensions under this signature's telescope.

    Raises
    ------
    KeyError
        If the signature contains no parameter of this name.
    """
    for parameter, shape in self.parameter_shapes:
        if parameter == name:
            return shape
    raise KeyError(name)

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: Sequence[tuple[str, int, tuple[int | None, ...]]]

event_rank

Native sample event rank.

TYPE: int

event_sources

Alternative parameters fixing the sample's trailing native dimensions.

TYPE: Sequence[str]

event_offsets

Existing nonnegative parameter-to-sample offsets.

TYPE: tuple[int, ...] DEFAULT: ()

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
def 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.

    Parameters
    ----------
    parameters : Sequence[tuple[str, int, tuple[int | None, ...]]]
        Parameter name, rank, and legacy event-dimension correspondence.
    event_rank : int
        Native sample event rank.
    event_sources : Sequence[str]
        Alternative parameters fixing the sample's trailing native dimensions.
    event_offsets : tuple[int, ...]
        Existing nonnegative parameter-to-sample offsets.

    Returns
    -------
    FamilyShapeSignature
        A canonical contract consumed by the same checking path as explicitly
        authored shape signatures.

    Raises
    ------
    ValueError
        If legacy ranks, sources, or event-dimension correspondences conflict.
    """
    if type(event_rank) is not int or event_rank < 0:
        raise ValueError("native event rank must be a nonnegative integer")
    if event_offsets and (
        len(event_offsets) != event_rank
        or any(type(v) is not int or v < 0 for v in event_offsets)
    ):
        raise ValueError(
            "event offsets require one nonnegative integer per event dimension"
        )
    ranks = {name: rank for name, rank, _ in parameters}
    for source in event_sources:
        if source not in ranks:
            raise ValueError(f"event source {source!r} is not a parameter")
        if ranks[source] < event_rank:
            raise ValueError(
                f"event source {source!r} has rank below the family's event rank"
            )
    for name, rank, correspondence in parameters:
        if type(rank) is not int or rank < 0:
            raise ValueError(f"parameter {name!r} rank must be a nonnegative integer")
        if correspondence and (
            len(correspondence) != rank
            or any(
                v is not None and (type(v) is not int or not 0 <= v < event_rank)
                for v in correspondence
            )
        ):
            raise ValueError(f"parameter {name!r} has incompatible event dimensions")
    binders = []

    def variable(name):
        """Declare one fresh local Nat axis for translated metadata.

        Parameters
        ----------
        name : str
            Local scheme name.

        Returns
        -------
        IndexVariable
            The variable declared by the appended telescope binder.
        """
        binders.append(IndexBinder(name=name, sort=NAT))
        return IndexVariable(name=name, sort=NAT)

    event = tuple(variable(f"event_{i}") for i in range(event_rank))
    patterns = []
    for name, rank, correspondence in parameters:
        dimensions = []
        for i in range(rank):
            dimension = correspondence[i] if correspondence else None
            dimensions.append(
                event[dimension]
                if dimension is not None
                else variable(f"parameter_{name}_{i}")
            )
        shape = tuple(dimensions)
        patterns.append((name, shape))
    if event_sources and event_rank:
        source = dict(patterns)[event_sources[0]]
        event = tuple(
            shift_index(size, offset)
            for size, offset in zip(
                source[-event_rank:], event_offsets or (0,) * event_rank, strict=True
            )
        )
    return FamilyShapeSignature(
        telescope=tuple(binders), parameter_shapes=tuple(patterns), event_shape=event
    )

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: FamilyShapeSignature

indices

One replacement for every local Nat binder.

TYPE: Mapping[str, IndexTerm]

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
def 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.

    Parameters
    ----------
    signature : FamilyShapeSignature
        The local dependent shape contract.
    indices : Mapping[str, IndexTerm]
        One replacement for every local Nat binder.

    Returns
    -------
    tuple[dict[str, tuple[IndexTerm, ...]], tuple[IndexTerm, ...]]
        Parameter patterns and sample event pattern after substitution.

    Raises
    ------
    ValueError
        If substitutions do not supply exactly the local telescope.
    """
    if set(indices) != {b.name for b in signature.telescope}:
        raise ValueError(
            "family shape substitution must instantiate its exact telescope"
        )
    for term in indices.values():
        add_indices(term)
    replacement = StaticSubstitution(
        types=(), indices=tuple(indices.items()), effects=()
    )
    return (
        {
            name: tuple(substitute_index(t, replacement) for t in shape)
            for name, shape in signature.parameter_shapes
        },
        tuple(substitute_index(t, replacement) for t in signature.event_shape),
    )

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: Mapping[str, tuple[IndexTerm, ...]]

event_shape

Instantiated sample event pattern.

TYPE: tuple[IndexTerm, ...]

actual_shapes

Supplied intrinsic parameter dimensions; scalar broadcasts omit shape evidence rather than inventing dimensions.

TYPE: Mapping[str, tuple[IndexTerm, ...]]

event

Declared native event dimensions, when available.

TYPE: tuple[IndexTerm, ...] or None DEFAULT: None

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
def 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.

    Parameters
    ----------
    parameter_shapes : Mapping[str, tuple[IndexTerm, ...]]
        Instantiated intrinsic shape patterns.
    event_shape : tuple[IndexTerm, ...]
        Instantiated sample event pattern.
    actual_shapes : Mapping[str, tuple[IndexTerm, ...]]
        Supplied intrinsic parameter dimensions; scalar broadcasts omit shape
        evidence rather than inventing dimensions.
    event : tuple[IndexTerm, ...] or None
        Declared native event dimensions, when available.

    Returns
    -------
    tuple[tuple[IndexTerm, IndexTerm], ...]
        Pattern/actual equations, without mutating either scope.

    Raises
    ------
    ValueError
        If a supplied intrinsic parameter or event has the wrong rank.
    """
    pairs = []
    for name, actual in actual_shapes.items():
        expected = parameter_shapes[name]
        if len(actual) != len(expected):
            raise ValueError(
                f"parameter {name!r} has rank {len(actual)}, expected {len(expected)}"
            )
        pairs.extend(zip(expected, actual, strict=True))
    if event is not None:
        if len(event) != len(event_shape):
            raise ValueError("distribution event has the wrong rank")
        pairs.extend(zip(event_shape, event, strict=True))
    return tuple(pairs)

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: FamilyShapeSignature

actual_shapes

Intrinsic supplied parameter shapes.

TYPE: Mapping[str, tuple[IndexTerm, ...]]

event

Native event dimensions supplied by a plate or result type.

TYPE: tuple[IndexTerm, ...] or None DEFAULT: None

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
def 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.

    Parameters
    ----------
    signature : FamilyShapeSignature
        Dependent family contract.
    actual_shapes : Mapping[str, tuple[IndexTerm, ...]]
        Intrinsic supplied parameter shapes.
    event : tuple[IndexTerm, ...] or None
        Native event dimensions supplied by a plate or result type.

    Returns
    -------
    tuple[IndexTerm, ...]
        The uniquely instantiated native event shape.

    Raises
    ------
    ValueError
        If exact shape equations disagree or cannot determine the event.
    """
    used = {
        v.name
        for shape in (*actual_shapes.values(), event or ())
        for t in shape
        for v in _variables(t)
    }
    indices = {}
    for position, binder in enumerate(signature.telescope):
        name = f"__qvr_family_shape_{position}"
        while name in used:
            name += "_"
        used.add(name)
        indices[binder.name] = IndexVariable(name=name, sort=NAT)
    parameters, expected_event = instantiate_family_shapes(signature, indices)
    equations = list(
        family_shape_equations(parameters, expected_event, actual_shapes, event)
    )
    unknowns = set(indices.values())
    ground = [
        (left, int(right.value))
        for left, right in equations
        if isinstance(right, IndexLiteral) and right.sort == NAT
    ]
    inferred = infer_index_extents(ground)
    replacement = StaticSubstitution(
        types=(),
        indices=tuple(
            (name, IndexLiteral(value=value, sort=NAT))
            for name, value in inferred.items()
        ),
        effects=(),
    )
    unknowns = {v for v in unknowns if v.name not in inferred}
    while True:
        changed = False
        for left, right in equations:
            left, right = (
                substitute_index(left, replacement),
                substitute_index(right, replacement),
            )
            if left == right:
                continue
            for unknown in sorted(unknowns, key=lambda variable: variable.name):
                solution = solve_index_equation(left, right, unknown)
                if solution is None:
                    continue
                fixed = StaticSubstitution(
                    types=(), indices=((unknown.name, solution),), effects=()
                )
                prior = tuple(
                    (name, substitute_index(term, fixed))
                    for name, term in replacement.indices
                )
                replacement = StaticSubstitution(
                    types=(), indices=(*prior, (unknown.name, solution)), effects=()
                )
                unknowns.remove(unknown)
                changed = True
                break
        if not changed:
            break
    if any(
        substitute_index(a, replacement) != substitute_index(b, replacement)
        for a, b in equations
    ):
        raise ValueError("incompatible dependent family parameter/event extents")
    result = tuple(substitute_index(t, replacement) for t in expected_event)
    if any(v in unknowns for t in result for v in _variables(t)):
        raise ValueError("family event shape requires further extent evidence")
    return result

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: FamilyShapeSignature

shapes

Supplied intrinsic tensor dimensions.

TYPE: Mapping[str, Sequence[int]]

RETURNS DESCRIPTION
dict[str, int]

Uniquely inferred scheme extents.

RAISES DESCRIPTION
ValueError

If a parameter has the wrong rank or exact shape evidence conflicts.

Source code in src/quivers/qiec/family_shapes.py
def validate_family_shape_dimensions(
    signature: FamilyShapeSignature, shapes: Mapping[str, Sequence[int]]
) -> dict[str, int]:
    """Validate concrete host dimensions with the shared exact Nat solver.

    Parameters
    ----------
    signature : FamilyShapeSignature
        The same contract used by source and kernel checking.
    shapes : Mapping[str, Sequence[int]]
        Supplied intrinsic tensor dimensions.

    Returns
    -------
    dict[str, int]
        Uniquely inferred scheme extents.

    Raises
    ------
    ValueError
        If a parameter has the wrong rank or exact shape evidence conflicts.
    """
    actual = {}
    for name, dimensions in shapes.items():
        if any(
            isinstance(size, bool) or not isinstance(size, int) for size in dimensions
        ):
            raise TypeError("observed shape extents must be integers")
        actual[name] = tuple(IndexLiteral(value=size, sort=NAT) for size in dimensions)
    equations = family_shape_equations(
        dict(signature.parameter_shapes), signature.event_shape, actual
    )
    inferred = infer_index_extents(
        [
            (pattern, int(cast(IndexLiteral, value).value))
            for pattern, value in equations
        ]
    )
    replacement = StaticSubstitution(
        types=(),
        indices=tuple(
            (name, IndexLiteral(value=value, sort=NAT))
            for name, value in inferred.items()
        ),
        effects=(),
    )
    if any(
        substitute_index(pattern, replacement) != value for pattern, value in equations
    ):
        raise ValueError("family shape contract requires further extent evidence")
    return inferred