Five megabytes of math that widens before it overflows
NumKong exists because Int8 dot products shouldn't overflow into Int8, and because BLAS alternatives shouldn't need 700 MB.

What it does
NumKong is a portable numeric kernel library that provides SIMD-accelerated dot products, distance metrics, matrix multiplication, geospatial functions, and cast/reduce operations across 15+ numeric types—from 4-bit integers and 6-bit floats to 128-bit complex—on x86, Arm, RISC-V, LoongArch, Power, and WebAssembly. It exposes these through bindings for C, C++, Python, Rust, JavaScript, Swift, and Go, and deliberately avoids managing threads or memory so it slots into whatever parallelism model or allocator you already use. Every kernel is validated against 118-bit extended-precision baselines and cross-checked against OpenBLAS, Intel MKL, and Apple Accelerate.
The interesting bit
Where most libraries return dot products in the same type as the inputs—Float16 × Float16 → Float16, Int8 × Int8 → Int8—NumKong widens accumulators to dodge quiet overflow. That gives it a latency edge over NumPy, PyTorch, and JAX on single-threaded dot products, though throughput on large f64 or f32 matrix multiplies still favors mature BLAS. The payoff is binary size: roughly 5 MB versus PyTorch’s 705 MB or JAX’s 357 MB.
Key highlights
- 2,000+ SIMD kernels covering 1D and 2D registers like AMX and SME.
- 15+ numeric types with hardware-aware defaults (Arm prefers
f16, x86 prefersbf16). - Wider accumulators by default:
i8→i32,f16→f32,f32→f64, plus compensatedDot2summation forf64. - Higher single-threaded latency and lower error than NumPy/OpenBLAS, PyTorch/MKL, and JAX on many types in the provided benchmarks.
- 5 MB binary with no hidden allocations or thread management.
Caveats
- Throughput-oriented matrix multiplication is not uniformly faster than mature BLAS; on the tested Intel Sapphire Rapids chip, NumKong trails PyTorch + MKL for
f64andf32matrix multiply, though it leads fori8ande5m2. - Language bindings are uneven: JavaScript lacks geospatial, mesh, sparse, curved, reduce, each, and trigonometry ops; Swift and Go are also missing several categories.
Verdict
NumKong is worth a look if you need low-latency, mixed-precision numeric kernels in a small, embeddable binary without hidden memory or thread behavior. If you are already saturating PyTorch or MKL on throughput-heavy f64/f32 matrix work and don’t mind the install size, it may not replace your current stack.
Frequently asked
- What is ashvardanian/NumKong?
- NumKong exists because Int8 dot products shouldn't overflow into Int8, and because BLAS alternatives shouldn't need 700 MB.
- Is NumKong open source?
- Yes — ashvardanian/NumKong is open source, released under the Apache-2.0 license.
- What language is NumKong written in?
- ashvardanian/NumKong is primarily written in C.
- How popular is NumKong?
- ashvardanian/NumKong has 1.9k stars on GitHub.
- Where can I find NumKong?
- ashvardanian/NumKong is on GitHub at https://github.com/ashvardanian/NumKong.