# Why we build our own C and C++ inference engines

Original title: Why we write our own C and C++ inference engines

> Hacker News story 49125065 · language: en · submitted 2026-07-31
> Web version: https://zeli.app/story/49125065
> About this feed: https://zeli.app/llms.txt · Agent guide: https://zeli.app/skill.md

▲ 128 · by [eatonphil](<https://news.ycombinator.com/user?id=eatonphil>) · 💬 50
[original](<https://localai.io/blog/why-we-write-our-own-engines/>) · [HN discussion](<https://news.ycombinator.com/item?id=49125065>)

## Summary

LocalAI's team explains why they sometimes write custom C/C++ ports of AI models instead of wrapping existing engines. The payoff: a 66 MiB binary that matches vLLM's throughput and memory footprint, and a CPU port that beats PyTorch 1.31x on depth estimation. But the real gate is parity—outputs must match the reference exactly—and the cost is heavy maintenance, especially on GPU kernels.

## Key quote

> A port that is fast and slightly wrong is worthless, and without a per-component gate you find out it is wrong months later.

## HN discussion (50 comments)

### [stephbook](<https://news.ycombinator.com/item?id=49151027>)

> Should have started with writing your own blog posts.

### [dennis16384](<https://news.ycombinator.com/item?id=49151149>)

> I had a similar success with Model2Vec static embedder and NER inference (both GGUF, compiled for WASM), ported to plain C from ONNX Runtime.
>
> Wasm size from 30Mb to 300kb and 1.5x speedup. It's definitely worth it for performance or distribution size.

### [aabdi](<https://news.ycombinator.com/item?id=49153179>)

> I don’t think it would be surprising that people want to write their own kernels.
>
> A big problem with the existing engines like llama or sd is that they don’t support optimal graph compilation. Usually this means about a real 2 or 3x multiplier loss relative to optimal. Cuda graphs do okay but they still leave a lot on the floor
>
> It’s usually worth it to optimize in that context if you are willing to peer into the mechanics.
>
> Of course that’s expensive. You need to know how to appropriately pipeline and merge your kernels.

### [scottcodie](<https://news.ycombinator.com/item?id=49151382>)

> I did took a native c++ approach when writing a relational transformers engine (RelativeDB). My journey was pytorch -> c++ -> Triton (lang). While C++ was more performant than Triton, I couldn't afford to optimize on every gpu. I just accepted the ~15% throughput loss for my cloud service, which honestly wasn't bad for the amount of flexibility I got out of it.
>
> But the cpp port of vllm looks great, that'd be great if you'll maintain that. I hit the same limitations with vllm.

### [piterrro](<https://news.ycombinator.com/item?id=49151930>)

> Could this vllm port be faster to install? Im starting gpu machine multiple times a day and it takes 5 minutes to set vllm up. If Inise this port that time is minimized?

---

## Cite

- Page: https://zeli.app/story/49125065
- Date: 2026-07-31
- Source: localai.io (https://localai.io/blog/why-we-write-our-own-engines/)
- Hacker News: https://news.ycombinator.com/item?id=49125065

## Other languages

- zh: https://zeli.app/zh/story/49125065 · markdown: https://zeli.app/zh/story/49125065.md
- ja: https://zeli.app/ja/story/49125065 · markdown: https://zeli.app/ja/story/49125065.md
- ko: https://zeli.app/ko/story/49125065 · markdown: https://zeli.app/ko/story/49125065.md
- de: https://zeli.app/de/story/49125065 · markdown: https://zeli.app/de/story/49125065.md
- es: https://zeli.app/es/story/49125065 · markdown: https://zeli.app/es/story/49125065.md
