Checked programs¶
A program morphism that runs its checked computation on the reference machine.
checked_program
¶
A program morphism that runs its checked computation.
A program that calls a named computation has no step table the
runtime compiler can build: the call's body is a term of the checked
module, and only the reference machine runs it. Its compiled form is a
CheckedProgram, a
morphism whose forward samples and joint densities are the module's own
sample_program and
run_program runs, so the
program's Python surface is the one entry point the command line and the
REPL invoke.
CheckedProgram
¶
CheckedProgram(domain: AnySpace, codomain: AnySpace, module: QiecModule, name: str)
Bases: ContinuousMorphism
A program run as its elaborated computation on the reference machine.
| PARAMETER | DESCRIPTION |
|---|---|
domain
|
The program's declared domain.
TYPE:
|
codomain
|
The program's declared codomain.
TYPE:
|
module
|
The checked module holding the program's entry point.
TYPE:
|
name
|
The program's name.
TYPE:
|
Source code in src/quivers/effects/checked_program.py
observed_names
¶
The names the program observes.
| RETURNS | DESCRIPTION |
|---|---|
set[str]
|
The labels of its |
Source code in src/quivers/effects/checked_program.py
rsample
¶
rsample(x: Tensor, sample_shape: Size = Size(), observations: Mapping[str, Tensor] | None = None) -> Tensor
Run the program forward, once per input row and sample.
| PARAMETER | DESCRIPTION |
|---|---|
x
|
Program input. Shape
TYPE:
|
sample_shape
|
Additional leading sample dimensions; each element is one independent run. |
observations
|
The program's data by parameter name, and values for the sample sites the runs condition on; every other site is drawn.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
The returned values, shape |
Source code in src/quivers/effects/checked_program.py
has_conditional_density
¶
No: a program's density at its output marginalizes its draws.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Always |
Source code in src/quivers/effects/checked_program.py
log_prob
¶
Log-probability is not defined for a program's output alone.
| PARAMETER | DESCRIPTION |
|---|---|
x
|
Program input.
TYPE:
|
y
|
Program output.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
NotImplementedError
|
Always: the density at the output marginalizes every draw. |
Source code in src/quivers/effects/checked_program.py
log_joint
¶
The joint log-density at given values for every site.
| PARAMETER | DESCRIPTION |
|---|---|
x
|
Program input. Shape
TYPE:
|
intermediates
|
The program's data by parameter name and a value for every sample site, by label.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
The log joint of each input row's run. Shape |
| RAISES | DESCRIPTION |
|---|---|
ExecutionFailure
|
If a site the program reaches is given no value, or a given site is never reached. |