Contracts¶
A query over a rule presentation asks for one observable of the derivations of a judgment, under one interpretation of the rules. What an executor may do to answer it depends on the laws of the weight algebra, on how recursion is solved, on how accurate the answer has to be, and on what provenance is kept. The contract records state each of these as data that crosses the wire codec, and the checkers refuse every combination that does not fit, with the reason.
| record | what it states |
|---|---|
QuerySpec |
presentation, interpretation, observable, input types, inputs of the gradient, batch axes, retention |
LawClaim |
a law of a subject, with evidence that is proved, decided, tested or assumed |
Recursion |
acyclic, linear cyclic, monotone polynomial, bounded by the model, or unrolled |
AccuracyContract |
numerics, target and metric, guarantee, controls, budget, failure policy, derivative |
ComplexityClaim |
bounds per phase and resource, each with its optimality status |
WorkReport |
counters of the work of one phase |
Retention |
no provenance, parent counts, requested evidence, or the packed forest |
AccuracyReport |
what a run reached, why it stopped, what it cost, which claims it used |
GroupingRecord |
checked reducer, row and key types, mode, exact counts, and reduction costs |
Observables¶
Write \([\![j]\!] = \sum_{d \in D(j)} w(d) \cdot \mathrm{fold}(d)\) for the detailed meaning of a judgment \(j\): the formal sum over its derivations \(D(j)\), with \(w(d)\) the product of the axiom occurrence and rule weights. An observable is a map \(h\) from detailed meanings to results. A summary map \(s\) licenses aggregation when it preserves the sum of alternatives and commutes with every rule, and \(h\) factors through it. Each observable states what it needs:
| observable | laws of the algebra | other needs |
|---|---|---|
Support |
semiring, zero-sum-free, no zero divisors | no derivative |
Weight |
semiring | |
Best |
semiring, selective sum | a tie rule for its derivative |
KBest |
semiring, selective sum, superior rules | a tie rule for its derivative |
Outcome |
semiring | a key computation |
ProjectedWeightRows |
semiring | an ordered field of a checked judgment |
NormalizedWeightRows |
source weighting laws and division | finitely many rows with positive total mass |
WeightedProofRows |
ordered product with unit and absorbing zero, and associative commutative sum and division when normalized | finitely many derivations for a guaranteed result |
BooleanProofWeightRows |
semiring, and division when normalized | a truth table over the ordered premises of every rule |
Statistic |
semiring, semimodule action | a statistic computation |
Marginal |
semiring, and division when normalized | |
Sample |
semiring, division | no derivative |
Fold |
semiring, and linearity of the fold | the packed forest |
NonlinearFold |
semiring | the packed forest; finitely many derivations for a guaranteed result |
Forest |
none | the packed forest; no derivative |
A nonlinear fold has no summary in general: the alternatives \(-1\) and \(1\) sum to \(0\), whose square is \(0\), while their squares sum to \(2\).
Law claims¶
A claim's status is read from its evidence, so the two cannot disagree.
Proved cites a written argument and
Decided names a procedure that decides the law on the carrier:
every tuple of a finite carrier, a normal form of polynomial terms, or quantifier elimination over
the reals. These two are established. Tested evaluates
finitely many points of a larger carrier, which can refute a law and cannot establish it, and
Assumed is a declaration. An exact, certified or
probabilistic result needs every law it uses to be established; a heuristic result needs every
law it uses to be claimed. A claim is about the mathematical carrier: a floating point
implementation satisfies no algebraic law exactly, and its rounding belongs to
Numerics.
Recursion¶
| contract | solution | exact by a finite method | derivative |
|---|---|---|---|
Acyclic |
unique, one relaxation per hyperedge | yes | reverse accumulation |
LinearCyclic |
least solution \(A^* b\), needs the star law | yes | \(A^* \, dA \, A^*\) on the open domain of convergence |
MonotonePolynomial |
least fixed point in the omega-continuous completion; Newton needs a real embedding (certified) or an idempotent star (exact) | no: at best certified | implicit, if the spectral radius of the Jacobian at the solution is below one; or unrolled |
Bounded |
the bound is part of the model | yes | exact for the bounded model |
Unrolled |
the first \(k\) iterates, a lower bound in an ordered algebra | no | of the \(k\) iterates and of nothing else |
A bound on constructor depth or length changes the model. An iteration limit, a fuel count or a tolerance does not, and it never changes the value a query denotes.
Accuracy¶
The fields of an AccuracyContract are separate: a
method parameter (Control) is never read as a guarantee, a
ResourceBudget is never an error bound, and the
derivative has its own semantics. The default is Exact with
FailurePolicy.REFUSE.
A guarantee is one of: Exact, the mathematical value up to the
rounding in Numerics; Certified, a bound that holds on
every run; Probabilistic, a bound that fails with
probability at most \(\delta\); or Heuristic. A certified
bound that a run reports carries its Certificate: an
outward rounded enclosure, a duality gap, an argument backed by an established claim, or a
composition of certified parts. A residual below a tolerance is none of these.
Every metric is read with the computed value first and the target second. Absolute error, absolute error of log weights and total variation satisfy the triangle inequality. Relative error does not: with target \(1\), an intermediate value \(100\) and a computed value \(101\) it is \(100\), against \(0.01 + 99\) through the intermediate value. Kullback-Leibler divergence does not: for Bernoulli laws with means \(0.1\), \(0.5\) and \(0.9\) it is \(1.758\) from the first to the third, against \(0.368 + 0.511\) through the second. Since the logarithm maps the nonnegative reals isomorphically onto the log weights, a relative error of probabilities is an absolute error of log weights.
The composition law¶
compose gives the attainment of an operation
\(g : X_1 \times \dots \times X_n \to Y\) applied to results that each have an attainment. Write
\(x_i\) for the targets, \(\hat x_i\) for the computed values, \(y = g(x_1, \dots, x_n)\), and
\(\hat y = \hat g(\hat x_1, \dots, \hat x_n)\) for the computed result, where \(\hat g\) is the floating
point implementation of \(g\). Let \(d\) be the metric of \(Y\) and \(d_i\) the metric of part \(i\).
Hypotheses.
- Lipschitz constants. For each argument with a constant \(L_i \ge 0\), and all points \(z, z'\) of a product region \(R\) that contains \((x_1, \dots, x_n)\) and \((\hat x_1, \dots, \hat x_n)\) and that differ only in coordinate \(i\), \(d(g(z), g(z')) \le L_i \, d_i(z_i, z'_i)\). This is Lipschitz continuity in each argument.
- Rounding of the operation. \(d(\hat y, g(\hat x_1, \dots, \hat x_n)) \le r\).
- Parts. \(d_i(\hat x_i, x_i) \le e_i + \rho_i\), where \(e_i\) is the bound of the part's guarantee (\(0\) when exact) and \(\rho_i\) its rounding bound. For a certified part this holds on every run; for a probabilistic part, outside an event \(F_i\) with \(P(F_i) \le \delta_i\).
- Triangle inequality. \(d(a, c) \le d(a, b) + d(b, c)\) on \(Y\).
Theorem. Under these hypotheses, outside \(F_1 \cup \dots \cup F_n\),
and \(P(F_1 \cup \dots \cup F_n) \le \sum_i \delta_i\).
Proof. Let \(h_0 = (\hat x_1, \dots, \hat x_n)\) and \(h_k = (x_1, \dots, x_k, \hat x_{k+1}, \dots, \hat x_n)\), so \(h_n = (x_1, \dots, x_n)\). Each coordinate of each \(h_k\) is a target or a computed value, so every \(h_k\) lies in the product region \(R\), and \(h_{k-1}\), \(h_k\) differ only in coordinate \(k\), where they hold \(\hat x_k\) and \(x_k\). Applying the triangle inequality \(n\) times along \(\hat y, g(h_0), g(h_1), \dots, g(h_n) = y\),
by hypotheses 2 and 1. Outside \(\bigcup_i F_i\) every part satisfies hypothesis 3, and \(L_k \ge 0\), so the sum is at most \(\sum_k L_k (e_k + \rho_k)\), which rearranges to the bound. The probability of the union is at most the sum of the probabilities by the union bound, which needs no independence. QED
Corollary (the guarantee of a composite). The composite takes the weakest guarantee of its parts, in the order exact, certified, probabilistic, heuristic:
- every part exact: the composite is exact, with rounding \(r + \sum_i L_i \rho_i\) when every term is known, and unknown otherwise;
- every part exact or certified, each certified part with a constant in its own metric: certified
with bound \(\sum_i L_i e_i\), and its certificate is the
Compositionof the terms, which can be checked again; - some part probabilistic, the rest as in 2: probabilistic with bound \(\sum_i L_i e_i\) and failure probability \(\sum_i \delta_i\), when this is below one; at one or more the statement says nothing and the composite is heuristic;
- some part that is not exact without a constant in its own metric, some heuristic part with a constant above zero, or a metric of \(Y\) without the triangle inequality while some part is not exact: heuristic.
Case 4 is sharp. With \(g\) the identity, a heuristic part may be arbitrarily far from its target, so no finite bound holds; without the triangle inequality the step of the proof fails, as the two counterexamples above show. A heuristic part whose constant is zero does not move the result and is left out.
Local tolerances do not make a global bound. A run that stops because a residual fell below
its tolerance has no certificate, so
attained_guarantee makes it heuristic, and by case
4 so is every composite that depends on it. The residual can be small while the error is large:
Kleene iteration of a cycle of weight \(0.999\), stopped when the log weight changes by less than
\(10^{-3}\), returns \(6.2158\) after \(693\) iterates, while the exact log weight is
\(\log 1000 = 6.9078\).
Derivatives of a composite. The derivative of a composite is the weakest of the derivatives of its parts and of the operation itself, component by component (below), with two differences from the meet. The unrolled loops of all parts are counted together, since each part unrolls its own loop. An estimate stays unbiased only when every estimated part is unbiased and enters an argument in which the operation is affine, because an expectation commutes with sums and deterministic multiples and not with other functions: for a Bernoulli draw \(X\) with mean \(p\), \(X\) is unbiased for \(p\), while \(E[X^2] = p\) differs from \(p^2\). Otherwise the bias is unknown. The composite is almost everywhere regular when every part and the operation are: these are computations whose primitives are analytic and whose decisions are sign tests of computed values, a class closed under composition, and the zero set of an analytic function that is not identically zero has measure zero. So the composite is at most as strong as each part.
Derivative semantics and reports¶
A DerivativeSemantics is a product of components,
each ordered from strong to weak: whether a derivative exists, whether regular points have full
measure, the tie rule of every selection, the hypotheses of implicit derivatives, the iteration
counts of unrolled loops, the estimator of each random site, and the bias of the estimate.
at_least compares them component by
component, so it is a preorder with no derivative at the bottom, and
meet is its greatest lower bound. Two tie
rules have no meet: mixing them makes a result depend on bracketing, so there is one rule,
FIRST_MAXIMIZER.
The forms of a derivative report are points of this order: exact at regular points, a selected
branch at ties, implicit under conditions, unrolled, an estimator per site with its bias, and none
with its reason. A DerivativeReport holds one
semantics per output and input of a run, its summary is the meet of its entries, and an
AccuracyReport requires the derivative of its attainment
to be that summary. An estimator report is the estimator and bias components of the same record,
so a derivative report of a handled program is an instance of these records, not a second kind.
Reports and failure¶
Three rules hold of every report that
report_refusals admits:
- a resource budget is never an error bound: no guarantee accepts a budget as its bound, and an exhausted run claims only the bound of a certificate it computed;
- a residual is never a certificate;
- exhaustion never returns a value labelled exact.
settle applies the failure policy: the value when the report
meets the contract, ContractNotMet under
REFUSE, and an Unestablished wrapper under
RETURN_UNESTABLISHED. The wrapper is not a number, so nothing that expects a weight accepts it.
No policy truncates silently, switches method, or returns zero.
Admissibility¶
admissibility returns every reason a query, its
recursion, its contract and the available claims do not fit; report_refusals does the same for
a report, and complexity_refusals for a complexity
claim.
| refusal | refused combination |
|---|---|
missing-claim |
a law the observable, the recursion or the executor needs has no claim |
claim-not-established |
a needed law is only tested or assumed, and the guarantee is not heuristic |
exact-without-finite-method |
an exact guarantee for a monotone polynomial or unrolled system |
derivative-unavailable |
a derivative the recursion does not give |
gradient-without-inputs |
a derivative with respect to nothing |
inputs-without-gradient |
inputs to differentiate, and no derivative requested |
observable-not-differentiable |
a derivative of support, a sample or the forest |
selection-without-tie-rule |
a derivative of a best derivation without the tie rule it accepts |
forest-not-retained |
a fold or the forest without the packed forest |
infinite-derivations |
a guaranteed nonlinear fold of a system that can have infinitely many derivations |
request-with-certificate |
a requested bound that carries a certificate |
duplicate-control |
a control set twice |
early-stop-labelled-exact |
a run stopped by its budget or a control, reported exact |
certified-without-certificate |
an attained bound without its certificate |
bound-below-certificate |
an attained bound below what its certificate shows |
argument-not-established |
a bound argued from a claim that is only tested or assumed |
certificate-metric |
an enclosure outside absolute errors, or a duality gap outside objective gaps |
used-claim-not-established |
a guaranteed result from a run that used a claim that is not established |
exact-for-inexact-recursion |
an exact result of a monotone polynomial or unrolled system |
unmet-misreported |
unmet requirements that differ from the ones the contract and the attainment give |
incomplete-claim |
a phase with neither a time and a space bound nor a declaration that it does not apply, or with both |
undeclared-parameter |
a bound in a name the claim does not declare |
lower-bound-mismatch |
an optimality proof whose lower bound is not the bound |
Complexity claims and work¶
A ComplexityClaim states time and space bounds for
construction, execution, differentiation and refitting in named parameters, in a stated
ComputationModel. Each bound has a status:
ProvedOptimal with the matching lower bound and its
model, Conditional on a hypothesis,
BestKnown, Unresolved
as a research obligation, or Deficient with a better bound
and a reviewed justification. A WorkReport counts the work
of one phase in elements inside tensor operations, and a run exceeds its budget when the counts,
added over phases, or the peaks, compared phase by phase, pass a limit.
contracts
¶
Contract records: what a query asks for and what a run may claim.
A query names its observable, the laws it relies on, how recursion is solved, how accurate the answer must be, what the work costs, and what provenance is kept. Each of these is a record here, and every record crosses the QIEC wire codec.
Three rules hold by construction and are checked again by
report_refusals:
- a resource budget is never an error bound: budgets are counts of work, and no guarantee accepts one as its bound;
- a residual is never a certificate: a run that stopped on a control claims a bound only through a certificate, and a certificate is an enclosure, a duality gap, an established argument, or a composition of certified parts;
- exhaustion never returns a value labelled exact.
compose is the composition law of accuracy guarantees: the composite
takes the weakest guarantee of its parts, and error bounds propagate
through declared Lipschitz constants. Local tolerances alone give a
heuristic composite. The proof is in the API page of this module.
SPECTRAL_RADIUS_BELOW_ONE
module-attribute
¶
SPECTRAL_RADIUS_BELOW_ONE = Condition(name='spectral-radius-below-one', statement='the spectral radius of the Jacobian of the system at its least fixed point is below one, so the implicit derivative (I - DF)^-1 dF exists')
The hypothesis of the implicit derivative of a least fixed point.
NOT_DIFFERENTIATED
module-attribute
¶
NOT_DIFFERENTIATED = DerivativeSemantics.none('not differentiated')
The semantics of a run that computes no derivative.
ALGEBRA_OPERATIONS
module-attribute
¶
ALGEBRA_OPERATIONS = ComputationModel(name='algebra-operations', description='one unit per scalar operation of the weight algebra, counted inside tensor kernels')
Algebra operations at unit cost on scalars.
WORD_RAM_EXPECTED_HASHING
module-attribute
¶
WORD_RAM_EXPECTED_HASHING = ComputationModel(name='word-ram-expected-hashing', description='word RAM for indices, with hashing in expected constant time')
A word RAM with expected constant time hashing.
BOUND_FUNCTIONS
module-attribute
¶
Function and constant names a bound may use besides its parameters.
BM(n) is the cost of a Boolean matrix product and omega the
exponent of matrix multiplication.
TIME_FIELDS
module-attribute
¶
TIME_FIELDS: frozenset[WorkField] = frozenset({WorkField.SCALAR_SUMS, WorkField.SCALAR_PRODUCTS, WorkField.SCALAR_DIVISIONS, WorkField.STAR_PIVOTS, WorkField.EXACT_OPERATIONS, WorkField.KEY_COMPARISONS, WorkField.HASH_OPERATIONS})
The counters whose sum is the time of the algebra-operations model.
SPACE_FIELDS
module-attribute
¶
SPACE_FIELDS: Mapping[Phase, frozenset[WorkField]] = MappingProxyType({Phase.CONSTRUCTION: frozenset({WorkField.PEAK_LIVE_ELEMENTS}), Phase.EXECUTION: frozenset({WorkField.PEAK_LIVE_ELEMENTS}), Phase.DIFFERENTIATION: frozenset({WorkField.PEAK_LIVE_ELEMENTS, WorkField.ELEMENTS_SAVED_FOR_BACKWARD}), Phase.REFIT: frozenset({WorkField.PEAK_LIVE_ELEMENTS})})
The counters whose largest is the space of a phase in the model.
Bias
¶
Bias = Unbiased | BiasBound | BiasUnknown
What is known about the expectation of a derivative estimate.
Metric
¶
Metric = AbsoluteError | AbsoluteLogError | RelativeError | TotalVariation | KLDivergence | ObjectiveGap
How the distance between a computed value and its target is measured.
Every metric is read with the computed value first and the target second.
Certificate
¶
Certificate = Enclosure | DualityGap | Argument | Composition
Evidence for a certified bound. A residual is not one of them.
Guarantee
¶
Guarantee = Exact | Certified | Probabilistic | Heuristic
What is promised about the distance between a result and its target.
Recursion
¶
Recursion = Acyclic | LinearCyclic | MonotonePolynomial | Bounded | Unrolled
How a recursive system is solved, and what that solution is.
Retention
¶
Retention = NoRetention | ParentCounts | RequestedEvidence | PackedForest
Which provenance a run keeps beside the autograd tape.
Observable
¶
Observable = Support | Weight | Best | KBest | Outcome | ProjectedWeightRows | NormalizedWeightRows | WeightedProofRows | Statistic | Marginal | Sample | Fold | NonlinearFold | Forest | BooleanProofWeightRows
What a query observes of the detailed meaning of a judgment.
OptimalityStatus
¶
OptimalityStatus = ProvedOptimal | Conditional | BestKnown | Unresolved | Deficient
How a bound compares with what is known to be possible.
PresentationId
didactic-model
¶
InterpretationId
didactic-model
¶
OccurrenceId
didactic-model
¶
ParameterId
didactic-model
¶
Rational
didactic-model
¶
Bases: QiecModel
An exact nonnegative or signed rational number in lowest terms.
Bounds are exact so that adding them, as the composition law does, never rounds a bound down.
| PARAMETER | DESCRIPTION |
|---|---|
numerator
|
The numerator.
TYPE:
|
denominator
|
The denominator, positive and coprime to the numerator.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValidationError
|
If the denominator is not positive or the fraction is not in lowest terms. |
fraction
property
¶
The number as a fractions.Fraction.
| RETURNS | DESCRIPTION |
|---|---|
Fraction
|
The same number. |
of
classmethod
¶
of(value: Fraction | int | float) -> Rational
Build the rational equal to a number.
| PARAMETER | DESCRIPTION |
|---|---|
value
|
The number. A float converts exactly, digit for digit of its binary value.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Rational
|
The same number in lowest terms. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the value is a boolean or a float that is not finite. |
Source code in src/quivers/qiec/contracts.py
Condition
didactic-model
¶
Bases: QiecModel
A hypothesis under which a result holds.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
A short name, unique among conditions.
TYPE:
|
statement
|
The hypothesis.
TYPE:
|
Unbiased
didactic-model
¶
Bases: QiecModel
An estimate whose expectation is the quantity estimated.
| PARAMETER | DESCRIPTION |
|---|---|
tag
|
Always
TYPE:
|
BiasBound
didactic-model
¶
BiasBound(*, bound: Rational = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['bias-bound'] = 'bias-bound')
Bases: QiecModel
An estimate whose bias is at most a declared positive bound.
| PARAMETER | DESCRIPTION |
|---|---|
bound
|
The bound on the norm of the bias, positive.
TYPE:
|
tag
|
Always
TYPE:
|
BiasUnknown
didactic-model
¶
Bases: QiecModel
An estimate with a bias of unknown size.
| PARAMETER | DESCRIPTION |
|---|---|
tag
|
Always
TYPE:
|
SiteEstimator
didactic-model
¶
SiteEstimator(*, site: SiteId = field(opaque=True, extras=OPAQUE_BY_VALUE), estimator: str)
Bases: QiecModel
The estimator that handles one random site under differentiation.
| PARAMETER | DESCRIPTION |
|---|---|
site
|
The site.
TYPE:
|
estimator
|
Its estimator, such as
TYPE:
|
DerivativeSemantics
didactic-model
¶
DerivativeSemantics(*, missing: tuple[str, ...] = field(default=(), opaque=True, extras=OPAQUE_BY_VALUE), almost_everywhere: bool = False, tie_rule: TieRule | None = field(default=None, opaque=True, extras=OPAQUE_BY_VALUE), implicit_conditions: tuple[Condition, ...] = field(default=(), opaque=True, extras=OPAQUE_BY_VALUE), unrolled: tuple[int, ...] = field(default=(), opaque=True, extras=OPAQUE_BY_VALUE), estimators: tuple[SiteEstimator, ...] = field(default=(), opaque=True, extras=OPAQUE_BY_VALUE), bias: Bias = field(default=Unbiased(), opaque=True, extras=OPAQUE_BY_VALUE))
Bases: QiecModel
What a derivative is the derivative of, and how it was obtained.
The record is a product of independent components, each ordered from
strong to weak, and one semantics is at least as strong as another
when it is in every component (at_least). The forms of a derivative
report are its points:
- exact at regular points (
exact), almost everywhere when every primitive is analytic and every decision is a sign test; - a selected branch at ties (
selected_branch), by one tie rule; - implicit (
implicit), under stated conditions; - unrolled (
unrolled): the derivative of the firstkiterates and of nothing else; - an estimator (
estimated) per random site, with its bias; - none (
none), with the reason.
A composite holds several at once, and kind names its weakest.
| PARAMETER | DESCRIPTION |
|---|---|
missing
|
Reasons why there is no derivative. When any is given, every other component is at its strongest value.
TYPE:
|
almost_everywhere
|
Whether the regular points have full measure.
TYPE:
|
tie_rule
|
The rule of every selection in the computation, or
TYPE:
|
implicit_conditions
|
Hypotheses of implicit derivatives, sorted and without repeats.
TYPE:
|
unrolled
|
Iteration counts of the unrolled loops the derivative passes through, sorted, one entry per loop.
TYPE:
|
estimators
|
The estimator of each random site, sorted, one per site.
TYPE:
|
bias
|
What is known about the expectation of the estimate.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValidationError
|
If a missing derivative carries other components, a loop has fewer than one iteration, a site has two estimators, or a bias is declared without an estimator. |
kind
property
¶
The weakest form the semantics holds.
| RETURNS | DESCRIPTION |
|---|---|
str
|
|
exact
classmethod
¶
exact(*, almost_everywhere: bool = False) -> DerivativeSemantics
The exact derivative at regular points.
| PARAMETER | DESCRIPTION |
|---|---|
almost_everywhere
|
Whether the regular points have full measure.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
DerivativeSemantics
|
The strongest semantics. |
Source code in src/quivers/qiec/contracts.py
selected_branch
classmethod
¶
selected_branch(rule: TieRule, *, almost_everywhere: bool = False) -> DerivativeSemantics
The exact derivative at regular points, and a rule's element at ties.
| PARAMETER | DESCRIPTION |
|---|---|
rule
|
The tie rule of every selection.
TYPE:
|
almost_everywhere
|
Whether the regular points have full measure.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
DerivativeSemantics
|
The semantics. |
Source code in src/quivers/qiec/contracts.py
implicit
classmethod
¶
implicit(*conditions: Condition) -> DerivativeSemantics
The implicit derivative under hypotheses.
| PARAMETER | DESCRIPTION |
|---|---|
conditions
|
The hypotheses.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
DerivativeSemantics
|
The semantics. |
Source code in src/quivers/qiec/contracts.py
unrolled_iterations
classmethod
¶
unrolled_iterations(*iterations: int) -> DerivativeSemantics
The derivative of unrolled loops and of nothing else.
| PARAMETER | DESCRIPTION |
|---|---|
iterations
|
The iteration count of each loop.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
DerivativeSemantics
|
The semantics. |
Source code in src/quivers/qiec/contracts.py
estimated
classmethod
¶
estimated(*estimators: SiteEstimator, bias: Bias = Unbiased()) -> DerivativeSemantics
An estimate of the derivative from estimators at random sites.
| PARAMETER | DESCRIPTION |
|---|---|
estimators
|
The estimator of each site.
TYPE:
|
bias
|
What is known about the expectation of the estimate. |
| RETURNS | DESCRIPTION |
|---|---|
DerivativeSemantics
|
The semantics. |
Source code in src/quivers/qiec/contracts.py
none
classmethod
¶
none(*reasons: str) -> DerivativeSemantics
No derivative.
| PARAMETER | DESCRIPTION |
|---|---|
reasons
|
Why there is none.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
DerivativeSemantics
|
The weakest semantics. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If no reason is given. |
Source code in src/quivers/qiec/contracts.py
at_least
¶
at_least(request: DerivativeSemantics) -> bool
Whether this semantics is at least as strong as a request.
| PARAMETER | DESCRIPTION |
|---|---|
request
|
The weakest semantics that is acceptable.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True when the request asks for no derivative, or when in every component this one is at least as strong: no missing derivative, regular points of full measure if asked, a tie rule only if the request has the same one, and conditions, unrolled loops and estimators that the request admits, with a bias no larger than the request's. |
Source code in src/quivers/qiec/contracts.py
meet
¶
meet(other: DerivativeSemantics) -> DerivativeSemantics
The strongest semantics that both this one and another reach.
| PARAMETER | DESCRIPTION |
|---|---|
other
|
The other semantics.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
DerivativeSemantics
|
The componentwise weakest: the reasons of both when either has none, regular points of full measure only if both have them, the tie rule of either, the union of conditions and of estimators, the larger count of each unrolled loop length, and the larger bias. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the two use different tie rules, or estimate one site by two estimators. Neither has a meet: mixing tie rules makes a result depend on bracketing. |
Source code in src/quivers/qiec/contracts.py
DerivativeEntry
didactic-model
¶
DerivativeEntry(*, output: str, wrt: ParameterId | OccurrenceId = field(opaque=True, extras=OPAQUE_BY_VALUE), semantics: DerivativeSemantics = field(opaque=True, extras=OPAQUE_BY_VALUE))
Bases: QiecModel
The derivative semantics of one output with respect to one input.
| PARAMETER | DESCRIPTION |
|---|---|
output
|
The output.
TYPE:
|
wrt
|
The parameter or the occurrence differentiated.
TYPE:
|
semantics
|
What the derivative is.
TYPE:
|
DerivativeReport
didactic-model
¶
DerivativeReport(*, entries: tuple[DerivativeEntry, ...] = field(default=(), opaque=True, extras=OPAQUE_BY_VALUE))
Bases: QiecModel
The derivative semantics of every output and input of a run.
| PARAMETER | DESCRIPTION |
|---|---|
entries
|
One entry per output and input, without repeats.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValidationError
|
If an output and input pair has two entries. |
summary
property
¶
summary: DerivativeSemantics
The strongest semantics every entry reaches.
| RETURNS | DESCRIPTION |
|---|---|
DerivativeSemantics
|
The meet of the entries, or |
AbsoluteError
didactic-model
¶
Bases: QiecModel
The distance |computed - target|.
| PARAMETER | DESCRIPTION |
|---|---|
tag
|
Always
TYPE:
|
triangle_inequality
property
¶
Whether the triangle inequality holds.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True: it is a metric. |
AbsoluteLogError
didactic-model
¶
Bases: QiecModel
The distance |log computed - log target| on positive weights.
Since the logarithm is a semiring isomorphism from the nonnegative reals onto the log weights, a relative error of probabilities is an absolute error of log weights.
| PARAMETER | DESCRIPTION |
|---|---|
tag
|
Always
TYPE:
|
triangle_inequality
property
¶
Whether the triangle inequality holds.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True: it is a metric. |
RelativeError
didactic-model
¶
Bases: QiecModel
The divergence |computed - target| / |target|.
It fails the triangle inequality: with target 1, a midpoint of 100 and a computed value of 101, it is 100 against 0.01 plus 99.
| PARAMETER | DESCRIPTION |
|---|---|
tag
|
Always
TYPE:
|
triangle_inequality
property
¶
Whether the triangle inequality holds.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
False. |
TotalVariation
didactic-model
¶
Bases: QiecModel
The total variation distance between two distributions.
| PARAMETER | DESCRIPTION |
|---|---|
tag
|
Always
TYPE:
|
triangle_inequality
property
¶
Whether the triangle inequality holds.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True: it is a metric. |
KLDivergence
didactic-model
¶
KLDivergence(*, direction: Literal['target-to-computed', 'computed-to-target'], tag: Literal['kl'] = 'kl')
Bases: QiecModel
The Kullback-Leibler divergence in a stated direction.
It fails the triangle inequality: for Bernoulli laws with means 0.1, 0.5 and 0.9 it is 1.758 from the first to the third against 0.368 plus 0.511 through the second.
| PARAMETER | DESCRIPTION |
|---|---|
direction
|
TYPE:
|
tag
|
Always
TYPE:
|
triangle_inequality
property
¶
Whether the triangle inequality holds.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
False. |
ObjectiveGap
didactic-model
¶
Bases: QiecModel
The gap between an objective at the computed point and its optimum.
| PARAMETER | DESCRIPTION |
|---|---|
tag
|
Always
TYPE:
|
triangle_inequality
property
¶
Whether the triangle inequality holds.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
False: it compares objective values, not the points. |
Enclosure
didactic-model
¶
Enclosure(*, lower: Rational = field(opaque=True, extras=OPAQUE_BY_VALUE), upper: Rational = field(opaque=True, extras=OPAQUE_BY_VALUE), conditions: tuple[str, ...] = (), tag: Literal['enclosure'] = 'enclosure')
Bases: QiecModel
An interval that holds both the target and the computed value.
The endpoints come from outward rounded interval arithmetic, such as a lower iterate and a pre-fixed point of a monotone system. The bound it certifies is the width.
| PARAMETER | DESCRIPTION |
|---|---|
lower
|
The lower endpoint.
TYPE:
|
upper
|
The upper endpoint, at least the lower one.
TYPE:
|
conditions
|
What the enclosure rests on.
TYPE:
|
tag
|
Always
TYPE:
|
bound
property
¶
The bound the enclosure certifies.
| RETURNS | DESCRIPTION |
|---|---|
Fraction
|
The width of the interval. |
DualityGap
didactic-model
¶
DualityGap(*, primal: Rational = field(opaque=True, extras=OPAQUE_BY_VALUE), dual: Rational = field(opaque=True, extras=OPAQUE_BY_VALUE), conditions: tuple[str, ...] = (), tag: Literal['duality-gap'] = 'duality-gap')
Bases: QiecModel
A primal value and a dual bound of an optimization.
The optimum lies between them, so the gap bounds how far the primal value is from it.
| PARAMETER | DESCRIPTION |
|---|---|
primal
|
The objective of a feasible point.
TYPE:
|
dual
|
A bound on the optimum, on the other side.
TYPE:
|
conditions
|
What the dual bound rests on, such as exact local solves.
TYPE:
|
tag
|
Always
TYPE:
|
bound
property
¶
The bound the gap certifies.
| RETURNS | DESCRIPTION |
|---|---|
Fraction
|
|
Argument
didactic-model
¶
Argument(*, value: Rational = field(opaque=True, extras=OPAQUE_BY_VALUE), claim: LawClaim = field(opaque=True, extras=OPAQUE_BY_VALUE), conditions: tuple[str, ...] = (), tag: Literal['argument'] = 'argument')
Bases: QiecModel
A bound that an established claim proves.
| PARAMETER | DESCRIPTION |
|---|---|
value
|
The bound, at least zero.
TYPE:
|
claim
|
The theorem that gives the bound, such as an a posteriori bound of a contraction with a proved rate. It must be established.
TYPE:
|
conditions
|
The hypotheses of the theorem that the run checked.
TYPE:
|
tag
|
Always
TYPE:
|
bound
property
¶
The bound the argument certifies.
| RETURNS | DESCRIPTION |
|---|---|
Fraction
|
The stated bound. |
ComposedTerm
didactic-model
¶
ComposedTerm(*, lipschitz: Rational = field(opaque=True, extras=OPAQUE_BY_VALUE), bound: Rational = field(opaque=True, extras=OPAQUE_BY_VALUE))
Bases: QiecModel
One part of a composition: its bound and its Lipschitz constant.
| PARAMETER | DESCRIPTION |
|---|---|
lipschitz
|
The constant of the operation in the part's argument.
TYPE:
|
bound
|
The part's bound.
TYPE:
|
Composition
didactic-model
¶
Composition(*, operation: str, terms: tuple[ComposedTerm, ...] = field(opaque=True, extras=OPAQUE_BY_VALUE), conditions: tuple[str, ...] = (), tag: Literal['composition'] = 'composition')
Bases: QiecModel
A bound obtained by the composition law from certified parts.
| PARAMETER | DESCRIPTION |
|---|---|
operation
|
The operation that combines the parts.
TYPE:
|
terms
|
The parts that are not exact.
TYPE:
|
conditions
|
The conditions of the parts and of the constants.
TYPE:
|
tag
|
Always
TYPE:
|
bound
property
¶
The bound the composition certifies.
| RETURNS | DESCRIPTION |
|---|---|
Fraction
|
The sum of each constant times its part's bound. |
Exact
didactic-model
¶
Bases: QiecModel
The mathematical value, up to the rounding stated in Numerics.
| PARAMETER | DESCRIPTION |
|---|---|
tag
|
Always
TYPE:
|
Certified
didactic-model
¶
Certified(*, bound: Rational = field(opaque=True, extras=OPAQUE_BY_VALUE), conditions: tuple[str, ...] = (), certificate: Certificate | None = field(default=None, opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['certified'] = 'certified')
Bases: QiecModel
A bound that holds on every run, up to the stated rounding.
In a contract it is the requested bound and carries no certificate. In a report it is the attained bound and must carry the certificate that shows it.
| PARAMETER | DESCRIPTION |
|---|---|
bound
|
The bound on the distance to the target, at least zero.
TYPE:
|
conditions
|
The hypotheses under which it holds.
TYPE:
|
certificate
|
The evidence, in a report.
TYPE:
|
tag
|
Always
TYPE:
|
Probabilistic
didactic-model
¶
Probabilistic(*, epsilon: Rational = field(opaque=True, extras=OPAQUE_BY_VALUE), delta: Rational = field(opaque=True, extras=OPAQUE_BY_VALUE), assumptions: tuple[str, ...] = (), tag: Literal['probabilistic'] = 'probabilistic')
Bases: QiecModel
A bound that fails with probability at most delta.
| PARAMETER | DESCRIPTION |
|---|---|
epsilon
|
The bound, at least zero.
TYPE:
|
delta
|
The probability of failure, strictly between zero and one.
TYPE:
|
assumptions
|
What the probability rests on.
TYPE:
|
tag
|
Always
TYPE:
|
Heuristic
didactic-model
¶
Bases: QiecModel
No guarantee.
| PARAMETER | DESCRIPTION |
|---|---|
reason
|
Why there is none.
TYPE:
|
tag
|
Always
TYPE:
|
Numerics
didactic-model
¶
Numerics(*, dtype: Literal['bool', 'int64', 'float16', 'bfloat16', 'float32', 'float64'], domain: Literal['linear', 'log'] = 'linear', reduction: Literal['plain', 'compensated'] = 'plain', rounding: Rational | None = field(default=None, opaque=True, extras=OPAQUE_BY_VALUE))
Bases: QiecModel
Precision of a computation.
| PARAMETER | DESCRIPTION |
|---|---|
dtype
|
The element type.
TYPE:
|
domain
|
TYPE:
|
reduction
|
TYPE:
|
rounding
|
A bound on the rounding error in the target's metric, from the
operation count and the condition number, or
TYPE:
|
Target
didactic-model
¶
Target(*, quantity: str, metric: Metric = field(opaque=True, extras=OPAQUE_BY_VALUE))
Bases: QiecModel
The mathematical quantity a result approximates, and its metric.
| PARAMETER | DESCRIPTION |
|---|---|
quantity
|
The quantity, such as the observable of the query or the least fixed point of its system.
TYPE:
|
metric
|
How distance to it is measured.
TYPE:
|
Control
didactic-model
¶
Control(*, name: str, value: Rational | str = field(opaque=True, extras=OPAQUE_BY_VALUE))
Bases: QiecModel
A method parameter. It is recorded and never read as a guarantee.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
Its name, such as
TYPE:
|
value
|
Its value.
TYPE:
|
ResourceBudget
didactic-model
¶
ResourceBudget(*, iterations: int | None = None, scalar_work: int | None = None, states: int | None = None, elements: int | None = None, bytes: int | None = None, seconds: Rational | None = field(default=None, opaque=True, extras=OPAQUE_BY_VALUE))
Bases: QiecModel
Limits on the work of a run. A budget is never an error bound.
Each limit is None when there is none.
| PARAMETER | DESCRIPTION |
|---|---|
iterations
|
Iterations of a solver.
TYPE:
|
scalar_work
|
Scalar sums, products and divisions.
TYPE:
|
states
|
Product states created.
TYPE:
|
elements
|
Elements live at once.
TYPE:
|
bytes
|
Bytes live at once.
TYPE:
|
seconds
|
Wall time.
TYPE:
|
FailurePolicy
¶
Bases: str, Enum
What a run does when it cannot meet its contract.
Neither policy truncates silently, switches method, or returns zero.
AccuracyContract
didactic-model
¶
AccuracyContract(*, numerics: Numerics = field(opaque=True, extras=OPAQUE_BY_VALUE), target: Target = field(opaque=True, extras=OPAQUE_BY_VALUE), guarantee: Guarantee = field(default=Exact(), opaque=True, extras=OPAQUE_BY_VALUE), controls: tuple[Control, ...] = field(default=(), opaque=True, extras=OPAQUE_BY_VALUE), budget: ResourceBudget = field(default=UNLIMITED, opaque=True, extras=OPAQUE_BY_VALUE), on_failure: FailurePolicy = field(default=REFUSE, opaque=True, extras=OPAQUE_BY_VALUE), gradient: DerivativeSemantics = field(default=NOT_DIFFERENTIATED, opaque=True, extras=OPAQUE_BY_VALUE))
Bases: QiecModel
How accurate a result must be, and what happens when it is not.
The fields are separate on purpose: a method parameter is not a guarantee, a budget is not an error bound, and the derivative has its own semantics.
| PARAMETER | DESCRIPTION |
|---|---|
numerics
|
Precision.
TYPE:
|
target
|
The quantity and its metric.
TYPE:
|
guarantee
|
The weakest acceptable guarantee.
TYPE:
|
controls
|
Method parameters.
TYPE:
|
budget
|
Limits on work.
TYPE:
|
on_failure
|
Refuse, or return the value wrapped as unestablished.
TYPE:
|
gradient
|
The weakest acceptable derivative semantics, or
TYPE:
|
Acyclic
didactic-model
¶
Bases: QiecModel
The derived hypergraph has no cycle, found by parent counts.
The solution is unique, and one relaxation per hyperedge computes it.
| PARAMETER | DESCRIPTION |
|---|---|
tag
|
Always
TYPE:
|
finite_method
property
¶
Whether a finite procedure computes the exact value.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True. |
finite_derivations
property
¶
Whether every judgment has finitely many derivations.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True. |
laws
¶
laws() -> tuple[Law, ...]
The laws the solution needs beyond the observable's.
| RETURNS | DESCRIPTION |
|---|---|
tuple of Law
|
None. |
admits
¶
admits(gradient: DerivativeSemantics) -> bool
Whether a requested derivative is available.
| PARAMETER | DESCRIPTION |
|---|---|
gradient
|
The request.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True: reverse accumulation of the computation is exact. |
Source code in src/quivers/qiec/contracts.py
LinearCyclic
didactic-model
¶
Bases: QiecModel
Each strongly connected component has at most one premise inside it.
The least solution is A* b in an algebra with a star.
| PARAMETER | DESCRIPTION |
|---|---|
tag
|
Always
TYPE:
|
finite_method
property
¶
Whether a finite procedure computes the exact value.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True: elimination computes the star. |
finite_derivations
property
¶
Whether every judgment has finitely many derivations.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
False. |
laws
¶
laws() -> tuple[Law, ...]
The laws the solution needs beyond the observable's.
| RETURNS | DESCRIPTION |
|---|---|
tuple of Law
|
The star law. |
admits
¶
admits(gradient: DerivativeSemantics) -> bool
Whether a requested derivative is available.
| PARAMETER | DESCRIPTION |
|---|---|
gradient
|
The request.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True: the derivative of |
Source code in src/quivers/qiec/contracts.py
MonotonePolynomial
didactic-model
¶
Bases: QiecModel
A nonnegative polynomial system x = f(x) with a least fixed point.
Kleene and Newton iterates increase to the least fixed point, and a pre-fixed point bounds it from above. No finite procedure computes it exactly in general, so the result is at best certified.
| PARAMETER | DESCRIPTION |
|---|---|
tag
|
Always
TYPE:
|
finite_method
property
¶
Whether a finite procedure computes the exact value.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
False. |
finite_derivations
property
¶
Whether every judgment has finitely many derivations.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
False. |
laws
¶
laws() -> tuple[Law, ...]
The laws the solution needs beyond the observable's.
| RETURNS | DESCRIPTION |
|---|---|
tuple of Law
|
None of their own: the least fixed point lies in the omega-continuous completion of the weights, and the executor that solves the system states the laws it uses, an embedding in the nonnegative reals for certified Newton or an idempotent sum with a star for exact Newton. |
Source code in src/quivers/qiec/contracts.py
admits
¶
admits(gradient: DerivativeSemantics) -> bool
Whether a requested derivative is available.
| PARAMETER | DESCRIPTION |
|---|---|
gradient
|
The request.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True when the request asks for no derivative, admits the implicit derivative under its spectral condition, or admits an unrolled one. |
Source code in src/quivers/qiec/contracts.py
Bounded
didactic-model
¶
Bounded(*, measure: Literal['constructor-depth', 'length', 'height'], limit: int, tag: Literal['bounded'] = 'bounded')
Bases: QiecModel
The model restricts its derivations by a bound that is part of it.
A bound on constructor depth, length or height changes the model and its name; an execution budget does not.
| PARAMETER | DESCRIPTION |
|---|---|
measure
|
TYPE:
|
limit
|
The bound, at least zero.
TYPE:
|
tag
|
Always
TYPE:
|
finite_method
property
¶
Whether a finite procedure computes the exact value.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True. |
finite_derivations
property
¶
Whether every judgment has finitely many derivations.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True. |
laws
¶
laws() -> tuple[Law, ...]
The laws the solution needs beyond the observable's.
| RETURNS | DESCRIPTION |
|---|---|
tuple of Law
|
None. |
admits
¶
admits(gradient: DerivativeSemantics) -> bool
Whether a requested derivative is available.
| PARAMETER | DESCRIPTION |
|---|---|
gradient
|
The request.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True: the bounded model is finite and acyclic. |
Source code in src/quivers/qiec/contracts.py
Unrolled
didactic-model
¶
Bases: QiecModel
The first iterations iterates of a recursive system.
In an ordered algebra with increasing iterates they bound the solution from below. They are not the solution, and their derivative is the derivative of the iterates and of nothing else.
| PARAMETER | DESCRIPTION |
|---|---|
iterations
|
How many iterates, at least one.
TYPE:
|
tag
|
Always
TYPE:
|
finite_method
property
¶
Whether a finite procedure computes the exact value.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
False: the iterates are not the solution. |
finite_derivations
property
¶
Whether every judgment has finitely many derivations.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
False. |
laws
¶
laws() -> tuple[Law, ...]
The laws the solution needs beyond the observable's.
| RETURNS | DESCRIPTION |
|---|---|
tuple of Law
|
None. |
admits
¶
admits(gradient: DerivativeSemantics) -> bool
Whether a requested derivative is available.
| PARAMETER | DESCRIPTION |
|---|---|
gradient
|
The request.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True when the request asks for no derivative or admits a loop unrolled this many times. |
Source code in src/quivers/qiec/contracts.py
NoRetention
didactic-model
¶
Bases: QiecModel
Keep no provenance beyond the values.
| PARAMETER | DESCRIPTION |
|---|---|
tag
|
Always
TYPE:
|
keeps_forest
property
¶
Whether the packed forest is kept.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
False. |
ParentCounts
didactic-model
¶
Bases: QiecModel
Keep a count of pending parents per item, and no edges.
| PARAMETER | DESCRIPTION |
|---|---|
tag
|
Always
TYPE:
|
keeps_forest
property
¶
Whether the packed forest is kept.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
False. |
JudgmentPattern
didactic-model
¶
JudgmentPattern(*, family: FamilyId = field(opaque=True, extras=OPAQUE_BY_VALUE))
Bases: QiecModel
The judgments of one family whose evidence is kept.
| PARAMETER | DESCRIPTION |
|---|---|
family
|
The family of the judgments.
TYPE:
|
RequestedEvidence
didactic-model
¶
RequestedEvidence(*, patterns: tuple[JudgmentPattern, ...] = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['requested'] = 'requested')
Bases: QiecModel
Keep the evidence of the judgments that match patterns.
| PARAMETER | DESCRIPTION |
|---|---|
patterns
|
The judgments, at least one pattern and none repeated.
TYPE:
|
tag
|
Always
TYPE:
|
keeps_forest
property
¶
Whether the packed forest is kept.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
False. |
PackedForest
didactic-model
¶
Bases: QiecModel
Keep the derived hypergraph with occurrences and grounded instances.
Its tree unfoldings from a judgment correspond one to one to the derivations of the judgment when it is acyclic, so every linear fold can be computed from it.
| PARAMETER | DESCRIPTION |
|---|---|
tag
|
Always
TYPE:
|
keeps_forest
property
¶
Whether the packed forest is kept.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True. |
Support
didactic-model
¶
Bases: _Observable
Whether the detailed meaning has a derivation of nonzero weight.
Support is a homomorphism to the Boolean algebra when no sum of nonzero weights and no product of nonzero weights is zero.
| PARAMETER | DESCRIPTION |
|---|---|
tag
|
Always
TYPE:
|
differentiable
property
¶
Whether the result has a derivative in the weights.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
False: it is a truth value. |
requirements
¶
requirements(algebra: ClaimSubject) -> tuple[Requirement, ...]
The laws the result needs.
| PARAMETER | DESCRIPTION |
|---|---|
algebra
|
The weight algebra.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple of Requirement
|
The semiring laws, no zero sums and no zero divisors. |
Source code in src/quivers/qiec/contracts.py
Weight
didactic-model
¶
Bases: _Observable
The sum of the weights of all derivations.
| PARAMETER | DESCRIPTION |
|---|---|
tag
|
Always
TYPE:
|
Best
didactic-model
¶
Bases: _Observable
The best derivation's weight and the derivation.
| PARAMETER | DESCRIPTION |
|---|---|
tag
|
Always
TYPE:
|
selects
property
¶
Whether the result selects among alternatives.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True. |
requirements
¶
requirements(algebra: ClaimSubject) -> tuple[Requirement, ...]
The laws the result needs.
| PARAMETER | DESCRIPTION |
|---|---|
algebra
|
The weight algebra.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple of Requirement
|
The semiring laws and a selective sum. |
Source code in src/quivers/qiec/contracts.py
KBest
didactic-model
¶
Bases: _Observable
The k best derivations.
| PARAMETER | DESCRIPTION |
|---|---|
k
|
How many, at least one.
TYPE:
|
tag
|
Always
TYPE:
|
selects
property
¶
Whether the result selects among alternatives.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True. |
requirements
¶
requirements(algebra: ClaimSubject) -> tuple[Requirement, ...]
The laws the result needs.
| PARAMETER | DESCRIPTION |
|---|---|
algebra
|
The weight algebra.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple of Requirement
|
The semiring laws, a selective sum and superior rules. |
Source code in src/quivers/qiec/contracts.py
Outcome
didactic-model
¶
Outcome(*, key: ComputationId = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['outcome'] = 'outcome')
Bases: _Observable
The weight of each outcome: the pushforward along a key.
| PARAMETER | DESCRIPTION |
|---|---|
key
|
The computation that maps a meaning to its outcome, with a decidable equality on outcomes.
TYPE:
|
tag
|
Always
TYPE:
|
ProjectedWeightRows
didactic-model
¶
ProjectedWeightRows(*, judgment: FamilyId = field(opaque=True, extras=OPAQUE_BY_VALUE), position: int, field: IndexBinder = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['projected-weight-rows'] = 'projected-weight-rows')
Bases: _Observable
The weights of items grouped by exact equality at one judgment index.
| PARAMETER | DESCRIPTION |
|---|---|
judgment
|
The checked family of the items whose weights are grouped.
TYPE:
|
position
|
The zero-based position in that judgment's ordered index telescope.
TYPE:
|
field
|
The binder and sort declared at that position.
TYPE:
|
tag
|
Always
TYPE:
|
NormalizedWeightRows
didactic-model
¶
NormalizedWeightRows(*, source: Weight | Outcome | ProjectedWeightRows = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['normalized-weight-rows'] = 'normalized-weight-rows')
Bases: _Observable
A finite collection of weight rows divided by their common total.
The source fixes the row key. All supported rows share one divisor. The normalization is defined only for positive total mass.
| PARAMETER | DESCRIPTION |
|---|---|
source
|
The unnormalized item weights or their checked pushforward.
TYPE:
|
tag
|
Always
TYPE:
|
requirements
¶
requirements(algebra: ClaimSubject) -> tuple[Requirement, ...]
Require the source weighting laws and division by a nonzero total.
| PARAMETER | DESCRIPTION |
|---|---|
algebra
|
The weight algebra.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple of Requirement
|
The source requirements followed by division. |
Source code in src/quivers/qiec/contracts.py
WeightedProofRows
didactic-model
¶
WeightedProofRows(*, normalized: bool = False, tag: Literal['weighted-proof-rows'] = 'weighted-proof-rows')
Bases: _Observable
The positive-weight derivations and their individual log masses.
Rows preserve proof occurrences, even if their checked proof values coincide. A normalized result divides their weights by the common positive total mass.
| PARAMETER | DESCRIPTION |
|---|---|
normalized
|
Whether to normalize the returned proof weights.
TYPE:
|
tag
|
Always
TYPE:
|
needs_finite_derivations
property
¶
Whether a guaranteed result lists finitely many derivations.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True. The observable lists all supported proof occurrences. |
requirements
¶
requirements(algebra: ClaimSubject) -> tuple[Requirement, ...]
The laws needed to assign the proof weights.
| PARAMETER | DESCRIPTION |
|---|---|
algebra
|
The weight algebra.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple of Requirement
|
An associative ordered product with a unit and absorbing zero. Normalization also needs an associative commutative sum and division. |
Source code in src/quivers/qiec/contracts.py
BooleanProofWeightRows
didactic-model
¶
BooleanProofWeightRows(*, normalized: bool = False, tag: Literal['boolean-proof-weight-rows'] = 'boolean-proof-weight-rows')
Bases: _Observable
The mass of each positive Boolean meaning of the proofs.
The interpretation supplies one truth value per lexical word and a truth table over each rule's ordered premise meanings. The result has at most one row for each Boolean value.
| PARAMETER | DESCRIPTION |
|---|---|
normalized
|
Whether to divide the two masses by their common positive total.
TYPE:
|
tag
|
Always
TYPE:
|
requirements
¶
requirements(algebra: ClaimSubject) -> tuple[Requirement, ...]
Require finite sums of products and optional division.
| PARAMETER | DESCRIPTION |
|---|---|
algebra
|
The weight algebra.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple of Requirement
|
The semiring laws, and division for a normalized result. |
Source code in src/quivers/qiec/contracts.py
Statistic
didactic-model
¶
Statistic(*, statistic: ComputationId = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['statistic'] = 'statistic')
Bases: _Observable
The weight and the expectation of a statistic, in a semimodule.
| PARAMETER | DESCRIPTION |
|---|---|
statistic
|
The computation of the statistic of a derivation.
TYPE:
|
tag
|
Always
TYPE:
|
requirements
¶
requirements(algebra: ClaimSubject) -> tuple[Requirement, ...]
The laws the result needs.
| PARAMETER | DESCRIPTION |
|---|---|
algebra
|
The weight algebra.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple of Requirement
|
The semiring laws and the semimodule action. |
Source code in src/quivers/qiec/contracts.py
Marginal
didactic-model
¶
Bases: _Observable
The derivative of the weight in each occurrence weight.
| PARAMETER | DESCRIPTION |
|---|---|
normalized
|
Whether the marginals are divided by the total weight.
TYPE:
|
tag
|
Always
TYPE:
|
requirements
¶
requirements(algebra: ClaimSubject) -> tuple[Requirement, ...]
The laws the result needs.
| PARAMETER | DESCRIPTION |
|---|---|
algebra
|
The weight algebra.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple of Requirement
|
The semiring laws, and division when normalized. |
Source code in src/quivers/qiec/contracts.py
Sample
didactic-model
¶
Bases: _Observable
Derivations drawn in proportion to their weight.
| PARAMETER | DESCRIPTION |
|---|---|
n
|
How many draws, at least one.
TYPE:
|
tag
|
Always
TYPE:
|
differentiable
property
¶
Whether the result has a derivative in the weights.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
False: a draw has none. The gradient of an expectation is a statistic with an estimator. |
requirements
¶
requirements(algebra: ClaimSubject) -> tuple[Requirement, ...]
The laws the result needs.
| PARAMETER | DESCRIPTION |
|---|---|
algebra
|
The weight algebra.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple of Requirement
|
The semiring laws and division, which normalizing needs. |
Source code in src/quivers/qiec/contracts.py
Fold
didactic-model
¶
Fold(*, fold: ComputationId = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['fold'] = 'fold')
Bases: _Observable
A fold of the detailed meaning that is linear in the weights.
| PARAMETER | DESCRIPTION |
|---|---|
fold
|
The fold.
TYPE:
|
tag
|
Always
TYPE:
|
needs_forest
property
¶
Whether the result needs the packed forest.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True. |
requirements
¶
requirements(algebra: ClaimSubject) -> tuple[Requirement, ...]
The laws the result needs.
| PARAMETER | DESCRIPTION |
|---|---|
algebra
|
The weight algebra.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple of Requirement
|
The semiring laws, and linearity of the fold. |
Source code in src/quivers/qiec/contracts.py
NonlinearFold
didactic-model
¶
NonlinearFold(*, fold: ComputationId = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['nonlinear-fold'] = 'nonlinear-fold')
Bases: _Observable
Any fold of the detailed meaning, linear or not.
No aggregate summarizes it in general: the alternatives -1 and 1 sum to 0 and have squares summing to 2. It needs every derivation, so a guaranteed result needs finitely many and the packed forest.
| PARAMETER | DESCRIPTION |
|---|---|
fold
|
The fold.
TYPE:
|
tag
|
Always
TYPE:
|
Forest
didactic-model
¶
Bases: _Observable
The packed forest itself.
| PARAMETER | DESCRIPTION |
|---|---|
tag
|
Always
TYPE:
|
differentiable
property
¶
Whether the result has a derivative in the weights.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
False: it is a structure. |
needs_forest
property
¶
Whether the result needs the packed forest.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True. |
requirements
¶
requirements(algebra: ClaimSubject) -> tuple[Requirement, ...]
The laws the result needs.
| PARAMETER | DESCRIPTION |
|---|---|
algebra
|
The weight algebra.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple of Requirement
|
None: the forest is the derivations, not their weights. |
Source code in src/quivers/qiec/contracts.py
QuerySpec
didactic-model
¶
QuerySpec(*, presentation: PresentationId = field(opaque=True, extras=OPAQUE_BY_VALUE), interpretation: InterpretationId = field(opaque=True, extras=OPAQUE_BY_VALUE), observable: Observable = field(opaque=True, extras=OPAQUE_BY_VALUE), input_types: tuple[TypeExpr, ...] = field(default=(), opaque=True, extras=OPAQUE_BY_VALUE), differentiate_with_respect_to: tuple[ParameterId | OccurrenceId, ...] = field(default=(), opaque=True, extras=OPAQUE_BY_VALUE), batch_axes: tuple[str, ...] = (), retention: Retention = field(default=NoRetention(), opaque=True, extras=OPAQUE_BY_VALUE))
Bases: QiecModel
What a query asks of a presentation under an interpretation.
| PARAMETER | DESCRIPTION |
|---|---|
presentation
|
The rule presentation.
TYPE:
|
interpretation
|
The interpretation of its rules.
TYPE:
|
observable
|
What is observed.
TYPE:
|
input_types
|
The types of the inputs.
TYPE:
|
differentiate_with_respect_to
|
The parameters and occurrences differentiated, in the order of the gradient, without repeats.
TYPE:
|
batch_axes
|
Names of batch axes, without repeats.
TYPE:
|
retention
|
The provenance kept.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValidationError
|
If a differentiated input or a batch axis repeats. |
Phase
¶
Bases: str, Enum
A phase of a computation whose work is bounded and counted apart.
ComputationModel
didactic-model
¶
Bases: QiecModel
The model of computation a bound is stated in.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
A short name.
TYPE:
|
description
|
What costs one unit.
TYPE:
|
ComplexityParameter
didactic-model
¶
Bases: QiecModel
A named size that bounds are stated in.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
An identifier, such as
TYPE:
|
meaning
|
What it counts.
TYPE:
|
ProvedOptimal
didactic-model
¶
ProvedOptimal(*, lower_bound: str, model: ComputationModel = field(opaque=True, extras=OPAQUE_BY_VALUE), sources: tuple[Citation, ...] = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['proved-optimal'] = 'proved-optimal')
Bases: QiecModel
The bound is optimal: a lower bound matches it in a stated model.
| PARAMETER | DESCRIPTION |
|---|---|
lower_bound
|
The lower bound, in the parameters of the claim, without the asymptotic symbol. It must equal the bound's expression.
TYPE:
|
model
|
The model of the lower bound.
TYPE:
|
sources
|
Where it is proved, at least one.
TYPE:
|
tag
|
Always
TYPE:
|
Conditional
didactic-model
¶
Conditional(*, hypothesis: str, sources: tuple[Citation, ...] = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['conditional'] = 'conditional')
Bases: QiecModel
The bound is optimal if a stated hypothesis holds.
| PARAMETER | DESCRIPTION |
|---|---|
hypothesis
|
The hypothesis, such as a conjecture of fine-grained complexity.
TYPE:
|
sources
|
Where the conditional lower bound is proved, at least one.
TYPE:
|
tag
|
Always
TYPE:
|
BestKnown
didactic-model
¶
BestKnown(*, sources: tuple[Citation, ...] = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['best-known'] = 'best-known')
Bases: QiecModel
The bound is the best published, with no matching lower bound.
| PARAMETER | DESCRIPTION |
|---|---|
sources
|
Where it is published, at least one.
TYPE:
|
tag
|
Always
TYPE:
|
Unresolved
didactic-model
¶
Bases: QiecModel
Whether the bound can be improved is open: a research obligation.
| PARAMETER | DESCRIPTION |
|---|---|
obligation
|
What remains to be shown.
TYPE:
|
tag
|
Always
TYPE:
|
Deficient
didactic-model
¶
Deficient(*, better_bound: str, justification: str, reviewed_by: str, sources: tuple[Citation, ...] = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['deficient'] = 'deficient')
Bases: QiecModel
A better bound is known, and a reviewed reason keeps this one.
| PARAMETER | DESCRIPTION |
|---|---|
better_bound
|
The better bound, in the parameters of the claim.
TYPE:
|
justification
|
Why this bound is kept, and in which regime of parameters.
TYPE:
|
reviewed_by
|
Who reviewed the justification.
TYPE:
|
sources
|
Where the better bound is published, at least one.
TYPE:
|
tag
|
Always
TYPE:
|
ComplexityBound
didactic-model
¶
ComplexityBound(*, phase: Phase = field(opaque=True, extras=OPAQUE_BY_VALUE), resource: Literal['time', 'space'], expression: str, status: OptimalityStatus = field(opaque=True, extras=OPAQUE_BY_VALUE))
Bases: QiecModel
An upper bound on one resource of one phase.
| PARAMETER | DESCRIPTION |
|---|---|
phase
|
The phase.
TYPE:
|
resource
|
TYPE:
|
expression
|
The bound in the parameters of the claim, without the asymptotic
symbol:
TYPE:
|
status
|
How it compares with what is known.
TYPE:
|
PhaseInapplicable
didactic-model
¶
PhaseInapplicable(*, phase: Phase = field(opaque=True, extras=OPAQUE_BY_VALUE), reason: str)
Bases: QiecModel
A phase that the query class does not have.
| PARAMETER | DESCRIPTION |
|---|---|
phase
|
The phase.
TYPE:
|
reason
|
Why it does not apply.
TYPE:
|
ComplexityClaim
didactic-model
¶
ComplexityClaim(*, query: str, parameters: tuple[ComplexityParameter, ...] = field(opaque=True, extras=OPAQUE_BY_VALUE), model: ComputationModel = field(opaque=True, extras=OPAQUE_BY_VALUE), bounds: tuple[ComplexityBound, ...] = field(opaque=True, extras=OPAQUE_BY_VALUE), inapplicable: tuple[PhaseInapplicable, ...] = field(default=(), opaque=True, extras=OPAQUE_BY_VALUE), conditions: tuple[str, ...] = ())
Bases: QiecModel
Bounds on the work of a query class, with their optimality status.
| PARAMETER | DESCRIPTION |
|---|---|
query
|
The query class.
TYPE:
|
parameters
|
The sizes the bounds are stated in.
TYPE:
|
model
|
The model of the bounds.
TYPE:
|
bounds
|
A time and a space bound for every phase that applies.
TYPE:
|
inapplicable
|
The phases that do not apply.
TYPE:
|
conditions
|
What the bounds need of the algebra and the input.
TYPE:
|
GroupingRecord
didactic-model
¶
GroupingRecord(*, handler: HandlerId = field(opaque=True, extras=OPAQUE_BY_VALUE), operation: OperationId = field(opaque=True, extras=OPAQUE_BY_VALUE), row_type: TypeExpr = field(opaque=True, extras=OPAQUE_BY_VALUE), key_type: TypeExpr = field(opaque=True, extras=OPAQUE_BY_VALUE), empty: ConstructorId = field(opaque=True, extras=OPAQUE_BY_VALUE), entry: ConstructorId = field(opaque=True, extras=OPAQUE_BY_VALUE), normalized: bool, input_rows: int, distinct_keys: int, positive_rows: int, algebra: ClaimSubject, claims: tuple[LawClaim, ...] = field(opaque=True, extras=OPAQUE_BY_VALUE), complexity: ComplexityClaim = field(opaque=True, extras=OPAQUE_BY_VALUE))
Bases: QiecModel
The checked reduction of supplied log weights by exact structural keys.
Each input row contributes once to its key. The result keeps one row per positive key in first-occurrence order. A normalized result divides all its masses by their positive common total.
| PARAMETER | DESCRIPTION |
|---|---|
handler
|
The installed handler and reached grouping operation.
TYPE:
|
operation
|
The installed handler and reached grouping operation.
TYPE:
|
row_type
|
The checked closed row-list and key types.
TYPE:
|
key_type
|
The checked closed row-list and key types.
TYPE:
|
empty
|
The exact constructors used for the input and output row list.
TYPE:
|
entry
|
The exact constructors used for the input and output row list.
TYPE:
|
normalized
|
Whether the successful result divides by a common positive total.
TYPE:
|
input_rows
|
The supplied rows, all distinct keys, and the positive output rows.
TYPE:
|
distinct_keys
|
The supplied rows, all distinct keys, and the positive output rows.
TYPE:
|
positive_rows
|
The supplied rows, all distinct keys, and the positive output rows.
TYPE:
|
algebra
|
The weight algebra and its available law claims.
TYPE:
|
claims
|
The weight algebra and its available law claims.
TYPE:
|
complexity
|
Bounds for the reduction from supplied rows, including its weight derivative.
TYPE:
|
requirements
¶
requirements() -> tuple[Requirement, ...]
State the laws used to aggregate keys and preserve positive support.
| RETURNS | DESCRIPTION |
|---|---|
tuple of Requirement
|
The additive laws and zero-sum-freeness, with division when normalized. |
Source code in src/quivers/qiec/contracts.py
WorkField
¶
Bases: str, Enum
A counter of a work report.
WorkReport
didactic-model
¶
WorkReport(*, phase: Phase = field(opaque=True, extras=OPAQUE_BY_VALUE), iterations: int = 0, scalar_sums: int = 0, scalar_products: int = 0, scalar_divisions: int = 0, star_pivots: int = 0, exact_operations: int = 0, key_comparisons: int = 0, hash_operations: int = 0, product_states: int = 0, arcs_visited: int = 0, elements_allocated: int = 0, peak_live_elements: int = 0, peak_bytes: int = 0, elements_saved_for_backward: int = 0, provenance_records: int = 0, nodes_validated: int = 0, nodes_instantiated: int = 0, cache_hits: int = 0, cache_invalidations: int = 0, seconds: Rational | None = field(default=None, opaque=True, extras=OPAQUE_BY_VALUE), measured: tuple[WorkField, ...] = field(default=(), opaque=True, extras=OPAQUE_BY_VALUE))
Bases: QiecModel
Counters of the work of one phase of a run.
Counts are elements inside tensor operations, not kernel launches.
| PARAMETER | DESCRIPTION |
|---|---|
phase
|
The phase counted.
TYPE:
|
iterations
|
Solver iterations.
TYPE:
|
scalar_sums
|
Scalar sums.
TYPE:
|
scalar_products
|
Scalar products.
TYPE:
|
scalar_divisions
|
Scalar divisions outside closures of one element.
TYPE:
|
star_pivots
|
Pivots of star computations: closures of one element, each one operation of the algebra, whatever it computes inside.
TYPE:
|
exact_operations
|
Rational or interval updates of an exact or enclosed decision, run when rounding alone cannot decide.
TYPE:
|
key_comparisons
|
Comparisons of keys.
TYPE:
|
hash_operations
|
Hash computations and lookups.
TYPE:
|
product_states
|
Product states created.
TYPE:
|
arcs_visited
|
Arcs visited.
TYPE:
|
elements_allocated
|
Elements allocated.
TYPE:
|
peak_live_elements
|
Elements live at once, at most.
TYPE:
|
peak_bytes
|
Bytes live at once, at most.
TYPE:
|
elements_saved_for_backward
|
Elements saved for the backward pass.
TYPE:
|
provenance_records
|
Provenance records kept.
TYPE:
|
nodes_validated
|
Graph nodes validated.
TYPE:
|
nodes_instantiated
|
Graph nodes instantiated.
TYPE:
|
cache_hits
|
Cache hits.
TYPE:
|
cache_invalidations
|
Cache invalidations.
TYPE:
|
seconds
|
Wall time, when measured.
TYPE:
|
measured
|
The counters the producer counted, in the order of
TYPE:
|
scalar_work
property
¶
Scalar sums, products and divisions.
| RETURNS | DESCRIPTION |
|---|---|
int
|
Their total. |
UnmeasuredWork
¶
UnmeasuredWork(field: WorkField, reason: str)
Bases: ValueError
A cost claim bounds a counter the work report did not count.
| PARAMETER | DESCRIPTION |
|---|---|
field
|
The counter.
TYPE:
|
reason
|
What was being checked.
TYPE:
|
Source code in src/quivers/qiec/contracts.py
Attainment
didactic-model
¶
Attainment(*, guarantee: Guarantee = field(opaque=True, extras=OPAQUE_BY_VALUE), metric: Metric = field(opaque=True, extras=OPAQUE_BY_VALUE), rounding: Rational | None = field(default=None, opaque=True, extras=OPAQUE_BY_VALUE), derivative: DerivativeSemantics = field(default=NOT_DIFFERENTIATED, opaque=True, extras=OPAQUE_BY_VALUE))
Bases: QiecModel
What a result reached: its guarantee, metric, rounding and derivative.
| PARAMETER | DESCRIPTION |
|---|---|
guarantee
|
The guarantee reached. A certified bound carries its certificate.
TYPE:
|
metric
|
The metric of the guarantee.
TYPE:
|
rounding
|
A bound on the rounding error in the metric, or
TYPE:
|
derivative
|
The derivative reached.
TYPE:
|
total_bound
property
¶
The bound with rounding included, when both parts are known.
| RETURNS | DESCRIPTION |
|---|---|
Fraction or None
|
The certified or exact bound plus the rounding bound, or
|
ArgumentBound
didactic-model
¶
ArgumentBound(*, metric: Metric = field(opaque=True, extras=OPAQUE_BY_VALUE), lipschitz: Rational | None = field(default=None, opaque=True, extras=OPAQUE_BY_VALUE), affine: bool = False)
Bases: QiecModel
What an operation promises about one of its arguments.
| PARAMETER | DESCRIPTION |
|---|---|
metric
|
The metric of the argument the constant is stated in.
TYPE:
|
lipschitz
|
A constant
TYPE:
|
affine
|
Whether the operation is affine in this argument, which keeps unbiased estimates unbiased.
TYPE:
|
OperationBound
didactic-model
¶
OperationBound(*, name: str, arguments: tuple[ArgumentBound, ...] = field(opaque=True, extras=OPAQUE_BY_VALUE), metric: Metric = field(opaque=True, extras=OPAQUE_BY_VALUE), rounding: Rational | None = field(default=None, opaque=True, extras=OPAQUE_BY_VALUE), derivative: DerivativeSemantics = field(default=DerivativeSemantics(), opaque=True, extras=OPAQUE_BY_VALUE), conditions: tuple[str, ...] = ())
Bases: QiecModel
What an operation that combines results promises about them.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The operation.
TYPE:
|
arguments
|
One per argument.
TYPE:
|
metric
|
The metric of the result.
TYPE:
|
rounding
|
A bound on the operation's own rounding error, or
TYPE:
|
derivative
|
The derivative of the operation itself, such as a tie rule for a maximum or none for a threshold.
TYPE:
|
conditions
|
Where the constants hold.
TYPE:
|
Completed
didactic-model
¶
Bases: QiecModel
The method ran to its end.
| PARAMETER | DESCRIPTION |
|---|---|
tag
|
Always
TYPE:
|
early
property
¶
Whether the run stopped before its method ended.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
False. |
BudgetExhausted
didactic-model
¶
BudgetExhausted(*, resource: Literal['iterations', 'scalar_work', 'states', 'elements', 'bytes', 'seconds'], limit: Rational = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['budget-exhausted'] = 'budget-exhausted')
Bases: QiecModel
The run stopped because a resource limit was reached.
| PARAMETER | DESCRIPTION |
|---|---|
resource
|
The limit, a field of
TYPE:
|
limit
|
Its value.
TYPE:
|
tag
|
Always
TYPE:
|
early
property
¶
Whether the run stopped before its method ended.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True. |
ControlReached
didactic-model
¶
ControlReached(*, control: str, value: Rational = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['control-reached'] = 'control-reached')
Bases: QiecModel
The run stopped because a control was reached, such as a residual.
A residual below a tolerance is a diagnostic, not a certificate.
| PARAMETER | DESCRIPTION |
|---|---|
control
|
The control.
TYPE:
|
value
|
The diagnostic when it stopped.
TYPE:
|
tag
|
Always
TYPE:
|
early
property
¶
Whether the run stopped before its method ended.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True. |
ContractField
¶
Bases: str, Enum
A requirement of an accuracy contract that a run can fail.
AccuracyReport
didactic-model
¶
AccuracyReport(*, attainment: Attainment = field(opaque=True, extras=OPAQUE_BY_VALUE), stop: StopReason = field(default=Completed(), opaque=True, extras=OPAQUE_BY_VALUE), unmet: tuple[ContractField, ...] = field(default=(), opaque=True, extras=OPAQUE_BY_VALUE), derivatives: DerivativeReport = field(default=DerivativeReport(), opaque=True, extras=OPAQUE_BY_VALUE), work: tuple[WorkReport, ...] = field(default=(), opaque=True, extras=OPAQUE_BY_VALUE), claims: tuple[LawClaim, ...] = field(default=(), opaque=True, extras=OPAQUE_BY_VALUE))
Bases: QiecModel
What a run reached, why it stopped, and what it cost.
A derivative report of a run is the derivatives field, and its
summary is the derivative of the attainment.
| PARAMETER | DESCRIPTION |
|---|---|
attainment
|
What the result reached.
TYPE:
|
stop
|
Why the run stopped.
TYPE:
|
unmet
|
The requirements not met.
TYPE:
|
derivatives
|
The derivative of each output and input.
TYPE:
|
work
|
The work of each phase, one report per phase.
TYPE:
|
claims
|
Every law claim the run used.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValidationError
|
If a phase has two work reports, or the attainment's derivative is not the summary of the derivative report. |
Unestablished
didactic-model
¶
Unestablished(*, value: HeldValue = field(opaque=True, extras=OPAQUE_BY_IDENTITY), report: AccuracyReport = field(opaque=True, extras=OPAQUE_BY_VALUE))
Bases: QiecModel
A value whose contract was not met, with the report that says why.
It is not a weight, a tensor or a number, and nothing that expects one accepts it.
| PARAMETER | DESCRIPTION |
|---|---|
value
|
The value the run computed.
TYPE:
|
report
|
What it reached, with the unmet requirements.
TYPE:
|
ContractNotMet
¶
ContractNotMet(report: AccuracyReport)
Bases: ValueError
A run did not meet its contract, and the contract says to refuse.
| PARAMETER | DESCRIPTION |
|---|---|
report
|
What the run reached.
TYPE:
|
Source code in src/quivers/qiec/contracts.py
RefusalCode
¶
Bases: str, Enum
Why a combination of contract records is inadmissible.
Refusal
didactic-model
¶
Refusal(*, code: RefusalCode = field(opaque=True, extras=OPAQUE_BY_VALUE), reason: str)
Bases: QiecModel
One reason a combination is inadmissible.
| PARAMETER | DESCRIPTION |
|---|---|
code
|
The kind of reason.
TYPE:
|
reason
|
The reason, with the records it concerns.
TYPE:
|
InadmissibleContract
¶
InadmissibleContract(refusals: tuple[Refusal, ...])
Bases: ValueError
A query, its recursion, its contract and its claims do not fit.
| PARAMETER | DESCRIPTION |
|---|---|
refusals
|
Every reason.
TYPE:
|
Source code in src/quivers/qiec/contracts.py
InadmissibleReport
¶
InadmissibleReport(refusals: tuple[Refusal, ...])
Bases: ValueError
A report claims what its run cannot show, or contradicts its contract.
| PARAMETER | DESCRIPTION |
|---|---|
refusals
|
Every reason.
TYPE:
|
Source code in src/quivers/qiec/contracts.py
measuring
¶
Counters as a work report lists them: in the order of WorkField, each once.
| PARAMETER | DESCRIPTION |
|---|---|
fields
|
The counters.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple of WorkField
|
The listing. |
Source code in src/quivers/qiec/contracts.py
bounded_fields
¶
bounded_fields(bound: ComplexityBound) -> frozenset[WorkField]
The counters a bound of the algebra-operations model bounds.
| PARAMETER | DESCRIPTION |
|---|---|
bound
|
The bound.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
frozenset of WorkField
|
The time counters for a time bound, the space counters of its phase for a space bound. |
Source code in src/quivers/qiec/contracts.py
measured_total
¶
measured_total(bound: ComplexityBound, report: WorkReport) -> int
The measured quantity a bound bounds: the time spent, or the space held.
| PARAMETER | DESCRIPTION |
|---|---|
bound
|
The bound.
TYPE:
|
report
|
The work of the bound's phase.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
int
|
The sum of the time counters, or the largest space counter. |
| RAISES | DESCRIPTION |
|---|---|
UnmeasuredWork
|
If a counter the bound bounds is not measured. |
ValueError
|
If the report is of another phase. |
Source code in src/quivers/qiec/contracts.py
compose
¶
compose(parts: tuple[Attainment, ...], operation: OperationBound) -> Attainment
The attainment of an operation applied to results.
This is the composition law: the guarantee of the composite is the weakest of its parts, and a bound propagates through each part's Lipschitz constant. A part with a bound but no constant in its own metric makes the composite heuristic, and so does a heuristic part unless the operation is constant in it.
| PARAMETER | DESCRIPTION |
|---|---|
parts
|
The attainment of each argument.
TYPE:
|
operation
|
What the operation promises.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Attainment
|
The composite. Its bound is |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the number of parts is not the number of arguments, or the parts use different tie rules or estimate one site twice. |
Source code in src/quivers/qiec/contracts.py
3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 | |
attained_guarantee
¶
attained_guarantee(stop: StopReason, method: Guarantee, certificate: Certificate | None) -> Guarantee
The guarantee a run may claim.
| PARAMETER | DESCRIPTION |
|---|---|
stop
|
Why the run stopped.
TYPE:
|
method
|
The guarantee of the method when it runs to its end.
TYPE:
|
certificate
|
A certificate the run computed, if any.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Guarantee
|
The method's guarantee when it completed. A run that stopped early claims the bound of its certificate, and without one it claims nothing: neither the budget nor the residual is a bound. |
Source code in src/quivers/qiec/contracts.py
unmet_fields
¶
unmet_fields(contract: AccuracyContract, attainment: Attainment, work: tuple[WorkReport, ...]) -> tuple[ContractField, ...]
The requirements of a contract that a run did not meet.
| PARAMETER | DESCRIPTION |
|---|---|
contract
|
The contract.
TYPE:
|
attainment
|
What the run reached.
TYPE:
|
work
|
Its work.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple of ContractField
|
In the order of |
Source code in src/quivers/qiec/contracts.py
settle
¶
settle(contract: AccuracyContract, value: T, report: AccuracyReport) -> T | Unestablished
Apply a contract's failure policy to a run's result.
| PARAMETER | DESCRIPTION |
|---|---|
contract
|
The contract.
TYPE:
|
value
|
The value the run computed.
TYPE:
|
report
|
Its report.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
T or Unestablished
|
The value when the report meets the contract; otherwise the value wrapped as unestablished, when the contract says to return it. |
| RAISES | DESCRIPTION |
|---|---|
InadmissibleReport
|
If the report is inconsistent with the contract. |
ContractNotMet
|
If the contract is not met and says to refuse. |
Source code in src/quivers/qiec/contracts.py
admissibility
¶
admissibility(query: QuerySpec, recursion: Recursion, contract: AccuracyContract, *, algebra: ClaimSubject, claims: tuple[LawClaim, ...], uses: tuple[Requirement, ...] = ()) -> tuple[Refusal, ...]
Every reason a query, its recursion, contract and claims do not fit.
| PARAMETER | DESCRIPTION |
|---|---|
query
|
The query.
TYPE:
|
recursion
|
How its system is solved.
TYPE:
|
contract
|
Its accuracy contract.
TYPE:
|
algebra
|
Its weight algebra.
TYPE:
|
claims
|
The law claims available.
TYPE:
|
uses
|
Further laws the executor relies on, such as commutativity of the product for an elimination order.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple of Refusal
|
Empty when the combination is admissible. |
Source code in src/quivers/qiec/contracts.py
4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 | |
check_admissible
¶
check_admissible(query: QuerySpec, recursion: Recursion, contract: AccuracyContract, *, algebra: ClaimSubject, claims: tuple[LawClaim, ...], uses: tuple[Requirement, ...] = ()) -> None
Refuse a query, recursion, contract and claims that do not fit.
| PARAMETER | DESCRIPTION |
|---|---|
query
|
The query.
TYPE:
|
recursion
|
How its system is solved.
TYPE:
|
contract
|
Its accuracy contract.
TYPE:
|
algebra
|
Its weight algebra.
TYPE:
|
claims
|
The law claims available.
TYPE:
|
uses
|
Further laws the executor relies on.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
InadmissibleContract
|
With every reason, if there is one. |
Source code in src/quivers/qiec/contracts.py
report_refusals
¶
report_refusals(contract: AccuracyContract, report: AccuracyReport, recursion: Recursion | None = None) -> tuple[Refusal, ...]
Every reason a report claims what its run cannot show.
| PARAMETER | DESCRIPTION |
|---|---|
contract
|
The contract of the run.
TYPE:
|
report
|
Its report.
TYPE:
|
recursion
|
How the run solved its system, when it has one.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple of Refusal
|
Empty when the report is admissible. |
Source code in src/quivers/qiec/contracts.py
4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 | |
check_report
¶
check_report(contract: AccuracyContract, report: AccuracyReport, recursion: Recursion | None = None) -> None
Refuse a report that claims what its run cannot show.
| PARAMETER | DESCRIPTION |
|---|---|
contract
|
The contract of the run.
TYPE:
|
report
|
Its report.
TYPE:
|
recursion
|
How the run solved its system, when it has one.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
InadmissibleReport
|
With every reason, if there is one. |
Source code in src/quivers/qiec/contracts.py
complexity_refusals
¶
complexity_refusals(claim: ComplexityClaim) -> tuple[Refusal, ...]
Every reason a complexity claim is incomplete or unsupported.
| PARAMETER | DESCRIPTION |
|---|---|
claim
|
The claim.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple of Refusal
|
Empty when every phase has a time and a space bound or is declared inapplicable (not both), every bound uses only the declared parameters, and every optimality proof has a lower bound equal to its bound. |
Source code in src/quivers/qiec/contracts.py
4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 | |
check_complexity
¶
check_complexity(claim: ComplexityClaim) -> None
Refuse an incomplete or unsupported complexity claim.
| PARAMETER | DESCRIPTION |
|---|---|
claim
|
The claim.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
InadmissibleContract
|
With every reason, if there is one. |