Skip to content

LUT-free Mini-Float Upcasting#310

Draft
ashvardanian wants to merge 4 commits into
main-devfrom
lut-free-casts
Draft

LUT-free Mini-Float Upcasting#310
ashvardanian wants to merge 4 commits into
main-devfrom
lut-free-casts

Conversation

@ashvardanian
Copy link
Copy Markdown
Owner

This patch explores the idea of LUT-free arithmetic upcasts for mini-float representations into F32. The current results look inconclusive and should be later investigated together with a GEMM redesign to hoist the upcasts & fuse them with loads.

This patch explores the idea of LUT-free arithmetic upcasts
for mini-float representations into F32. The current results
look inconclusive and should be later investigated together
with a GEMM redesign to hoist the upcasts & fuse them with
loads.
Closes #328

On x86 Sapphire Rapids cores - denormal values choke FMA:
- F32 slows from ~3cy to ~86cy (28x slower)
- F64 slows from ~3cy to ~104cy (34x slower)
That's why previous versions of this library suggested changing
FTX/DAZ settings to ensure high throughput. We now always
use mixed-precision schemes that are safe even against such
inputs. All of F32 denormals become normal in F64 accumulators
and it's a similar story for other inputs.
With denormal f32 intermediates now safe, replace the two-path
integer-add + subnormal-LUT upcast with Giesen's magic-multiply
trick across all backends (Haswell, Skylake, NEON, RVV, WASM,
serial). A single float multiply — reinterpret magnitude bits as
a tiny f32, multiply by 2^(127-bias) — correctly handles zero,
subnormals, and normals in one instruction, eliminating per-format
LUT constants and subnormal mask+blend logic (-169 lines net).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant