Skip to content

Program elaboration

Elaboration of program declarations into QIEC computations.

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 fibrations 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 fibration re-indexes a grouped latent's arguments to the observation rows and segments the observation's weights back to the groups.

ObjectInfo dataclass

ObjectInfo(extent: int | IndexVariable | None = None, real_width: int | IndexVariable | None = None, finite: bool = False)

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: int | IndexVariable | None DEFAULT: None

real_width

The width of a Real N object, whose values are real vectors.

TYPE: int | IndexVariable | None DEFAULT: None

finite

Whether the object is a finite set.

TYPE: bool DEFAULT: False