Skip to main content

PrecisionGuarantee

Struct PrecisionGuarantee 

Source
pub struct PrecisionGuarantee {
    pub bit_stable_on_same_hardware: bool,
    pub max_ulp: Option<u32>,
    pub max_relative: Option<f64>,
    pub max_absolute: Option<f64>,
    pub notes: &'static str,
}
Expand description

What this kernel guarantees about its numerical behavior.

Replaces the binary-flag OracleGrade concept that pre-architecture drafts used; per architecture v1.0 every kernel registration carries a structured precision statement so the optimizer can reason about tolerance budgets and pick comparators for calibration.

bit_stable_on_same_hardware is the strongest property. The always-built backend (fuel-cpu-backend by convention) commits to providing at least one bit_stable_on_same_hardware: true kernel per primitive op as the architecture v1.0 coverage commitment; step 7 enforces this via a CI lint.

The Optional fields encode the bound’s flavor (ULP / relative / absolute). Multiple may be present; the optimizer takes the intersection (a budget is admissible only if every populated bound satisfies it). Absent bounds mean “this kernel makes no claim about that flavor.”

Fields§

§bit_stable_on_same_hardware: bool

True iff this kernel produces bit-identical output for bit-identical inputs on the same hardware (no nondeterminism from kernel scheduling, atomic ordering, etc.).

§max_ulp: Option<u32>

Maximum unit-in-last-place error vs the IEEE-754 correctly- rounded result. Tighter than max_relative for low-magnitude values; many vendor math libraries quote ULPs.

§max_relative: Option<f64>

Maximum relative error: |out - ref| / max(|ref|, eps).

§max_absolute: Option<f64>

Maximum absolute error: |out - ref|.

§notes: &'static str

Free-text qualifier — for audited claims, this carries the audit reason (vendor citation, scheduler-dependence note, implementation hint). For the UNAUDITED sentinel, this is a fixed placeholder string the coverage lint matches against to distinguish unaudited placeholders from audited claims that happen to have no static bound. If you change UNAUDITED.notes, the lint’s detector picks up the new value automatically — it reads PrecisionGuarantee::UNAUDITED.notes at test time, not a hardcoded string.

Implementations§

Source§

impl PrecisionGuarantee

Source

pub const REFERENCE: PrecisionGuarantee

“Reference” guarantee: bit-stable on same hardware, no error claim above that. Used by reference-grade CPU kernels that commit to deterministic IEEE-754 evaluation.

Source

pub const PRIMITIVE_DETERMINISTIC_CPU: PrecisionGuarantee

Phase 7.6 step 7b: shared precision guarantee for the always-built CPU backend’s primitive kernels — elementwise unary/binary, reductions, matmul, casts, comparisons, indexing, scalar ops, transcendentals (Exp/Log/Sin/Cos/Tanh/Sigmoid/ Gelu/Silu), etc. All claim:

  • bit_stable_on_same_hardware: true (deterministic iteration order; no atomic FP adds; sequential nested loops)
  • F32 accumulator for BF16/F16 inputs, native F32 / F64 / U32 for matching dtypes
  • No specific ULP / relative / absolute bound claimed at this layer — the empirical calibration framework in step 8 populates per-op-per-shape bounds via reference comparisons

This is the default value bulk-applied by crate::kernel::KernelBindingTable::fill_unset_cpu_precision at the end of register_cpu_kernels. Sites that need a different claim must call crate::kernel::KernelBindingTable::register_with_precision explicitly with the weaker guarantee — those don’t get bulk-overwritten because the fill only touches UNAUDITED entries.

Source

pub const UNAUDITED: PrecisionGuarantee

Default placeholder for kernels whose precision hasn’t been audited yet. Identified by the coverage lint via notes- equality against PrecisionGuarantee::UNAUDITED.notes — the only way a registration ends up with this specific notes string is by using the literal UNAUDITED const (the default in unannotated register(...) / register_with_caps(...) calls).

For kernels audited and concluded “no static bound applies” (e.g. Vulkan subgroup reductions where FADD order is scheduler-determined per dispatch), use none instead. It returns a structurally-similar PrecisionGuarantee but with the audit reason in notes, captured at the registration site. The lint accepts any notes value other than UNAUDITED’s specific text.

Source

pub const fn none(reason: &'static str) -> PrecisionGuarantee

Constructor for the “audited, no static guarantee could be established” conclusion. Used by Vulkan subgroup reductions (where FADD order is scheduler-determined per dispatch) and similar kernels whose numerical character can’t be summarized by static ULP / relative / absolute bounds.

The reason is captured in notes, so the audit reasoning lives at the registration site — visible in code review, not buried in a separate lint allowlist file. Any reason other than UNAUDITED.notes makes the resulting value pass the coverage lint.

Distinguished from UNAUDITED by notes content alone (the value-field shape is identical). The lint uses precision.notes == PrecisionGuarantee::UNAUDITED.notes as the unaudited detector — robust to UNAUDITED’s notes text drifting because it reads from the const itself.

Source

pub fn makes_no_static_claim(&self) -> bool

Does this guarantee assert nothing machine-checkable — no bit-stability, no ULP / relative / absolute bound?

True for BOTH UNAUDITED and none: they are field-identical, because they make the same (empty) set of claims. What separates them is provenance, not claim content — see Self::is_audited_no_bound.

Source

pub fn is_audited_no_bound(&self) -> bool

Is this an audited conclusion that no static bound applies (none(reason)) rather than the never-audited placeholder (UNAUDITED)?

§Why this is a method and not an open-coded check (GAP-095)

These two states are field-identical apart from notes, so any consumer that must tell them apart is forced to key on a string. Two consumers previously invented their own predicate and disagreed: the bit-stable coverage lint compared notes against UNAUDITED.notes, while KernelBindingTable::fill_unset_cpu_precision looked only at the four value fields — and therefore silently rewrote an audited “no static bound applies” conclusion into a bit_stable_on_same_hardware: true claim the audit had declined to make.

One definition, so the next consumer inherits the distinction instead of re-deriving it. This is a seam, not a cure: a &'static str remains the load-bearing discriminator, and only making the two states structurally distinct would make conflation unrepresentable. That change is priced at ~64 PrecisionGuarantee literals across three crates and is tracked separately; when it lands, this method’s body changes and its callers do not.

Trait Implementations§

Source§

impl Clone for PrecisionGuarantee

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for PrecisionGuarantee

Source§

impl Debug for PrecisionGuarantee

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more