DeepSeek Deep Dive R1 at Home!

The plot thickens! I got my best token generation numbers with 64 threads (SMT turned back on), and nothing cached since I had just rebooted after reenabling SMT. This would potentially correlate with the caching issue in that github link. More testing needed!

./build/bin/llama-bench \
    --model ./models/unsloth/DeepSeek-R1-GGUF/DeepSeek-R1-UD-Q2_K_XL-00001-of-00005.gguf \
    --cache-type-k q4_0 \
    --cache-type-v f16 \
    --threads 64 \
    --numa distribute
model size params backend threads type_k test t/s
deepseek2 671B Q2_K - Medium 211.03 GiB 671.03 B CPU 64 q4_0 pp512 15.66 ± 1.13
deepseek2 671B Q2_K - Medium 211.03 GiB 671.03 B CPU 64 q4_0 tg128 5.42 ± 0.35
3 Likes

Also, in very limited testing, this distill of DeepSeek is the best of any I’ve used, including the “full” model from ollama. I’m 99% sure that this is because I don’t have enough system memory to have an adequate context size for that model, so it is unable to finish a thought before it runs out of memory. So far this one is quite solid.

1 Like

If any intrepid hacker wants to try this sketchy approach to running the unsloth R1 quants with ktransformers instead of llama.cpp it may give more tok/sec in less VRAM! If it even works right lol…

I tossed together a rough manic guide lol:

1 Like

Using that cache-flush method, I can get 2-4 t/s running with 64 threads on Rome with an 8k context, which is very usable. Now I’m quite curious to know if my faster CPU will make any difference or if I’m memory-bandwidth-capped at this point.

./build/bin/llama-cli \
    --model ./models/unsloth/DeepSeek-R1-GGUF/DeepSeek-R1-UD-Q2_K_XL-00001-of-00005.gguf \
    --threads 64 \
    --numa distribute \
    --interactive \
    --color \
    --ctx-size 8192 
1 Like

Oh nice yes that is enough to write some regex or generate a few chapters of your fav fan fiction!! haha…

You can get a little more out of it too by compressing the k (can’t comprss the v without flash attention support).

Here is another way you could run it to access either through the local web app or through litellm python client:

./build/bin/llama-server \
    --model ./models/unsloth/DeepSeek-R1-GGUF/DeepSeek-R1-UD-Q2_K_XL-00001-of-00005.gguf \
    --threads 64 \
    --numa distribute \
    --ctx-size 8192 \
    --override-kv deepseek2.expert_used_count=int:8 \
    --cache-type-k q4_0 \
    --cache-type-v f16 \
    --parallel 1 \
    --host 127.0.0.1 \
    --port 8080

Open your browser to https://127.0.0.1:8080 and have a nice simple GUI.

Exciting, yeah curious how it goes with your other CPU!

1 Like

Right on! With those optimizations, I was seeing 4.5-5 t/s in the web ui. Just one change to the above code: I used llama-server instead of llama-cli

1 Like

fixed! copy pasta error, good catch! wow that is a useful setup!

i’m fussing with that ktransformers stuff which has promise on a rig like yours, especially if you plug in a 3090TI 24GB or something it supposedly keeps the experts on the VRAM for speedups…

its moving faster than i can keep up haha… enjoy!

1 Like

Hmmm… That could be awesome. I could pick up a used 3090 or even a couple of 3060s if 24GB is enough to see a decent speedup.

Oh right, one more change from the above code that I had to make: I changed the host to 0.0.0.0 since I’m accessing the server from another machine.

Thanks again for all of your experimentation. This is very exciting!

1 Like

I wish I had bought an extra 3090TI from microcenter when I built my rig 9 months ago. They’ve gone up in price lol. I told myself “I’ll get it later…” haha…

It’ll also speed up llama.cpp but more on the prompt proessing than token generation I’m guessing.

Oooh the latest ktransformers keeps crashing because it is Intel AMX Optimization only haha… Interesting china is going dual XEON for ktransformers ??? is it time to invest :face_with_monocle: lol…

Intel AMX Optimization – Our AMX-accelerated kernel is meticulously tuned, running several times faster than existing llama.cpp implementations. We plan to open-source this kernel after cleansing and are considering upstream contributions to llama.cpp.

2 Likes

I don’t have the latest hardware but would this even work on older servers as long as you toss enough RAM at the system?
What is the cut-off for hardware in your opinion for even attempting to run this?
The test hardware I have has 768 GB of RAM but not the latest gear.

Will it run yes, will it be fast, likely not

1 Like

I’m running a 32-core 2nd-gen Epyc with 512GB DDR4 and getting 4-5 t/s on the distilled model linked by @ubergarm, so you can kind of judge from that.

1 Like

is there a basic rule about when you want more bit precision and when you want bigger models, in what scenario you do what?

1 Like

tl;dr;

Anecdotally bigger models can be quantized down more than smaller models without major quality losses. Except for R1 671B, I tend to avoid going lower than a 4bpw quant e.g. no lower than IQ4_XS.

Long Winded

Yeah that is a good question. The answer to any good question is always “it depends” lol.

When thinking about what LLM to use consider:

  • What are the breakpoints in your hardware setup
    • For example, a 70B@IQ2 can fit into 24GB VRAM and run pretty fast with 8k context, but a 70B@IQ4 won’t fit entirely into VRAM so be much slower.
  • How much context do you really need for the job? 8k is honestly enough for a lot of mundane one or two shot questions like writing sample code or a short story. Most of the “long context” models still don’t perform super well beyond 32k context at best imo.
  • Do you need “quality” or “speed”? If you need speed, you can use --parallel N and multiply the context by N so each concurrent slot will run simultenously and increase aggregate tok/sec despite each individual generation being slower.
  • Are you feeding in context from a RAG or web search results, or are you relying on the model itself to have knowledge? Many smaller models have decent logic and reasoning capability but very little knowledge. Bigger models often have both builtin knowledge and even better reasoning.

On my personal rig (3090TI 24GB VRAM + 96 GB DDR5@88GB/s + 9950X + single Gen 5 x4 NVMe SSD) these are my most common setups:

Best Quality

If I want the best quality answer, and am willing to wait while it runs for up to an hour or so in the background, I’ll go for the unsloth R1 671B @ R1-UD-Q2_K_XL mentioned above at 8k context and let it chug at 1-2 tok/sec.

I use this to refactor python code, throw a man page at it and ask it to write the command, or for higher quality creative writing and prose.

This is about the only model that will come up with more varied answers when prompted the same. Most smaller models seem to give almost the same answer every time.

Good Quality

If I want okay quality, but somewhat faster I go with something like bartowski/Athene-V2-Chat-GGUF @ IQ4_XS. It doesn’t fit entirely in 24GB VRAM with 8k-12k context but runs around ~4-5 tok/sec. Also because it is not a <think></think> reasoning model it immediately spits out some python code.

Okay Quality Fast

If I want fast or longer context I go with a 32B@~4bpw e.g. bartowski/FuseO1-DeepSeekR1-QwQ-SkyT1-Flash-32B-Preview-GGUF@Q4_K_M. This 32B size is the sweet spot imo for 24GB VRAM systems. I would probably choose this over a 70B@2bpw.

Fast Long Context

For when I want parallel inferencing to scrape multiple websites concurrently and summarize it all or any kind of RAG type thing I go with a long context 8B or even 14B e.g. mradermacher/Qwen2.5-14B-Instruct-1M-i1-GGUF@IQ4_XS. Many of the Qwen2.5 models are quite performant even at smaller sizes and available at multiple breakpoints depending on your target hardware. These models have very little knowledge, but if you inject good clean context they can pick out the best answer from those you provide in the prompt.

Little Guys

The little 1.5B and smaller might make sense for mobile devices or similar where you mainly just want it to complete sentences or do a single very specific task for which it has been custom fine-tuned.

Conclusion

Okay way too much, but it might give a feel for how you can choose the right model for the job. Every few months I go through and replace the models in each class with whatever the new SOTA hotness is trending on huggingface.

Cheers!

4 Likes

Alright. 7C13 installed and initial tests done. I see a fairly substantial increase in prompt processing, but only a small increase in token generation from the 7532. Looks like 64 threads may be the sweet spot for this processor–going higher doesn’t do much…

model size params backend threads type_k test t/s
deepseek2 671B Q2_K - Medium 211.03 GiB 671.03 B CPU 64 q4_0 pp512 24.15 ± 1.88
deepseek2 671B Q2_K - Medium 211.03 GiB 671.03 B CPU 64 q4_0 tg128 6.63 ± 0.22
deepseek2 671B Q2_K - Medium 211.03 GiB 671.03 B CPU 96 q4_0 pp512 23.32 ± 0.32
deepseek2 671B Q2_K - Medium 211.03 GiB 671.03 B CPU 96 q4_0 tg128 5.88 ± 0.04
deepseek2 671B Q2_K - Medium 211.03 GiB 671.03 B CPU 128 q4_0 pp512 24.66 ± 1.84
deepseek2 671B Q2_K - Medium 211.03 GiB 671.03 B CPU 128 q4_0 tg128 5.44 ± 0.21
2 Likes

Hey all, I’m here from the L1 video where he talks about running models locally.

I tried to get it working with llama.cpp the other day, but I ended up using ollama because I couldn’t figure out how do download the ggml models from huggingface. Do you have to pay or is there like a bittorrent for it?

Also I was wondering what my best bet is for intel laptop chips with xe graphics. Is enabling the vulkan backend worth it or should I be using something else?

I’ve also got a weird power9 computer I could max out the memory to like 256GiB for a couple hundred bucks (it uses a 2211M) so that could be fun if I can get llama.cpp to compile.

1 Like

Here’s the link for how to install huggingface hub, which can then pull the models (see here). You can also just download the gguf files using a browser.

1 Like

Has anyone here used any of the older AMD ML cards (e.g. MI60) with llama.cpp (or ktransformers for that matter)? They’re the least expensive cards with > 16GB of memory, but my understanding is that AMD has EOL’d them. Just curious if they still work…

1 Like

Bookmarking this for the coming months of building a dedicated Linux system. I’m currently a windows nub but am looking to fully transition by October of this year. Great breakdown, even though I understand maybe 3% of this right now.

2 Likes

Have you used Windows Subystem for Linux “WSL” ? You can install it from Windows and launch a shell which is very similar to “real” Ubuntu Linux. Great way to get your feet wet running commands and getting used to it. You can even run nvidia-smi and access your GPU to try out some smaller LLMs and such!

2 Likes