r/LocalAIStack • • 24d ago • Mindblown 1

I wrote a Rust inference engine for Qwen models on a 12 GB GPU, decode is ~1.7x llama.cpp on my RTX3060

I've been working on this for a while: RustingStrata. It runs Qwen GGUF models (Qwen3.5/3.6 from 2B up to 35B-A3B, Qwen3 4B and 30B-A3B, Qwen3-Next 80B). It's pure Rust, no ggml. The CUDA kernels get compiled at startup with NVRTC, and the same kernels also run on Vulkan.

The main trick is for MoE models that don't fit in VRAM. Experts that don't fit run on the CPU at the same time as the GPU work, and the engine keeps moving the often-used experts onto the GPU while it runs.

My setup is a 3060 12 GB, a 7600X and 32 GB RAM. Qwen3.6-35B-A3B Q2_K_XL is 11.7 GiB, so it doesn't fit. On it I get about 118 tok/s decode on a short prompt and 113 after a 4K prompt. llama.cpp, tuned as well as I could (-ncmoe 12, -ub 2048, flash attention), gets 68 and 66. Prefill is basically a tie: 2216 tok/s vs about 2236 for llama.cpp at 4K, so I'm not claiming anything there. At 32K it's 1800 prefill and 92 decode.

With MTP drafts on, decode goes up to 160 tok/s, but that's on an easy prompt. On normal text expect around +16%.

Qwen3-Next-80B IQ1_S was the most fun one: most experts sit on the CPU, and it still decodes at about 92 tok/s. llama.cpp's best -ncmoe gives me around 44.

Output matches llama.cpp greedy on 98-99% of tokens. llama.cpp agrees with itself only 98.3% between its batch and token-by-token modes, so the misses are near-ties.

It also has chat, an OpenAI-compatible server with tool calling, and a calibrate command that tunes itself for your machine.

I've only tested it on my own machine. If you have a different card, especially AMD on Vulkan, I'd love to see strata bench output. Vulkan needs shaderFloat64 and subgroup size 32, so Intel Arc and older AMD won't work. On Windows you need the VS C++ Build Tools.

[RustingStrata](https://github.com/RustingStudio/RustingStrata)

40 Upvotes

30 comments sorted by

3

u/Ori_553 24d ago

I like that it's pure rust with presumably fewer dependencies than other inference engines.
How does it compare to strata itself?

3

u/Serious_Scarcity7818 24d ago

yes, it use not so much dependencies.
about "compare to strata", I can't tell, bc it will be not apples to apple, bc original Strata run only qwen3.8-flash-next which I don't have yet, and it will not fair to compare other models with Strata, so everything that I can do is only compare it with default and custom llama.cpp
I will compare original Strata with my when I will add there qwen3.8-flash-next, but it require a lot of work, bc I need to implement SSD offload, which I have never done yet.
Also I want to work or Strata for Image and Video models, I guess it's crazy Idea, for example Flux.2-klein:4b that will run 2 times faster is really impressive, since people can run very good Image/Video models on most GPU, this project might be insane perspective

1

u/baron_von_noseboop 23d ago

Strata is no longer specific to QFN.

3

u/backafterdeleting 22d ago

now all we need is for qwen to actually release some smaller modern models with MoE. As a 3060 user I'm definetely going to try this though

1

u/Serious_Scarcity7818 22d ago

yes, I wait for new Qwen4 MoE model, I will immediately add it in my Strata and all other Qwen4 model too

2

u/Possible_Ingenuity69 18d ago

Golang may be good too

1

u/Serious_Scarcity7818 18d ago

yes, I just like rust

1

u/ea_man 23d ago

Can we ask how much did it take?

I may like to do the same yet for AMD / ROCm.

Also if you didn't use the very 27B to do that what did you use? DeepSeek or a closed source SOTA?

1

u/Serious_Scarcity7818 23d ago

So it took like 2 months to create, but to be fair if I would invent it like Strata, then it would take much longer. And I already do this for AMD eith Vulkan, but it's difficult to test, since I have no AMD gpu.

And what do you mean with "Also if you didn't use...", I didn't understood this hole part, so can you somehow tell it in other words?

1

u/ea_man 23d ago

> And what do you mean with "Also if you didn't use...", I didn't understood this hole part, so can you somehow tell it in other words?

I mean what LLM did you use to assist in the project: time / effort is related to the performance of the AI assist used, it if was say 27B or a SOTA like GPT.

> And I already do this for AMD eith Vulkan, but it's difficult to test, since I have no AMD gpu.

I see that https://github.com/RustingStudio/RustingStrata shows usage with vulkan, that is a start yet on my systems ROCm is more performant and with low performance hw every bit counts.

I've made a customized llama.cp fork for that yet I never consider to convert it to rust.

1

u/Serious_Scarcity7818 23d ago

So, I started alone and later I used Claude Code with Opus5.5 to help me and I was writting code like almost every day for that

1

u/ea_man 23d ago

Thanks for the info, when I started my work with https://store.piffa.net/lm/bug/ I used 27B and A3B, the problem was that for testing I had to run a small model on one GPU and an other for the tests, so sometimes I resolved to use DeepSeek or other for some better automation.

As said, time required changes a lot when using a slower and less strong local model.

1

u/Serious_Scarcity7818 23d ago

yes, I really want someday in the future buy some cool server with a lot of VRAM to run very big Qwen models local, but for now I will use some subscription for something like Claude Code

1

u/ea_man 23d ago

He it's a bad time to buy hw now, yet I say that with just one more GPU it goes fine, +16GB allows you 27B at Q6. Let's hope the new 4.0 version helps more with KV cache.

Yet Anthropic is too much for me, I can do DeepSeek, that is open source while Dario is full against open software.

1

u/Serious_Scarcity7818 23d ago

I mean I don't want to buy like rn, but maybe in few years when I will have money, and just buy more GPU to run a lot of different LLM in same time, and I don't know exactly why, it's just vibe.
Also about Qwen4.0, I guess they will use architecture close to Qwen3.8 Flash Next with new Attention blocks, so we would be able to offload it on Ram and even SSD and still get good performance. I hope they will release it earlier

1

u/ea_man 23d ago

Aye they said the will release this week, can't way to see what the new 27B will be like and the "small" MoE.

1

u/No-Swordfish687 22d ago

I am near finished with an engine I've developed to run different models (not just text but also image, video, audio and embeddings). I make it mostly for my dual 7900xtx so ROCm is the first class citizen there, but I also support CUDA because I have Nvidia GPU on my laptop. 

I'm making it modular so new hardware architectures, model architectures, kernel optimizations, etc can be shared with others. My dream is to have a repo from where you get ready made optimized things for your needs and if something is missing, there's good documentation so you can ask an agent to write what is missing. 

I've been working on it using Claude Code and Anthropic as well as Qwen models for more than a month now. The code is mostly in Rust. Using C++ just for kernels. Will publish in about a week, I think I'll use MIT license. I'm getting really good performance and I'm careful to test quality, too so there are configurable tradeoffs between speed and quality.

1

u/ea_man 22d ago

That will be nice to see, appreciated.

If possible try to publish some artifacts too with the code so we can point to those and integrate your work into others.

Thanks and Have Fun with your coding!

1

u/RDA_Gg2 21d ago

Yo, i'm just asking, but would it work on my rx 580 8gb and my 16gb of ram?

1

u/Serious_Scarcity7818 21d ago

This is Strata for a lot of different Qwen models, from 4B to 35B, just find one that you like. For 8GB vram I can suggest maybe Qwen3.6-35b-a3b, with Q3_K_M or IQ3_XXS its like 13-15Gb and if you will not ran out of ram(based on what you run in same time, like browser and etc.) then it's the best speed and quality option. Or you can try qwen3-8b, it must fully fit in your Vram in Q5 or Q6, speed will be better, but this model is more dumb

1

u/RDA_Gg2 21d ago

Okay thanks for the recommendation

1

u/mesolimbic-bliss 20d ago

how about a version for 2 x 3060's?

1

u/Serious_Scarcity7818 20d ago

Multi gpu is in testing now, I am not sure if it will work, but single gpu works perfectly

1

u/Life-Screen-9923 17d ago

There are no Prebuilt binaries for Linux (x86_64, glibc 2.35+) and Windows (x86_64)

1

u/Serious_Scarcity7818 17d ago

Thwre are, in release tags

1

u/Life-Screen-9923 17d ago

I see only source code files

1

u/Serious_Scarcity7818 17d ago

Oh, yes, maybe I forgot to put them there, ty

2

u/RelaxedFlame311 21d ago

Noticed this, I have an RX 7900 XTX + 7900 XT setup on Ubuntu, and Opus 5.5 vibe coded an RDNA3 inference engine for Qwen3.8-Flash-Next. The decode path is HIP kernels: one persistent kernel launch per token, with tensor parallelism across both cards over PCIe p2p. It doesn't use llama.cpp or PyTorch for any of the model math. With DFlash speculative decoding I'm getting about 123-203 tok/s vs llama.cpp + DFlash's 65-92. What a time to be alive.

1

u/Joseflong1 8d ago

Check this out, I have a merge for RTX support.

https://github.com/Avarok-Cybersecurity/atlas