[GH-ISSUE #50] How to properly disable offloading MoE layers to CPU? #27

Closed
opened 2026-10-29 14:32:46 +00:00 by bsakaguchi · 5 comments
Owner

Originally created by @molamooo on GitHub (Aug 21, 2024).
Original GitHub issue: https://github.com/kvcache-ai/ktransformers/issues/50

Originally created by @molamooo on GitHub (Aug 21, 2024). Original GitHub issue: https://github.com/kvcache-ai/ktransformers/issues/50
Author
Owner

@Azure-Tang commented on GitHub (Aug 22, 2024):

Regarding your question on disabling the offloading of MoE layers to the CPU, I’ve provided a brief explanation in my earlier response (#46 ). Please take a look there for detailed instructions.

<!-- gh-comment-id:2303558009 --> @Azure-Tang commented on GitHub (Aug 22, 2024): Regarding your question on disabling the offloading of MoE layers to the CPU, I’ve provided a brief explanation in my earlier response (#46 ). Please take a look there for detailed instructions.
Author
Owner

@molamooo commented on GitHub (Aug 22, 2024):

I tried using custom rule file to put all layers on GPU, but KTransformer triggers oom when dequantizing parameters. I use a 24GB 4090 to run deepseek-v2-lite-chat with q8_0 quantization. It should only takes ~16GB memory. Other systems like llama.cpp can run without issue.

<!-- gh-comment-id:2303670413 --> @molamooo commented on GitHub (Aug 22, 2024): I tried using custom rule file to put all layers on GPU, but KTransformer triggers oom when dequantizing parameters. I use a 24GB 4090 to run deepseek-v2-lite-chat with q8_0 quantization. It should only takes ~16GB memory. Other systems like llama.cpp can run without issue.
Author
Owner

@ELigoP commented on GitHub (Aug 22, 2024):

This is hardly possible.
What is your model size? With q8 quantization it should be >200 GB. If you

put all layers on GPU

no wonder it OOMs. Llama.cpp automatically offloads layers in to CPU suboptimal way. If you force it to offload everything to GPU it will also OOM.

E.g. with my setup I get 7.5 tps with suboptimal llama.cpp CPU offload and 9 tps with ktransformers (even that it utilizies VRAM suboptimally).

<!-- gh-comment-id:2303829439 --> @ELigoP commented on GitHub (Aug 22, 2024): This is hardly possible. What is your model size? With q8 quantization it should be >200 GB. If you > put all layers on GPU no wonder it OOMs. Llama.cpp automatically offloads layers in to CPU suboptimal way. If you force it to offload everything to GPU it will also OOM. E.g. with my setup I get 7.5 tps with suboptimal llama.cpp CPU offload and 9 tps with ktransformers (even that it utilizies VRAM suboptimally).
Author
Owner

@molamooo commented on GitHub (Aug 22, 2024):

This is hardly possible. What is your model size? With q8 quantization it should be >200 GB.

I mentioned that I use deepseek-v2-lite-chat, which is a 16B model. It shouldn't oom.

<!-- gh-comment-id:2303830871 --> @molamooo commented on GitHub (Aug 22, 2024): > This is hardly possible. What is your model size? With q8 quantization it should be >200 GB. I mentioned that I use deepseek-v2-lite-chat, which is a 16B model. It shouldn't oom.
Author
Owner

@Azure-Tang commented on GitHub (Aug 22, 2024):

I see, if you are using KExpertsTorch as backend, it will dequant the weights to model's default dtype, for deepseek this is bf16. So this is why it oom. Maybe you can try marlin backend? But we didn't optimise this operator in generate phase.

<!-- gh-comment-id:2303938838 --> @Azure-Tang commented on GitHub (Aug 22, 2024): I see, if you are using KExpertsTorch as backend, it will dequant the weights to model's default dtype, for deepseek this is bf16. So this is why it oom. Maybe you can try marlin backend? But we didn't optimise this operator in generate phase.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
kvcache-ai/ktransformers#27
No description provided.