Phiacta
ExplorePostDocsGuidesContributingAbout

Phiacta

The knowledge backend.

Contact Us
ExploreQF8 Encoding: 1-bit sign + 7-bit u3.4 log₂ code + E8M0 block scale

QF8 Encoding: 1-bit sign + 7-bit u3.4 log₂ code + E8M0 block scale

The QF8 format encodes each value as a 1-bit sign and 7-bit u3.4 fixed-point log₂ code, with a shared E8M0 block exponent per 32 elements. Reconstruction: x̂ = (-1)^σ · s · 2^((c-64)/16). Effective cost: 8.25 bits/element. Provides 16 levels per octave across 8 octaves.

ContentIssuesEditsHistoryFilesReferences4

QF8 Encoding

Format Structure

A QF8-encoded block of k = 32 values consists of:

  • Shared block scale (8 bits): An E8M0 power-of-2 exponent s ∈ {2⁻¹²⁷, …, 2¹²⁷}.
  • Per-element code (8 bits each): 1 sign bit σ ∈ {0,1} and a 7-bit unsigned u3.4 fixed-point code c ∈ {0, 1, …, 127}.

Reconstruction

x^=(−1)σ⋅s⋅2(c−64)/16,c≠0\hat{x} = (-1)^\sigma \cdot s \cdot 2^{(c - 64)/16}, \quad c \neq 0x^=(−1)σ⋅s⋅2(c−64)/16,c=0

with c = 0 encoding exact zero. The effective storage cost is 8 + 8/32 = 8.25 bits per element.

Logarithmic Spacing

The u3.4 code provides 3 integer bits and 4 fractional bits of log₂|x/s|, spanning 8 octaves with 16 representable levels per octave. The ratio between consecutive representable values is constant:

r=21/16≈1.0443r = 2^{1/16} \approx 1.0443r=21/16≈1.0443

giving a maximum relative quantization error of (r − 1)/2 ≈ 2.22%.

Compare FP8 E4M3: 8 levels per octave (3-bit mantissa), maximum relative error 1/16 = 6.25% within each binade.

Multiplication as Integer Addition

For two QF8 values with log codes c_a, c_b:

  • sign_product = σ_a ⊕ σ_b (XOR)
  • log-code_product = c_a + c_b (7-bit integer addition)

This replaces a 4×4 mantissa multiplier (FP8) with a 7-bit carry-lookahead adder — a ~3.5× reduction in gate count (66 vs. 231 gates).

Accumulation Strategy

QF8 adopts Kulisch accumulation (Johnson, 2018):

  1. Multiply in log domain (integer addition of codes)
  2. Convert each product to linear domain via a 16-entry lookup table
  3. Accumulate in a wide fixed-point register (32–48 bits)

Metadata

Type
definition
Visibility
public
Published
Mar 27, 2026
Last updated
Mar 27, 2026

Tags

block-scalingencodingnumber-formatquakefloat8