Plans and hashes¶
plan
¶
Resolving an experiment declaration into a closed, hashable plan.
An experiment names its entry, data, fixed values, inference method, seed, sweeps, the holes it fills, and the handlers it installs. Planning resolves all of these against the checked module graph and computes the experiment's identity without running anything:
- the graph is loaded with the experiment's
linkclauses filling its holes, so the linked program is the one that runs; - a computation entry with
handleclauses runs under those handlers: the plan adds the computation that installs them around the entry, outermost first, and runs that; - every
data,fix, andsweepname must be a parameter of the entry (or, for a program run, a sample site); - each point of the sweeps' product is one run, and its point hash is the digest of the entry's content hash, the pinned data digests, the values given by name, the method and every option after defaults, and the seed. Names of the experiment, the entry, and the declarations do not enter it, so renaming any of them keeps the hash; any change to what the run computes changes it.
The experiment's hash is the digest of its points' hashes in sweep order.
EXPERIMENT_FORMAT
module-attribute
¶
The format of an experiment's hash inputs; part of every hash.
WRAPPER_MEMBER
module-attribute
¶
The member name of the computation that installs an experiment's handlers:
experiment E runs E.entry.
PlannedData
didactic-model
¶
PlannedData(*, name: str, path: str, written: str, pin: ContentPin | None, line: int, column: int)
Bases: Model
A data clause with its file resolved.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The parameter or site it gives a value to.
TYPE:
|
path
|
The file, absolute.
TYPE:
|
written
|
The path as the experiment writes it.
TYPE:
|
pin
|
The pinned content hash.
TYPE:
|
line
|
The clause's line.
TYPE:
|
column
|
The clause's column.
TYPE:
|
PointValue
didactic-model
¶
Bases: Model
One value given by name at a point.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The parameter or site.
TYPE:
|
value
|
The value as canonical JSON text.
TYPE:
|
ExperimentPoint
didactic-model
¶
ExperimentPoint(*, index: tuple[int, ...], sweep: tuple[PointValue, ...], hash: str)
Bases: Model
One run of an experiment: one point of its sweeps' product.
| PARAMETER | DESCRIPTION |
|---|---|
index
|
The position of each sweep's value, in sweep order; empty for an experiment without sweeps.
TYPE:
|
sweep
|
The swept values at this point.
TYPE:
|
hash
|
The point hash.
TYPE:
|
label
property
¶
The point as name=value pairs.
| RETURNS | DESCRIPTION |
|---|---|
str
|
The swept values, or empty for the single point of an experiment without sweeps. |
SourceFile
didactic-model
¶
Bases: Model
A source file of the program an experiment runs.
| PARAMETER | DESCRIPTION |
|---|---|
path
|
The file.
TYPE:
|
module
|
The module it is.
TYPE:
|
digest
|
The BLAKE3 digest of its bytes.
TYPE:
|
swhid
|
Its Software Heritage content identifier,
TYPE:
|
ExperimentPlan
didactic-model
¶
ExperimentPlan(*, name: str, file: str, line: int, root: str, entry: str, program: str, entry_kind: Literal['program', 'computation'], entry_hash: str, method: str, kind: MethodKind, options: tuple[PointValue, ...], seed: int, data: tuple[PlannedData, ...], fixed: tuple[PointValue, ...], points: tuple[ExperimentPoint, ...], hash: str, sources: tuple[SourceFile, ...], links: tuple[ExperimentLink, ...], handlers: tuple[str, ...], module: QiecModule = field(opaque=True, extras=OPAQUE_BY_VALUE), model: Model | None = field(default=None, opaque=True, extras=OPAQUE_BY_IDENTITY))
Bases: ValueModel
An experiment resolved against its program, ready to run or hash.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The experiment's name.
TYPE:
|
file
|
The file declaring it.
TYPE:
|
line
|
Its line.
TYPE:
|
root
|
The module declaring it.
TYPE:
|
entry
|
The entry it runs, a flat-program name (the handler-installing computation when the experiment installs handlers).
TYPE:
|
program
|
The entry its
TYPE:
|
entry_kind
|
Whether the entry is a program or a computation.
TYPE:
|
entry_hash
|
The content hash of the entry; for a fit, combined with the interpretation bindings and the source's statement digest.
TYPE:
|
method
|
The inference method.
TYPE:
|
kind
|
Whether the method runs the entry or fits it.
TYPE:
|
options
|
Every option of the method after defaults, sorted by name.
TYPE:
|
seed
|
The seed.
TYPE:
|
data
|
The data clauses.
TYPE:
|
fixed
|
The fixed values.
TYPE:
|
points
|
The runs, in sweep order.
TYPE:
|
hash
|
The experiment's hash.
TYPE:
|
sources
|
The source files of the program.
TYPE:
|
links
|
The holes filled.
TYPE:
|
handlers
|
The handlers installed, as
TYPE:
|
module
|
The checked module the entry runs in.
TYPE:
|
model
|
For a fit, the live model of the program, compared by identity.
TYPE:
|
option_values
¶
option_values() -> dict[str, OptionValue]
The method's options as values.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, OptionValue]
|
Each option's value, by name. |
Source code in src/quivers/experiments/plan.py
swhid
¶
The Software Heritage identifier of a file's content.
| PARAMETER | DESCRIPTION |
|---|---|
data
|
The file's bytes.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
|
Source code in src/quivers/experiments/plan.py
declared_experiments
¶
declared_experiments(path: str | Path) -> tuple[ExperimentDecl, ...]
The experiments a module file declares, read without resolving them.
| PARAMETER | DESCRIPTION |
|---|---|
path
|
A
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[ExperimentDecl, ...]
|
Its experiments, in source order. |
| RAISES | DESCRIPTION |
|---|---|
OSError
|
If the file cannot be read. |
ParseError
|
If it does not parse. |
Source code in src/quivers/experiments/plan.py
point_hash
¶
point_hash(*, kind: MethodKind, entry_hash: str, data: tuple[PlannedData, ...], values: tuple[PointValue, ...], method: str, options: tuple[PointValue, ...], seed: int) -> str
The hash of one run of an experiment.
| PARAMETER | DESCRIPTION |
|---|---|
kind
|
Whether the run runs or fits the entry.
TYPE:
|
entry_hash
|
The entry's content hash.
TYPE:
|
data
|
The data clauses, each with its pin.
TYPE:
|
values
|
The fixed and swept values.
TYPE:
|
method
|
The inference method.
TYPE:
|
options
|
Its options after defaults.
TYPE:
|
seed
|
The seed.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The digest of the experiment format and every input, each list sorted by name, so the order clauses are written in does not change it. |
| RAISES | DESCRIPTION |
|---|---|
ExperimentError
|
With code |
Source code in src/quivers/experiments/plan.py
experiment_hash
¶
experiment_hash(points: tuple[ExperimentPoint, ...]) -> str
The hash of an experiment: its points' hashes in sweep order.
| PARAMETER | DESCRIPTION |
|---|---|
points
|
The experiment's points.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The digest of the point hashes with their indices. |
Source code in src/quivers/experiments/plan.py
plan_experiment
¶
plan_experiment(path: str | Path, name: str | None = None, *, roots: tuple[str | Path, ...] | None = None) -> ExperimentPlan
Resolve one experiment of a module file into a plan.
| PARAMETER | DESCRIPTION |
|---|---|
path
|
The
TYPE:
|
name
|
The experiment; the only one the file declares when None.
TYPE:
|
roots
|
The directories module paths are relative to. When None, a module
of a package is read in its package's build
(
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ExperimentPlan
|
The plan, with every point's hash. |
| RAISES | DESCRIPTION |
|---|---|
ExperimentError
|
If the experiment does not exist, names no entry, gives a value to a name the entry does not have, leaves a computation's parameter without one, names an unknown method or option, leaves data unpinned, installs a handler that does not apply, or runs a program with typed holes or unfilled holes. |
ModuleError
|
If the module graph does not load or resolve. |
ManifestError
|
If the manifest of the file's package is malformed. |
PackageError
|
If an import or link of a package module crosses a package boundary the rules forbid, or its lockfile does not match the packages. |
ParseError
|
If a module does not parse. |
CompileError
|
If the program does not compile. |
Source code in src/quivers/experiments/plan.py
748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 | |