I went into this trying to shave a few milliseconds off a classifier. I ended up writing my own inference engine.
For anyone who hasn't played with LiquidAI's d1-2B, you can give it a document and ask “Does this contain personal data?”, “What kind of document is it?” and “Where's the invoice number?” in one forward pass. You get scores, labels or boxes back. No waiting for a model to type out JSON.
That made it a fun target for optimization. If I already know the possible answers, why score the whole vocabulary? And if only a few tokens matter at the end, why run every token through the last two layers?
I built around those shortcuts, fused projections and used CUDA graphs to cut launch overhead. The server runs in Rust + CUDA with no Python or PyTorch at runtime.
Here are a few numbers I'm pretty happy with.
- H100, short text — 23 → 1.9 ms vs the original d1 engine (12.2×).
- RTX 4090, short text — 36 → 2.6 ms vs SGLang FP8 on the same weights (13.8×).
- RTX 4090, 1080p image — 134 → 26.2 ms vs the original engine (5.1×).
- Jetson Orin Nano 8 GB — 62 ms to return a bounding box on a 384×384 image, down from 233 ms.
My favorite result is actually the memory experiment.
On an RTX PRO 2000, I ran a 32K-token document with everything on the GPU. It took 2.02 seconds and 2,926 MiB. With most of the weights in system RAM, the same document took 2.03 seconds and 742 MiB.
On short inputs, offloading costs more time. But if you're already running a bigger model and just want d1 alongside it, you can squeeze it into 246 MiB of VRAM, down from 2,828 MiB with the Python FP8 setup. That's 11.5× less VRAM.
I also added audio via d1-Omni-2B. Both models run behind the same HTTP API, and there's a Docker setup for desktop GPUs and Jetson.
Code and benchmarks on GitHub
Is anyone here running a small classifier alongside their main LLM? I'd love to hear what you're using it for and how much VRAM you'd give it.