Program elaboration¶
These functions elaborate a program declaration
into a Quivers Indexed Effect Core (QIEC) computation, resolving its names and dependencies. A change to how
draws, observations, or deterministic bindings
run is made here.
Internal module
This module is an implementation detail of the compiler and its
tooling. Its __all__ is empty, so none of the names below are
part of the public API, and they may change without notice.
program_elaboration
¶
Elaboration of program declarations into QIEC computations.
A program is domain-specific notation for a named computation: its data,
observations, and index maps are the computation's typed parameters, its
sample steps perform Random.sample on the module's canonical
random instance, its observe and score steps perform
Score.add on the canonical score instance, its let steps bind
pure expressions, its marginalize blocks call a helper computation
that enumerates a finite latent under the prelude's enumeration handler,
and its return builds the result tuple. The elaboration is a mixin
over the QIEC elaborator, since it shares the value lowering, the
registry, and the diagnostics of every other declaration.
Plates are typed data. A step's over and iid_over axes, its
: Axis annotation, and a morphism's Real N codomain fix a
PlateShape on the step's distribution, whose sample type is the
tensor over those axes; a via index map re-indexes a grouped latent's
arguments to the observation rows and segments the observation's weights
back to the groups.
ObjectInfo
didactic-model
¶
ObjectInfo(*, extent: int | IndexTerm | None = field(default=None, opaque=True, extras=OPAQUE_BY_VALUE), real_width: int | IndexVariable | None = field(default=None, opaque=True, extras=OPAQUE_BY_VALUE), finite: bool = False)
Bases: QiecModel
What the elaborator reads off one object declaration.
| PARAMETER | DESCRIPTION |
|---|---|
extent
|
The object's size as an axis: its cardinality when finite, its coordinate count when continuous. An object parameter of a program template has an index variable for its size, bound by the template's telescope.
TYPE:
|
real_width
|
The width of a
TYPE:
|
finite
|
Whether the object is a finite set.
TYPE:
|
marginal_helper_name
¶
The name of the helper a marginalize step generates.
| PARAMETER | DESCRIPTION |
|---|---|
program
|
The program holding the step.
TYPE:
|
latent
|
The marginalized latent's name.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The member |
Source code in src/quivers/dsl/program_elaboration.py
reached_site_labels
¶
reached_site_labels(name: str, declarations: Mapping[str, ProgramDecl]) -> frozenset[str]
The labels of every site a program reaches when it runs.
A program reaches its own sites, the sites of the programs it calls
with let y <- p(...), which keep their labels, and the sites of
the step programs it scans with, which it reaches once per position
under the same labels.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The program's name.
TYPE:
|
declarations
|
The module's program declarations, step programs included.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
frozenset[str]
|
The labels; empty for a name that is not a program. |