ds4 icon indicating copy to clipboard operation
ds4 copied to clipboard

Does it support CPU MoE offloading?

Open Nekotekina opened this issue 5 months ago • 10 comments

Nekotekina avatar Jun 09 '26 18:06 Nekotekina

@Nekotekina So, according to this function:

https://github.com/antirez/ds4/blob/80ebbc396aee40eedc1d829222f3362d10fa4c6c/ds4_help.c#L146-L186

There is no way or command line argument to offload MoE layers or experts to CPU, or system RAM. What you can only do instead is using --ssd-streaming and other similar options in your ds4 or ds4-server command according to these lines of code at https://github.com/antirez/ds4/blob/80ebbc396aee40eedc1d829222f3362d10fa4c6c/ds4_help.c#L165-168

They basically do DirectStorage but for weights.

OPS-NeoRetro avatar Jun 20 '26 13:06 OPS-NeoRetro

We keep asking for the --n-cpu-moe implementation but 'till now we got no answers. 🙄

requies avatar Jul 21 '26 21:07 requies

llama.cpp got proper DS4 support, not sure what's the point of this project anymore

Nekotekina avatar Jul 22 '26 00:07 Nekotekina

We keep asking for the --n-cpu-moe implementation but 'till now we got no answers. 🙄

There is no CPU-side MoE layers setting. DS4 was a DeepSeek V4 runtime that was first designed to run on Apple Silicon, and the early code assumed that the CPU and GPU share the same RAM. You can use SSD streaming instead.

OPS-NeoRetro avatar Jul 24 '26 08:07 OPS-NeoRetro

We keep asking for the --n-cpu-moe implementation but 'till now we got no answers. 🙄

There is no CPU-side MoE layers setting. DS4 was a DeepSeek V4 runtime that was first designed to run on Apple Silicon, and the early code assumed that the CPU and GPU share the same RAM. You can use SSD streaming instead.

That's why we are asking to implement it. It's pretty ironic to say the goal is "Democratizing AI" while "leaving out" users with consumer hardware.

As nice as ssd-streaming is, it's not a valid solution. On my machine (128GB ram + 16GB VRAM) i can get ~5tk/s using DS4. Using the same Antirez iq2 model on llama.cpp i get ~15tk/s.

requies avatar Jul 24 '26 08:07 requies

We keep asking for the --n-cpu-moe implementation but 'till now we got no answers. 🙄

There is no CPU-side MoE layers setting. DS4 was a DeepSeek V4 runtime that was first designed to run on Apple Silicon, and the early code assumed that the CPU and GPU share the same RAM. You can use SSD streaming instead.

That's why we are asking to implement it. It's pretty ironic to say the goal is "Democratizing AI" while "leaving out" users with consumer hardware.

As nice as ssd-streaming is, it's not a valid solution. On my machine (128GB ram + 16GB VRAM) i can get ~5tk/s using DS4. Using the same Antirez iq2 model on llama.cpp i get ~15tk/s.

I'm extremely sorry. This project actually assumes a unified memory system. Normal PCs with dedicated GPUs do not use unified memory. This project also only uses ARM64 NEON intrinsics, which is basically, a tell-tale sign of being Apple-Silicon-first.

OPS-NeoRetro avatar Jul 25 '26 06:07 OPS-NeoRetro

It seems to have MoE caching, which is quite superior: copy an expert into vram when needed, run it, leave it in vram unless there's no vram left and some other expert needs the space. Some other projects (llama.cpp forks) have shown that this works -- there are certain experts that are more frequently needed for a given output. With this and streaming from ssd you can potentially run VERY large MoE's. If llama.cpp and vllm would grow that feature, open weight AI would be a very different landscape.

lee-b avatar Jul 29 '26 10:07 lee-b

It seems to have MoE caching, which is quite superior: copy an expert into vram when needed, run it, leave it in vram unless there's no vram left and some other expert needs the space. Some other projects (llama.cpp forks) have shown that this works -- there are certain experts that are more frequently needed for a given output. With this and streaming from ssd you can potentially run VERY large MoE's. If llama.cpp and vllm would grow that feature, open weight AI would be a very different landscape.

Yeah. I agree with that.

OPS-NeoRetro avatar Jul 29 '26 11:07 OPS-NeoRetro

Sadly I discovered that ds4 won't do this with multi-gpu setups.

lee-b avatar Jul 30 '26 09:07 lee-b

Sadly I discovered that ds4 won't do this with multi-gpu setups.

Just open up a new issue.

OPS-NeoRetro avatar Jul 30 '26 12:07 OPS-NeoRetro