kvcache-ai / kvcache-ai/ktransformers
How to use 2 16G GPUs to run kt-kernel 0.4.x
- Dominant language
- Python
- Stars
- 19.5k
- Forks
- 1.6k
- Avg merge
- 19h 32m
- Merged PRs (30d)
- 27
Description
### Reminder
- [x] I have read the above rules and searched the existing issues.
### System Info
Intel 6416H * 1 CPU
768G RAM
4060Ti 16G *2 GPU
### Reproduction
```
File "/home/aigao/sglang/python/sglang/srt/managers/scheduler.py", line 2674, in run_scheduler_process
scheduler = Scheduler(
^^^^^^^^^^
File "/home/aigao/sglang/python/sglang/srt/managers/scheduler.py", line 311, in __init__
self.tp_worker = TpModelWorker(
^^^^^^^^^^^^^^
File "/home/aigao/sglang/python/sglang/srt/managers/tp_worker.py", line 237, in __init__
self._model_runner = ModelRunner(
^^^^^^^^^^^^
File "/home/aigao/sglang/python/sglang/srt/model_executor/model_runner.py", line 323, in __init__
self.initialize(min_per_gpu_memory)
File "/home/aigao/sglang/python/sglang/srt/model_executor/model_runner.py", line 404, in initialize
self.load_model()
File "/home/aigao/sglang/python/sglang/srt/model_executor/model_runner.py", line 758, in load_model
self.model = get_model(
^^^^^^^^^^
File "/home/aigao/sglang/python/sglang/srt/model_loader/__init__.py", line 28, in get_model
return loader.load_model(
^^^^^^^^^^^^^^^^^^
File "/home/aigao/sglang/python/sglang/srt/model_loader/loader.py", line 594, in load_model
model = _initialize_model(
^^^^^^^^^^^^^^^^^^
File "/home/aigao/sglang/python/sglang/srt/model_loader/loader.py", line 262, in _initialize_model
return model_class(**kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/home/aigao/sglang/python/sglang/srt/models/deepseek_v2.py", line 3034, in __init__
self.model = DeepseekV2Model(
^^^^^^^^^^^^^^^^
File "/home/aigao/sglang/python/sglang/srt/models/deepseek_v2.py", line 2830, in __init__
self.layers, self.start_layer, self.end_layer = make_layers(
^^^^^^^^^^^^
File "/home/aigao/sglang/python/sglang/srt/utils/common.py", line 576, in make_layers
+ get_offloader().wrap_modules(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/aigao/sglang/python/sglang/srt/utils/offloader.py", line 36, in wrap_modules
return list(all_modules_generator)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/aigao/sglang/python/sglang/srt/utils/common.py", line 578, in
layer_fn(idx=idx, prefix=add_prefix(idx, prefix))
File "/home/aigao/sglang/python/sglang/srt/models/deepseek_v2.py", line 2832, in
lambda idx, prefix: DeepseekV2DecoderLayer(
^^^^^^^^^^^^^^^^^^^^^^^
File "/home/aigao/sglang/python/sglang/srt/models/deepseek_v2.py", line 2588, in __init__
self.self_attn = DeepseekV2AttentionMLA(
^^^^^^^^^^^^^^^^^^^^^^^
File "/home/aigao/sglang/python/sglang/srt/models/deepseek_v2.py", line 1203, in __init__
self.o_proj = RowParallelLinear(
^^^^^^^^^^^^^^^^^^
File "/home/aigao/sglang/python/sglang/srt/layers/linear.py", line 1255, in __init__
self.quant_method.create_weights(
File "/home/aigao/sglang/python/sglang/srt/layers/quantization/fp8.py", line 293, in create_weights
data=torch.empty(
^^^^^^^^^^^^
File "/home/aigao/anaconda3/envs/kt-kernel/lib/python3.11/site-packages/torch/utils/_device.py", line 103, in __torch_function__
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
torch.OutOfMemoryError: CUDA out of memory. Tried to allocate 112.00 MiB. GPU 0 has a total capacity of 15.57 GiB of which 4.69 MiB is free. Including non-PyTorch memory, this process has 15.55 GiB memory in use. Of the allocated memory 15.19 GiB is allocated by PyTorch, and 208.94 MiB is reserved by PyTorch but unallocated. If reserved but unallocated memory is large try setting PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True to avoid fragmentation. See documentation for Memory Management (https://pytorch.org/docs/stable/notes/cuda.html#environment-variables)
[2025-12-08 16:43:01] Received sigquit from a child process. It usually means the child failed.
./ktdsv32.sh: 第 20 行: 626563 已杀死 python -m sglang.launch_server --host 0.0.0.0 --port 30000 --model /opt/ai-models/v3-2 --kt-weight-path /opt/ai-models/v3-2-CPU --kt-cpuinfer 36 --kt-threadpool-count 1 --kt-num-gpu-experts 0 --attention-backend triton -
-trust-remote-code --mem-fraction-static 0.98 --chunked-prefill-size 2048 --max-running-requests 16 --max-total-tokens 20000 --served-model-name DeepSeek-V3.2 --enable-mixed-chunk --tensor-parallel-size 1 --enable-p2p-check --disable-shared-experts-fusion --kt-method AMXINT4```
```
### Others
I know that kt-kernel 0.4.x need more VDRAM to run new models, for example: DeepSeek V3.2, Kimi Thinking.
But is there a way to use cheap GPU to run it?
I have 2 4060Ti 16G, total 32G, can it run DeepSeek V3.2?
Because in document, DeepSeek V3.2 with kt-kernel 0.4.3 only need 27G VDRAM.
Therer is my startup script:
```bash
python -m sglang.launch_server \
--host 0.0.0.0 \
--port 30000 \
--model /opt/ai-models/v3-2 \
--kt-weight-path /opt/ai-models/v3-2-CPU \
--kt-cpuinfer 36 \
--kt-threadpool-count 1 \
--kt-num-gpu-experts 0 \
--attention-backend triton \
--trust-remote-code \
--mem-fraction-static 0.98 \
--chunked-prefill-size 2048 \
--max-running-requests 16 \
--max-total-tokens 20000 \
--served-model-name DeepSeek-V3.2 \
--enable-mixed-chunk \
--tensor-parallel-size 1 \
--enable-p2p-check \
--disable-shared-experts-fusion \
--kt-method AMXINT4
```
I tried adjust `tensor-parallel-size` to 1 or 2, and `kt-num-gpu-experts` to 0 or 1.
Contributor guide
Assessment
This issue has not been assessed yet.