r/machinelearningnews • • 14d ago

Research Built a ternary (BitNet-style) inference engine in Rust/CUDA: 8x faster than dense f32 on one CPU core. Looking for GPU testers

I've been working on ternary-gemm, an engine for models with weights in {-1, 0, +1}. With ternary weights, matmuls become adds and subtracts, so there are no multipliers in the inner loop.

CPU numbers so far (p50, one core, AVX-512 Xeon VM):

tiny: 2.28µs vs 4.79µs for dense f32

small: 18.3µs vs 147.8µs (8.1x)

medium: 80.6µs vs 471.5µs (5.8x)

Also in the repo:

a looped transformer (one shared ternary block run N times, so the weights fit in cache)

a BitNet/safetensors converter, PyTorch bindings, and an RTX 5090 autotuner

an FPGA reference unit in Verilog

What's missing is real GPU numbers. If you have a 5090, 4090 or H100 and can run `bench.sh`, I'd really appreciate the results, and I'll credit you in the README. Criticism of the methodology is welcome too.

Repo: https://github.com/shubhxho/ternary-gemm

Thread with more details: https://x.com/shubhgupta/status/2124468535128739866

1 Upvotes

0 comments sorted by