mirror of
https://github.com/kvcache-ai/ktransformers.git
synced 2026-11-05 01:07:28 +00:00
[GH-ISSUE #117] Support for DeepseekV3 680B #65
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
kvcache-ai/ktransformers#65
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @sorasoras on GitHub (Dec 25, 2024).
Original GitHub issue: https://github.com/kvcache-ai/ktransformers/issues/117
https://huggingface.co/deepseek-ai/DeepSeek-V3-Base
well, that's a beast.
@fengyang95 commented on GitHub (Dec 26, 2024):
+1
@Nottlespike commented on GitHub (Dec 26, 2024):
Does ktransformers depend on HF transformers support for a for a model arch? If so we are going to have to wait until DeepSeek-V3 supports HF transformers as it does not yet and I don't see a PR from the DeepSeek team yet.
@ghost commented on GitHub (Dec 27, 2024):
The ktransformer backend is an old commit of llama.cpp iirc
Edit: 6 months old
github.com/ggerganov/llama.cpp@a94e6ff877@Nottlespike commented on GitHub (Dec 27, 2024):
Is it just me or is this not promising... I mean I'm patient but this means that transformers needs to support DeepSeek-V3 then llama.cpp needs to suppport DeepSeek-V3 then ktransformers needs to support llama.cpp's DeepSeek-V3 implementation....
@sorasoras commented on GitHub (Dec 27, 2024):
I heard that it s not hard to support V3 on llama cpp due to been resemblance to v2
@Nottlespike commented on GitHub (Dec 27, 2024):
Sadly this is not the case in two ways. Firstly V3 from the technical report is far far more complex than V2. Second V2 never actually got a HF transformers implementation sadly only a stale draft PR.
This is an issue that shows the problem in action https://github.com/huggingface/transformers/issues/34335
This is the stale attempt at V2 integration https://github.com/huggingface/transformers/pull/31976
@sorasoras commented on GitHub (Dec 27, 2024):
well. kt do support DS2 so it should be just a upgrade with next gen moe router
@Nottlespike commented on GitHub (Dec 27, 2024):
What they do is use remote code. There is no native HF transformers implemenation. Feel free to find it if you think I am incorrect. If people wish to use this for enterprise deployment letting a model run what is functionally arbitrary code on your servers is 100% a no go like it is for my startup.
@mahald commented on GitHub (Dec 28, 2024):
+1
@lzumot commented on GitHub (Dec 29, 2024):
+1
@Azure-Tang commented on GitHub (Dec 30, 2024):
Supporting this seems easy; however, it requires approximately 400g of RAM for even q4km?
@Nottlespike commented on GitHub (Dec 30, 2024):
Does ktransformers not need transformers or llama.cpp support for a a model? https://github.com/huggingface/transformers/issues/35425 Back of the napkin math is more like 5XXGB of VRAM/RAM would be needed given context.
@Azure-Tang commented on GitHub (Dec 31, 2024):
Yes, we need transformers‘ modeling.py.
@16x3b commented on GitHub (Dec 31, 2024):
Just spitballing. Would it be possible to do some speculative decoding with a smaller model (dense or moe) and then on the larger moe just use nvme for some of the experts? Why do we need all experts loaded into ram at all times instead of selecting experts as necessary?
Again just throwing an idea out there from where my understanding is at. I'd like to understand better why this would not work.
@sorasoras commented on GitHub (Jan 1, 2025):
why would you need smaller model speculative decoding when you can do it via MTP?
@Nottlespike commented on GitHub (Jan 2, 2025):
@Azure-Tang
We are basically done with integrating DeepSeek-V3 into llama.cpp via a very very elegant solution from @fairydreaming
https://github.com/ggerganov/llama.cpp/issues/10981#issuecomment-2568349563
Can you see if you can try what they did?
@Nottlespike commented on GitHub (Jan 6, 2025):
For those looking for an update on this I've to forked it and I think I know how to get this working but no ETA.
@ELigoP commented on GitHub (Jan 9, 2025):
I manage to fit in Q3_K_M quant within 96GB VRAM + 256GB RAM. Q4_K_M is out of my reach.
@hvico commented on GitHub (Jan 9, 2025):
Wow. Great news. What would be the mininum specs to be able to run a Q4_K_M with 96 GB VRAM? 512 GB of RAM plus that VRAM would be enough? I have that much VRAM but I will upgrade my RAM for that. Thanks!
@16x3b commented on GitHub (Jan 12, 2025):
I don't see how MTP helps me. I'm suggesting speculative decoding because we can get faster inference from a smaller model and only refer to the larger model if confidence is low. No need to call the large model if the small one has a confident answer.
@sorasoras commented on GitHub (Jan 13, 2025):
MTP generate two token and you use second token as speculative decode. This is call self-speculative decode. no need for extra model
@16x3b commented on GitHub (Jan 14, 2025):
Understood. That's excellent! Thank you for explaining that to me. I see why there's no need to implement speculative decoding with a model that already has MTP implemented.
@sorasoras commented on GitHub (Jan 14, 2025):
if you read the paper, it mentioned you can get 90% hit rate with MTP 2-token and SD.
I guess we are going to have 4-token MTP in the future.
@bitnom commented on GitHub (Jan 28, 2025):
so hot right now
@whisper-bye commented on GitHub (Jan 28, 2025):
Dynamic 1.58-bit
https://unsloth.ai/blog/deepseekr1-dynamic
@ChandanVerma commented on GitHub (Jan 29, 2025):
Any updates by when can we see deepseek v3 or r1 in ktransformers? Really looking forward to it. It would be of great help to everyone
Thanks
@Azure-Tang commented on GitHub (Jan 29, 2025):
I'm actively tracking the DeepSeek V3/R1 integration. The HuggingFace Transformers team is finalizing support for DeepSeek V3 (see PR #35926), which ktransformers relies on.
I'm pausing my vacation resolving any remaining compatibility issues. Expect a quick follow-up release for ktransformers once dependencies stabilize.
I’ll keep you updated here – appreciate your patience and support! 🙌
@Nondzu commented on GitHub (Jan 29, 2025):
I can run DS V3 and R1 on my workstation 768g of RAM. llama.cpp tested and works fine with deepseek v3/r1 Q4_K_M and Q5 models.
If you need any tests or help to implementation pls ping me.
@ChandanVerma commented on GitHub (Jan 30, 2025):
Is it usable? How many TPS do you get? I am planning to run on my local server with 512g RAM and 6x3090 system
@Azure-Tang commented on GitHub (Jan 31, 2025):
I have successfully deployed DeepSeek-V3 on the KTransformers framework, but there are still some accuracy issues that I am currently investigating.
Based on preliminary tests, using the Q4KM weight file requires at least 16GB of VRAM and 480GB of RAM. On a positive note, the generation speed can reach approximately 3.8 tokens/s.”
See #122
@Azure-Tang commented on GitHub (Jan 31, 2025):
What's your generate speed using llama.cpp with v3/r1 Q4_K_M?
@ChandanVerma commented on GitHub (Jan 31, 2025):
Thats wonderful.. Really appreciate the hard work. Just a small question if i inject more layers to the gpu since i have 144 GB of VRAM, will the RAM consumption go down and will i be able to allocate more context?
@Azure-Tang commented on GitHub (Jan 31, 2025):
yes, theoretically you can use marling expert as KExperts' backend (but we haven't test this op, this may cause some bug orz, and it's loading will be veeeeeeery slow)
@Nondzu commented on GitHub (Jan 31, 2025):
@ChandanVerma @Azure-Tang I've ~7t/s by llama.cpp with 100% CPU offload. don't have any GPU on that machine. and yes, it's usable as well with that speed
@Azure-Tang commented on GitHub (Jan 31, 2025):
Our framework's architectural design suggests it should have inherent performance advantages in CPU-only environments. there might be some factors I haven't accounted for yet.
@trilog-inc commented on GitHub (Jan 31, 2025):
Watching this closely. Thanks for your hardwork @Azure-Tang
@Nondzu commented on GitHub (Jan 31, 2025):
llama.cpp benchmark deepseek-256x20B-v3-q4_k.gguf
| deepseek2 671B Q4_K - Medium | 376.65 GiB | 671.03 B | CPU | 112 | pp512 | 49.65 ± 2.25 |
| deepseek2 671B Q4_K - Medium | 376.65 GiB | 671.03 B | CPU | 112 | tg128 | 7.37 ± 0.00 |
@ChandanVerma commented on GitHub (Jan 31, 2025):
Great....How much RAM does it consume and whats the context size you are able to achieve?
@Nondzu commented on GitHub (Jan 31, 2025):
i use R1 Q5 for last days with 32000 ctx and predict 16000, it need almost 600g of RAM
@Green0-0 commented on GitHub (Jan 31, 2025):
What are the chances of getting MTP support? That would greatly increase the t/s.
@Aiden-Frost commented on GitHub (Feb 1, 2025):
Is it possible to run the DeepSeek R1 in just 4 A100 GPU (roughly 320 GB VRAM) using accelerate with offloading to disk? While this will be really really slow, but for some analysis purpose is it possible to run with this setup?
@Azure-Tang commented on GitHub (Feb 1, 2025):
It's possible. Loading process will be slow in this way, but the inference speed can be greatly accelerated. You can refer this:
I would check our marlin expert op once down supporting DeepSeekv3.
@Azure-Tang commented on GitHub (Feb 1, 2025):
Could you please help me check the precision issue? I'm currently stuck. The problem is similar to this:
user: hi
assistant: Hello! How are youHello! How can I have a nice to meet can you today. Good evening! Hello! How are youHello! or fine thanks for your, . can i have a chatI'mm but I am good-day evening! eveniny
I think this may cased by mla/rope implements or moe gates?
@Nondzu commented on GitHub (Feb 1, 2025):
@Azure-Tang I've issue to install ktransformers without cuda on machine. is it possible to build and install with CPU only ?
atm machine doesn't have any gpu
@Azure-Tang commented on GitHub (Feb 1, 2025):
Currently we does require GPU orz. Thanks for reaching out—I'll try to find a workaround.
@ELigoP commented on GitHub (Feb 3, 2025):
Do we need specific weights/quants to try DeepSeek V3 support pull request or any would work? E.g. IQ3_M or Q3_K_M GGUFs?
@Azure-Tang commented on GitHub (Feb 3, 2025):
Any would work;We are currently investigating precision problem; I think release version would be available in one or two days.
@huliangbing commented on GitHub (Feb 3, 2025):
期待...
@davidsyoung commented on GitHub (Feb 3, 2025):
Watching this very closely. I have 9x3090's along with 256GB DDR4 RAM. Is it worth testing your current PR @Azure-Tang?
@Azure-Tang commented on GitHub (Feb 4, 2025):
Hi everyone,
Exciting updates to share! After intensive development efforts, we are pleased to announce that ktransformers now supports Deepseek-V3 and R1 architectures. The working PR (#122 ) is currently undergoing final validation and is expected to merge into main branch within the next few days. You can build from source via the feat-DeepSeekV3 branch for early access.
Special thanks to our community for the continued support.
@Azure-Tang commented on GitHub (Feb 4, 2025):
You may need bigger RAM for now, it requires 380GB RAM for my default optimization yaml…… Or you can try to modify yaml to use marlin expert to use more DRAM?
@davidsyoung commented on GitHub (Feb 4, 2025):
Fantastic! Going to try to get this working. Could you give a config/gguf that you recommend for this?
I'm currently attempting to launch with the following docker compose but not sure if I'm missing something. Could you give an example config/launch params for a Deepseek R1? Thank you very much for the hard work!
I'm getting
It's possible that my docker compose didn't fully rebuild from branch, forcing rebuild now
@davidsyoung commented on GitHub (Feb 4, 2025):
I can most definitely work on doing this and release once I get it working!
@Azure-Tang commented on GitHub (Feb 4, 2025):
Ok,the 380GB is obtained by q4km v3 model. Just try it!
@davidsyoung commented on GitHub (Feb 4, 2025):
Trying with unsloth/DeepSeek-R1-GGUF-Q4_K_M once done building. Thank you!
@Azure-Tang commented on GitHub (Feb 4, 2025):
As developer usually I run/test project from code like this:
Maybe try to install from source/conda can avoid this XD?
@davidsyoung commented on GitHub (Feb 4, 2025):
I'm hoping that the Dockerfile contained will do an okay job at this? I'm thinking... I find it hard to build from source with conda with the server I run it on!
@davidsyoung commented on GitHub (Feb 4, 2025):
Okay built and ran with these commands:
Output:
@davidsyoung commented on GitHub (Feb 4, 2025):
Ignore me, I believe the dockerfile isn't referencing the feature branch and building from main instead. Will re-build and try again
@ELigoP commented on GitHub (Feb 4, 2025):
Managed to run DeepSeek-V3 with
But couldn't run R1 with IQ3_M with
flash-attninrequirements-local_chat.txtand no build isolation to install.@Nondzu commented on GitHub (Feb 4, 2025):
@Azure-Tang Great job, Thanks !
Do you have any update about CPU build without CUDA?
@Azure-Tang commented on GitHub (Feb 4, 2025):
Sorry, IQ3_M support is still under development and marked as a todo item.
@Azure-Tang commented on GitHub (Feb 4, 2025):
You could try removing the "KTransformersOps" dependency, as it requires CUDA. However, if you're not using a GPU, have you considered using llamacpp directly? The main advantage of ktransformers is its ability to offload high arithmetic intensity operations to the GPU while keeping others on the CPU.
@trilog-inc commented on GitHub (Feb 4, 2025):
Great news!
Ran a simple test with
python ktransformers/local_chat.py --model_path deepseek-ai/DeepSeek-R1 --gguf_path /mnt/home_extend/models/bartowski_DeepSeek-R1-GGUF/DeepSeek-R1-Q4_K_M --max_new_tokens 5000
prompt: test
Answer:
with the following performance:
2025-02-04 14:48:08,724 INFO /mnt/home_extend/llm/ktransformers/ktransformers/server/backend/base.py[64]: Performance(T/s): prefill 1.5659206588635783, decode 2.8615367519258315. Time(s): tokenize 0.08403253555297852, prefill 2.554407835006714, decode 114.97318696975708
However, I am at the upper limit of my current setup ( 384GB DDR5, 3x3090 but only 1 being used ). top reports a 98.3% memory usage just when at the prompt. nvidia-smi settles around 12870MiB.
@davidsyoung commented on GitHub (Feb 4, 2025):
Ok, great news - I got it running! Had to do some finicky stuff to make it work in Docker.
Next stage. Do you have any recommendations for how I would make use of the 9x3090's I have instead of putting into CPU/DRAM @Azure-Tang? As I don't have enough DRAM to run it without.
I'm going to take a look at the multi gpu config file but thought it'd be useful to get some direction here!
@trilog-inc commented on GitHub (Feb 5, 2025):
I was getting a lot of "Segmentation fault" when using the Q4_K_M model, so i switched to the Q4_K_XS and it did not help. For example using the following prompt: "Use python and the fastapi library to write a generic openAI compatible endpoint for /v1/models" ( so i can use this library with open WebUI! ).
I thought it was an OOM error at first, but with the Q4_K_XS model, there is still 43GB available on the system.
Could there be something else causing this? What can i do to root cause this issue?
@ELigoP commented on GitHub (Feb 5, 2025):
Maybe that's default context length which is too large? Try
--total_context 1024and--max_new_tokens 1024or smth like first.@RodriMora commented on GitHub (Feb 5, 2025):
Hi!
I'm testing but get this error:
Running using this:
python ktransformers/local_chat.py --model_path deepseek-ai/DeepSeek-R1 --gguf_path /home/ubuntuai/models/DeepSeek-R1-Q3_K_M --max_new_tokens 1000 --total_context 2000I haven't used ktransformers in the past, do I have to point to the folder containing all the .gguf's shards right? not the first 00001.gguf?
System:
EPYC 7402 24c/48t
512GB Ram 3200Mhz
4x3090
I installed manually everything, and I use python venv instead of conda:
@Azure-Tang commented on GitHub (Feb 5, 2025):
You could try injecting some layers' experts and using Marlin exports to replace KExpertsCPU as the backend for KTransformersExperts. A detailed tutorial can be found here. You may refer to multi-gpu yaml to learn how to replace some layers while keeping others on cpu.
That said, I haven’t tested this with the v3 model yet, so there might be some bugs. If you run into any issues, feel free to ping us!
@Azure-Tang commented on GitHub (Feb 5, 2025):
Did this works? ⬇️
@trilog-inc commented on GitHub (Feb 5, 2025):
It did not unfortunately. Here is the debug output when using --max_new_tokens 512 --total_context 512
With this prompt "Use python and the fastapi library to write a generic openAI compatible endpoint for /v1/models"
@ELigoP commented on GitHub (Feb 5, 2025):
Installation guide recommends conda, but I also wanted problems :) had to work it out with
pyenv+venv.First install
pyenvfrom official guide. Then runpyenv install 3.11.6andpyenv activate 3.11.6. Then this is my diff that I worked out:then run
bash install.sh.@Nottlespike commented on GitHub (Feb 5, 2025):
I've been messing around with GDB to identify exactly where the segfault is occuring and from my testing this is my failure point with this command
python ktransformers/local_chat.py --model_path deepseek-ai/DeepSeek-R1 --gguf_path ./DeepSeek-R1-GGUF --total_context 8192 --max_new_tokens 8192:When running a backtrace to get some more debugging info I am getting this output:
This led me to rebuild the branch from scratch but this error recurred exactly the same way. To further debug I used valgrind and this is the summary of many many issues with memory:
I am on a 4x3090 Ti system with a ThreadRipper Pro 5965WX, 24 cores, and 8x128GB sticks of Samsung ECC DDR4 DRAM running Ubuntu 24.04 LTS. When running this model with the latest build of llama.cpp it is working quite well.
@huliangbing commented on GitHub (Feb 6, 2025):
@Azure-Tang Great work! What's the benchmark and performance of some GPU and CPU hardware?
@ELigoP commented on GitHub (Feb 6, 2025):
I am now testing with
And I always reproduce segfault on second reply.
@ELigoP commented on GitHub (Feb 6, 2025):
This might be interesting: I tried with context and length of 2048, and after second reply I got
Seems to be
generate_idsdimension is always slightly bigger than max context, this time it is[1, 2053]vs context length2048, and in previous comment it was[1, 1029]vs context length1024.Could that be the issue?
@Azure-Tang commented on GitHub (Feb 6, 2025):
We seem have located the segment fault problem. Try latest pr?
@RodriMora commented on GitHub (Feb 6, 2025):
That solved it for me, quick test:
Same settings as https://github.com/kvcache-ai/ktransformers/issues/117#issuecomment-2636883021
@ELigoP commented on GitHub (Feb 6, 2025):
Me too. Now performance looks slow, but I will investigate that.
@RodriMora commented on GitHub (Feb 6, 2025):
I'm trying to see how much vram and ram it's being allocated but not sure if the args are right.
--max_new_tokens, seems pretty self explanatory, how long the response can be, shouldn't affect how much ram/vram it takes.
But, how do I define the max context for the model to load?
Is it --total_context? or rather --length? can't tell by the docs
@Azure-Tang commented on GitHub (Feb 6, 2025):
Ok, it seems influenced prefill speed. We have fixed in latest commit. Try to pull again?
@trilog-inc commented on GitHub (Feb 6, 2025):
Can confirm the latest commit affected performance:
with prompt: test
using the longer prompt: Use python and the fastapi library to write a generic openAI compatible endpoint for /v1/models
command: python ktransformers/local_chat.py --model_path deepseek-ai/DeepSeek-R1 --gguf_path /mnt/home_extend/models/bartowski_DeepSeek-R1-GGUF/DeepSeek-R1-Q4_K_M --max_new_tokens 1024 --total_context 1024 --cpu_infer 46
@RodriMora commented on GitHub (Feb 6, 2025):
Working fine for me:
python ktransformers/local_chat.py --model_path deepseek-ai/DeepSeek-R1 --gguf_path /home/ubuntuai/models/DeepSeek-R1-Q3_K_M --max_new_tokens 1000 --total_context 2000@trilog-inc commented on GitHub (Feb 6, 2025):
You are right, my bad.
Flushed the entire conda environment and ktransformers folder, rebuilt and it works as expected 🙌
Going to play with this today, huge thanks to the team for their efforts!
@RodriMora commented on GitHub (Feb 6, 2025):
Did you change the 0.0.0.0 for privacy? you should use the actual IP of the server, it's working for me.
{"id":"7ff95288-d334-431f-9d94-867f372bd497","object":"chat.completion.chunk","created":1738864152,"model":"not implmented","system_fingerprint":"not implmented","usage":null,"choices":[{"index":0,"message":{"content":"<think>\nOkay, so the user wants me to write numbers from 1 to 10, each on a new line, and they specified no coding. Let me make sure I understand. They mentioned \"You are an AI coding assistant\" but then said \"no coding,\" so maybe they want the output to be simple text without any code formatting like in a code block. Got it.\n\nSo, I need to list numbers 1 through 10, each on separate lines. Let me check if there's any other requirement. The user wrote \"explain as minimum as possible,\" which probably means not adding any extra explanations or comments. Just the numbers. Alright.\n\nI think that's all. I'll write each number from 1 to 10, each on a new line. Let me count to confirm: 10 numbers, each separated. Yes, that should do it.\n</think>\n\n1 \n2 \n3 \n4 \n5 \n6 \n7 \n8 \n9 \n10","role":"assistant","name":null},"logprobs":null,"finish_reason":null}]}@ELigoP commented on GitHub (Feb 6, 2025):
Thanks! My bad, I didn't pull latest change. Now server responds.
Still performance is not as expected (comparable and even worse than llama.cpp, which as I understand offloads only first layers to GPU):
llama.cpp gets 3.5 tps prompt processing (I guess this is prefill) and 2.5 tps token generation (which I guess is decode).
I will play with settings more.
@RodriMora what is your system specs, by the way? Mine is 4xRTX 3090 (only first two cards used with my command) and Threadripper 3970X with 256GB DDR4 RAM (4 ram channels, RAM read speed about 80GB/s).
@RodriMora commented on GitHub (Feb 6, 2025):
Similar to yours but on Epyc cpu:
EPYC 7402 24c/48t
512GB RAM 3200MHz
4x3090s
I'm currently doing some performance tests, comparing it to llama.cpp at different context lenghts. I've never used ktransformers so I dont know how to manage how many GPU's to use? It seems to use 2/4 at the moment.
@Nottlespike commented on GitHub (Feb 6, 2025):
The relative path for the multi GPU .yaml is at
ktransformers/optimize/optimize_rules/DeepSeek-V3-Chat-multi-gpu.yaml.With the tutorial on injection being here: https://github.com/kvcache-ai/ktransformers/blob/feat-DeepSeekV3/doc/en/injection_tutorial.md
I've been stymied by the regex for offloading to more than 2 GPU's with specifically this piece being particularly confusing
(0|[1-9]|[12][0-9])as I assume this is for the fact that the first 3 layers of the model are dense but given the pipe I'm not sure how ktransformers handles the "or" regex here and still loads all 61 layers.Either way it looks like the segfault issue is fixed so I'm rebuilding then testing.
@Nottlespike commented on GitHub (Feb 6, 2025):
@RodriMora @ELigoP
So it seems NCCL speeds matter a LOT for TPS. I'm getting WAY faster speeds using 2 GPU's with NVLink than vanilla llama.cpp with the same 4x3090/3090 Ti setup with 14 layers offloaded. For me
cuda:0andcuda:2are NVLinked together so when I replaced allcuda:1instances withcuda:2inktransformers/optimize/optimize_rules/DeepSeek-V3-Chat-multi-gpu.yamlI saw a massive speedup of ~10tps which is 2x vanilla llama.cpp with--max_new_tokens 8192 --total_context 8192and same context on vanilla llama.cpp.Now to write the 4 GPU config! Any assitance with adapting the
ktransformers/optimize/optimize_rules/DeepSeek-V2-Chat-multi-gpu-4.yamlto DeepSeek-V3/R1 would be appreciated @Azure-Tang! I've taken a VERY short look at the paper and it seems that the main difference here is that there is 1 dense layer in V2 vs the 3 in V3 and 60 layers in V2 vs 61 layers in V3 yet my regex for layer assignment seems to break despite my best efforts and reading the injection tutorial multiple times.@Azure-Tang commented on GitHub (Feb 7, 2025):
Try to adjust
cpu_inferaccording to your cpu core~@Azure-Tang commented on GitHub (Feb 7, 2025):
Hi,
I’ve updated the Marlin backend and added a small example YAML in ktransformers/optimize/optimize_rules/DeepSeek-V3-Chat-multi-gpu-marlin.yaml.
To fully utilize your VRAM, try injecting more KExpertsMarlin as the KTransformersExperts backend.
Please note:
• If you use KExpertsMarlin, you need to set --use_cuda_graph False. (This will be added to the documentation later.)
• Loading speed will be significantly slower as you add more KExpertsMarlin.
@Azure-Tang commented on GitHub (Feb 7, 2025):
You can copy the v2 4-GPU YAML and make slight modifications. The changes needed can be identified by comparing the differences between DeepSeek-V2-Chat-multi-gpu and DeepSeek-V3-Chat-multi-gpu.
I’m sure this will be a piece of cake for you! >.-
@Nottlespike commented on GitHub (Feb 7, 2025):
哎呀
@huliangbing commented on GitHub (Feb 7, 2025):
Waiting for the results of 4 GPUs ....
@RodriMora commented on GitHub (Feb 7, 2025):
I did some test with my system:
Command to test:
ktransformers --model_path deepseek-ai/DeepSeek-R1 --gguf_path /mnt/llms/models/DeepSeek-R1-UD-Q2_K_XL --total_context 1024 --max_new_tokens 512 --port 5000 --host 0.0.0.0 --cpu_infer 24 --optimize_config_path ktransformers/optimize/optimize_rules/DeepSeek-V3-Chat-multi-gpu-marlin.yamlFor the 2 gpu optimize rules a used this (I would say same results as without any optimization rules, it seems to use 2 gpus anyways by default but not fully, like less than 50% each card):
https://github.com/kvcache-ai/ktransformers/blob/feat-DeepSeekV3/ktransformers/optimize/optimize_rules/DeepSeek-V3-Chat-multi-gpu-marlin.yaml
For the 4 gpu optimize rules I made this, also uses low vram only 4-6GB each card:
https://github.com/RodriMora/ktransformers/blob/main/ktransformers/optimize/optimize_rules/DeepSeek-V3-Chat-multi-gpu-marlin-4.yaml
Note: --use_cuda_graph False doesn't seem to be enabled as an arg while loading the openai api.
Edit: Comparasion vs llama.cpp:
Same prompt and tokens. llama.cpp with -ngl 20 with the gpus at 23/24Gb VRAM full. 40% increase with ktransformers
@KMSorSMS commented on GitHub (Feb 8, 2025):
This testing result is consistent with our test which will come soon. Our performance video shows faster prefilling decoding compared with llama.cpp. Seems your CPU has about 24 cores on a single Numa Node and in multi GPU context also slows some performance ( As our multi GPU uses pipeline(pp), not tensor Tensor Parallel, So putting in a single GPU is best). You can try to modify .yaml of deepseekv3 to inject more marlin experts to fully utilize GPU and use command
numactl -N 1 -m 1to bind the infer on the same Numa node. And if you want to see more, you can set the --cache_lens , command arg, to 1536. But it will constrain your input and output lens, so be cautious. And our detailed test will come with a stable new release. Coming soon~ 😃@Azure-Tang commented on GitHub (Feb 10, 2025):
Hi! We’ve merged the PR supporting Deepseek-V3/R1 into the main branch, and we’ve also introduced additional optimizations for even better performance. For more details, please check our README and tutorial. Thank you for your support—if you find this helpful, we’d really appreciate any recommendations you share with your friends or community!
@davidsyoung commented on GitHub (Feb 10, 2025):
Thank you for all of your work on this! If you could create some theoretical optimised YAML versions for more GPU's I could test it here on my side. I have 10x3090's, soon to be 12 with a 7713 EPYC 256gb 3200mhz.
@RodriMora commented on GitHub (Feb 10, 2025):
What does the "--cache_lens 1536" do? I got from 5.2t/s decode to 9t/s, using the current main branch compiled (so I think 0.2, not 0.3). That's an insane increase of speed. Is there any compromise?
For the rest, using either:
DeepSeek-V3-Chat.yaml
DeepSeek-V3-Chat-multi-gpu.yaml
DeepSeek-V3-Chat-multi-gpu-marlin.yaml
yields the same results. I think using the single gpu DeepSeek-V3-Chat.yaml for longer context give OOM errors, the rest works fine but with similar performance. 24-25 prefill and 5 decode.
I'll try 0.3 next
@RodriMora commented on GitHub (Feb 10, 2025):
I installed 0.3.
Few notes, in my Ubuntu 22.04 installation was needed to add the:
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install --only-upgrade libstdc++6
Othewise it gives this error:
ImportError: /lib/x86_64-linux-gnu/libstdc++.so.6: versionGLIBCXX_3.4.32' not found (required by /home/ubuntuai/ktransformers/.venv/lib/python3.11/site-packages/KTransformersOps.cpython-311-x86_64-linux-gnu.so)`But I guess my CPU is not compatible? EPYC 7402
@KMSorSMS commented on GitHub (Feb 10, 2025):
TL;DR
The --cache_lens has no use.
It's because --cache_lens used to be an arg which indicates a static area to compute attention even if there is no such a huge prompt to calculate. So in the older version, we set it smaller to our actual prompt will make it faster (as the default is too large). Now the new version we set this to the prompt length and your max_nex_token size. (But it can't support history context now).
Some further intro:
Actually, If you use the current main branch( which is our release V0.2), we get rid of the arg cache-lens in local_chat. (But it remains in server backend, so we just keep this in the tutorial command ). The more insane increase can come from our support for dual-socket support ( make sure you first set env var USE_NUMA
export USE_NUMA=1, see the link in detail). Tips: you may need to use apt to install the libnuma. If you don't use this, you can also check our best test on a single socket. link.@chenht2022 commented on GitHub (Feb 10, 2025):
AMD CPUs like EPYC does not support AMX instruction, our V0.3 currently only supports Intel Xeon CPUs.
@RodriMora commented on GitHub (Feb 10, 2025):
My server only has 1 socket and 1 numa, so it doesn't get any benefit from numactl -N 1 -m 1 (or numactl -N 0 -m 0 in my case).
The --cache_lens 1536 though gives a 80% increase in speed
@KMSorSMS commented on GitHub (Feb 10, 2025):
Have you test again without the --cache_lens args? As it has no use now in local_chat run.
@RodriMora commented on GitHub (Feb 10, 2025):
Yes. Got the same performance on local_chat. The difference is in the openai api server.
With --cache_lens
prompt eval count: 16 token(s)
prompt eval duration: 1.1299359798431396s
prompt eval rate: 14.160094275625383 tokens/s
eval count: 1000 token(s)
eval duration: 98.3808274269104s
eval rate: 10.164582125952592 tokens/s
Without: --cache_lens
prompt eval count: 16 token(s)
prompt eval duration: 1.133697271347046s
prompt eval rate: 14.11311503024876 tokens/s
eval count: 1000 token(s)
eval duration: 98.45745468139648s
eval rate: 10.156671257000815 tokens/s
@KMSorSMS commented on GitHub (Feb 10, 2025):
Good! This is exactly what we have test and post on the Report(our result is 8.73 tokens/s in decoding as our single socket only get 32 cores). The cache_lens args have no use in the current version of our local_chat.py.
@ArYuZzz commented on GitHub (Feb 11, 2025):
Does v0.3 supports earlier Xeon CPUs like gen3 or gen2 which only support AVX-512?
And if not, does v0.2 support AVX-512 and can also accelerate the inference of deepseek?
@KMSorSMS commented on GitHub (Feb 11, 2025):
The preview version of V0.3 doesn't support earlier Xeon CPU. But V0.2 can support as it doesn't contain AMX instruction acceleration implementation. So you can try V0.2 to accelerate the inference of deepseek
@chenht2022 commented on GitHub (Feb 11, 2025):
AMX instructions are not supported on Xeon gen2 and gen3 , and you can also check the supported instruction sets through command
lscpu. If AMX instruction are supported, there will be flags such as amx_bf16, amx_tile, amx_int8V0.2 will automatically use the AVX512 instruction set on hardware that supports AVX512
@WuNein commented on GitHub (Feb 11, 2025):
must I download the BF16 version gguf to use V0.3?
https://huggingface.co/unsloth/DeepSeek-R1-GGUF/tree/main/DeepSeek-R1-BF16
It is giant!!
@chenht2022 commented on GitHub (Feb 11, 2025):
Yes, for V0.3 preview version. We will consider optimizing it in the official release version, maybe support online dequantization.
@ArYuZzz commented on GitHub (Feb 11, 2025):
Thanks for reply and contribution. Will the upcoming v0.3 supports AVX512?
@KMSorSMS commented on GitHub (Feb 11, 2025):
We will consider it. But most likely it will not contain as the V0.3 most focus on AMX optimization