[GH-ISSUE #1050] [Feature] capturing cuda graph加载比较慢 #740

Closed
opened 2026-10-29 14:43:48 +00:00 by bsakaguchi · 4 comments
Owner

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

Checklist

  • 1. If the issue you raised is not a feature but a question, please raise a discussion at https://github.com/kvcache-ai/ktransformers/discussions. Otherwise, it will be closed.
  • 2. To help the community, I will use Chinese/English or attach an Chinese/English translation if using another language. Non-English/Chinese content without translation may be closed.

Motivation

到这一步的时候加载比较慢,有办法优化吗
loading output_norm.weight to cuda
capturing cuda graph 1 1
2025-04-05 12:17:54,410 - INFO - flashinfer.jit: Loading JIT ops: batch_mla_attention_dtype_q_bf16_dtype_kv_bf16_dtype_o_bf16_dtype_idx_i32_head_dim_ckv_512_head_dim_kpe_64_profiler_False
/home/sean/miniconda3/envs/kt/lib/python3.10/site-packages/torch/utils/cpp_extension.py:2059: UserWarning: TORCH_CUDA_ARCH_LIST is not set, all archs for visible cards are included for compilation.
If this is not desired, please set os.environ['TORCH_CUDA_ARCH_LIST'].
warnings.warn(
/home/sean/miniconda3/envs/kt/lib/python3.10/site-packages/torch/utils/cpp_extension.py:2059: UserWarning: TORCH_CUDA_ARCH_LIST is not set, all archs for visible cards are included for compilation.
If this is not desired, please set os.environ['TORCH_CUDA_ARCH_LIST'].
warnings.warn(
2025-04-05 12:17:54,431 - INFO - flashinfer.jit: Finished loading JIT ops: batch_mla_attention_dtype_q_bf16_dtype_kv_bf16_dtype_o_bf16_dtype_idx_i32_head_dim_ckv_512_head_dim_kpe_64_profiler_False
2025-04-05 12:17:54,457 - INFO - flashinfer.jit: Loading JIT ops: norm
/home/sean/miniconda3/envs/kt/lib/python3.10/site-packages/torch/utils/cpp_extension.py:2059: UserWarning: TORCH_CUDA_ARCH_LIST is not set, all archs for visible cards are included for compilation.
If this is not desired, please set os.environ['TORCH_CUDA_ARCH_LIST'].
warnings.warn(
/home/sean/miniconda3/envs/kt/lib/python3.10/site-packages/torch/utils/cpp_extension.py:2059: UserWarning: TORCH_CUDA_ARCH_LIST is not set, all archs for visible cards are included for compilation.
If this is not desired, please set os.environ['TORCH_CUDA_ARCH_LIST'].
warnings.warn(
2025-04-05 12:17:54,474 - INFO - flashinfer.jit: Finished loading JIT ops: norm
cuda_graph: 1/6, warmup finished.
capturing cuda graph 2 2
cuda_graph: 2/6, warmup finished.
capturing cuda graph 3 3
cuda_graph: 3/6, warmup finished.
capturing cuda graph 4 4
cuda_graph: 4/6, warmup finished.
capturing cuda graph 4 64
cuda_graph: 5/6, warmup finished.
capturing cuda graph 4 256
cuda_graph: 6/6, warmup finished.

No response

Originally created by @344303947 on GitHub (Apr 5, 2025). Original GitHub issue: https://github.com/kvcache-ai/ktransformers/issues/1050 ### Checklist - [x] 1. If the issue you raised is not a feature but a question, please raise a discussion at https://github.com/kvcache-ai/ktransformers/discussions. Otherwise, it will be closed. - [x] 2. To help the community, I will use Chinese/English or attach an Chinese/English translation if using another language. Non-English/Chinese content without translation may be closed. ### Motivation 到这一步的时候加载比较慢,有办法优化吗 loading output_norm.weight to cuda capturing cuda graph 1 1 2025-04-05 12:17:54,410 - INFO - flashinfer.jit: Loading JIT ops: batch_mla_attention_dtype_q_bf16_dtype_kv_bf16_dtype_o_bf16_dtype_idx_i32_head_dim_ckv_512_head_dim_kpe_64_profiler_False /home/sean/miniconda3/envs/kt/lib/python3.10/site-packages/torch/utils/cpp_extension.py:2059: UserWarning: TORCH_CUDA_ARCH_LIST is not set, all archs for visible cards are included for compilation. If this is not desired, please set os.environ['TORCH_CUDA_ARCH_LIST']. warnings.warn( /home/sean/miniconda3/envs/kt/lib/python3.10/site-packages/torch/utils/cpp_extension.py:2059: UserWarning: TORCH_CUDA_ARCH_LIST is not set, all archs for visible cards are included for compilation. If this is not desired, please set os.environ['TORCH_CUDA_ARCH_LIST']. warnings.warn( 2025-04-05 12:17:54,431 - INFO - flashinfer.jit: Finished loading JIT ops: batch_mla_attention_dtype_q_bf16_dtype_kv_bf16_dtype_o_bf16_dtype_idx_i32_head_dim_ckv_512_head_dim_kpe_64_profiler_False 2025-04-05 12:17:54,457 - INFO - flashinfer.jit: Loading JIT ops: norm /home/sean/miniconda3/envs/kt/lib/python3.10/site-packages/torch/utils/cpp_extension.py:2059: UserWarning: TORCH_CUDA_ARCH_LIST is not set, all archs for visible cards are included for compilation. If this is not desired, please set os.environ['TORCH_CUDA_ARCH_LIST']. warnings.warn( /home/sean/miniconda3/envs/kt/lib/python3.10/site-packages/torch/utils/cpp_extension.py:2059: UserWarning: TORCH_CUDA_ARCH_LIST is not set, all archs for visible cards are included for compilation. If this is not desired, please set os.environ['TORCH_CUDA_ARCH_LIST']. warnings.warn( 2025-04-05 12:17:54,474 - INFO - flashinfer.jit: Finished loading JIT ops: norm cuda_graph: 1/6, warmup finished. capturing cuda graph 2 2 cuda_graph: 2/6, warmup finished. capturing cuda graph 3 3 cuda_graph: 3/6, warmup finished. capturing cuda graph 4 4 cuda_graph: 4/6, warmup finished. capturing cuda graph 4 64 cuda_graph: 5/6, warmup finished. capturing cuda graph 4 256 cuda_graph: 6/6, warmup finished. ### Related resources _No response_
Author
Owner

@qiyuxinlin commented on GitHub (Apr 5, 2025):

您好,我们开了 [1,2,3,4,64,256] 这几组 cuda graph,其中 256 对应 chunk_size,您可以调整 chunk_size 来加速 capture 流程,但是这可能会影响 prefill 速度

<!-- gh-comment-id:2780264009 --> @qiyuxinlin commented on GitHub (Apr 5, 2025): 您好,我们开了 [1,2,3,4,64,256] 这几组 cuda graph,其中 256 对应 chunk_size,您可以调整 chunk_size 来加速 capture 流程,但是这可能会影响 prefill 速度
Author
Owner

@344303947 commented on GitHub (Apr 5, 2025):

好的感谢告知,就是对比以前的版本 load 完成就可以对话了,感觉时间长了很多。

<!-- gh-comment-id:2780298812 --> @344303947 commented on GitHub (Apr 5, 2025): 好的感谢告知,就是对比以前的版本 load 完成就可以对话了,感觉时间长了很多。
Author
Owner

@344303947 commented on GitHub (Apr 5, 2025):

--max_new_tokens 2024
--cache_lens 32768

设置成 --max_new_tokens 32000 \ 如果设置过高,就不会并发执行了,不知道是什么问题

<!-- gh-comment-id:2780350602 --> @344303947 commented on GitHub (Apr 5, 2025): --max_new_tokens 2024 \ --cache_lens 32768 设置成 --max_new_tokens 32000 \ 如果设置过高,就不会并发执行了,不知道是什么问题
Author
Owner

@yeungtuzi commented on GitHub (Apr 10, 2025):

--max_new_tokens 2024 --cache_lens 32768

设置成 --max_new_tokens 32000 \ 如果设置过高,就不会并发执行了,不知道是什么问题

需要cache_lens >= 并发数*max_new_tokens

<!-- gh-comment-id:2792213992 --> @yeungtuzi commented on GitHub (Apr 10, 2025): > --max_new_tokens 2024 --cache_lens 32768 > > 设置成 --max_new_tokens 32000 \ 如果设置过高,就不会并发执行了,不知道是什么问题 需要cache_lens >= 并发数*max_new_tokens
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#740
No description provided.