kvcache-ai / kvcache-ai/ktransformers
kt-kernel 0.4.2 Kimi-K2 Thinking: torch.OutOfMemoryError: CUDA out of memory.
- 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
Ubuntu 24.04.3
kt-kernel 0.4.2
Kimi-K2 Thinking
Dual-6416h CPU
1T RAM
RTX 3090 24G
### Reproduction
```
python -m sglang.launch_server --host 0.0.0.0 --port 60000 --model /opt/ai-models/Kimi-K2-Thinking/ --kt-weight-path /opt/ai-models/Kimi-K2-Instruct-CPU-weight/ --kt-cpuinfer 36 --kt-threadpool-count 2 --kt-num-gpu-experts 16 --kt-method AMXINT4 --attention-backend flashinfer --trust-remote-code --mem-fraction-static 0.98 --chunked-prefill-size 4096 --max-running-requests 37
--max-total-tokens 3700 --enable-mixed-chunk --tensor-parallel-size 1 --enable-p2p-check --disable-shared-experts-fusion```
```
WorkerPool[0x2a5a6f30] 2 subpools, [numa:threads][0:18] [1:18]
===========In NumaPool============
In Numa Worker Pool at NUMA 0, 18 threads
===========In NumaPool============
In Numa Worker Pool at NUMA 1, 18 threads
[2025-11-28 11:19:49] Scheduler hit an exception: Traceback (most recent call last):
File "/home/aigao/sglang/python/sglang/srt/managers/scheduler.py", line 2630, in run_scheduler_process
scheduler = Scheduler(
^^^^^^^^^^
File "/home/aigao/sglang/python/sglang/srt/managers/scheduler.py", line 309, 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 338, in __init__
self.initialize(min_per_gpu_memory)
File "/home/aigao/sglang/python/sglang/srt/model_executor/model_runner.py", line 442, in initialize
self.load_model()
File "/home/aigao/sglang/python/sglang/srt/model_executor/model_runner.py", line 806, 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 3394, in __init__
self.model = DeepseekV2Model(
^^^^^^^^^^^^^^^^
File "/home/aigao/sglang/python/sglang/srt/models/deepseek_v2.py", line 3172, in __init__
self.model = DeepseekV2Model(
File "/home/aigao/sglang/python/sglang/srt/utils/common.py", line 591, 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 593, in
layer_fn(idx=idx, prefix=add_prefix(idx, prefix))
File "/home/aigao/sglang/python/sglang/srt/models/deepseek_v2.py", line 3174, in
lambda idx, prefix: DeepseekV2DecoderLayer(
^^^^^^^^^^^^^^^^^^^^^^^
File "/home/aigao/sglang/python/sglang/srt/models/deepseek_v2.py", line 2895, in __init__
self.self_attn = DeepseekV2AttentionMLA(
^^^^^^^^^^^^^^^^^^^^^^^
File "/home/aigao/sglang/python/sglang/srt/models/deepseek_v2.py", line 1305, 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/unquant.py", line 108, in create_weights
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 23.56 GiB of which 109.50 MiB is free. Processtorch.OutOfMemoryError: CUDA out of memory. Tried to allocate 112.00 MiB. GPU 0 has a total capacity of 23.56 GiB of which 109.50 MiB is free. Process 4308 has 360.00 MiB memory in use. Including non-PyTorch memory, this process has 23.07 GiB memory in use. Of the allocated memory 22.72 GiB is alloc 4308 has 360.00 MiB memory in use. Including non-PyTorch memory, this process has 23.07 GiB memory in use. Of the allocated memory 22.72 GiB is alloca
```
### Others
Can kt-kernel support 24G DRAM? like kt 0.3.2?
If not, is mean only 1 n090 card can only use kt 0.3.2?
Contributor guide
Assessment
This issue has not been assessed yet.