[GH-ISSUE #1286] [Bug] inference_context.v_cache[0][i] IndexError: list index out of range #871

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

Originally created by @coderjingluo on GitHub (May 13, 2025).
Original GitHub issue: https://github.com/kvcache-ai/ktransformers/issues/1286

检查清单

  • 1. 我已经搜索过相关问题,但未能获得预期的帮助
  • 2. 该问题在最新版本中尚未修复
  • 3. 请注意,如果您提交的BUG相关 issue 缺少对应环境信息和最小可复现示例,我们将难以复现和定位问题,降低获得反馈的可能性
  • 4. 如果您提出的不是bug而是问题,请在讨论区发起讨论 https://github.com/kvcache-ai/ktransformers/discussions。否则该 issue 将被关闭
  • 5. 为方便社区交流,我将使用中文/英文或附上中文/英文翻译(如使用其他语言)。未附带翻译的非中文/英语内容可能会被关闭

问题描述

Deploying qwen3-235-a22b-q4 with ktransformers reports an error

Image

复现步骤

Use USE_BALANCE_SERVE=1 KTRANSFORMERS_FORCE_BUILD=TRUE MAX_JOBS=50 TORCH_USE_CUDA_DSA=1 TORCH_CUDA_ARCH_LIST="8.6" . After /install.sh has been compiled successfully

python ktransformers/server/main.py --architectures Qwen3MoeForCausalLm --model_path /home/user/aimodel/models/lmstudio-community/config --gguf_path /home/user/aimodel/models/lmstudio-community/Qwen3-235B-A22B-GGUF --optimize_config_path ktransformers/optimize/optimize_rules/Qwen3Moe-serve.yaml --port 10002 --use_cuda_graph --cpu_infer 54 --chunk_size 512 --max_new_tokens 10240 --max_batch_size 4 --cache_lens 4096 --cache_q4 true --backend_type balance_serve

Image

环境信息

Image

Originally created by @coderjingluo on GitHub (May 13, 2025). Original GitHub issue: https://github.com/kvcache-ai/ktransformers/issues/1286 ### 检查清单 - [x] 1. 我已经搜索过相关问题,但未能获得预期的帮助 - [x] 2. 该问题在最新版本中尚未修复 - [ ] 3. 请注意,如果您提交的BUG相关 issue 缺少对应环境信息和最小可复现示例,我们将难以复现和定位问题,降低获得反馈的可能性 - [ ] 4. 如果您提出的不是bug而是问题,请在讨论区发起讨论 https://github.com/kvcache-ai/ktransformers/discussions。否则该 issue 将被关闭 - [ ] 5. 为方便社区交流,我将使用中文/英文或附上中文/英文翻译(如使用其他语言)。未附带翻译的非中文/英语内容可能会被关闭 ### 问题描述 Deploying qwen3-235-a22b-q4 with ktransformers reports an error ![Image](https://github.com/user-attachments/assets/557146c8-a277-4c55-ab14-50f8a25212cc) ### 复现步骤 Use USE_BALANCE_SERVE=1 KTRANSFORMERS_FORCE_BUILD=TRUE MAX_JOBS=50 TORCH_USE_CUDA_DSA=1 TORCH_CUDA_ARCH_LIST="8.6" . After /install.sh has been compiled successfully python ktransformers/server/main.py --architectures Qwen3MoeForCausalLm --model_path /home/user/aimodel/models/lmstudio-community/config --gguf_path /home/user/aimodel/models/lmstudio-community/Qwen3-235B-A22B-GGUF --optimize_config_path ktransformers/optimize/optimize_rules/Qwen3Moe-serve.yaml --port 10002 --use_cuda_graph --cpu_infer 54 --chunk_size 512 --max_new_tokens 10240 --max_batch_size 4 --cache_lens 4096 --cache_q4 true --backend_type balance_serve ![Image](https://github.com/user-attachments/assets/c5ce6255-48cb-42b1-8886-a8bc4c5ecfbe) ### 环境信息 ![Image](https://github.com/user-attachments/assets/ab835f75-0010-4dd7-94aa-10421a5455a5)
Author
Owner

@qiyuxinlin commented on GitHub (May 13, 2025):

@coderjingluo 您好,这是最新代码吗?我知道您这个报错是因为 --architectures Qwen3MoeForCausaLlm 参数不对,但是最新的代码我删掉了这个参数

Image

<!-- gh-comment-id:2876024553 --> @qiyuxinlin commented on GitHub (May 13, 2025): @coderjingluo 您好,这是最新代码吗?我知道您这个报错是因为 --architectures Qwen3MoeForCausaLlm 参数不对,但是最新的代码我删掉了这个参数 ![Image](https://github.com/user-attachments/assets/25804fa1-c22f-4216-b75f-9a9d62d968ed)
Author
Owner

@coderjingluo commented on GitHub (May 13, 2025):

@coderjingluo 您好,这是最新代码吗?我知道您这个报错是因为 --architectures Qwen3MoeForCausaLlm 参数不对,但是最新的代码我删掉了这个参数

Image

这个问题解决,不过好像又有新的问题

2025-05-13 12:41:06,232 - INFO - flashinfer.jit: Loading JIT ops: batch_prefill_with_kv_cache_dtype_q_bf16_dtype_kv_bf16_dtype_o_bf16_dtype_idx_i32_head_dim_qk_128_head_dim_vo_128_posenc_0_use_swa_False_use_logits_cap_False_f16qk_False
2025-05-13 12:41:06,246 - INFO - flashinfer.jit: Finished loading JIT ops: batch_prefill_with_kv_cache_dtype_q_bf16_dtype_kv_bf16_dtype_o_bf16_dtype_idx_i32_head_dim_qk_128_head_dim_vo_128_posenc_0_use_swa_False_use_logits_cap_False_f16qk_False
2025-05-13 12:41:06,629 - INFO - flashinfer.jit: Loading JIT ops: norm
2025-05-13 12:41:06,641 - INFO - flashinfer.jit: Finished loading JIT ops: norm
2025-05-13 12:41:06,748 - INFO - flashinfer.jit: Loading JIT ops: page
2025-05-13 12:41:06,759 - INFO - flashinfer.jit: Finished loading JIT ops: page
cuda_graph: 1/8, warmup finished.
capturing cuda graph 2 2
cuda_graph: 2/8, warmup finished.
capturing cuda graph 3 3
cuda_graph: 3/8, warmup finished.
capturing cuda graph 1 1
cuda_graph: 4/8, warmup finished.
capturing cuda graph 4 64
Process SpawnProcess-1:
Traceback (most recent call last):
File "/home/user/anaconda3/envs/kt311/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap
self.run()
File "/home/user/anaconda3/envs/kt311/lib/python3.11/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/server/backend/interfaces/balance_serve.py", line 279, in run_engine
engine.model_runner.warmup()
File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/server/balance_serve/inference/model_runner.py", line 148, in warmup
self.outputs_buf[i] = self.model(self.input[i], self.features_buf[i], self.bsz_tensor_buf, self.num_tokens_tensor_buf, self.page_idx_buf[i], self.page_offset_buf[i], cuda_graph_idx=i)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/models/custom_modeling_qwen3_moe.py", line 109, in forward
hidden_states = decode_layer.mlp(hidden_states.unsqueeze(0), num_tokens_tensors, cuda_graph_idx)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/operators/experts.py", line 1438, in forward
y = self.moe_on_cpuinfer(hidden_states, selected_experts, routing_weights, bsz_tensor, cuda_graph_idx).view(*orig_shape).to(device=hidden_states.device)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/operators/experts.py", line 1459, in moe_on_cpuinfer
outs = self.experts(x, topk_ids, topk_weight, bsz_tensor, cuda_graph_idx)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/operators/experts.py", line 1272, in forward
return self.generate_experts.forward(input_tensor, expert_ids, weights, bsz_tensor, cuda_graph_idx)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/operators/experts.py", line 311, in forward
input_tensor = input_tensor.contiguous().cpu()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: CUDA error: an illegal memory access was encountered
CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1
Compile with TORCH_USE_CUDA_DSA to enable device-side assertions.

terminate called after throwing an instance of 'c10::Error'
what(): CUDA error: an illegal memory access was encountered
CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1
Compile with TORCH_USE_CUDA_DSA to enable device-side assertions.

Exception raised from c10_cuda_check_implementation at /pytorch/c10/cuda/CUDAException.cpp:43 (most recent call first):
frame #0: c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits, std::allocator >) + 0x98 (0x7f6acdd785e8 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10.so)
frame #1: c10::detail::torchCheckFail(char const*, char const*, unsigned int, std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&) + 0xe0 (0x7f6acdd0d4a2 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10.so)
frame #2: c10::cuda::c10_cuda_check_implementation(int, char const*, char const*, int, bool) + 0x3c2 (0x7f6ace145422 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10_cuda.so)
frame #3: + 0x32953 (0x7f6ace121953 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10_cuda.so)
frame #4: + 0x32b01 (0x7f6ace121b01 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10_cuda.so)
frame #5: + 0x66c7f2 (0x7f6ac59bb7f2 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libtorch_python.so)
frame #6: + 0x457608 (0x7f6ac57a6608 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libtorch_python.so)
frame #7: + 0x7b385 (0x7f6acdd59385 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10.so)
frame #8: c10::TensorImpl::~TensorImpl() + 0x9 (0x7f6acdd52f39 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10.so)
frame #9: + 0x7182b8 (0x7f6ac5a672b8 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libtorch_python.so)
frame #10: + 0x7186d1 (0x7f6ac5a676d1 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libtorch_python.so)
frame #11: /home/user/anaconda3/envs/kt311/bin/python() [0x4f5eb7]
frame #12: /home/user/anaconda3/envs/kt311/bin/python() [0x5031bf]
frame #13: /home/user/anaconda3/envs/kt311/bin/python() [0x55f246]
frame #14: /home/user/anaconda3/envs/kt311/bin/python() [0x50302a]
frame #15: /home/user/anaconda3/envs/kt311/bin/python() [0x5031bf]
frame #16: /home/user/anaconda3/envs/kt311/bin/python() [0x55f246]
frame #17: /home/user/anaconda3/envs/kt311/bin/python() [0x55ef87]
frame #18: /home/user/anaconda3/envs/kt311/bin/python() [0x55f040]
frame #19: /home/user/anaconda3/envs/kt311/bin/python() [0x541355]
frame #20: /home/user/anaconda3/envs/kt311/bin/python() [0x53fd88]
frame #21: /home/user/anaconda3/envs/kt311/bin/python() [0x53fdc4]
frame #22: /home/user/anaconda3/envs/kt311/bin/python() [0x53fdc4]
frame #23: /home/user/anaconda3/envs/kt311/bin/python() [0x54e833]
frame #24: _PyEval_EvalFrameDefault + 0x46f9 (0x515ac9 in /home/user/anaconda3/envs/kt311/bin/python)
frame #25: /home/user/anaconda3/envs/kt311/bin/python() [0x5cc3aa]
frame #26: PyEval_EvalCode + 0x9f (0x5cba7f in /home/user/anaconda3/envs/kt311/bin/python)
frame #27: /home/user/anaconda3/envs/kt311/bin/python() [0x5ecba7]
frame #28: /home/user/anaconda3/envs/kt311/bin/python() [0x5e8740]
frame #29: PyRun_StringFlags + 0x5f (0x5db24f in /home/user/anaconda3/envs/kt311/bin/python)
frame #30: PyRun_SimpleStringFlags + 0x3b (0x5daffb in /home/user/anaconda3/envs/kt311/bin/python)
frame #31: Py_RunMain + 0x388 (0x5f7498 in /home/user/anaconda3/envs/kt311/bin/python)
frame #32: Py_BytesMain + 0x39 (0x5bc149 in /home/user/anaconda3/envs/kt311/bin/python)
frame #33: + 0x29d90 (0x7f6ad082ad90 in /lib/x86_64-linux-gnu/libc.so.6)
frame #34: __libc_start_main + 0x80 (0x7f6ad082ae40 in /lib/x86_64-linux-gnu/libc.so.6)
frame #35: /home/user/anaconda3/envs/kt311/bin/python() [0x5bbf9

Image

<!-- gh-comment-id:2876356157 --> @coderjingluo commented on GitHub (May 13, 2025): > [@coderjingluo](https://github.com/coderjingluo) 您好,这是最新代码吗?我知道您这个报错是因为 --architectures Qwen3MoeForCausaLlm 参数不对,但是最新的代码我删掉了这个参数 > > ![Image](https://github.com/user-attachments/assets/25804fa1-c22f-4216-b75f-9a9d62d968ed) 这个问题解决,不过好像又有新的问题 2025-05-13 12:41:06,232 - INFO - flashinfer.jit: Loading JIT ops: batch_prefill_with_kv_cache_dtype_q_bf16_dtype_kv_bf16_dtype_o_bf16_dtype_idx_i32_head_dim_qk_128_head_dim_vo_128_posenc_0_use_swa_False_use_logits_cap_False_f16qk_False 2025-05-13 12:41:06,246 - INFO - flashinfer.jit: Finished loading JIT ops: batch_prefill_with_kv_cache_dtype_q_bf16_dtype_kv_bf16_dtype_o_bf16_dtype_idx_i32_head_dim_qk_128_head_dim_vo_128_posenc_0_use_swa_False_use_logits_cap_False_f16qk_False 2025-05-13 12:41:06,629 - INFO - flashinfer.jit: Loading JIT ops: norm 2025-05-13 12:41:06,641 - INFO - flashinfer.jit: Finished loading JIT ops: norm 2025-05-13 12:41:06,748 - INFO - flashinfer.jit: Loading JIT ops: page 2025-05-13 12:41:06,759 - INFO - flashinfer.jit: Finished loading JIT ops: page cuda_graph: 1/8, warmup finished. capturing cuda graph 2 2 cuda_graph: 2/8, warmup finished. capturing cuda graph 3 3 cuda_graph: 3/8, warmup finished. capturing cuda graph 1 1 cuda_graph: 4/8, warmup finished. capturing cuda graph 4 64 Process SpawnProcess-1: Traceback (most recent call last): File "/home/user/anaconda3/envs/kt311/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap self.run() File "/home/user/anaconda3/envs/kt311/lib/python3.11/multiprocessing/process.py", line 108, in run self._target(*self._args, **self._kwargs) File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/server/backend/interfaces/balance_serve.py", line 279, in run_engine engine.model_runner.warmup() File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/server/balance_serve/inference/model_runner.py", line 148, in warmup self.outputs_buf[i] = self.model(self.input[i], self.features_buf[i], self.bsz_tensor_buf, self.num_tokens_tensor_buf, self.page_idx_buf[i], self.page_offset_buf[i], cuda_graph_idx=i) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/models/custom_modeling_qwen3_moe.py", line 109, in forward hidden_states = decode_layer.mlp(hidden_states.unsqueeze(0), num_tokens_tensors, cuda_graph_idx) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/operators/experts.py", line 1438, in forward y = self.moe_on_cpuinfer(hidden_states, selected_experts, routing_weights, bsz_tensor, cuda_graph_idx).view(*orig_shape).to(device=hidden_states.device) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/operators/experts.py", line 1459, in moe_on_cpuinfer outs = self.experts(x, topk_ids, topk_weight, bsz_tensor, cuda_graph_idx) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/operators/experts.py", line 1272, in forward return self.generate_experts.forward(input_tensor, expert_ids, weights, bsz_tensor, cuda_graph_idx) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/operators/experts.py", line 311, in forward input_tensor = input_tensor.contiguous().cpu() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RuntimeError: CUDA error: an illegal memory access was encountered CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect. For debugging consider passing CUDA_LAUNCH_BLOCKING=1 Compile with `TORCH_USE_CUDA_DSA` to enable device-side assertions. terminate called after throwing an instance of 'c10::Error' what(): CUDA error: an illegal memory access was encountered CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect. For debugging consider passing CUDA_LAUNCH_BLOCKING=1 Compile with `TORCH_USE_CUDA_DSA` to enable device-side assertions. Exception raised from c10_cuda_check_implementation at /pytorch/c10/cuda/CUDAException.cpp:43 (most recent call first): frame #0: c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) + 0x98 (0x7f6acdd785e8 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10.so) frame #1: c10::detail::torchCheckFail(char const*, char const*, unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) + 0xe0 (0x7f6acdd0d4a2 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10.so) frame #2: c10::cuda::c10_cuda_check_implementation(int, char const*, char const*, int, bool) + 0x3c2 (0x7f6ace145422 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10_cuda.so) frame #3: <unknown function> + 0x32953 (0x7f6ace121953 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10_cuda.so) frame #4: <unknown function> + 0x32b01 (0x7f6ace121b01 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10_cuda.so) frame #5: <unknown function> + 0x66c7f2 (0x7f6ac59bb7f2 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libtorch_python.so) frame #6: <unknown function> + 0x457608 (0x7f6ac57a6608 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libtorch_python.so) frame #7: <unknown function> + 0x7b385 (0x7f6acdd59385 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10.so) frame #8: c10::TensorImpl::~TensorImpl() + 0x9 (0x7f6acdd52f39 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10.so) frame #9: <unknown function> + 0x7182b8 (0x7f6ac5a672b8 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libtorch_python.so) frame #10: <unknown function> + 0x7186d1 (0x7f6ac5a676d1 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libtorch_python.so) frame #11: /home/user/anaconda3/envs/kt311/bin/python() [0x4f5eb7] frame #12: /home/user/anaconda3/envs/kt311/bin/python() [0x5031bf] frame #13: /home/user/anaconda3/envs/kt311/bin/python() [0x55f246] frame #14: /home/user/anaconda3/envs/kt311/bin/python() [0x50302a] frame #15: /home/user/anaconda3/envs/kt311/bin/python() [0x5031bf] frame #16: /home/user/anaconda3/envs/kt311/bin/python() [0x55f246] frame #17: /home/user/anaconda3/envs/kt311/bin/python() [0x55ef87] frame #18: /home/user/anaconda3/envs/kt311/bin/python() [0x55f040] frame #19: /home/user/anaconda3/envs/kt311/bin/python() [0x541355] frame #20: /home/user/anaconda3/envs/kt311/bin/python() [0x53fd88] frame #21: /home/user/anaconda3/envs/kt311/bin/python() [0x53fdc4] frame #22: /home/user/anaconda3/envs/kt311/bin/python() [0x53fdc4] frame #23: /home/user/anaconda3/envs/kt311/bin/python() [0x54e833] frame #24: _PyEval_EvalFrameDefault + 0x46f9 (0x515ac9 in /home/user/anaconda3/envs/kt311/bin/python) frame #25: /home/user/anaconda3/envs/kt311/bin/python() [0x5cc3aa] frame #26: PyEval_EvalCode + 0x9f (0x5cba7f in /home/user/anaconda3/envs/kt311/bin/python) frame #27: /home/user/anaconda3/envs/kt311/bin/python() [0x5ecba7] frame #28: /home/user/anaconda3/envs/kt311/bin/python() [0x5e8740] frame #29: PyRun_StringFlags + 0x5f (0x5db24f in /home/user/anaconda3/envs/kt311/bin/python) frame #30: PyRun_SimpleStringFlags + 0x3b (0x5daffb in /home/user/anaconda3/envs/kt311/bin/python) frame #31: Py_RunMain + 0x388 (0x5f7498 in /home/user/anaconda3/envs/kt311/bin/python) frame #32: Py_BytesMain + 0x39 (0x5bc149 in /home/user/anaconda3/envs/kt311/bin/python) frame #33: <unknown function> + 0x29d90 (0x7f6ad082ad90 in /lib/x86_64-linux-gnu/libc.so.6) frame #34: __libc_start_main + 0x80 (0x7f6ad082ae40 in /lib/x86_64-linux-gnu/libc.so.6) frame #35: /home/user/anaconda3/envs/kt311/bin/python() [0x5bbf9 ![Image](https://github.com/user-attachments/assets/655518cb-7cdf-45e1-857f-c93412638b37)
Author
Owner

@qiyuxinlin commented on GitHub (May 13, 2025):

@coderjingluo 您好,这是最新代码吗?我知道您这个报错是因为 --architectures Qwen3MoeForCausaLlm 参数不对,但是最新的代码我删掉了这个参数
Image

这个问题解决,不过好像又有新的问题

2025-05-13 12:41:06,232 - INFO - flashinfer.jit: Loading JIT ops: batch_prefill_with_kv_cache_dtype_q_bf16_dtype_kv_bf16_dtype_o_bf16_dtype_idx_i32_head_dim_qk_128_head_dim_vo_128_posenc_0_use_swa_False_use_logits_cap_False_f16qk_False 2025-05-13 12:41:06,246 - INFO - flashinfer.jit: Finished loading JIT ops: batch_prefill_with_kv_cache_dtype_q_bf16_dtype_kv_bf16_dtype_o_bf16_dtype_idx_i32_head_dim_qk_128_head_dim_vo_128_posenc_0_use_swa_False_use_logits_cap_False_f16qk_False 2025-05-13 12:41:06,629 - INFO - flashinfer.jit: Loading JIT ops: norm 2025-05-13 12:41:06,641 - INFO - flashinfer.jit: Finished loading JIT ops: norm 2025-05-13 12:41:06,748 - INFO - flashinfer.jit: Loading JIT ops: page 2025-05-13 12:41:06,759 - INFO - flashinfer.jit: Finished loading JIT ops: page cuda_graph: 1/8, warmup finished. capturing cuda graph 2 2 cuda_graph: 2/8, warmup finished. capturing cuda graph 3 3 cuda_graph: 3/8, warmup finished. capturing cuda graph 1 1 cuda_graph: 4/8, warmup finished. capturing cuda graph 4 64 Process SpawnProcess-1: Traceback (most recent call last): File "/home/user/anaconda3/envs/kt311/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap self.run() File "/home/user/anaconda3/envs/kt311/lib/python3.11/multiprocessing/process.py", line 108, in run self._target(*self._args, **self._kwargs) File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/server/backend/interfaces/balance_serve.py", line 279, in run_engine engine.model_runner.warmup() File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/server/balance_serve/inference/model_runner.py", line 148, in warmup self.outputs_buf[i] = self.model(self.input[i], self.features_buf[i], self.bsz_tensor_buf, self.num_tokens_tensor_buf, self.page_idx_buf[i], self.page_offset_buf[i], cuda_graph_idx=i) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/models/custom_modeling_qwen3_moe.py", line 109, in forward hidden_states = decode_layer.mlp(hidden_states.unsqueeze(0), num_tokens_tensors, cuda_graph_idx) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/operators/experts.py", line 1438, in forward y = self.moe_on_cpuinfer(hidden_states, selected_experts, routing_weights, bsz_tensor, cuda_graph_idx).view(*orig_shape).to(device=hidden_states.device) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/operators/experts.py", line 1459, in moe_on_cpuinfer outs = self.experts(x, topk_ids, topk_weight, bsz_tensor, cuda_graph_idx) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/operators/experts.py", line 1272, in forward return self.generate_experts.forward(input_tensor, expert_ids, weights, bsz_tensor, cuda_graph_idx) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/operators/experts.py", line 311, in forward input_tensor = input_tensor.contiguous().cpu() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RuntimeError: CUDA error: an illegal memory access was encountered CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect. For debugging consider passing CUDA_LAUNCH_BLOCKING=1 Compile with TORCH_USE_CUDA_DSA to enable device-side assertions.

terminate called after throwing an instance of 'c10::Error' what(): CUDA error: an illegal memory access was encountered CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect. For debugging consider passing CUDA_LAUNCH_BLOCKING=1 Compile with TORCH_USE_CUDA_DSA to enable device-side assertions.

Exception raised from c10_cuda_check_implementation at /pytorch/c10/cuda/CUDAException.cpp:43 (most recent call first): frame #0: c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits, std::allocator >) + 0x98 (0x7f6acdd785e8 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10.so) frame #1: c10::detail::torchCheckFail(char const*, char const*, unsigned int, std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&) + 0xe0 (0x7f6acdd0d4a2 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10.so) frame #2: c10::cuda::c10_cuda_check_implementation(int, char const*, char const*, int, bool) + 0x3c2 (0x7f6ace145422 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10_cuda.so) frame #3: + 0x32953 (0x7f6ace121953 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10_cuda.so) frame #4: + 0x32b01 (0x7f6ace121b01 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10_cuda.so) frame #5: + 0x66c7f2 (0x7f6ac59bb7f2 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libtorch_python.so) frame #6: + 0x457608 (0x7f6ac57a6608 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libtorch_python.so) frame #7: + 0x7b385 (0x7f6acdd59385 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10.so) frame #8: c10::TensorImpl::~TensorImpl() + 0x9 (0x7f6acdd52f39 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10.so) frame #9: + 0x7182b8 (0x7f6ac5a672b8 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libtorch_python.so) frame #10: + 0x7186d1 (0x7f6ac5a676d1 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libtorch_python.so) frame #11: /home/user/anaconda3/envs/kt311/bin/python() [0x4f5eb7] frame #12: /home/user/anaconda3/envs/kt311/bin/python() [0x5031bf] frame #13: /home/user/anaconda3/envs/kt311/bin/python() [0x55f246] frame #14: /home/user/anaconda3/envs/kt311/bin/python() [0x50302a] frame #15: /home/user/anaconda3/envs/kt311/bin/python() [0x5031bf] frame #16: /home/user/anaconda3/envs/kt311/bin/python() [0x55f246] frame #17: /home/user/anaconda3/envs/kt311/bin/python() [0x55ef87] frame #18: /home/user/anaconda3/envs/kt311/bin/python() [0x55f040] frame #19: /home/user/anaconda3/envs/kt311/bin/python() [0x541355] frame #20: /home/user/anaconda3/envs/kt311/bin/python() [0x53fd88] frame #21: /home/user/anaconda3/envs/kt311/bin/python() [0x53fdc4] frame #22: /home/user/anaconda3/envs/kt311/bin/python() [0x53fdc4] frame #23: /home/user/anaconda3/envs/kt311/bin/python() [0x54e833] frame #24: _PyEval_EvalFrameDefault + 0x46f9 (0x515ac9 in /home/user/anaconda3/envs/kt311/bin/python) frame #25: /home/user/anaconda3/envs/kt311/bin/python() [0x5cc3aa] frame #26: PyEval_EvalCode + 0x9f (0x5cba7f in /home/user/anaconda3/envs/kt311/bin/python) frame #27: /home/user/anaconda3/envs/kt311/bin/python() [0x5ecba7] frame #28: /home/user/anaconda3/envs/kt311/bin/python() [0x5e8740] frame #29: PyRun_StringFlags + 0x5f (0x5db24f in /home/user/anaconda3/envs/kt311/bin/python) frame #30: PyRun_SimpleStringFlags + 0x3b (0x5daffb in /home/user/anaconda3/envs/kt311/bin/python) frame #31: Py_RunMain + 0x388 (0x5f7498 in /home/user/anaconda3/envs/kt311/bin/python) frame #32: Py_BytesMain + 0x39 (0x5bc149 in /home/user/anaconda3/envs/kt311/bin/python) frame #33: + 0x29d90 (0x7f6ad082ad90 in /lib/x86_64-linux-gnu/libc.so.6) frame #34: __libc_start_main + 0x80 (0x7f6ad082ae40 in /lib/x86_64-linux-gnu/libc.so.6) frame #35: /home/user/anaconda3/envs/kt311/bin/python() [0x5bbf9

Image

我刚刚提交了一份新的代码,默认的 cache_lens 太小了,你改成 10k以上试试呢

<!-- gh-comment-id:2876368736 --> @qiyuxinlin commented on GitHub (May 13, 2025): > > [@coderjingluo](https://github.com/coderjingluo) 您好,这是最新代码吗?我知道您这个报错是因为 --architectures Qwen3MoeForCausaLlm 参数不对,但是最新的代码我删掉了这个参数 > > ![Image](https://github.com/user-attachments/assets/25804fa1-c22f-4216-b75f-9a9d62d968ed) > > 这个问题解决,不过好像又有新的问题 > > 2025-05-13 12:41:06,232 - INFO - flashinfer.jit: Loading JIT ops: batch_prefill_with_kv_cache_dtype_q_bf16_dtype_kv_bf16_dtype_o_bf16_dtype_idx_i32_head_dim_qk_128_head_dim_vo_128_posenc_0_use_swa_False_use_logits_cap_False_f16qk_False 2025-05-13 12:41:06,246 - INFO - flashinfer.jit: Finished loading JIT ops: batch_prefill_with_kv_cache_dtype_q_bf16_dtype_kv_bf16_dtype_o_bf16_dtype_idx_i32_head_dim_qk_128_head_dim_vo_128_posenc_0_use_swa_False_use_logits_cap_False_f16qk_False 2025-05-13 12:41:06,629 - INFO - flashinfer.jit: Loading JIT ops: norm 2025-05-13 12:41:06,641 - INFO - flashinfer.jit: Finished loading JIT ops: norm 2025-05-13 12:41:06,748 - INFO - flashinfer.jit: Loading JIT ops: page 2025-05-13 12:41:06,759 - INFO - flashinfer.jit: Finished loading JIT ops: page cuda_graph: 1/8, warmup finished. capturing cuda graph 2 2 cuda_graph: 2/8, warmup finished. capturing cuda graph 3 3 cuda_graph: 3/8, warmup finished. capturing cuda graph 1 1 cuda_graph: 4/8, warmup finished. capturing cuda graph 4 64 Process SpawnProcess-1: Traceback (most recent call last): File "/home/user/anaconda3/envs/kt311/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap self.run() File "/home/user/anaconda3/envs/kt311/lib/python3.11/multiprocessing/process.py", line 108, in run self._target(*self._args, **self._kwargs) File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/server/backend/interfaces/balance_serve.py", line 279, in run_engine engine.model_runner.warmup() File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/server/balance_serve/inference/model_runner.py", line 148, in warmup self.outputs_buf[i] = self.model(self.input[i], self.features_buf[i], self.bsz_tensor_buf, self.num_tokens_tensor_buf, self.page_idx_buf[i], self.page_offset_buf[i], cuda_graph_idx=i) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/models/custom_modeling_qwen3_moe.py", line 109, in forward hidden_states = decode_layer.mlp(hidden_states.unsqueeze(0), num_tokens_tensors, cuda_graph_idx) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/operators/experts.py", line 1438, in forward y = self.moe_on_cpuinfer(hidden_states, selected_experts, routing_weights, bsz_tensor, cuda_graph_idx).view(*orig_shape).to(device=hidden_states.device) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/operators/experts.py", line 1459, in moe_on_cpuinfer outs = self.experts(x, topk_ids, topk_weight, bsz_tensor, cuda_graph_idx) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/operators/experts.py", line 1272, in forward return self.generate_experts.forward(input_tensor, expert_ids, weights, bsz_tensor, cuda_graph_idx) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/operators/experts.py", line 311, in forward input_tensor = input_tensor.contiguous().cpu() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RuntimeError: CUDA error: an illegal memory access was encountered CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect. For debugging consider passing CUDA_LAUNCH_BLOCKING=1 Compile with `TORCH_USE_CUDA_DSA` to enable device-side assertions. > > terminate called after throwing an instance of 'c10::Error' what(): CUDA error: an illegal memory access was encountered CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect. For debugging consider passing CUDA_LAUNCH_BLOCKING=1 Compile with `TORCH_USE_CUDA_DSA` to enable device-side assertions. > > Exception raised from c10_cuda_check_implementation at /pytorch/c10/cuda/CUDAException.cpp:43 (most recent call first): frame #0: c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits, std::allocator >) + 0x98 (0x7f6acdd785e8 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10.so) frame [#1](https://github.com/kvcache-ai/ktransformers/discussions/1): c10::detail::torchCheckFail(char const*, char const*, unsigned int, std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&) + 0xe0 (0x7f6acdd0d4a2 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10.so) frame [#2](https://github.com/kvcache-ai/ktransformers/pull/2): c10::cuda::c10_cuda_check_implementation(int, char const*, char const*, int, bool) + 0x3c2 (0x7f6ace145422 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10_cuda.so) frame [#3](https://github.com/kvcache-ai/ktransformers/discussions/3): + 0x32953 (0x7f6ace121953 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10_cuda.so) frame [#4](https://github.com/kvcache-ai/ktransformers/issues/4): + 0x32b01 (0x7f6ace121b01 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10_cuda.so) frame [#5](https://github.com/kvcache-ai/ktransformers/issues/5): + 0x66c7f2 (0x7f6ac59bb7f2 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libtorch_python.so) frame [#6](https://github.com/kvcache-ai/ktransformers/discussions/6): + 0x457608 (0x7f6ac57a6608 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libtorch_python.so) frame [#7](https://github.com/kvcache-ai/ktransformers/pull/7): + 0x7b385 (0x7f6acdd59385 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10.so) frame [#8](https://github.com/kvcache-ai/ktransformers/issues/8): c10::TensorImpl::~TensorImpl() + 0x9 (0x7f6acdd52f39 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10.so) frame [#9](https://github.com/kvcache-ai/ktransformers/issues/9): + 0x7182b8 (0x7f6ac5a672b8 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libtorch_python.so) frame [#10](https://github.com/kvcache-ai/ktransformers/issues/10): + 0x7186d1 (0x7f6ac5a676d1 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libtorch_python.so) frame [#11](https://github.com/kvcache-ai/ktransformers/issues/11): /home/user/anaconda3/envs/kt311/bin/python() [0x4f5eb7] frame [#12](https://github.com/kvcache-ai/ktransformers/issues/12): /home/user/anaconda3/envs/kt311/bin/python() [0x5031bf] frame [#13](https://github.com/kvcache-ai/ktransformers/issues/13): /home/user/anaconda3/envs/kt311/bin/python() [0x55f246] frame [#14](https://github.com/kvcache-ai/ktransformers/pull/14): /home/user/anaconda3/envs/kt311/bin/python() [0x50302a] frame [#15](https://github.com/kvcache-ai/ktransformers/issues/15): /home/user/anaconda3/envs/kt311/bin/python() [0x5031bf] frame [#16](https://github.com/kvcache-ai/ktransformers/issues/16): /home/user/anaconda3/envs/kt311/bin/python() [0x55f246] frame [#17](https://github.com/kvcache-ai/ktransformers/pull/17): /home/user/anaconda3/envs/kt311/bin/python() [0x55ef87] frame [#18](https://github.com/kvcache-ai/ktransformers/pull/18): /home/user/anaconda3/envs/kt311/bin/python() [0x55f040] frame [#19](https://github.com/kvcache-ai/ktransformers/issues/19): /home/user/anaconda3/envs/kt311/bin/python() [0x541355] frame [#20](https://github.com/kvcache-ai/ktransformers/issues/20): /home/user/anaconda3/envs/kt311/bin/python() [0x53fd88] frame [#21](https://github.com/kvcache-ai/ktransformers/issues/21): /home/user/anaconda3/envs/kt311/bin/python() [0x53fdc4] frame [#22](https://github.com/kvcache-ai/ktransformers/issues/22): /home/user/anaconda3/envs/kt311/bin/python() [0x53fdc4] frame [#23](https://github.com/kvcache-ai/ktransformers/issues/23): /home/user/anaconda3/envs/kt311/bin/python() [0x54e833] frame [#24](https://github.com/kvcache-ai/ktransformers/pull/24): _PyEval_EvalFrameDefault + 0x46f9 (0x515ac9 in /home/user/anaconda3/envs/kt311/bin/python) frame [#25](https://github.com/kvcache-ai/ktransformers/pull/25): /home/user/anaconda3/envs/kt311/bin/python() [0x5cc3aa] frame [#26](https://github.com/kvcache-ai/ktransformers/pull/26): PyEval_EvalCode + 0x9f (0x5cba7f in /home/user/anaconda3/envs/kt311/bin/python) frame [#27](https://github.com/kvcache-ai/ktransformers/pull/27): /home/user/anaconda3/envs/kt311/bin/python() [0x5ecba7] frame [#28](https://github.com/kvcache-ai/ktransformers/issues/28): /home/user/anaconda3/envs/kt311/bin/python() [0x5e8740] frame [#29](https://github.com/kvcache-ai/ktransformers/pull/29): PyRun_StringFlags + 0x5f (0x5db24f in /home/user/anaconda3/envs/kt311/bin/python) frame [#30](https://github.com/kvcache-ai/ktransformers/pull/30): PyRun_SimpleStringFlags + 0x3b (0x5daffb in /home/user/anaconda3/envs/kt311/bin/python) frame [#31](https://github.com/kvcache-ai/ktransformers/issues/31): Py_RunMain + 0x388 (0x5f7498 in /home/user/anaconda3/envs/kt311/bin/python) frame [#32](https://github.com/kvcache-ai/ktransformers/issues/32): Py_BytesMain + 0x39 (0x5bc149 in /home/user/anaconda3/envs/kt311/bin/python) frame [#33](https://github.com/kvcache-ai/ktransformers/issues/33): + 0x29d90 (0x7f6ad082ad90 in /lib/x86_64-linux-gnu/libc.so.6) frame [#34](https://github.com/kvcache-ai/ktransformers/pull/34): __libc_start_main + 0x80 (0x7f6ad082ae40 in /lib/x86_64-linux-gnu/libc.so.6) frame [#35](https://github.com/kvcache-ai/ktransformers/pull/35): /home/user/anaconda3/envs/kt311/bin/python() [0x5bbf9 > > ![Image](https://github.com/user-attachments/assets/655518cb-7cdf-45e1-857f-c93412638b37) 我刚刚提交了一份新的代码,默认的 cache_lens 太小了,你改成 10k以上试试呢
Author
Owner

@coderjingluo commented on GitHub (May 13, 2025):

@coderjingluo 您好,这是最新代码吗?我知道您这个报错是因为 --architectures Qwen3MoeForCausaLlm 参数不对,但是最新的代码我删掉了这个参数
Image

这个问题解决,不过好像又有新的问题
2025-05-13 12:41:06,232 - INFO - flashinfer.jit: Loading JIT ops: batch_prefill_with_kv_cache_dtype_q_bf16_dtype_kv_bf16_dtype_o_bf16_dtype_idx_i32_head_dim_qk_128_head_dim_vo_128_posenc_0_use_swa_False_use_logits_cap_False_f16qk_False 2025-05-13 12:41:06,246 - INFO - flashinfer.jit: Finished loading JIT ops: batch_prefill_with_kv_cache_dtype_q_bf16_dtype_kv_bf16_dtype_o_bf16_dtype_idx_i32_head_dim_qk_128_head_dim_vo_128_posenc_0_use_swa_False_use_logits_cap_False_f16qk_False 2025-05-13 12:41:06,629 - INFO - flashinfer.jit: Loading JIT ops: norm 2025-05-13 12:41:06,641 - INFO - flashinfer.jit: Finished loading JIT ops: norm 2025-05-13 12:41:06,748 - INFO - flashinfer.jit: Loading JIT ops: page 2025-05-13 12:41:06,759 - INFO - flashinfer.jit: Finished loading JIT ops: page cuda_graph: 1/8, warmup finished. capturing cuda graph 2 2 cuda_graph: 2/8, warmup finished. capturing cuda graph 3 3 cuda_graph: 3/8, warmup finished. capturing cuda graph 1 1 cuda_graph: 4/8, warmup finished. capturing cuda graph 4 64 Process SpawnProcess-1: Traceback (most recent call last): File "/home/user/anaconda3/envs/kt311/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap self.run() File "/home/user/anaconda3/envs/kt311/lib/python3.11/multiprocessing/process.py", line 108, in run self._target(*self._args, **self._kwargs) File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/server/backend/interfaces/balance_serve.py", line 279, in run_engine engine.model_runner.warmup() File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/server/balance_serve/inference/model_runner.py", line 148, in warmup self.outputs_buf[i] = self.model(self.input[i], self.features_buf[i], self.bsz_tensor_buf, self.num_tokens_tensor_buf, self.page_idx_buf[i], self.page_offset_buf[i], cuda_graph_idx=i) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/models/custom_modeling_qwen3_moe.py", line 109, in forward hidden_states = decode_layer.mlp(hidden_states.unsqueeze(0), num_tokens_tensors, cuda_graph_idx) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/operators/experts.py", line 1438, in forward y = self.moe_on_cpuinfer(hidden_states, selected_experts, routing_weights, bsz_tensor, cuda_graph_idx).view(*orig_shape).to(device=hidden_states.device) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/operators/experts.py", line 1459, in moe_on_cpuinfer outs = self.experts(x, topk_ids, topk_weight, bsz_tensor, cuda_graph_idx) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl return self._call_impl(*args, *kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl return forward_call(args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/operators/experts.py", line 1272, in forward return self.generate_experts.forward(input_tensor, expert_ids, weights, bsz_tensor, cuda_graph_idx) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/operators/experts.py", line 311, in forward input_tensor = input_tensor.contiguous().cpu() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RuntimeError: CUDA error: an illegal memory access was encountered CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect. For debugging consider passing CUDA_LAUNCH_BLOCKING=1 Compile with TORCH_USE_CUDA_DSA to enable device-side assertions.
terminate called after throwing an instance of 'c10::Error' what(): CUDA error: an illegal memory access was encountered CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect. For debugging consider passing CUDA_LAUNCH_BLOCKING=1 Compile with TORCH_USE_CUDA_DSA to enable device-side assertions.
Exception raised from c10_cuda_check_implementation at /pytorch/c10/cuda/CUDAException.cpp:43 (most recent call first): frame #0: c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits, std::allocator >) + 0x98 (0x7f6acdd785e8 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10.so) frame #1: c10::detail::torchCheckFail(char const
, char const
, unsigned int, std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&) + 0xe0 (0x7f6acdd0d4a2 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10.so) frame #2: c10::cuda::c10_cuda_check_implementation(int, char const
, char const
, int, bool) + 0x3c2 (0x7f6ace145422 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10_cuda.so) frame #3: + 0x32953 (0x7f6ace121953 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10_cuda.so) frame #4: + 0x32b01 (0x7f6ace121b01 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10_cuda.so) frame #5: + 0x66c7f2 (0x7f6ac59bb7f2 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libtorch_python.so) frame #6: + 0x457608 (0x7f6ac57a6608 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libtorch_python.so) frame #7: + 0x7b385 (0x7f6acdd59385 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10.so) frame #8: c10::TensorImpl::~TensorImpl() + 0x9 (0x7f6acdd52f39 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10.so) frame #9: + 0x7182b8 (0x7f6ac5a672b8 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libtorch_python.so) frame #10: + 0x7186d1 (0x7f6ac5a676d1 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libtorch_python.so) frame #11: /home/user/anaconda3/envs/kt311/bin/python() [0x4f5eb7] frame #12: /home/user/anaconda3/envs/kt311/bin/python() [0x5031bf] frame #13: /home/user/anaconda3/envs/kt311/bin/python() [0x55f246] frame #14: /home/user/anaconda3/envs/kt311/bin/python() [0x50302a] frame #15: /home/user/anaconda3/envs/kt311/bin/python() [0x5031bf] frame #16: /home/user/anaconda3/envs/kt311/bin/python() [0x55f246] frame #17: /home/user/anaconda3/envs/kt311/bin/python() [0x55ef87] frame #18: /home/user/anaconda3/envs/kt311/bin/python() [0x55f040] frame #19: /home/user/anaconda3/envs/kt311/bin/python() [0x541355] frame #20: /home/user/anaconda3/envs/kt311/bin/python() [0x53fd88] frame #21: /home/user/anaconda3/envs/kt311/bin/python() [0x53fdc4] frame #22: /home/user/anaconda3/envs/kt311/bin/python() [0x53fdc4] frame #23: /home/user/anaconda3/envs/kt311/bin/python() [0x54e833] frame #24: _PyEval_EvalFrameDefault + 0x46f9 (0x515ac9 in /home/user/anaconda3/envs/kt311/bin/python) frame #25: /home/user/anaconda3/envs/kt311/bin/python() [0x5cc3aa] frame #26: PyEval_EvalCode + 0x9f (0x5cba7f in /home/user/anaconda3/envs/kt311/bin/python) frame #27: /home/user/anaconda3/envs/kt311/bin/python() [0x5ecba7] frame #28: /home/user/anaconda3/envs/kt311/bin/python() [0x5e8740] frame #29: PyRun_StringFlags + 0x5f (0x5db24f in /home/user/anaconda3/envs/kt311/bin/python) frame #30: PyRun_SimpleStringFlags + 0x3b (0x5daffb in /home/user/anaconda3/envs/kt311/bin/python) frame #31: Py_RunMain + 0x388 (0x5f7498 in /home/user/anaconda3/envs/kt311/bin/python) frame #32: Py_BytesMain + 0x39 (0x5bc149 in /home/user/anaconda3/envs/kt311/bin/python) frame #33: + 0x29d90 (0x7f6ad082ad90 in /lib/x86_64-linux-gnu/libc.so.6) frame #34: __libc_start_main + 0x80 (0x7f6ad082ae40 in /lib/x86_64-linux-gnu/libc.so.6) frame #35: /home/user/anaconda3/envs/kt311/bin/python() [0x5bbf9
Image

我刚刚提交了一份新的代码,默认的 cache_lens 太小了,你改成 10k以上试试呢

嗯嗯,运行成功了,有个小问题想问下,92GB显存,256GB内存 Q4量化,使用ktransformers的话最多同时支持多少人访问呢

<!-- gh-comment-id:2876492287 --> @coderjingluo commented on GitHub (May 13, 2025): > > > [@coderjingluo](https://github.com/coderjingluo) 您好,这是最新代码吗?我知道您这个报错是因为 --architectures Qwen3MoeForCausaLlm 参数不对,但是最新的代码我删掉了这个参数 > > > ![Image](https://github.com/user-attachments/assets/25804fa1-c22f-4216-b75f-9a9d62d968ed) > > > > > > 这个问题解决,不过好像又有新的问题 > > 2025-05-13 12:41:06,232 - INFO - flashinfer.jit: Loading JIT ops: batch_prefill_with_kv_cache_dtype_q_bf16_dtype_kv_bf16_dtype_o_bf16_dtype_idx_i32_head_dim_qk_128_head_dim_vo_128_posenc_0_use_swa_False_use_logits_cap_False_f16qk_False 2025-05-13 12:41:06,246 - INFO - flashinfer.jit: Finished loading JIT ops: batch_prefill_with_kv_cache_dtype_q_bf16_dtype_kv_bf16_dtype_o_bf16_dtype_idx_i32_head_dim_qk_128_head_dim_vo_128_posenc_0_use_swa_False_use_logits_cap_False_f16qk_False 2025-05-13 12:41:06,629 - INFO - flashinfer.jit: Loading JIT ops: norm 2025-05-13 12:41:06,641 - INFO - flashinfer.jit: Finished loading JIT ops: norm 2025-05-13 12:41:06,748 - INFO - flashinfer.jit: Loading JIT ops: page 2025-05-13 12:41:06,759 - INFO - flashinfer.jit: Finished loading JIT ops: page cuda_graph: 1/8, warmup finished. capturing cuda graph 2 2 cuda_graph: 2/8, warmup finished. capturing cuda graph 3 3 cuda_graph: 3/8, warmup finished. capturing cuda graph 1 1 cuda_graph: 4/8, warmup finished. capturing cuda graph 4 64 Process SpawnProcess-1: Traceback (most recent call last): File "/home/user/anaconda3/envs/kt311/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap self.run() File "/home/user/anaconda3/envs/kt311/lib/python3.11/multiprocessing/process.py", line 108, in run self._target(*self._args, **self._kwargs) File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/server/backend/interfaces/balance_serve.py", line 279, in run_engine engine.model_runner.warmup() File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/server/balance_serve/inference/model_runner.py", line 148, in warmup self.outputs_buf[i] = self.model(self.input[i], self.features_buf[i], self.bsz_tensor_buf, self.num_tokens_tensor_buf, self.page_idx_buf[i], self.page_offset_buf[i], cuda_graph_idx=i) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/models/custom_modeling_qwen3_moe.py", line 109, in forward hidden_states = decode_layer.mlp(hidden_states.unsqueeze(0), num_tokens_tensors, cuda_graph_idx) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/operators/experts.py", line 1438, in forward y = self.moe_on_cpuinfer(hidden_states, selected_experts, routing_weights, bsz_tensor, cuda_graph_idx).view(*orig_shape).to(device=hidden_states.device) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/operators/experts.py", line 1459, in moe_on_cpuinfer outs = self.experts(x, topk_ids, topk_weight, bsz_tensor, cuda_graph_idx) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/operators/experts.py", line 1272, in forward return self.generate_experts.forward(input_tensor, expert_ids, weights, bsz_tensor, cuda_graph_idx) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/operators/experts.py", line 311, in forward input_tensor = input_tensor.contiguous().cpu() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RuntimeError: CUDA error: an illegal memory access was encountered CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect. For debugging consider passing CUDA_LAUNCH_BLOCKING=1 Compile with `TORCH_USE_CUDA_DSA` to enable device-side assertions. > > terminate called after throwing an instance of 'c10::Error' what(): CUDA error: an illegal memory access was encountered CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect. For debugging consider passing CUDA_LAUNCH_BLOCKING=1 Compile with `TORCH_USE_CUDA_DSA` to enable device-side assertions. > > Exception raised from c10_cuda_check_implementation at /pytorch/c10/cuda/CUDAException.cpp:43 (most recent call first): frame #0: c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits, std::allocator >) + 0x98 (0x7f6acdd785e8 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10.so) frame [#1](https://github.com/kvcache-ai/ktransformers/discussions/1): c10::detail::torchCheckFail(char const*, char const*, unsigned int, std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&) + 0xe0 (0x7f6acdd0d4a2 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10.so) frame [#2](https://github.com/kvcache-ai/ktransformers/pull/2): c10::cuda::c10_cuda_check_implementation(int, char const*, char const*, int, bool) + 0x3c2 (0x7f6ace145422 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10_cuda.so) frame [#3](https://github.com/kvcache-ai/ktransformers/discussions/3): + 0x32953 (0x7f6ace121953 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10_cuda.so) frame [#4](https://github.com/kvcache-ai/ktransformers/issues/4): + 0x32b01 (0x7f6ace121b01 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10_cuda.so) frame [#5](https://github.com/kvcache-ai/ktransformers/issues/5): + 0x66c7f2 (0x7f6ac59bb7f2 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libtorch_python.so) frame [#6](https://github.com/kvcache-ai/ktransformers/discussions/6): + 0x457608 (0x7f6ac57a6608 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libtorch_python.so) frame [#7](https://github.com/kvcache-ai/ktransformers/pull/7): + 0x7b385 (0x7f6acdd59385 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10.so) frame [#8](https://github.com/kvcache-ai/ktransformers/issues/8): c10::TensorImpl::~TensorImpl() + 0x9 (0x7f6acdd52f39 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10.so) frame [#9](https://github.com/kvcache-ai/ktransformers/issues/9): + 0x7182b8 (0x7f6ac5a672b8 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libtorch_python.so) frame [#10](https://github.com/kvcache-ai/ktransformers/issues/10): + 0x7186d1 (0x7f6ac5a676d1 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libtorch_python.so) frame [#11](https://github.com/kvcache-ai/ktransformers/issues/11): /home/user/anaconda3/envs/kt311/bin/python() [0x4f5eb7] frame [#12](https://github.com/kvcache-ai/ktransformers/issues/12): /home/user/anaconda3/envs/kt311/bin/python() [0x5031bf] frame [#13](https://github.com/kvcache-ai/ktransformers/issues/13): /home/user/anaconda3/envs/kt311/bin/python() [0x55f246] frame [#14](https://github.com/kvcache-ai/ktransformers/pull/14): /home/user/anaconda3/envs/kt311/bin/python() [0x50302a] frame [#15](https://github.com/kvcache-ai/ktransformers/issues/15): /home/user/anaconda3/envs/kt311/bin/python() [0x5031bf] frame [#16](https://github.com/kvcache-ai/ktransformers/issues/16): /home/user/anaconda3/envs/kt311/bin/python() [0x55f246] frame [#17](https://github.com/kvcache-ai/ktransformers/pull/17): /home/user/anaconda3/envs/kt311/bin/python() [0x55ef87] frame [#18](https://github.com/kvcache-ai/ktransformers/pull/18): /home/user/anaconda3/envs/kt311/bin/python() [0x55f040] frame [#19](https://github.com/kvcache-ai/ktransformers/issues/19): /home/user/anaconda3/envs/kt311/bin/python() [0x541355] frame [#20](https://github.com/kvcache-ai/ktransformers/issues/20): /home/user/anaconda3/envs/kt311/bin/python() [0x53fd88] frame [#21](https://github.com/kvcache-ai/ktransformers/issues/21): /home/user/anaconda3/envs/kt311/bin/python() [0x53fdc4] frame [#22](https://github.com/kvcache-ai/ktransformers/issues/22): /home/user/anaconda3/envs/kt311/bin/python() [0x53fdc4] frame [#23](https://github.com/kvcache-ai/ktransformers/issues/23): /home/user/anaconda3/envs/kt311/bin/python() [0x54e833] frame [#24](https://github.com/kvcache-ai/ktransformers/pull/24): _PyEval_EvalFrameDefault + 0x46f9 (0x515ac9 in /home/user/anaconda3/envs/kt311/bin/python) frame [#25](https://github.com/kvcache-ai/ktransformers/pull/25): /home/user/anaconda3/envs/kt311/bin/python() [0x5cc3aa] frame [#26](https://github.com/kvcache-ai/ktransformers/pull/26): PyEval_EvalCode + 0x9f (0x5cba7f in /home/user/anaconda3/envs/kt311/bin/python) frame [#27](https://github.com/kvcache-ai/ktransformers/pull/27): /home/user/anaconda3/envs/kt311/bin/python() [0x5ecba7] frame [#28](https://github.com/kvcache-ai/ktransformers/issues/28): /home/user/anaconda3/envs/kt311/bin/python() [0x5e8740] frame [#29](https://github.com/kvcache-ai/ktransformers/pull/29): PyRun_StringFlags + 0x5f (0x5db24f in /home/user/anaconda3/envs/kt311/bin/python) frame [#30](https://github.com/kvcache-ai/ktransformers/pull/30): PyRun_SimpleStringFlags + 0x3b (0x5daffb in /home/user/anaconda3/envs/kt311/bin/python) frame [#31](https://github.com/kvcache-ai/ktransformers/issues/31): Py_RunMain + 0x388 (0x5f7498 in /home/user/anaconda3/envs/kt311/bin/python) frame [#32](https://github.com/kvcache-ai/ktransformers/issues/32): Py_BytesMain + 0x39 (0x5bc149 in /home/user/anaconda3/envs/kt311/bin/python) frame [#33](https://github.com/kvcache-ai/ktransformers/issues/33): + 0x29d90 (0x7f6ad082ad90 in /lib/x86_64-linux-gnu/libc.so.6) frame [#34](https://github.com/kvcache-ai/ktransformers/pull/34): __libc_start_main + 0x80 (0x7f6ad082ae40 in /lib/x86_64-linux-gnu/libc.so.6) frame [#35](https://github.com/kvcache-ai/ktransformers/pull/35): /home/user/anaconda3/envs/kt311/bin/python() [0x5bbf9 > > ![Image](https://github.com/user-attachments/assets/655518cb-7cdf-45e1-857f-c93412638b37) > > 我刚刚提交了一份新的代码,默认的 cache_lens 太小了,你改成 10k以上试试呢 嗯嗯,运行成功了,有个小问题想问下,92GB显存,256GB内存 Q4量化,使用ktransformers的话最多同时支持多少人访问呢
Author
Owner

@qiyuxinlin commented on GitHub (May 15, 2025):

@coderjingluo 您好,这是最新代码吗?我知道您这个报错是因为 --architectures Qwen3MoeForCausaLlm 参数不对,但是最新的代码我删掉了这个参数
Image

这个问题解决,不过好像又有新的问题
2025-05-13 12:41:06,232 - INFO - flashinfer.jit: Loading JIT ops: batch_prefill_with_kv_cache_dtype_q_bf16_dtype_kv_bf16_dtype_o_bf16_dtype_idx_i32_head_dim_qk_128_head_dim_vo_128_posenc_0_use_swa_False_use_logits_cap_False_f16qk_False 2025-05-13 12:41:06,246 - INFO - flashinfer.jit: Finished loading JIT ops: batch_prefill_with_kv_cache_dtype_q_bf16_dtype_kv_bf16_dtype_o_bf16_dtype_idx_i32_head_dim_qk_128_head_dim_vo_128_posenc_0_use_swa_False_use_logits_cap_False_f16qk_False 2025-05-13 12:41:06,629 - INFO - flashinfer.jit: Loading JIT ops: norm 2025-05-13 12:41:06,641 - INFO - flashinfer.jit: Finished loading JIT ops: norm 2025-05-13 12:41:06,748 - INFO - flashinfer.jit: Loading JIT ops: page 2025-05-13 12:41:06,759 - INFO - flashinfer.jit: Finished loading JIT ops: page cuda_graph: 1/8, warmup finished. capturing cuda graph 2 2 cuda_graph: 2/8, warmup finished. capturing cuda graph 3 3 cuda_graph: 3/8, warmup finished. capturing cuda graph 1 1 cuda_graph: 4/8, warmup finished. capturing cuda graph 4 64 Process SpawnProcess-1: Traceback (most recent call last): File "/home/user/anaconda3/envs/kt311/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap self.run() File "/home/user/anaconda3/envs/kt311/lib/python3.11/multiprocessing/process.py", line 108, in run self._target(*self._args, **self._kwargs) File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/server/backend/interfaces/balance_serve.py", line 279, in run_engine engine.model_runner.warmup() File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/server/balance_serve/inference/model_runner.py", line 148, in warmup self.outputs_buf[i] = self.model(self.input[i], self.features_buf[i], self.bsz_tensor_buf, self.num_tokens_tensor_buf, self.page_idx_buf[i], self.page_offset_buf[i], cuda_graph_idx=i) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/models/custom_modeling_qwen3_moe.py", line 109, in forward hidden_states = decode_layer.mlp(hidden_states.unsqueeze(0), num_tokens_tensors, cuda_graph_idx) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/operators/experts.py", line 1438, in forward y = self.moe_on_cpuinfer(hidden_states, selected_experts, routing_weights, bsz_tensor, cuda_graph_idx).view(*orig_shape).to(device=hidden_states.device) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/operators/experts.py", line 1459, in moe_on_cpuinfer outs = self.experts(x, topk_ids, topk_weight, bsz_tensor, cuda_graph_idx) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl return self._call_impl(*args, *_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl return forward_call(_args, __kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/operators/experts.py", line 1272, in forward return self.generate_experts.forward(input_tensor, expert_ids, weights, bsz_tensor, cuda_graph_idx) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/operators/experts.py", line 311, in forward input_tensor = input_tensor.contiguous().cpu() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RuntimeError: CUDA error: an illegal memory access was encountered CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect. For debugging consider passing CUDA_LAUNCH_BLOCKING=1 Compile with TORCH_USE_CUDA_DSA to enable device-side assertions.2025-05-13 12:41:06,232 - INFO - flashinfer.jit:加载 JIT 操作:batch_prefill_with_kv_cache_dtype_q_bf16_dtype_kv_bf16_dtype_o_bf16_dtype_idx_i32_head_dim_qk_128_head_dim_vo_128_posenc_0_use_swa_False_use_logits_cap_False_f16qk_False 2025-05-13 12:41:06,246 - INFO - flashinfer.jit:已完成加载 JIT 操作: batch_prefill_with_kv_cache_dtype_q_bf16_dtype_kv_bf16_dtype_o_bf16_dtype_idx_i32_head_dim_qk_128_head_dim_vo_128_posenc_0_use_swa_False_use_logits_cap_False_f16qk_False 2025-05-13 12:41:06,629 - INFO - flashinfer.jit:正在加载 JIT 操作:norm 2025-05-13 12:41:06,641 - INFO - flashinfer.jit:已完成加载 JIT 操作:norm 2025-05-13 12:41:06,748 - INFO - flashinfer.jit:正在加载 JIT 操作:page 2025-05-13 12:41:06,759 - INFO - flashinfer.jit:已完成加载 JIT 操作:页面 cuda_graph:1/8,预热完成。捕获 cuda 图 2 2 cuda_graph:2/8,预热完成。捕获 cuda 图 3 3 cuda_graph:3/8,预热完成。捕获 cuda 图 1 1 cuda_graph:4/8,预热完成。 捕获 cuda graph 4 64 进程 SpawnProcess-1:回溯(最近一次调用最后一次):文件“/home/user/anaconda3/envs/kt311/lib/python3.11/multiprocessing/process.py”,第 314 行,在 _bootstrap self.run() 文件“/home/user/anaconda3/envs/kt311/lib/python3.11/multiprocessing/process.py”,第 108 行,在运行 self._target(*self._args, **self._kwargs) 文件“/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/server/backend/interfaces/balance_serve.py”,第 279 行,在 run_engine engine.model_runner.warmup() 文件中“/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/server/balance_serve/inference/model_runner.py”,第 148 行,正在预热 self.outputs_buf[i] = self.model(self.input[i], self.features_buf[i], self.bsz_tensor_buf, self.num_tokens_tensor_buf, self.page_idx_buf[i], self.page_offset_buf[i], cuda_graph_idx=i) ^ ... **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 文件“/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py”,第 1762 行,在 _call_impl 中返回 forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 文件“/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/models/custom_modeling_qwen3_moe.py”,第 109 行,在 forward hidden_​​states = decoder.mlp(hidden_​​states.unsqueeze(0), num_tokens_tensors,cuda_graph_idx) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 文件“/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py”,第 1751 行,在 _wrapped_call_impl 中返回 self._call_impl(*args,**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 文件“/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py”,第 1762 行,在 _call_impl 中返回 forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 文件“/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/operators/experts.py”,第 1438 行,在 forward y = self.moe_on_cpuinfer(hidden_​​states, selected_experts, routes_weights, bsz_tensor, cuda_graph_idx).view(*orig_shape).to(device=hidden_​​states.device) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 文件“/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/utils/_contextlib.py”,第 116 行,在 decorate_context return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^ 文件“/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/operators/experts.py”,行 1459,在 moe_on_cpuinfer outs = self.experts(x, topk_ids, topk_weight, bsz_tensor, cuda_graph_idx) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 文件“/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py”,第 1751 行,在 _wrapped_call_impl 中返回 self._call_impl(*args, *kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 文件“/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py”,第 1762 行,在 _call_impl 中返回 forward_call(args,kwargs)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 文件“/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/operators/experts.py”,第 1272 行,在 forward 返回 self.generate_experts.forward(input_tensor、expert_ids、weights、bsz_tensor、cuda_graph_idx) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 文件“/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/operators/experts.py”,第 311 行,正向输入_tensor = input_tensor.contiguous().cpu() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RuntimeError:CUDA 错误:遇到非法内存访问 CUDA 内核错误可能会在其他一些 API 调用中异步报告,因此下面的堆栈跟踪可能不正确。 为了进行调试,请考虑传递 CUDA_LAUNCH_BLOCKING=1 使用 TORCH_USE_CUDA_DSA 进行编译以启用设备端断言。
terminate called after throwing an instance of 'c10::Error' what(): CUDA error: an illegal memory access was encountered CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect. For debugging consider passing CUDA_LAUNCH_BLOCKING=1 Compile with TORCH_USE_CUDA_DSA to enable device-side assertions.在抛出“c10::Error”what() 实例后调用终止:CUDA 错误:遇到非法内存访问。CUDA 内核错误可能在其他 API 调用中异步报告,因此以下堆栈跟踪可能不正确。为了进行调试,请传递 CUDA_LAUNCH_BLOCKING=1 并使用 TORCH_USE_CUDA_DSA 进行编译以启用设备端断言。
Exception raised from c10_cuda_check_implementation at /pytorch/c10/cuda/CUDAException.cpp:43 (most recent call first): frame #0: c10::Error::Error(c10::SourceLocation, std::cxx11::basic_string<char, std::char_traits, std::allocator >) + 0x98 (0x7f6acdd785e8 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10.so) frame #1: c10::detail::torchCheckFail(char const, char const, unsigned int, std::cxx11::basic_string<char, std::char_traits, std::allocator > const&) + 0xe0 (0x7f6acdd0d4a2 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10.so) frame #2: c10::cuda::c10_cuda_check_implementation(int, char const, char const, int, bool) + 0x3c2 (0x7f6ace145422 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10_cuda.so) frame #3: + 0x32953 (0x7f6ace121953 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10_cuda.so) frame #4: + 0x32b01 (0x7f6ace121b01 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10_cuda.so) frame #5: + 0x66c7f2 (0x7f6ac59bb7f2 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libtorch_python.so) frame #6: + 0x457608 (0x7f6ac57a6608 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libtorch_python.so) frame #7: + 0x7b385 (0x7f6acdd59385 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10.so) frame #8: c10::TensorImpl::~TensorImpl() + 0x9 (0x7f6acdd52f39 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10.so) frame #9: + 0x7182b8 (0x7f6ac5a672b8 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libtorch_python.so) frame #10: + 0x7186d1 (0x7f6ac5a676d1 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libtorch_python.so) frame #11: /home/user/anaconda3/envs/kt311/bin/python() [0x4f5eb7] frame #12: /home/user/anaconda3/envs/kt311/bin/python() [0x5031bf] frame #13: /home/user/anaconda3/envs/kt311/bin/python() [0x55f246] frame #14: /home/user/anaconda3/envs/kt311/bin/python() [0x50302a] frame #15: /home/user/anaconda3/envs/kt311/bin/python() [0x5031bf] frame #16: /home/user/anaconda3/envs/kt311/bin/python() [0x55f246] frame #17: /home/user/anaconda3/envs/kt311/bin/python() [0x55ef87] frame #18: /home/user/anaconda3/envs/kt311/bin/python() [0x55f040] frame #19: /home/user/anaconda3/envs/kt311/bin/python() [0x541355] frame #20: /home/user/anaconda3/envs/kt311/bin/python() [0x53fd88] frame #21: /home/user/anaconda3/envs/kt311/bin/python() [0x53fdc4] frame #22: /home/user/anaconda3/envs/kt311/bin/python() [0x53fdc4] frame #23: /home/user/anaconda3/envs/kt311/bin/python() [0x54e833] frame #24: _PyEval_EvalFrameDefault + 0x46f9 (0x515ac9 in /home/user/anaconda3/envs/kt311/bin/python) frame #25: /home/user/anaconda3/envs/kt311/bin/python() [0x5cc3aa] frame #26: PyEval_EvalCode + 0x9f (0x5cba7f in /home/user/anaconda3/envs/kt311/bin/python) frame #27: /home/user/anaconda3/envs/kt311/bin/python() [0x5ecba7] frame #28: /home/user/anaconda3/envs/kt311/bin/python() [0x5e8740] frame #29: PyRun_StringFlags + 0x5f (0x5db24f in /home/user/anaconda3/envs/kt311/bin/python) frame #30: PyRun_SimpleStringFlags + 0x3b (0x5daffb in /home/user/anaconda3/envs/kt311/bin/python) frame #31: Py_RunMain + 0x388 (0x5f7498 in /home/user/anaconda3/envs/kt311/bin/python) frame #32: Py_BytesMain + 0x39 (0x5bc149 in /home/user/anaconda3/envs/kt311/bin/python) frame #33: + 0x29d90 (0x7f6ad082ad90 in /lib/x86_64-linux-gnu/libc.so.6) frame #34: __libc_start_main + 0x80 (0x7f6ad082ae40 in /lib/x86_64-linux-gnu/libc.so.6) frame #35: /home/user/anaconda3/envs/kt311/bin/python() [0x5bbf9/pytorch/c10/cuda/CUDAException.cpp:43 处的 c10_cuda_check_implementation 引发异常(最近一次调用):帧#0:c10 :: Error :: Error(c10 :: SourceLocation,std :: __ cxx11 :: basic_string)+ 0x98(/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10.so 中的 0x7f6acdd785e8)帧#1:c10 :: detail :: torchCheckFail(char const,char const,unsigned int,std :: __ cxx11 :: basic_string const&)+ 0xe0(0x7f6acdd0d4a2 /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10.so) frame #2: c10::cuda::c10_cuda_check_implementation(int, char const, char const, int, bool) + 0x3c2 (0x7f6ace145422 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10_cuda.so) frame #3 : + 0x32953 (0x7f6ace121953 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10_cuda.so) frame #4 : + 0x32b01 (/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10_cuda.so 中的 0x7f6ace121b01) 帧 #5 :+ 0x66c7f2 (/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libtorch_python.so 中的 0x7f6ac59bb7f2) 帧 #6 :+ 0x457608 (/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libtorch_python.so 中的 0x7f6ac57a6608) 帧 #7 :+ 0x7b385 ( /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10.so) 框架 #8 :c10 :: TensorImpl ::〜TensorImpl()+ 0x9(0x7f6acdd52f39 在/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10.so)框架 #9 :+ 0x7182b8(0x7f6ac5a672b8 在/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libtorch_python.so)框架 #10 :+ 0x7186d1(0x7f6ac5a676d1 在 /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libtorch_python.so) 框架 #11 :/home/user/anaconda3/envs/kt311/bin/python()[0x4f5eb7] 框架 #12 :/home/user/anaconda3/envs/kt311/bin/python()[0x5031bf] 框架 #13 :/home/user/anaconda3/envs/kt311/bin/python()[0x55f246] 框架 #14 :/home/user/anaconda3/envs/kt311/bin/python()[0x50302a] 框架 #15 :/home/user/anaconda3/envs/kt311/bin/python()[0x5031bf] 框架 #16 :/home/user/anaconda3/envs/kt311/bin/python() [0x55f246] 帧 #17 :/home/user/anaconda3/envs/kt311/bin/python() [0x55ef87] 帧 #18 :/home/user/anaconda3/envs/kt311/bin/python() [0x55f040] 帧 #19 :/home/user/anaconda3/envs/kt311/bin/python() [0x541355] 帧 #20 :/home/user/anaconda3/envs/kt311/bin/python() [0x53fd88] 帧 #21 :/home/user/anaconda3/envs/kt311/bin/python() [0x53fdc4] 帧 #22 : /home/user/anaconda3/envs/kt311/bin/python() [0x53fdc4] 帧 #23 :/home/user/anaconda3/envs/kt311/bin/python() [0x54e833] 帧 #24 :_PyEval_EvalFrameDefault + 0x46f9(/home/user/anaconda3/envs/kt311/bin/python 中的 0x515ac9) 帧 #25 :/home/user/anaconda3/envs/kt311/bin/python() [0x5cc3aa] 帧 #26 :PyEval_EvalCode + 0x9f(/home/user/anaconda3/envs/kt311/bin/python 中的 0x5cba7f) 帧 #27 : /home/user/anaconda3/envs/kt311/bin/python() [0x5ecba7] 帧 #28 :/home/user/anaconda3/envs/kt311/bin/python() [0x5e8740] 帧 #29 :PyRun_StringFlags + 0x5f(/home/user/anaconda3/envs/kt311/bin/python 中的 0x5db24f) 帧 #30 :PyRun_SimpleStringFlags + 0x3b(0x5daffb /home/user/anaconda3/envs/kt311/bin/python) 框架 #31 : Py_RunMain + 0x388 (/home/user/anaconda3/envs/kt311/bin/python 中的 0x5f7498) 框架 #32 : Py_BytesMain + 0x39 (/home/user/anaconda3/envs/kt311/bin/python 中的 0x5bc149) 框架 #33 : + 0x29d90 (/lib/x86_64-linux-gnu/libc.so.6 中的 0x7f6ad082ad90) 框架 #34 : __libc_start_main + 0x80 (/lib/x86_64-linux-gnu/libc.so.6 中的 0x7f6ad082ae40) 框架 #35 : /home/user/anaconda3/envs/kt311/bin/python() [0x5bbf9
![Image](https://github.com/user-attachments/assets/655518cb-7cdf-45e1-857f-c93412638b37)

我刚刚提交了一份新的代码,默认的 cache_lens 太小了,你改成 10k以上试试呢

嗯嗯,运行成功了,有个小问题想问下,92GB显存,256GB内存 Q4量化,使用ktransformers的话最多同时支持多少人访问呢

这个主要取决于设置的 max_batch_size 和 cache_lens,默认 max_batch_size=4 支持 4 并发,另外如果你当前运行的所有请求 cache 长度超过了 cache_lens 程序会降并发度

<!-- gh-comment-id:2882002747 --> @qiyuxinlin commented on GitHub (May 15, 2025): > > > > [@coderjingluo](https://github.com/coderjingluo) 您好,这是最新代码吗?我知道您这个报错是因为 --architectures Qwen3MoeForCausaLlm 参数不对,但是最新的代码我删掉了这个参数 > > > > <img alt="Image" width="729" height="30.78125" src="https://private-user-images.githubusercontent.com/44601537/443173907-25804fa1-c22f-4216-b75f-9a9d62d968ed.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDcyNzQ2NDMsIm5iZiI6MTc0NzI3NDM0MywicGF0aCI6Ii80NDYwMTUzNy80NDMxNzM5MDctMjU4MDRmYTEtYzIyZi00MjE2LWI3NWYtOWE5ZDYyZDk2OGVkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTA1MTUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwNTE1VDAxNTkwM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWRlMzcxYmZiZWRhYzUxY2NmMThiMWVkNzdjZjY3MTU0YWM0N2RkNzRiOTg1MjJkYmQwZGViYWM3OGVlNDYxMmYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.h5iK9uQRr2HBw-X9qeozABl5QeZmm7zAFuSrN4V9TQ0"> > > > > > > > > > 这个问题解决,不过好像又有新的问题 > > > 2025-05-13 12:41:06,232 - INFO - flashinfer.jit: Loading JIT ops: batch_prefill_with_kv_cache_dtype_q_bf16_dtype_kv_bf16_dtype_o_bf16_dtype_idx_i32_head_dim_qk_128_head_dim_vo_128_posenc_0_use_swa_False_use_logits_cap_False_f16qk_False 2025-05-13 12:41:06,246 - INFO - flashinfer.jit: Finished loading JIT ops: batch_prefill_with_kv_cache_dtype_q_bf16_dtype_kv_bf16_dtype_o_bf16_dtype_idx_i32_head_dim_qk_128_head_dim_vo_128_posenc_0_use_swa_False_use_logits_cap_False_f16qk_False 2025-05-13 12:41:06,629 - INFO - flashinfer.jit: Loading JIT ops: norm 2025-05-13 12:41:06,641 - INFO - flashinfer.jit: Finished loading JIT ops: norm 2025-05-13 12:41:06,748 - INFO - flashinfer.jit: Loading JIT ops: page 2025-05-13 12:41:06,759 - INFO - flashinfer.jit: Finished loading JIT ops: page cuda_graph: 1/8, warmup finished. capturing cuda graph 2 2 cuda_graph: 2/8, warmup finished. capturing cuda graph 3 3 cuda_graph: 3/8, warmup finished. capturing cuda graph 1 1 cuda_graph: 4/8, warmup finished. capturing cuda graph 4 64 Process SpawnProcess-1: Traceback (most recent call last): File "/home/user/anaconda3/envs/kt311/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap self.run() File "/home/user/anaconda3/envs/kt311/lib/python3.11/multiprocessing/process.py", line 108, in run self._target(*self._args, **self._kwargs) File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/server/backend/interfaces/balance_serve.py", line 279, in run_engine engine.model_runner.warmup() File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/server/balance_serve/inference/model_runner.py", line 148, in warmup self.outputs_buf[i] = self.model(self.input[i], self.features_buf[i], self.bsz_tensor_buf, self.num_tokens_tensor_buf, self.page_idx_buf[i], self.page_offset_buf[i], cuda_graph_idx=i) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/models/custom_modeling_qwen3_moe.py", line 109, in forward hidden_states = decode_layer.mlp(hidden_states.unsqueeze(0), num_tokens_tensors, cuda_graph_idx) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/operators/experts.py", line 1438, in forward y = self.moe_on_cpuinfer(hidden_states, selected_experts, routing_weights, bsz_tensor, cuda_graph_idx).view(*orig_shape).to(device=hidden_states.device) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/operators/experts.py", line 1459, in moe_on_cpuinfer outs = self.experts(x, topk_ids, topk_weight, bsz_tensor, cuda_graph_idx) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl return self._call_impl(*args, *_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl return forward_call(_args, __kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/operators/experts.py", line 1272, in forward return self.generate_experts.forward(input_tensor, expert_ids, weights, bsz_tensor, cuda_graph_idx) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/operators/experts.py", line 311, in forward input_tensor = input_tensor.contiguous().cpu() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RuntimeError: CUDA error: an illegal memory access was encountered CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect. For debugging consider passing CUDA_LAUNCH_BLOCKING=1 Compile with `TORCH_USE_CUDA_DSA` to enable device-side assertions.2025-05-13 12:41:06,232 - INFO - flashinfer.jit:加载 JIT 操作:batch_prefill_with_kv_cache_dtype_q_bf16_dtype_kv_bf16_dtype_o_bf16_dtype_idx_i32_head_dim_qk_128_head_dim_vo_128_posenc_0_use_swa_False_use_logits_cap_False_f16qk_False 2025-05-13 12:41:06,246 - INFO - flashinfer.jit:已完成加载 JIT 操作: batch_prefill_with_kv_cache_dtype_q_bf16_dtype_kv_bf16_dtype_o_bf16_dtype_idx_i32_head_dim_qk_128_head_dim_vo_128_posenc_0_use_swa_False_use_logits_cap_False_f16qk_False 2025-05-13 12:41:06,629 - INFO - flashinfer.jit:正在加载 JIT 操作:norm 2025-05-13 12:41:06,641 - INFO - flashinfer.jit:已完成加载 JIT 操作:norm 2025-05-13 12:41:06,748 - INFO - flashinfer.jit:正在加载 JIT 操作:page 2025-05-13 12:41:06,759 - INFO - flashinfer.jit:已完成加载 JIT 操作:页面 cuda_graph:1/8,预热完成。捕获 cuda 图 2 2 cuda_graph:2/8,预热完成。捕获 cuda 图 3 3 cuda_graph:3/8,预热完成。捕获 cuda 图 1 1 cuda_graph:4/8,预热完成。 捕获 cuda graph 4 64 进程 SpawnProcess-1:回溯(最近一次调用最后一次):文件“/home/user/anaconda3/envs/kt311/lib/python3.11/multiprocessing/process.py”,第 314 行,在 _bootstrap self.run() 文件“/home/user/anaconda3/envs/kt311/lib/python3.11/multiprocessing/process.py”,第 108 行,在运行 self._target(*self._args, **self._kwargs) 文件“/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/server/backend/interfaces/balance_serve.py”,第 279 行,在 run_engine engine.model_runner.warmup() 文件中“/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/server/balance_serve/inference/model_runner.py”,第 148 行,正在预热 self.outputs_buf[i] = self.model(self.input[i], self.features_buf[i], self.bsz_tensor_buf, self.num_tokens_tensor_buf, self.page_idx_buf[i], self.page_offset_buf[i], cuda_graph_idx=i) ^ ... **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 文件“/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py”,第 1762 行,在 _call_impl 中返回 forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 文件“/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/models/custom_modeling_qwen3_moe.py”,第 109 行,在 forward hidden_​​states = decoder.mlp(hidden_​​states.unsqueeze(0), num_tokens_tensors,cuda_graph_idx) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 文件“/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py”,第 1751 行,在 _wrapped_call_impl 中返回 self._call_impl(*args,**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 文件“/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py”,第 1762 行,在 _call_impl 中返回 forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 文件“/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/operators/experts.py”,第 1438 行,在 forward y = self.moe_on_cpuinfer(hidden_​​states, selected_experts, routes_weights, bsz_tensor, cuda_graph_idx).view(*orig_shape).to(device=hidden_​​states.device) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 文件“/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/utils/_contextlib.py”,第 116 行,在 decorate_context return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^ 文件“/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/operators/experts.py”,行 1459,在 moe_on_cpuinfer outs = self.experts(x, topk_ids, topk_weight, bsz_tensor, cuda_graph_idx) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 文件“/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py”,第 1751 行,在 _wrapped_call_impl 中返回 self._call_impl(*args, *kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 文件“/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/nn/modules/module.py”,第 1762 行,在 _call_impl 中返回 forward_call(args,kwargs)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 文件“/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/operators/experts.py”,第 1272 行,在 forward 返回 self.generate_experts.forward(input_tensor、expert_ids、weights、bsz_tensor、cuda_graph_idx) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 文件“/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/ktransformers/operators/experts.py”,第 311 行,正向输入_tensor = input_tensor.contiguous().cpu() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RuntimeError:CUDA 错误:遇到非法内存访问 CUDA 内核错误可能会在其他一些 API 调用中异步报告,因此下面的堆栈跟踪可能不正确。 为了进行调试,请考虑传递 CUDA_LAUNCH_BLOCKING=1 使用 `TORCH_USE_CUDA_DSA` 进行编译以启用设备端断言。 > > > terminate called after throwing an instance of 'c10::Error' what(): CUDA error: an illegal memory access was encountered CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect. For debugging consider passing CUDA_LAUNCH_BLOCKING=1 Compile with `TORCH_USE_CUDA_DSA` to enable device-side assertions.在抛出“c10::Error”what() 实例后调用终止:CUDA 错误:遇到非法内存访问。CUDA 内核错误可能在其他 API 调用中异步报告,因此以下堆栈跟踪可能不正确。为了进行调试,请传递 CUDA_LAUNCH_BLOCKING=1 并使用 `TORCH_USE_CUDA_DSA` 进行编译以启用设备端断言。 > > > Exception raised from c10_cuda_check_implementation at /pytorch/c10/cuda/CUDAException.cpp:43 (most recent call first): frame #0: c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits, std::allocator >) + 0x98 (0x7f6acdd785e8 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10.so) frame [#1](https://github.com/kvcache-ai/ktransformers/discussions/1): c10::detail::torchCheckFail(char const_, char const_, unsigned int, std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&) + 0xe0 (0x7f6acdd0d4a2 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10.so) frame [#2](https://github.com/kvcache-ai/ktransformers/pull/2): c10::cuda::c10_cuda_check_implementation(int, char const_, char const_, int, bool) + 0x3c2 (0x7f6ace145422 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10_cuda.so) frame [#3](https://github.com/kvcache-ai/ktransformers/discussions/3): + 0x32953 (0x7f6ace121953 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10_cuda.so) frame [#4](https://github.com/kvcache-ai/ktransformers/issues/4): + 0x32b01 (0x7f6ace121b01 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10_cuda.so) frame [#5](https://github.com/kvcache-ai/ktransformers/issues/5): + 0x66c7f2 (0x7f6ac59bb7f2 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libtorch_python.so) frame [#6](https://github.com/kvcache-ai/ktransformers/discussions/6): + 0x457608 (0x7f6ac57a6608 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libtorch_python.so) frame [#7](https://github.com/kvcache-ai/ktransformers/pull/7): + 0x7b385 (0x7f6acdd59385 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10.so) frame [#8](https://github.com/kvcache-ai/ktransformers/issues/8): c10::TensorImpl::~TensorImpl() + 0x9 (0x7f6acdd52f39 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10.so) frame [#9](https://github.com/kvcache-ai/ktransformers/issues/9): + 0x7182b8 (0x7f6ac5a672b8 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libtorch_python.so) frame [#10](https://github.com/kvcache-ai/ktransformers/issues/10): + 0x7186d1 (0x7f6ac5a676d1 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libtorch_python.so) frame [#11](https://github.com/kvcache-ai/ktransformers/issues/11): /home/user/anaconda3/envs/kt311/bin/python() [0x4f5eb7] frame [#12](https://github.com/kvcache-ai/ktransformers/issues/12): /home/user/anaconda3/envs/kt311/bin/python() [0x5031bf] frame [#13](https://github.com/kvcache-ai/ktransformers/issues/13): /home/user/anaconda3/envs/kt311/bin/python() [0x55f246] frame [#14](https://github.com/kvcache-ai/ktransformers/pull/14): /home/user/anaconda3/envs/kt311/bin/python() [0x50302a] frame [#15](https://github.com/kvcache-ai/ktransformers/issues/15): /home/user/anaconda3/envs/kt311/bin/python() [0x5031bf] frame [#16](https://github.com/kvcache-ai/ktransformers/issues/16): /home/user/anaconda3/envs/kt311/bin/python() [0x55f246] frame [#17](https://github.com/kvcache-ai/ktransformers/pull/17): /home/user/anaconda3/envs/kt311/bin/python() [0x55ef87] frame [#18](https://github.com/kvcache-ai/ktransformers/pull/18): /home/user/anaconda3/envs/kt311/bin/python() [0x55f040] frame [#19](https://github.com/kvcache-ai/ktransformers/issues/19): /home/user/anaconda3/envs/kt311/bin/python() [0x541355] frame [#20](https://github.com/kvcache-ai/ktransformers/issues/20): /home/user/anaconda3/envs/kt311/bin/python() [0x53fd88] frame [#21](https://github.com/kvcache-ai/ktransformers/issues/21): /home/user/anaconda3/envs/kt311/bin/python() [0x53fdc4] frame [#22](https://github.com/kvcache-ai/ktransformers/issues/22): /home/user/anaconda3/envs/kt311/bin/python() [0x53fdc4] frame [#23](https://github.com/kvcache-ai/ktransformers/issues/23): /home/user/anaconda3/envs/kt311/bin/python() [0x54e833] frame [#24](https://github.com/kvcache-ai/ktransformers/pull/24): _PyEval_EvalFrameDefault + 0x46f9 (0x515ac9 in /home/user/anaconda3/envs/kt311/bin/python) frame [#25](https://github.com/kvcache-ai/ktransformers/pull/25): /home/user/anaconda3/envs/kt311/bin/python() [0x5cc3aa] frame [#26](https://github.com/kvcache-ai/ktransformers/pull/26): PyEval_EvalCode + 0x9f (0x5cba7f in /home/user/anaconda3/envs/kt311/bin/python) frame [#27](https://github.com/kvcache-ai/ktransformers/pull/27): /home/user/anaconda3/envs/kt311/bin/python() [0x5ecba7] frame [#28](https://github.com/kvcache-ai/ktransformers/issues/28): /home/user/anaconda3/envs/kt311/bin/python() [0x5e8740] frame [#29](https://github.com/kvcache-ai/ktransformers/pull/29): PyRun_StringFlags + 0x5f (0x5db24f in /home/user/anaconda3/envs/kt311/bin/python) frame [#30](https://github.com/kvcache-ai/ktransformers/pull/30): PyRun_SimpleStringFlags + 0x3b (0x5daffb in /home/user/anaconda3/envs/kt311/bin/python) frame [#31](https://github.com/kvcache-ai/ktransformers/issues/31): Py_RunMain + 0x388 (0x5f7498 in /home/user/anaconda3/envs/kt311/bin/python) frame [#32](https://github.com/kvcache-ai/ktransformers/issues/32): Py_BytesMain + 0x39 (0x5bc149 in /home/user/anaconda3/envs/kt311/bin/python) frame [#33](https://github.com/kvcache-ai/ktransformers/issues/33): + 0x29d90 (0x7f6ad082ad90 in /lib/x86_64-linux-gnu/libc.so.6) frame [#34](https://github.com/kvcache-ai/ktransformers/pull/34): __libc_start_main + 0x80 (0x7f6ad082ae40 in /lib/x86_64-linux-gnu/libc.so.6) frame [#35](https://github.com/kvcache-ai/ktransformers/pull/35): /home/user/anaconda3/envs/kt311/bin/python() [0x5bbf9/pytorch/c10/cuda/CUDAException.cpp:43 处的 c10_cuda_check_implementation 引发异常(最近一次调用):帧#0:c10 :: Error :: Error(c10 :: SourceLocation,std :: __ cxx11 :: basic_string)+ 0x98(/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10.so 中的 0x7f6acdd785e8)帧#1:c10 :: detail :: torchCheckFail(char const,char const,unsigned int,std :: __ cxx11 :: basic_string const&)+ 0xe0(0x7f6acdd0d4a2 /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10.so) frame #2: c10::cuda::c10_cuda_check_implementation(int, char const, char const, int, bool) + 0x3c2 (0x7f6ace145422 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10_cuda.so) frame [#3](https://github.com/kvcache-ai/ktransformers/discussions/3) : + 0x32953 (0x7f6ace121953 in /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10_cuda.so) frame [#4](https://github.com/kvcache-ai/ktransformers/issues/4) : + 0x32b01 (/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10_cuda.so 中的 0x7f6ace121b01) 帧 [#5](https://github.com/kvcache-ai/ktransformers/issues/5) :+ 0x66c7f2 (/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libtorch_python.so 中的 0x7f6ac59bb7f2) 帧 [#6](https://github.com/kvcache-ai/ktransformers/discussions/6) :+ 0x457608 (/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libtorch_python.so 中的 0x7f6ac57a6608) 帧 [#7](https://github.com/kvcache-ai/ktransformers/pull/7) :+ 0x7b385 ( /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10.so) 框架 [#8](https://github.com/kvcache-ai/ktransformers/issues/8) :c10 :: TensorImpl ::〜TensorImpl()+ 0x9(0x7f6acdd52f39 在/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libc10.so)框架 [#9](https://github.com/kvcache-ai/ktransformers/issues/9) :+ 0x7182b8(0x7f6ac5a672b8 在/home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libtorch_python.so)框架 [#10](https://github.com/kvcache-ai/ktransformers/issues/10) :+ 0x7186d1(0x7f6ac5a676d1 在 /home/user/anaconda3/envs/kt311/lib/python3.11/site-packages/torch/lib/libtorch_python.so) 框架 [#11](https://github.com/kvcache-ai/ktransformers/issues/11) :/home/user/anaconda3/envs/kt311/bin/python()[0x4f5eb7] 框架 [#12](https://github.com/kvcache-ai/ktransformers/issues/12) :/home/user/anaconda3/envs/kt311/bin/python()[0x5031bf] 框架 [#13](https://github.com/kvcache-ai/ktransformers/issues/13) :/home/user/anaconda3/envs/kt311/bin/python()[0x55f246] 框架 [#14](https://github.com/kvcache-ai/ktransformers/pull/14) :/home/user/anaconda3/envs/kt311/bin/python()[0x50302a] 框架 [#15](https://github.com/kvcache-ai/ktransformers/issues/15) :/home/user/anaconda3/envs/kt311/bin/python()[0x5031bf] 框架 [#16](https://github.com/kvcache-ai/ktransformers/issues/16) :/home/user/anaconda3/envs/kt311/bin/python() [0x55f246] 帧 [#17](https://github.com/kvcache-ai/ktransformers/pull/17) :/home/user/anaconda3/envs/kt311/bin/python() [0x55ef87] 帧 [#18](https://github.com/kvcache-ai/ktransformers/pull/18) :/home/user/anaconda3/envs/kt311/bin/python() [0x55f040] 帧 [#19](https://github.com/kvcache-ai/ktransformers/issues/19) :/home/user/anaconda3/envs/kt311/bin/python() [0x541355] 帧 [#20](https://github.com/kvcache-ai/ktransformers/issues/20) :/home/user/anaconda3/envs/kt311/bin/python() [0x53fd88] 帧 [#21](https://github.com/kvcache-ai/ktransformers/issues/21) :/home/user/anaconda3/envs/kt311/bin/python() [0x53fdc4] 帧 [#22](https://github.com/kvcache-ai/ktransformers/issues/22) : /home/user/anaconda3/envs/kt311/bin/python() [0x53fdc4] 帧 [#23](https://github.com/kvcache-ai/ktransformers/issues/23) :/home/user/anaconda3/envs/kt311/bin/python() [0x54e833] 帧 [#24](https://github.com/kvcache-ai/ktransformers/pull/24) :_PyEval_EvalFrameDefault + 0x46f9(/home/user/anaconda3/envs/kt311/bin/python 中的 0x515ac9) 帧 [#25](https://github.com/kvcache-ai/ktransformers/pull/25) :/home/user/anaconda3/envs/kt311/bin/python() [0x5cc3aa] 帧 [#26](https://github.com/kvcache-ai/ktransformers/pull/26) :PyEval_EvalCode + 0x9f(/home/user/anaconda3/envs/kt311/bin/python 中的 0x5cba7f) 帧 [#27](https://github.com/kvcache-ai/ktransformers/pull/27) : /home/user/anaconda3/envs/kt311/bin/python() [0x5ecba7] 帧 [#28](https://github.com/kvcache-ai/ktransformers/issues/28) :/home/user/anaconda3/envs/kt311/bin/python() [0x5e8740] 帧 [#29](https://github.com/kvcache-ai/ktransformers/pull/29) :PyRun_StringFlags + 0x5f(/home/user/anaconda3/envs/kt311/bin/python 中的 0x5db24f) 帧 [#30](https://github.com/kvcache-ai/ktransformers/pull/30) :PyRun_SimpleStringFlags + 0x3b(0x5daffb /home/user/anaconda3/envs/kt311/bin/python) 框架 [#31](https://github.com/kvcache-ai/ktransformers/issues/31) : Py_RunMain + 0x388 (/home/user/anaconda3/envs/kt311/bin/python 中的 0x5f7498) 框架 [#32](https://github.com/kvcache-ai/ktransformers/issues/32) : Py_BytesMain + 0x39 (/home/user/anaconda3/envs/kt311/bin/python 中的 0x5bc149) 框架 [#33](https://github.com/kvcache-ai/ktransformers/issues/33) : + 0x29d90 (/lib/x86_64-linux-gnu/libc.so.6 中的 0x7f6ad082ad90) 框架 [#34](https://github.com/kvcache-ai/ktransformers/pull/34) : __libc_start_main + 0x80 (/lib/x86_64-linux-gnu/libc.so.6 中的 0x7f6ad082ae40) 框架 [#35](https://github.com/kvcache-ai/ktransformers/pull/35) : /home/user/anaconda3/envs/kt311/bin/python() [0x5bbf9 > > > ![Image](https://github.com/user-attachments/assets/655518cb-7cdf-45e1-857f-c93412638b37) > > > > > > 我刚刚提交了一份新的代码,默认的 cache_lens 太小了,你改成 10k以上试试呢 > > 嗯嗯,运行成功了,有个小问题想问下,92GB显存,256GB内存 Q4量化,使用ktransformers的话最多同时支持多少人访问呢 这个主要取决于设置的 max_batch_size 和 cache_lens,默认 max_batch_size=4 支持 4 并发,另外如果你当前运行的所有请求 cache 长度超过了 cache_lens 程序会降并发度
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#871
No description provided.