Why we write our own C and C++ inference engines

localai.io

102 points by eatonphil 3 days ago


stephbook - 12 hours ago

Should have started with writing your own blog posts.

aabdi - 6 hours ago

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.

dennis16384 - 11 hours ago

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.

scottcodie - 11 hours ago

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 - 9 hours ago

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?

adithyassekhar - 11 hours ago

What you get: X is the A, Y is the B.

BedVibe_Studios - 4 hours ago

[flagged]

federicoTXTS - 2 days ago

[flagged]

openrockets - 8 hours ago

[dead]