[GH-ISSUE #1136] loading blk加载过慢,且出现numa_sched_setaffinity_v2_int() failed: Invalid argument #791

Open
opened 2026-10-29 14:44:33 +00:00 by bsakaguchi · 2 comments
Owner

Originally created by @daydayuptang on GitHub (Apr 14, 2025).
Original GitHub issue: https://github.com/kvcache-ai/ktransformers/issues/1136

Originally assigned to: @ErvinXie on GitHub.

我按照如下方式启动:
USE_NUMA=1 python ktransformers/server/main.py
--port 10002
--model_path /work/home/uptang14/DeepSeek-R1
--gguf_path /work/home/uptang14/DeepSeek-R1-GGUF/DeepSeek-R1-Q4_K_M
--optimize_config_path ktransformers/optimize/optimize_rules/DeepSeek-V3-Chat-serve.yaml
--max_new_tokens 1024
--cache_lens 32768
--chunk_size 256
--max_batch_size 4
--cpu_infer 32
--backend_type balance_serve
但是在加载过程中出现:numa_sched_setaffinity_v2_int() failed: Invalid argument
且加载刀blk.12就不动了,此过程持续2小时:
Image
Image

执行numactl --hardware:
available: 8 nodes (0-7)
node 0 cpus: 0 1 2 3 4 5 6 7
node 0 size: 262043 MB
node 0 free: 216468 MB
node 1 cpus: 8 9 10 11 12 13 14 15
node 1 size: 262143 MB
node 1 free: 216547 MB
node 2 cpus: 16 17 18 19 20 21 22 23
node 2 size: 262143 MB
node 2 free: 209068 MB
node 3 cpus: 24 25 26 27 28 29 30 31
node 3 size: 249855 MB
node 3 free: 208122 MB
node 4 cpus: 32 33 34 35 36 37 38 39
node 4 size: 262143 MB
node 4 free: 215227 MB
node 5 cpus: 40 41 42 43 44 45 46 47
node 5 size: 262143 MB
node 5 free: 214383 MB
node 6 cpus: 48 49 50 51 52 53 54 55
node 6 size: 262143 MB
node 6 free: 215844 MB
node 7 cpus: 56 57 58 59 60 61 62 63
node 7 size: 262143 MB
node 7 free: 120269 MB
node distances:
node 0 1 2 3 4 5 6 7
0: 10 16 16 16 28 28 22 28
1: 16 10 16 16 28 28 28 22
2: 16 16 10 16 22 28 28 28
3: 16 16 16 10 28 22 28 28
4: 28 28 22 28 10 16 16 16
5: 28 28 28 22 16 10 16 16
6: 22 28 28 28 16 16 10 16
7: 28 22 28 28 16 16 16 10

Originally created by @daydayuptang on GitHub (Apr 14, 2025). Original GitHub issue: https://github.com/kvcache-ai/ktransformers/issues/1136 Originally assigned to: @ErvinXie on GitHub. 我按照如下方式启动: USE_NUMA=1 python ktransformers/server/main.py \ --port 10002 \ --model_path /work/home/uptang14/DeepSeek-R1 \ --gguf_path /work/home/uptang14/DeepSeek-R1-GGUF/DeepSeek-R1-Q4_K_M \ --optimize_config_path ktransformers/optimize/optimize_rules/DeepSeek-V3-Chat-serve.yaml \ --max_new_tokens 1024 \ --cache_lens 32768 \ --chunk_size 256 \ --max_batch_size 4 \ --cpu_infer 32 \ --backend_type balance_serve 但是在加载过程中出现:numa_sched_setaffinity_v2_int() failed: Invalid argument 且加载刀blk.12就不动了,此过程持续2小时: <img width="247" alt="Image" src="https://github.com/user-attachments/assets/2bbe4096-e3af-4a5f-a0e3-059049a5c3c3" /> <img width="297" alt="Image" src="https://github.com/user-attachments/assets/70304256-5242-4323-8ce8-94f61a25aa60" /> 执行numactl --hardware: available: 8 nodes (0-7) node 0 cpus: 0 1 2 3 4 5 6 7 node 0 size: 262043 MB node 0 free: 216468 MB node 1 cpus: 8 9 10 11 12 13 14 15 node 1 size: 262143 MB node 1 free: 216547 MB node 2 cpus: 16 17 18 19 20 21 22 23 node 2 size: 262143 MB node 2 free: 209068 MB node 3 cpus: 24 25 26 27 28 29 30 31 node 3 size: 249855 MB node 3 free: 208122 MB node 4 cpus: 32 33 34 35 36 37 38 39 node 4 size: 262143 MB node 4 free: 215227 MB node 5 cpus: 40 41 42 43 44 45 46 47 node 5 size: 262143 MB node 5 free: 214383 MB node 6 cpus: 48 49 50 51 52 53 54 55 node 6 size: 262143 MB node 6 free: 215844 MB node 7 cpus: 56 57 58 59 60 61 62 63 node 7 size: 262143 MB node 7 free: 120269 MB node distances: node 0 1 2 3 4 5 6 7 0: 10 16 16 16 28 28 22 28 1: 16 10 16 16 28 28 28 22 2: 16 16 10 16 22 28 28 28 3: 16 16 16 10 28 22 28 28 4: 28 28 22 28 10 16 16 16 5: 28 28 28 22 16 10 16 16 6: 22 28 28 28 16 16 10 16 7: 28 22 28 28 16 16 16 10
Author
Owner

@ErvinXie commented on GitHub (Apr 14, 2025):

你好,我们现在这个版本的 NUMA 会复制权重各一份到每一个 NUMA 上,因此需要每个 NUMA 都有足够的内存。如果是多 NUMA 的机器,可以在 BIOS 当中设置,尽量减少 NUMA 的数量,然后再运行 ktransformers。

<!-- gh-comment-id:2800819870 --> @ErvinXie commented on GitHub (Apr 14, 2025): 你好,我们现在这个版本的 NUMA 会复制权重各一份到每一个 NUMA 上,因此需要每个 NUMA 都有足够的内存。如果是多 NUMA 的机器,可以在 BIOS 当中设置,尽量减少 NUMA 的数量,然后再运行 ktransformers。
Author
Owner

@daydayuptang commented on GitHub (Apr 18, 2025):

感谢您的回复,由于使用的是服务器配置无法在BIOS里进行更改,因此使用env USE_NUMA=1 \ numactl --cpunodebind=0-3,4-7 --interleave=0-3,4-7 \ python ktransformers/server/main.py \ --port 10002 \ --model_path /work/home/uptang14/DeepSeek-R1 \ --gguf_path /work/home/uptang14/DeepSeek-R1-GGUF/DeepSeek-R1-Q4_K_M \ --optimize_config_path ktransformers/optimize/optimize_rules/DeepSeek-V3-Chat-serve.yaml \ --max_new_tokens 1024 \ --cache_lens 32768 \ --chunk_size 256 \ --max_batch_size 4 \ --cpu_infer 32 \ --backend_type balance_serve \ --force_think
指令将8个numa节点逻辑合成四个。但是问题仍然相同,未解决。

值得注意的是,这条指令中修改cup_infer为24,即env USE_NUMA=1 \ numactl --cpunodebind=0-3,4-7 --interleave=0-3,4-7 \ python ktransformers/server/main.py \ --port 10002 \ --model_path /work/home/uptang14/DeepSeek-R1 \ --gguf_path /work/home/uptang14/DeepSeek-R1-GGUF/DeepSeek-R1-Q4_K_M \ --optimize_config_path ktransformers/optimize/optimize_rules/DeepSeek-V3-Chat-serve.yaml \ --max_new_tokens 1024 \ --cache_lens 32768 \ --chunk_size 256 \ --max_batch_size 4 \ --cpu_infer 24 \ --backend_type balance_serve \ --force_think则报错如下:loading token_embd.weight to cpu
loading token_embd.weight to cpu
loading token_embd.weight with CPU
loading blk.0.attn_q_a_norm.weight to cuda
loading blk.0.attn_kv_a_norm.weight to cuda
loading blk.0.attn_kv_b.weight to cuda:0
loading blk.0.attn_norm.weight to cuda
loading blk.0.ffn_norm.weight to cuda
loading blk.1.attn_q_a_norm.weight to cuda
loading blk.1.attn_kv_a_norm.weight to cuda
loading blk.1.attn_kv_b.weight to cuda:0
loading blk.1.attn_norm.weight to cuda
loading blk.1.ffn_norm.weight to cuda
loading blk.2.attn_q_a_norm.weight to cuda
loading blk.2.attn_kv_a_norm.weight to cuda
loading blk.2.attn_kv_b.weight to cuda:0
loading blk.2.attn_norm.weight to cuda
loading blk.2.ffn_norm.weight to cuda
loading blk.3.attn_q_a_norm.weight to cuda
loading blk.3.attn_kv_a_norm.weight to cuda
loading blk.3.attn_kv_b.weight to cuda:0
Process SpawnProcess-1:
Traceback (most recent call last):
File "/opt/conda/envs/kt/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap
self.run()
File "/opt/conda/envs/kt/lib/python3.11/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "/opt/conda/envs/kt/lib/python3.11/site-packages/ktransformers/server/backend/interfaces/balance_serve.py", line 244, in run_engine
engine = Engine(args, token_queue, broadcast_endpoint)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/envs/kt/lib/python3.11/site-packages/ktransformers/server/backend/interfaces/balance_serve.py", line 162, in init
optimize_and_load_gguf(self.model, optimize_config_path, gguf_path, config)
File "/opt/conda/envs/kt/lib/python3.11/site-packages/ktransformers/optimize/optimize.py", line 131, in optimize_and_load_gguf
load_weights(module, gguf_loader)
File "/opt/conda/envs/kt/lib/python3.11/site-packages/ktransformers/util/utils.py", line 125, in load_weights
load_weights(child, gguf_loader, prefix+name+".")
File "/opt/conda/envs/kt/lib/python3.11/site-packages/ktransformers/util/utils.py", line 127, in load_weights
module.load()
File "/opt/conda/envs/kt/lib/python3.11/site-packages/ktransformers/operators/base_operator.py", line 63, in load
utils.load_weights(child, self.gguf_loader, self.key+".")
File "/opt/conda/envs/kt/lib/python3.11/site-packages/ktransformers/util/utils.py", line 125, in load_weights
load_weights(child, gguf_loader, prefix+name+".")
File "/opt/conda/envs/kt/lib/python3.11/site-packages/ktransformers/util/utils.py", line 125, in load_weights
load_weights(child, gguf_loader, prefix+name+".")
File "/opt/conda/envs/kt/lib/python3.11/site-packages/ktransformers/util/utils.py", line 125, in load_weights
load_weights(child, gguf_loader, prefix+name+".")
File "/opt/conda/envs/kt/lib/python3.11/site-packages/ktransformers/util/utils.py", line 127, in load_weights
module.load()
File "/opt/conda/envs/kt/lib/python3.11/site-packages/ktransformers/operators/base_operator.py", line 63, in load
utils.load_weights(child, self.gguf_loader, self.key+".")
File "/opt/conda/envs/kt/lib/python3.11/site-packages/ktransformers/util/utils.py", line 125, in load_weights
load_weights(child, gguf_loader, prefix+name+".")
File "/opt/conda/envs/kt/lib/python3.11/site-packages/ktransformers/util/utils.py", line 127, in load_weights
module.load()
File "/opt/conda/envs/kt/lib/python3.11/site-packages/ktransformers/operators/experts.py", line 1192, in load
self.generate_experts.load(w, warmup=warmup)
File "/opt/conda/envs/kt/lib/python3.11/site-packages/ktransformers/operators/experts.py", line 185, in load
self.moe = MOE(moe_config)
^^^^^^^^^^^^^^^
KeyboardInterrupt

numa_sched_setaffinity_v2_int() failed: Invalid argument
numa_sched_setaffinity_v2_int() failed: Invalid argument
numa_sched_setaffinity_v2_int() failed: Invalid argument
numa_sched_setaffinity_v2_int() failed: Invalid argument
numa_sched_setaffinity_v2_int() failed: Invalid argument
numa_sched_setaffinity_v2_int() failed: Invalid argument
numa_sched_setaffinity_v2_int() failed: Invalid argument
numa_sched_setaffinity_v2_int() failed: Invalid argument
numa_sched_setaffinity_v2_int() failed: Invalid argument
numa_sched_setaffinity_v2_int() failed: Invalid argument
numa_sched_setaffinity_v2_int() failed: Invalid argument
numa_sched_setaffinity_v2_int() failed: Invalid argument
numa_sched_setaffinity_v2_int() failed: Invalid argument
numa_sched_setaffinity_v2_int() failed: Invalid argument
numa_sched_setaffinity_v2_int() failed: Invalid argument
numa_sched_setaffinity_v2_int() failed: Invalid argument
numa_sched_setaffinity_v2_int() failed: Invalid argument
numa_sched_setaffinity_v2_int() failed: Invalid argument
numa_sched_setaffinity_v2_int() failed: Invalid argument
numa_sched_setaffinity_v2_int() failed: Invalid argument
numa_sched_setaffinity_v2_int() failed: Invalid argument
loading blk.3.attn_norm.weight to cuda
loading blk.3.ffn_norm.weight to cuda
loading blk.4.attn_q_a_norm.weight to cuda
loading blk.4.attn_kv_a_norm.weight to cuda
loading blk.4.attn_kv_b.weight to cuda:0
...

<!-- gh-comment-id:2814819310 --> @daydayuptang commented on GitHub (Apr 18, 2025): 感谢您的回复,由于使用的是服务器配置无法在BIOS里进行更改,因此使用`env USE_NUMA=1 \ numactl --cpunodebind=0-3,4-7 --interleave=0-3,4-7 \ python ktransformers/server/main.py \ --port 10002 \ --model_path /work/home/uptang14/DeepSeek-R1 \ --gguf_path /work/home/uptang14/DeepSeek-R1-GGUF/DeepSeek-R1-Q4_K_M \ --optimize_config_path ktransformers/optimize/optimize_rules/DeepSeek-V3-Chat-serve.yaml \ --max_new_tokens 1024 \ --cache_lens 32768 \ --chunk_size 256 \ --max_batch_size 4 \ --cpu_infer 32 \ --backend_type balance_serve \ --force_think` 指令将8个numa节点逻辑合成四个。**但是问题仍然相同,未解决**。 值得注意的是,这条指令中修改cup_infer为24,即`env USE_NUMA=1 \ numactl --cpunodebind=0-3,4-7 --interleave=0-3,4-7 \ python ktransformers/server/main.py \ --port 10002 \ --model_path /work/home/uptang14/DeepSeek-R1 \ --gguf_path /work/home/uptang14/DeepSeek-R1-GGUF/DeepSeek-R1-Q4_K_M \ --optimize_config_path ktransformers/optimize/optimize_rules/DeepSeek-V3-Chat-serve.yaml \ --max_new_tokens 1024 \ --cache_lens 32768 \ --chunk_size 256 \ --max_batch_size 4 \ --cpu_infer 24 \ --backend_type balance_serve \ --force_think`则报错如下:loading token_embd.weight to cpu loading token_embd.weight to cpu loading token_embd.weight with CPU loading blk.0.attn_q_a_norm.weight to cuda loading blk.0.attn_kv_a_norm.weight to cuda loading blk.0.attn_kv_b.weight to cuda:0 loading blk.0.attn_norm.weight to cuda loading blk.0.ffn_norm.weight to cuda loading blk.1.attn_q_a_norm.weight to cuda loading blk.1.attn_kv_a_norm.weight to cuda loading blk.1.attn_kv_b.weight to cuda:0 loading blk.1.attn_norm.weight to cuda loading blk.1.ffn_norm.weight to cuda loading blk.2.attn_q_a_norm.weight to cuda loading blk.2.attn_kv_a_norm.weight to cuda loading blk.2.attn_kv_b.weight to cuda:0 loading blk.2.attn_norm.weight to cuda loading blk.2.ffn_norm.weight to cuda loading blk.3.attn_q_a_norm.weight to cuda loading blk.3.attn_kv_a_norm.weight to cuda loading blk.3.attn_kv_b.weight to cuda:0 Process SpawnProcess-1: Traceback (most recent call last): File "/opt/conda/envs/kt/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap self.run() File "/opt/conda/envs/kt/lib/python3.11/multiprocessing/process.py", line 108, in run self._target(*self._args, **self._kwargs) File "/opt/conda/envs/kt/lib/python3.11/site-packages/ktransformers/server/backend/interfaces/balance_serve.py", line 244, in run_engine engine = Engine(args, token_queue, broadcast_endpoint) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/conda/envs/kt/lib/python3.11/site-packages/ktransformers/server/backend/interfaces/balance_serve.py", line 162, in __init__ optimize_and_load_gguf(self.model, optimize_config_path, gguf_path, config) File "/opt/conda/envs/kt/lib/python3.11/site-packages/ktransformers/optimize/optimize.py", line 131, in optimize_and_load_gguf load_weights(module, gguf_loader) File "/opt/conda/envs/kt/lib/python3.11/site-packages/ktransformers/util/utils.py", line 125, in load_weights load_weights(child, gguf_loader, prefix+name+".") File "/opt/conda/envs/kt/lib/python3.11/site-packages/ktransformers/util/utils.py", line 127, in load_weights module.load() File "/opt/conda/envs/kt/lib/python3.11/site-packages/ktransformers/operators/base_operator.py", line 63, in load utils.load_weights(child, self.gguf_loader, self.key+".") File "/opt/conda/envs/kt/lib/python3.11/site-packages/ktransformers/util/utils.py", line 125, in load_weights load_weights(child, gguf_loader, prefix+name+".") File "/opt/conda/envs/kt/lib/python3.11/site-packages/ktransformers/util/utils.py", line 125, in load_weights load_weights(child, gguf_loader, prefix+name+".") File "/opt/conda/envs/kt/lib/python3.11/site-packages/ktransformers/util/utils.py", line 125, in load_weights load_weights(child, gguf_loader, prefix+name+".") File "/opt/conda/envs/kt/lib/python3.11/site-packages/ktransformers/util/utils.py", line 127, in load_weights module.load() File "/opt/conda/envs/kt/lib/python3.11/site-packages/ktransformers/operators/base_operator.py", line 63, in load utils.load_weights(child, self.gguf_loader, self.key+".") File "/opt/conda/envs/kt/lib/python3.11/site-packages/ktransformers/util/utils.py", line 125, in load_weights load_weights(child, gguf_loader, prefix+name+".") File "/opt/conda/envs/kt/lib/python3.11/site-packages/ktransformers/util/utils.py", line 127, in load_weights module.load() File "/opt/conda/envs/kt/lib/python3.11/site-packages/ktransformers/operators/experts.py", line 1192, in load self.generate_experts.load(w, warmup=warmup) File "/opt/conda/envs/kt/lib/python3.11/site-packages/ktransformers/operators/experts.py", line 185, in load self.moe = MOE(moe_config) ^^^^^^^^^^^^^^^ KeyboardInterrupt numa_sched_setaffinity_v2_int() failed: Invalid argument numa_sched_setaffinity_v2_int() failed: Invalid argument numa_sched_setaffinity_v2_int() failed: Invalid argument numa_sched_setaffinity_v2_int() failed: Invalid argument numa_sched_setaffinity_v2_int() failed: Invalid argument numa_sched_setaffinity_v2_int() failed: Invalid argument numa_sched_setaffinity_v2_int() failed: Invalid argument numa_sched_setaffinity_v2_int() failed: Invalid argument numa_sched_setaffinity_v2_int() failed: Invalid argument numa_sched_setaffinity_v2_int() failed: Invalid argument numa_sched_setaffinity_v2_int() failed: Invalid argument numa_sched_setaffinity_v2_int() failed: Invalid argument numa_sched_setaffinity_v2_int() failed: Invalid argument numa_sched_setaffinity_v2_int() failed: Invalid argument numa_sched_setaffinity_v2_int() failed: Invalid argument numa_sched_setaffinity_v2_int() failed: Invalid argument numa_sched_setaffinity_v2_int() failed: Invalid argument numa_sched_setaffinity_v2_int() failed: Invalid argument numa_sched_setaffinity_v2_int() failed: Invalid argument numa_sched_setaffinity_v2_int() failed: Invalid argument numa_sched_setaffinity_v2_int() failed: Invalid argument loading blk.3.attn_norm.weight to cuda loading blk.3.ffn_norm.weight to cuda loading blk.4.attn_q_a_norm.weight to cuda loading blk.4.attn_kv_a_norm.weight to cuda loading blk.4.attn_kv_b.weight to cuda:0 ...
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#791
No description provided.