Repolode
ashvardanian

ashvardanian/NumKong

SIMD-accelerated math kernels for distances, dot products, and matrix ops across 15+ numeric types, with bindings for Python, Rust, C/C++, JS, Swift, and Go.

Stars
1,908
Forks
142
Open issues
59
Last commit
7 days ago

What is it?

NumKong is a numerics library for vector and matrix operations such as dot products, distance and similarity metrics, and matrix multiplication. Its kernels are hand-tuned with SIMD for x86, Arm, RISC-V, LoongArch, Power, and WebAssembly, and cover numeric types from 4-bit integers and 6-bit floats up to 128-bit complex numbers. Dot products and related reductions accumulate in wider types, such as Float16 to Float32 or Int8 to Int32, so results do not silently overflow.

The library is written in C and exposes bindings for Python, Rust, C++, JavaScript, Swift, and Go. It does not manage threads or memory itself: callers supply their own threading model and buffers, and packed-matrix APIs let weights be prepared once and reused across many queries. The project documents its accuracy against extended-precision baselines and reports a much smaller binary size than several BLAS-style alternatives.

NumKong suits vector search and retrieval, embedding similarity computation, scientific computing that needs compensated summation, and low-precision inference workloads that use mini-float or integer types.

Key features

  • 01Provides SIMD kernels for dot products, distance metrics, and matrix multiplication across major CPU and WASM targets.
  • 02Supports 15+ numeric types, including 4-bit integers, 6-bit and 8-bit floats, Float16, BFloat16, and complex numbers.
  • 03Accumulates in wider types to avoid overflow, and uses compensated summation for Float64.
  • 04Offers bindings for Python, Rust, C/C++, JavaScript, Swift, and Go.
  • 05Leaves threading and memory allocation to the caller, so it works with any parallelism model or allocator.
  • 06Provides packed-matrix APIs that prepare data once for repeated queries.

Use cases

  • Computing cosine or Euclidean similarity between large embedding sets for vector search.
  • Running low-precision inference kernels on Float8, Float16, or Int8 data.
  • Embedding fast distance computations in a Python or Rust application without pulling in a large BLAS stack.
  • Running numerical kernels in browsers or Node.js via the JavaScript binding.

Topics

#simd#linear-algebra#vector-search#matrix-multiplication#blas#mixed-precision#distance-metrics#arm-neon#assembly#cpp

FAQ

What is NumKong?
SIMD-accelerated math kernels for distances, dot products, and matrix ops across 15+ numeric types, with bindings for Python, Rust, C/C++, JS, Swift, and Go. NumKong is a numerics library for vector and matrix operations such as dot products, distance and similarity metrics, and matrix multiplication. Its kernels are hand-tuned with SIMD for x86, Arm, RISC-V, LoongArch, Power, and WebAssembly, and cover numeric types from 4-bit integers and 6-bit floats up to 128-bit complex numbers. Dot products and related reductions accumulate in wider types, such as Float16 to Float32 or Int8 to Int32, so results do not silently overflow.
Is NumKong free to use? What license does it have?
NumKong is open source under the Apache-2.0 license. Check the license terms before using it in commercial products.
Is NumKong still maintained?
Actively maintained. The last commit to NumKong was on Oct 31, 2026.
What can I use NumKong for?
Computing cosine or Euclidean similarity between large embedding sets for vector search. Running low-precision inference kernels on Float8, Float16, or Int8 data. Embedding fast distance computations in a Python or Rust application without pulling in a large BLAS stack. Running numerical kernels in browsers or Node.js via the JavaScript binding.
Where can I get NumKong?
The source code and installation instructions are on GitHub: https://github.com/ashvardanian/NumKong

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects