Programs¶
A ProgramEntry records how an elaborated computation is exposed as a program: the roles of its
parameters, its sites, and its return names
(program declaration), so a caller
need not reconstruct them from source
(public boundary). The
body itself is the well-typed computation.
programs
¶
Typed entry-point metadata for programs elaborated into computations.
A program declaration elaborates to an ordinary named computation whose
parameters are the program's data, observations, and index maps, and whose
body performs the canonical Random.sample and Score.add requests.
What the computation alone does not say is which parameter plays which
role, which locals are the program's sites, and what the return tuple's
labels are. The records here carry that, beside the computation, so a
runtime, a transpiler, or a tool can drive the entry point without
re-reading the source.
ParameterRole
¶
ParameterRole = Literal['domain', 'scalar', 'data', 'observation', 'index_map', 'weight', 'bias', 'table', 'kernel-input']
How a program parameter is supplied.
domain parameters carry the value the program is applied to, one per
real factor of its domain; scalar ones are its declared parameters;
data ones are free names its steps read; observation ones are the
values observe steps score; index_map ones map observation rows to
groups; weight and bias are the numbers of a declared morphism's
affine parameter map and table those of a morphism over a finite
domain, one row per element; kernel-input holds a kernel's input
locations.
SiteKind
¶
What a program step does at its site.
ProgramParameter
didactic-model
¶
ProgramParameter(*, name: str, role: ParameterRole = field(opaque=True, extras=OPAQUE_BY_VALUE), type: TypeExpr = field(opaque=True, extras=OPAQUE_BY_VALUE), axes: tuple[str, ...] = field(default=(), opaque=True, extras=OPAQUE_BY_VALUE), per_row: bool = False, constraint: Literal['nonnegative'] | None = None, tag: Literal['program_parameter'] = 'program_parameter')
Bases: QiecModel
One parameter of an elaborated program.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The parameter's name, which is the computation parameter's.
TYPE:
|
role
|
How the parameter is supplied.
TYPE:
|
type
|
Its type.
TYPE:
|
axes
|
The name of each dimension of a tensor-typed parameter, the object or extent it ranges over; empty for a scalar.
TYPE:
|
per_row
|
Whether the parameter fills a family parameter of a plated draw directly, so that its leading axis is the draw's plate: a value without that axis is one value shared by every row, which a run broadcasts across the plate.
TYPE:
|
constraint
|
An additional checked value restriction.
TYPE:
|
tag
|
The serialization discriminator; always
TYPE:
|
ProgramSite
didactic-model
¶
ProgramSite(*, name: str, kind: SiteKind = field(opaque=True, extras=OPAQUE_BY_VALUE), family: str, batch: tuple[PlateAxis, ...] = field(default=(), opaque=True, extras=OPAQUE_BY_VALUE), event: tuple[PlateAxis, ...] = field(default=(), opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['program_site'] = 'program_site')
Bases: QiecModel
One probabilistic step of an elaborated program.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The site's label, the name the step binds or scores.
TYPE:
|
kind
|
Whether the step samples, observes, or marginalizes.
TYPE:
|
family
|
The distribution family the step draws from.
TYPE:
|
batch
|
The plate's batch axes.
TYPE:
|
event
|
The plate's event axes.
TYPE:
|
tag
|
The serialization discriminator; always
TYPE:
|
ProgramEntry
didactic-model
¶
ProgramEntry(*, name: str, computation: ComputationId = field(opaque=True, extras=OPAQUE_BY_VALUE), parameters: tuple[ProgramParameter, ...] = field(opaque=True, extras=OPAQUE_BY_VALUE), return_names: tuple[str, ...] = field(opaque=True, extras=OPAQUE_BY_VALUE), return_labels: tuple[str, ...] | None = field(opaque=True, extras=OPAQUE_BY_VALUE), sites: tuple[ProgramSite, ...] = field(opaque=True, extras=OPAQUE_BY_VALUE), random_instance: EffectInstanceId = field(opaque=True, extras=OPAQUE_BY_VALUE), score_instance: EffectInstanceId = field(opaque=True, extras=OPAQUE_BY_VALUE), telescope: Telescope = field(default=(), opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['program_entry'] = 'program_entry')
Bases: QiecModel
The typed entry point a program declaration elaborates to.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The program's source name.
TYPE:
|
computation
|
The identity of the named computation holding its body.
TYPE:
|
parameters
|
The computation's parameters with their roles, in order.
TYPE:
|
return_names
|
The names the program returns, in order.
TYPE:
|
return_labels
|
The labels of a labelled return tuple, or
TYPE:
|
sites
|
The program's probabilistic steps, in source order, those of marginalization scopes included.
TYPE:
|
random_instance
|
The lexical
TYPE:
|
score_instance
|
The lexical
TYPE:
|
telescope
|
The static binders the computation takes: one index binder per extent of an input the program's steps leave open, which a run reads off the data it is given.
TYPE:
|
tag
|
The serialization discriminator; always
TYPE:
|