ashvardanian/NumKong logo

ashvardanian/NumKong

Free

SIMD-accelerated distances, dot products, matrix ops, geospatial & geometric kernels for 16 numeric types — from 6-bit floats to 64-bit complex — across x86, Arm, RISC-V, and WASM, with bindings for Python, Rust, C, C++, Swift, JS, and Go 📐

FreeFree tier
Type
Open Source

About ashvardanian/NumKong

NumKong is a portable mixed-precision math, linear algebra, and retrieval library featuring over 2,000 SIMD kernels for x86, Arm, RISC-V, LoongArch, Power, and WebAssembly. It covers 15+ numeric types from 4-bit integers and 6-bit floats to 128-bit complex numbers, and is validated against 118-bit extended-precision baselines. The library leverages rare algebraic transforms with both 1D and 2D registers like AMX and SME, and is co-designed with Tensor abstractions in C++, Python, Rust, JavaScript, GoLang, and Swift. Unlike typical BLAS libraries, NumKong promotes to wider accumulators to prevent overflow and achieves a 5–100x smaller binary footprint while delivering high throughput (e.g., 14.8 gso/s for i8 dot products on Intel Sapphire Rapids).

Key Features

2,000+ SIMD kernels across multiple architectures
15+ numeric types from 4-bit integers to 128-bit complex numbers
Mixed-precision with automatic promotion to wider accumulators
Portable across x86, Arm, RISC-V, LoongArch, Power, WebAssembly
Bindings for C++, Python, Rust, JavaScript, GoLang, Swift
5–100x smaller binary than BLAS-like alternatives
Validated against 118-bit extended-precision baselines
Geospatial and geometric kernels included
Leverages rare algebraic transforms with 1D/2D registers (AMX, SME)

Pros & Cons

Pros
  • High performance (up to 14.8 gso/s for i8 dot product on Sapphire Rapids)
  • Wide range of supported numeric types
  • Portable across multiple CPU architectures
  • Open source and free
  • Small binary footprint (5–100x smaller than alternatives)
  • Numerical accuracy ensured by promotion and validation

Best For

High-performance linear algebraVector similarity search and retrievalGeospatial and geometric computationsMachine learning inference (dot products, matrix multiplication)Scientific computing with mixed precisionEmbedding-based applications