Why we write our own C and C++ inference engines
a day ago
- Deploying C++ ports yields a single shared library (66 MiB) instead of a multi-gigabyte Python virtualenv (9.1 GiB for vLLM), with predictable memory usage.
- vllm.cpp achieves throughput parity or slight advantage over vLLM across concurrency levels, with token-for-token identical output and lower peak memory (24.88 GiB vs 28.18 GiB).
- depth-anything.cpp runs 1.31x faster than PyTorch on CPU while using 27% of the memory, thanks to caching positional embeddings that were recomputed unnecessarily.
- face-detect.cpp and voice-detect.cpp prioritize exact output matching (cosine 1.0, pixel-level accuracy) over speed, enabling drop-in replacement without re-enrolling biometric templates.
- The porting method follows a strict order: convert weights to GGUF, port graph with per-component parity gates, optimize only after parity holds, and expose a flat C ABI.
- Maintenance cost is high: each engine needs its own CI, benchmarks, conversion scripts, and updates for new checkpoints; GPU kernels lag behind tuned cuDNN for convolution-heavy models.
- Porting is selective: many backends still wrap existing projects (llama.cpp, vLLM, whisper.cpp) when they are already excellent, large, and fast-moving.