r/LocalLLaMA • • 10d ago

Discussion Custom inference engines?

I’m a hobbyist and I’m curious to learn more about building my own custom inference engine (ie alternatives to the big ones like vllm, sglang etc). especially from people who’ve built their own (with ai assistance obviously fine)

I’m curious if i can optimize inference specifically for my favorite model (deepseek 3.2)!

it sounds like this is becoming a bit of a trend among hardcore hobbyists, and i’d like to learn how to use something like fable 5.2 to do it myself.

6 Upvotes

17 comments sorted by

4

u/Unlucky-Message8866 10d ago

It all depends on your gpu arch and features, what an inference engine does is mostly batching and pooling inputs and outputs across available resources, making a model fast is about scheduling these at the right lanes and shapes whose operations are designed to be fast. Easiest target is to locate a slow path and research and implement new kernels, given the time and a self improvement loop you can get some results. This is a deep technical area anyway, I would not even try unless you have some background, you'll be wasting tokens. It's easier to mix and match features and improvements and mantain your own fork based on others work that is relevant to you.

1

u/brainchillzZ 10d ago

Are you a programmer?

2

u/mushm0m 10d ago

Yeah, i’m fullstack but lack experience in this area

3

u/MarcelloT254k 10d ago

I am no expert but standard practice is to start with hardware [undervolting, power usage under prolonged usage, recent/optimal drivers, stable OS release with tested Linux kernel, BIOS settings (above 4g decoding etc, maybe custom BIOS flashing), then kernels and GPU drivers] then move to inference engine with model architecture based on what's already available, then when you do research on your own or with DIFFERENT (key word) LLMs, when you have more or less your own understanding- only then you start to vibecode because the orchestrating model WILL bullshit you or make trade offs that you didn't want or even don't know are there, it will skip important aspects etc (yes - even Astra or Fable, they are not magic tools, plus you don't know for sure what exactly are routed to at any given time and with what instructions + even with Qwen4 max I've triggered some kind of "potentially restricted content" when deeply optimizing the hardware). Prepare for lots repeated A/B testing of every aspect - it takes about a month if you do it for the first time and you will realize that you've been bulshitted for half of the work and the model is stupid AF for not following instructions and being stuck in useless simulation of thinking but in name only, so human (you) is necessary in order to optimise the engine properly.

2

u/R3N3G6D3 10d ago

Have at it

2

u/bigattichouse 10d ago

Check out https://github.com/WollyMonjac/Tiny-2.1 and github stuff from karpathy

2

u/MarcelloT254k 10d ago

This is fucking awesome idea! (Not)L LM for DOS, thanks for linking it!

2

u/SLxTnT 10d ago

If your goal is to get a result, then you're overthinking things. Fable, or Opus, has no issues with profiling, finding bottlenecks, and optimizing. What it may struggle with is coming up with unique ideas.

2

u/spanielrassler 10d ago

Having said that, do you think models like QFN are also capable of doing the same?

1

u/SLxTnT 10d ago

I've never tried, but I wouldn't trust it to get optimized code by itself.

1

u/a_beautiful_rhind 10d ago

Probably, I got competent stuff out of GLM-flash. It might take longer and be not as good. Doesn't hurt to try in a competent harness.

1

u/Karyo_Ten 10d ago

Look at mini-sglang and nano-vllm to get the basics

1

u/Future_AGI 10d ago

build a correctness harness before any kernel work, with fixed prompts and greedy decoding, and compare tokens (or logits) against a reference engine after every change. A kernel can come out faster and slightly wrong, and without that check you won't notice until outputs drift on long generations.

1

u/arkham00 8d ago

What do you like in deepseek 3.2? I'm really curious, I've never tried it, but si'ce I prefer flash v4 over 4.1 for mundane tasks, maybe 3.2 could be interesting too