# FP8 Search & KV-Caching in USearch

> GPUs moved to FP8. CPUs didn't. 200,000 lines of SIMD kernels later, USearch bridges both worlds — native Float8 Vector Search and KV Caching for the upcoming Arm-based NVIDIA Vera racks, Intel Xeons, open-source RISC-V chips, IBM Mainframes, Chinese LoongArch, and even WebAssembly in the browser — for higher throughput at 99% recall and half the memory cost

[Blog](https://www.unum.cloud/blog.md) [IO](https://www.unum.cloud/blog?tag=IO) [AI](https://www.unum.cloud/blog?tag=AI)

GPUs moved to FP8. CPUs didn't. 200,000 lines of SIMD kernels later, USearch bridges both worlds — native Float8 Vector Search and KV Caching for the upcoming Arm-based NVIDIA Vera racks, Intel Xeons, open-source RISC-V chips, IBM Mainframes, Chinese LoongArch, and even WebAssembly in the browser — for higher throughput at 99% recall and half the memory cost

- By

  Ash Vardanian

- Published

  Apr 20, 2026

## Setting The Stage in 2026

We at Unum haven’t published any blog posts in 3 years. So what’s the world like now? LLM inference is by far the most important workload in the datacenter. The bottleneck isn’t compute — it’s memory for attention kernels in Transformer AI models and their [KV Caches](https://huggingface.co/blog/not-lain/kv-caching). Attention is just a special case of Vector Search — every token’s query vector is compared against every cached key vector via inner products, which is a nearest-neighbor lookup. At small scale this is dense matrix multiplication; at large scale it’s [approximate nearest neighbor search](https://en.wikipedia.org/wiki/Nearest_neighbor_search#Approximate_nearest_neighbor) (ANN).

- The [AI inference market hit $106B in 2025](https://www.marketsandmarkets.com/PressReleases/ai-inference.asp) and is accelerating — [OpenAI alone targets $600B in compute spending by 2030](https://www.cnbc.com/2026/02/20/openai-resets-spend-expectations-targets-around-600-billion-by-2030.html)
- Memory is the constraint: [HBM is sold out through 2026](https://www.cnbc.com/2026/01/10/micron-ai-memory-shortage-hbm-nvidia-samsung.html), [DRAM prices are up 50% year-over-year](https://www.trendforce.com/news/2025/12/24/news-samsung-sk-hynix-reportedly-plan-20-hbm3e-price-hike-for-2026-as-nvidia-h200-asic-demand-rises/), and [SK Group’s chairman expects the shortage to last until 2030](https://www.tomshardware.com/pc-components/dram/sk-group-chairman-says-memory-chip-shortage-will-last-until-2030)
- Research is already moving: [RetrievalAttention](https://arxiv.org/abs/2409.10516) and [Quest](https://arxiv.org/abs/2406.10774) replace full attention with ANN lookup over the KV Cache, scanning just 1–3% of cached keys per token and cutting decode latency by up to 5×

On the Unum side, our USearch engine is now arguably the world’s most widely used search engine, powering [ClickHouse](https://github.com/ClickHouse/ClickHouse/tree/master/contrib/usearch), [DuckDB](https://github.com/duckdb/duckdb_vss), [YugabyteDB](https://github.com/yugabyte/yugabyte-db/tree/master/src/inline-thirdparty/usearch), and [ScyllaDB](https://github.com/scylladb/vector-store). It runs in government agencies, mobile apps, and edge software across hundreds of millions of devices, through 11 first-party and several community-maintained language bindings. But most importantly — it runs inside major AI labs around the globe. Many of them are already shifting towards heterogeneous data-centers with disaggregated prefill, caching, and decode running on separate chips.

- [Intel + SambaNova](https://www.businesswire.com/news/home/20260408117878/en/SambaNova-and-Intel-Announce-Blueprint-for-Heterogeneous-Inference-GPUs-for-Prefill-SambaNova-RDUs-for-Decode-and-Intel-Xeon-6-CPUs-for-Agentic-Tools) — Xeon CPUs for agentic tools, GPUs for prefill, RDUs for decode
- [NVIDIA + Groq](https://groq.com/newsroom/groq-and-nvidia-enter-non-exclusive-inference-technology-licensing-agreement-to-accelerate-ai-inference-at-global-scale) — $20B deal to bring Groq’s LPU decode technology into NVIDIA’s ecosystem
- [Cerebras + AWS Trainium](https://www.cerebras.ai/blog/disaggregated-inference) — Trainium for prefill, CS-3 wafer-scale engines for decode

Expect many more cross-combinations as the industry settles on the best pairings. In all of them, KV caches must be stored, transferred between chips, and searched — and the format they travel in matters.

Every year, hardware vendors push the numeric types tighter to squeeze more FLOPs per byte of stored and transferred memory. USearch was the first engine with proper hardware acceleration for 16-bit floating-point numbers. Now we are pushing the frontier with 8-bit and 6-bit representations. The result is 200,000 lines of new kernel code wired into USearch — heavily hardened, numerically stable SIMD acceleration for new data types across all CPUs produced over the last decade and two important upcoming platforms:

- [Intel Xeon7 Diamond Rapids](https://www.intel.com/content/www/us/en/products/platforms/details/diamond-rapids.html) with native AVX 10.2 FP8 instructions
- [NVIDIA Vera](https://nvidianews.nvidia.com/news/nvidia-vera-cpu) — 88 Arm-based Olympus cores with native Float8 dot products across 6 SIMD ports, shipping as full liquid-cooled CPU racks with up to 256 chips and no GPU in sight

We expect our partners at [Nebius](https://nebius.com/) to soon start making this infrastructure available to their clients. In the meantime, let’s check what’s under the hood.

## Mini-Floats and 200,000 Lines of Correctness

USearch was designed from day one as a modular tool, and once its internal linear algebra capabilities reached maturity, they were spun out into a standalone project, now powering even more applications than USearch itself. That library was recently renamed from SimSIMD to [NumKong](https://github.com/ashvardanian/NumKong) in a massive redesign that took **over three years**. The outcome: 2,000+ hand-written SIMD kernels covering 17 numeric types across 30+ CPU backends, leveraging not only vector 1D SIMD but also new tiled 2D instructions. This delivers an unprecedented level of performance-portability across CPU generations. Compared to the second most widely used search engine:

- Meta’s [FAISS](https://github.com/facebookresearch/faiss): **5 backends** (AVX2, AVX-512, AVX-512 SPR, NEON, SVE) across 2 architectures. No FP8, no FP6. Int8 is upcast to Float32 before distance computation — no [VNNI](https://en.wikipedia.org/wiki/AVX-512#VNNI) integer dot products despite SPR support. No RISC-V, no WASM, no Power, no LoongArch.
- USearch before v2.25: SimSIMD v6 with **15+ backends** across 2 architectures. On x86, for example, it includes specialized kernels for Haswell, Skylake, Ice Lake, Genoa, Sapphire Rapids, Turin, & Sierra Forest. No FP8 or FP6.
- USearch v2.25 and newer: NumKong v7 with **30+ backends** across 6 architectures (x86, Arm, RISC-V, Power, LoongArch, WASM), supporting all of the above and more. Not just with advanced hardware-specific instructions, but also with type-specific algebraic tricks not typically used in comparable tools.

Those kernels matter on their own, but even more important is their numerical stability and correctness. NumKong ships a validation toolkit for every platform, checking both absolute and relative errors for different input distributions and shapes, as well as mean & max ULP errors for every one of the following mini-floats.

| Type | Bits | Exp | Man | Range | Standard | Used For |
| - | - | - | - | - | - | - |
| BFloat16 | 16 | 8 | 7 | ±3.39e38 | Google | Training weights |
| Float16 | 16 | 5 | 10 | ±65,504 | IEEE 754 | NumPy, Arrow, ONNX storage |
| Float8, E5M2 | 8 | 5 | 2 | ±57,344 | OCP MX | Gradients, backward pass |
| Float8, E4M3FN | 8 | 4 | 3 | ±448 | OCP MX | Forward pass, KV caches |
| Float6, E3M2FN | 6 | 3 | 2 | ±28 | OCP MX | MX block-scaled weights |
| Float6, E2M3FN | 6 | 2 | 3 | ±7.5 | OCP MX | MX block-scaled weights |

## Bridging Search and KV-Caching

Every decode step in a Transformer computes `q · k` for every cached key — that’s a nearest-neighbor lookup. With long contexts (128K+ tokens), brute-force becomes expensive. [PQCache](https://arxiv.org/html/2407.12820v2) explicitly frames KV cache management as an embedding retrieval problem, using product quantization over the key vectors. KV caches on NVIDIA H100/H200 already [live in E4M3 by default](https://docs.vllm.ai/en/latest/features/quantization/quantized_kvcache/) — if your search engine requires Float32, you upcast on every query, every layer, every token.

USearch doesn’t upcast — and it doesn’t need to **explicitly** copy the data either. With [CUDA unified memory](https://developer.nvidia.com/blog/unified-memory-cuda-beginners/) (and looking ahead, [CXL](https://en.wikipedia.org/wiki/Compute_Express_Link)), GPU-resident buffers are directly addressable by the CPU. USearch’s dense index separates vector storage from [HNSW](https://arxiv.org/abs/1603.09320) graph links into independent allocators and abstraction layers:

```cpp
// The HNSW graph structure (index.hpp)
template <typename distance_at = default_distance_t,
          typename key_at = default_key_t,
          typename compressed_slot_at = default_slot_t,
          typename dynamic_allocator_at = std::allocator<byte_t>, // scratch space for traversals
          typename tape_allocator_at = dynamic_allocator_at>      // graph node & link storage
class index_gt;

// The dense index that adds vector management (index_dense.hpp)
template <typename key_at, typename compressed_slot_at>
class index_dense_gt {
    index_t* typed_;                                    // HNSW graph with its own allocator
    vectors_tape_allocator_t vectors_tape_allocator_;   // vector data — allocated separately
    vectors_lookup_t vectors_lookup_;                   // maps each slot to its vector pointer
};
```

Graph links and vector data are allocated **independently**. Point `vectors_tape_allocator_` at CUDA unified memory and the HNSW graph stays in system RAM — USearch traverses the graph on CPU while reading GPU-resident E4M3 vectors without an explicit copy step. We don’t advise this for production yet, but it greatly simplifies R\&D on [NVLink](https://www.nvidia.com/en-us/data-center/nvlink/)-powered systems with high CPU–GPU bandwidth, and hints at what becomes possible with CXL-attached memory pools.

No widely deployed CPU supports FP8 natively today. NumKong ships multiple kernels per ISA generation — the optimal upcast path depends on [execution port pressure](https://ashvardanian.com/posts/cpu-ports/) in the surrounding distance computation:

| Type | Approach | How it works | Upcast ports | Platforms |
| - | - | - | - | - |
| E5M2 | Free Float16 widen | Byte-to-word unpack — shared exponent bias makes it valid Float16 | `p0` shuffle | x86 Haswell+ |
| E4M3 | Giesen fake-Float16 | Shift mantissa, reinject sign, `VCVTPH2PS` to Float32, × 256 for bias | `p0` + `p1` CVT+FMA | x86 Skylake+ |
| E4M3 | LUT → BFloat16 | 8-entry subnormal LUT + arithmetic → BFloat16, then `VDPBF16PS` | `p5` shuffle + `p0` FMA | x86 Ice Lake+ |
| Both | Giesen magic-number | Shift magnitude into Float32 exponent field, × magic constant to rebias | multiply unit | Arm NEON, RISC-V, WASM |

On x86, the same chip may offer both a Giesen and a LUT path for E4M3 — NumKong picks the one that leaves the FMA ports free for the accumulation step. On Arm and RISC-V, Giesen’s trick is the only path — and the fastest — with no lookup table, no cache pressure, just a shift and a multiply:

```c
// E4M3 → F32 via Giesen's magic-number trick for Arm NEON
uint32x4_t magnitude = vandq_u32(input_e4m3, vdupq_n_u32(0x7F));       // strip sign
uint32x4_t positioned = vshlq_n_u32(magnitude, 20);                    // align in f32 space
float32x4_t converted = vmulq_f32(                                     // rebias exponent:
    vreinterpretq_f32_u32(positioned),                                 //   treat as denormal f32
    vreinterpretq_f32_u32(vdupq_n_u32(0x7B800000)));                   //   × 2^120 (bias 7 → 127)
```

The magic constant `0x7B800000` encodes 2^120 — the exact multiplier that rebiases E4M3’s exponent (bias 7) to Float32’s exponent (bias 127). Different formats use different constants: E5M2 uses 2^112 (`0x77800000`), E2M3 uses 2^126 (`0x7E800000`). Float6 types get an even better deal — every E2M3 value multiplied by 16 is an exact integer in \[-120, 120], so [Float6 dot products reduce to Int8 arithmetic with zero rounding error](https://ashvardanian.com/posts/numkong/#use-int16-and-int8-for-float6-arithmetic). All of this happens in registers with no heap allocations — the upcast is inline and the distance computation streams through L1 cache at full bandwidth.

## Int8 and Cosine on Legacy Hardware

The NVIDIA A100 has no FP8. Most CPUs don’t have it either. But Int8 and UInt8 are universally supported — that’s how [vLLM users on A100 quantize KV caches today](https://github.com/vllm-project/vllm/issues/33480). **Getting Int8 right on CPUs matters for the majority of deployed AI infrastructure — not someday, but right now.** And for quantized representations specifically, **cosine distance is more robust than raw dot product** because it normalizes out the magnitude distortion that quantization introduces.

Making both fast isn’t trivial. Integer dot products on most hardware require unsigned × signed operands, but embeddings and KV projections are signed × signed. The workaround is algebraic:

$$
a \cdot b = (a \oplus \text{0x80}) \cdot b - 128 \times \sum b
$$

XOR one operand to shift \[-128, 127] → \[0, 255], compute the biased product, subtract the correction. But the right instruction — and whether the trick is needed at all — varies by platform:

| Platform | Instruction | Signed × Signed | NumKong approach |
| - | - | - | - |
| x86 Haswell | `VPMADDUBSW` + `VPMADDWD` | No — u8 × i8 | XOR bias + widening chain |
| x86 Alder Lake | `VPDPBUSD` with AVX-VNNI | No — u8 × i8 | XOR bias + SAD correction |
| x86 Ice Lake | `VPDPBUSD` with AVX-512 VNNI | No — u8 × i8 | XOR bias + SAD correction |
| x86 Sierra Forest | `VPDPBSSD` | Yes — native | Direct |
| Arm NEON | `SDOT` via ARMv8.2+DotProd | Yes — native | Direct |
| Arm SVE | `SDOT` via SVE+DotProd | Yes — native | Direct |
| IBM Power 9+ | `VMSUMMBM` | No — i8 × u8 | XOR bias + correction |
| LoongArch LASX | `XVMADDWEV_H_B` | Yes — native | Direct, widening to i16 |
| WASM Relaxed SIMD | `relaxed_dot_i8x16_i7x16` | 7-bit signed | Sign mask + correction |

NumKong detects the ISA at runtime and picks the right kernel — no configuration needed.

OpenAI’s embedding vectors are 1,536 dimensions wide, but KV cache vectors are short — 64–128 dimensions in models using [Grouped Query Attention](https://arxiv.org/abs/2305.13245)! That drastically changes how your FLOPs are spent. The square root normalization in cosine distance becomes a significant fraction of total runtime, not just a rounding error at the end. NumKong replaces exact `sqrt` with approximate `rsqrt` followed by [Newton-Raphson](https://en.wikipedia.org/wiki/Newton%27s_method#Multiplicative_inverses_of_numbers_and_power_series) refinement. Each NR step roughly doubles the precision of the initial estimate, so the number of steps depends on the hardware’s starting accuracy:

| Platform | Exact `sqrt` | `rsqrt` estimate | NR steps | Final precision |
| - | - | - | - | - |
| x86 Haswell | 19 cy | `VRSQRTPS` — \~12-bit | 1 | \~24-bit |
| x86 Skylake-X | 20 cy | `VRSQRT14PS` — \~14-bit | 1 | \~28-bit |
| Arm NEON | 9–12 cy | `FRSQRTE` — \~8-bit | 2 | \~23-bit |
| IBM Power | 26 cy | `XVRSQRTESP` — \~12-bit | 2 | \~24-bit |

Haswell’s \~12-bit estimate needs one NR step to exceed Float32’s 23-bit mantissa; NEON’s \~8-bit needs two; Power takes an extra step for margin on a less tightly specified error bound. For Float64, NumKong uses exact `sqrt` on x86 and 3 × NR iterations on Arm SVE and Power. Accumulation uses [compensated summation](https://en.wikipedia.org/wiki/Kahan_summation_algorithm#Further_enhancements) — Neumaier for scalar paths, Dot2 with FMA for SIMD — to prevent catastrophic cancellation.

## Scaling to 100M Vectors & Beyond

Faster kernels are necessary but not sufficient — at 100M+ vectors on 100+ core systems, lock contention in the HNSW graph dominates. USearch v2.25 reworked the striped lock mechanism for better alignment and reduced contention, so kernel-level wins translate into end-to-end throughput gains.

We rebuilt our benchmarking suite in Rust — same parameters, less overhead, more backends. The new [RetriEval](https://github.com/ashvardanian/RetriEval) covers both float and integer datasets at 10M and 100M scale.

| Engine | DType | Recall @ 10 | Add/s | Search/s | Memory | Duration |
| - | - | - | - | - | - | - |
| FAISS | Float32 | 0.9944 ✓ | 7,491 | 16,486 | 14.1 GB | 20.6 m |
| FAISS | BFloat16 | 0.9944 ✓ | 3,800 | 10,391 | 12.1 GB | 39.4 m |
| FAISS | Float16 | 0.9944 ✓ | 2,545 | 10,032 | 12.1 GB | 1 h 1 m |
| | | | | | | |
| USearch | Float32 | 0.9929 ✓ | 8,532 | 12,331 | 13.0 GB | 18.3 m |
| USearch | BFloat16 | 0.9929 ✓ | 10,496 | 16,940 | 10.9 GB | 14.1 m |
| USearch | Float16 | 0.9929 ✓ | 10,969 | 20,246 | 10.9 GB | 13.5 m |
| **USearch** | **E5M2** | **0.9919** **✓** | **10,526** | **20,534** | **9.8 GB** | **13.5 m** |
| USearch | E4M3 | 0.9930 ✓ | 7,353 | 12,106 | 9.8 GB | 19.4 m |
| USearch | E3M2 | 0.9728 △ | 10,398 | 18,022 | 9.8 GB | 13.3 m |
| USearch | E2M3 | 0.7941 ✗ | 10,935 | 21,313 | 9.8 GB | 13.2 m |

> 10M × 100D Microsoft Turing-ANNS vectors on a dual-socket Intel Xeon 6 Granite Rapids with 96 cores and 192 threads. USearch v2.25 vs FAISS v1.12 with 48-neighbor connectivity and expansion factors of 768/384, tuned for ≥ 99% recall\@10.

FAISS doesn’t support mini-floats. Even its half-precision paths don’t improve throughput on one of the world’s most capable CPUs — scalar quantization in FAISS is exclusively a memory reduction technique. In USearch, every numeric type has its own optimized kernel with a distinct throughput profile, now also validated by [independent academic benchmarks](https://arxiv.org/abs/2505.07621).

- E5M2 is the standout — 99.2% recall at the highest throughput and a quarter the memory of Float32, thanks to a free bit-shift upcast to Float16.
- E4M3 matches Float32’s 99.3% recall but pays an emulation cost on current hardware.
- E3M2 and E2M3 trade recall for speed — 97.3% and 79.4% respectively — useful for coarse re-ranking stages where throughput matters more than precision.

As [we’ve previously shown](https://www.unum.cloud/blog/scaling-vector-search-with-intel.md), beyond 50 million entries the throughput gap between USearch and FAISS grows to 10–100×, making meaningful comparison nearly impossible. USearch’s scaling holds for E5M2 just as well — same recall, lower memory, and higher arithmetic intensity, paving the way to 100 million context lengths:

Recall @ 10

Float32 0.9929

BFloat16 0.9931

Float16 0.9930

E5M2 0.9924

Memory

Float32 139.6 GB

BFloat16 105.2 GB

Float16 105.2 GB

E5M2 88.0 GB

At 100M scale — same dataset, same parameters — E5M2 delivers the best throughput-to-memory ratio while meaningful comparison with FAISS becomes impractical.

## On Every Hardware & Software Platform

Despite all this complexity under the hood, getting started is one line. USearch + NumKong together are among the smallest AI-native libraries in the industry — auto-detecting the best SIMD backend at startup across 30+ backends, 6 architectures, and 63 platform combinations for Python alone.

```sh
pip install usearch           # Python — `from usearch.index import Index`
cargo add usearch             # Rust — `use usearch::{Index, IndexOptions}`
npm install usearch           # JavaScript — `const { Index } = require('usearch')`
dotnet add package usearch    # C# — `using Cloud.Unum.USearch`
vcpkg install usearch         # C/C++ — `#include <usearch/index.hpp>`

go get github.com/unum-cloud/USearch/golang # Go
swift package add-dependency https://github.com/unum-cloud/USearch --from 2 # Swift
wget https://github.com/unum-cloud/USearch/releases/download/vX.Y.Z/usearch-X.Y.Z.jar # Java
```

BFloat16 embeddings from your model go straight into an E5M2 index — USearch quantizes on the fly, and NumKong handles the AI-native types NumPy can’t:

```python
import usearch.index as ui                                      # search engine
import numkong as nk, numpy as np                               # array & math utilities

keys = np.arange(1000)                                          # 1000 integer labels
vectors = nk.Tensor(np.random.randn(1000, 768)).astype("bf16")  # 1000 document vectors from BERT
queries = nk.Tensor(np.random.randn(10, 768)).astype("bf16")    # 10 query vectors from the same model

index = ui.Index(ndim=768, metric="cos", dtype="e5m2")          # internally quantize to E5M2
index.add(keys, vectors, dtype="bf16", log=True)                # hint BF16 — opaque to NumPy
matches = index.search(queries, 10, dtype="bf16")               # batch search, top-10
```

This kind of work spans years, not weeks — timelines unusual for startups. Genuine thanks to our partners at [Nebius](https://nebius.com/) for providing the compute infrastructure behind this and [previous joint projects](https://nebius.com/customer-stories/unum), and to the open-source contributors who helped validate kernels across rare and pre-release hardware.

- [USearch](https://github.com/unum-cloud/USearch) — the search engine
- [NumKong](https://github.com/ashvardanian/NumKong) — the kernel library
- [RetriEval](https://github.com/ashvardanian/RetriEval) — the benchmarking suite
