Skip to main content

Crate tenferro_bf16_proof

Crate tenferro_bf16_proof 

Source
Expand description

Standard bfloat16 carried through the external-scalar boundary.

#1785 asks for half::bf16 as a standard scalar representation, with construction, views, materialization, explicit bf16/f32 conversions, basic forward arithmetic, and sum reduction through the same public boundary the other external scalars use. This crate supplies exactly that: the representation is half::bf16, and the thin wrapper exists only because a foreign type cannot implement tenferro’s local scalar traits, which #1785 accepts for an external contribution.

§Declared arithmetic, accumulation, and rounding

The behaviour is specified rather than implied, which is what #1785 asks for:

  • Storage is half::bf16, so a stored value is the nearest bfloat16 to what was written.
  • A single operation is computed in f32 and rounded back to bfloat16 once, so the result carries the rounding error of the operation and nothing else.
  • A reduction accumulates in f32 and rounds once at the end, so the accumulation does not quantize at every step. reduction::sum_in_f32_accumulation states this, and tests/reduction_precision.rs distinguishes that contract from repeated bfloat16 rounding, which is what #1785 requires of a promise like this one.

Repeated bfloat16 rounding is a different and weaker contract, so the tests measure the difference rather than asserting only that the sum is close.

Modules§

conversion
Directed conversions between bfloat16 storage and f32.
einsum
A bfloat16 contraction through the runtime’s extension module.
reduction
Reductions over bfloat16 storage.

Structs§

Bf16
A bfloat16 scalar in tenferro’s scalar contract.
Bf16Add
bfloat16 addition as an operation type.
Bf16Mul
bfloat16 multiplication as an operation type.
Bf16Sub
bfloat16 subtraction as an operation type.
bf16
The standard bfloat16 representation this contribution stores. A 16-bit floating point type implementing the bfloat16 format.

Enums§

Bf16Set
Value enum for the set that carries bfloat16 beside f32.
Bf16Tag
Tag for the set that pairs the standard narrow type with f32.