Skip to content

Programs

Typed entry-point metadata for programs elaborated into computations.

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 fibrations, 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', 'fibration', '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; fibration 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

SiteKind = Literal['sample', 'observe', 'marginal']

What a program step does at its site.

ProgramParameter dataclass

ProgramParameter(name: str, role: ParameterRole, type: TypeExpr, axes: tuple[str, ...] = (), tag: Literal['program_parameter'] = 'program_parameter')

One parameter of an elaborated program.

PARAMETER DESCRIPTION
name

The parameter's name, which is the computation parameter's.

TYPE: str

role

How the parameter is supplied.

TYPE: ParameterRole

type

Its type.

TYPE: TypeExpr

axes

The name of each dimension of a tensor-typed parameter, the object or extent it ranges over; empty for a scalar.

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

tag

The serialization discriminator; always "program_parameter".

TYPE: Literal['program_parameter'] DEFAULT: 'program_parameter'

ProgramSite dataclass

ProgramSite(name: str, kind: SiteKind, family: str, batch: tuple[PlateAxis, ...] = (), event: tuple[PlateAxis, ...] = (), tag: Literal['program_site'] = 'program_site')

One probabilistic step of an elaborated program.

PARAMETER DESCRIPTION
name

The site's label, the name the step binds or scores.

TYPE: str

kind

Whether the step samples, observes, or marginalizes.

TYPE: SiteKind

family

The distribution family the step draws from.

TYPE: str

batch

The plate's batch axes.

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

event

The plate's event axes.

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

tag

The serialization discriminator; always "program_site".

TYPE: Literal['program_site'] DEFAULT: 'program_site'

ProgramEntry dataclass

ProgramEntry(name: str, computation: ComputationId, parameters: tuple[ProgramParameter, ...], return_names: tuple[str, ...], return_labels: tuple[str, ...] | None, sites: tuple[ProgramSite, ...], random_instance: EffectInstanceId, score_instance: EffectInstanceId, telescope: Telescope = (), tag: Literal['program_entry'] = 'program_entry')

The typed entry point a program declaration elaborates to.

PARAMETER DESCRIPTION
name

The program's source name.

TYPE: str

computation

The identity of the named computation holding its body.

TYPE: ComputationId

parameters

The computation's parameters with their roles, in order.

TYPE: tuple[ProgramParameter, ...]

return_names

The names the program returns, in order.

TYPE: tuple[str, ...]

return_labels

The labels of a labelled return tuple, or None.

TYPE: tuple[str, ...] | None

sites

The program's probabilistic steps, in source order, those of marginalization scopes included.

TYPE: tuple[ProgramSite, ...]

random_instance

The lexical Random instance the program's samples address.

TYPE: EffectInstanceId

score_instance

The lexical Score instance the program's scores address.

TYPE: EffectInstanceId

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: Telescope DEFAULT: ()

tag

The serialization discriminator; always "program_entry".

TYPE: Literal['program_entry'] DEFAULT: 'program_entry'