Skip to main content

Layouts

A spec talks about logical tensors: K[b, s, h, d]. A kernel reads physical memory: pages of a KV cache, a strided view, a packed weight. A layout mapping is the function from one to the other. Pass one per pointer parameter in layout=:
“Parsed” layouts are accepted in annotations and recorded in reports. Where the engine does not model a layout yet, verification of that kernel ends UNKNOWN rather than assuming a layout. blockwise_scaled does more than remap indices: it interprets quantised storage as real-valued weights. Weight-quantisation error is the model provider’s decision, not a kernel bug. Activation quantisation changes the computation itself, and is out of scope.

Assumptions

An assumption is a precondition the kernel relies on but the spec does not guarantee:
Supported forms:
  • Integer conditions on shape symbols and integer parameters: T % 16 == 0, T <= 8192, S >= 1.
  • Tensor properties: contiguous(X).
Each assumption becomes a hypothesis of the proof, is listed under assumptions in the JSON report, and is written into the release certificate.

Vacuity

If the assumptions contradict each other or empty the shape domain (T % 16 == 0 with T ∈ [1, 8]), any kernel would be “proved”. The engine checks satisfiability first, and reports such a run as:

Runtime guards

A proof is only valid when its assumptions hold at runtime. theformalera guards generates a module with one check per kernel:
kernels/_theformalera_guards.py
Call the guard in the launcher, before the kernel:
  • Scalars bound to model constants get guards too, as eps == 1e-06 shows.
  • Guards only compare integers and metadata, so their cost is negligible.
  • Set THEFORMALERA_GUARDS=0 to disable them, for example in a benchmark.
  • A failed guard raises AssumptionViolated, a subclass of AssertionError.

Narrowing the domain

domain= narrows the shape domain of one kernel:
The narrowed domain is what gets proved, so it should match how the system is really deployed: for example, a prefill kernel that only ever sees chunks of at most 8192 tokens. Widening the default domain is rejected.
[policy] domain_narrowing (allow | warn | fail) is accepted in theformalera.toml but not enforced by this release, and narrowed domains are not yet listed in the release certificate. If a narrowing matters for your deployment, also state it as an assume= entry: assumptions are listed in the certificate and get runtime guards.