[GH-ISSUE #928] per_layer_prefill_intput_threshold参数设置为非0都报错 #660

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

Originally created by @riou-chen on GitHub (Mar 19, 2025).
Original GitHub issue: https://github.com/kvcache-ai/ktransformers/issues/928

检查清单

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

问题描述

如题,per_layer_prefill_intput_threshold这个参数在yaml中,默认配置为0,但是修改为其他值,例如128,1024等都报错,请问这个参数是用来控制什么的?怎样使用它才能生效?

复现步骤

  • match:
    name: "^model$"
    replace:
    class: "ktransformers.operators.models.KDeepseekV2Model"
    kwargs:
    per_layer_prefill_intput_threshold: 1024 # 0 is close layer wise prefill
    transfer_map:
    30: "cuda:1"
    类似于这样修改,会报self.up is None这种错误

环境信息

AMD 9A54+4090*2+1.5TDRAM

Originally created by @riou-chen on GitHub (Mar 19, 2025). Original GitHub issue: https://github.com/kvcache-ai/ktransformers/issues/928 ### 检查清单 - [ ] 1. 我已经搜索过相关问题,但未能获得预期的帮助 - [ ] 2. 该问题在最新版本中尚未修复 - [ ] 3. 请注意,如果您提交的BUG相关 issue 缺少对应环境信息和最小可复现示例,我们将难以复现和定位问题,降低获得反馈的可能性 - [ ] 4. 如果您提出的不是bug而是问题,请在讨论区发起讨论 https://github.com/kvcache-ai/ktransformers/discussions。否则该 issue 将被关闭 - [ ] 5. 为方便社区交流,我将使用中文/英文或附上中文/英文翻译(如使用其他语言)。未附带翻译的非中文/英语内容可能会被关闭 ### 问题描述 如题,per_layer_prefill_intput_threshold这个参数在yaml中,默认配置为0,但是修改为其他值,例如128,1024等都报错,请问这个参数是用来控制什么的?怎样使用它才能生效? ### 复现步骤 - match: name: "^model$" replace: class: "ktransformers.operators.models.KDeepseekV2Model" kwargs: per_layer_prefill_intput_threshold: 1024 # 0 is close layer wise prefill transfer_map: 30: "cuda:1" 类似于这样修改,会报self.up is None这种错误 ### 环境信息 AMD 9A54+4090*2+1.5TDRAM
Author
Owner

@Atream commented on GitHub (Mar 19, 2025):

此参数用于在输入prompt非常长时,将权重逐层转移到GPU上进行prefill,因为非常长的阈值很大,此功能有一段时间没有维护了,目前暂时通过设置0来禁用了。

<!-- gh-comment-id:2735828862 --> @Atream commented on GitHub (Mar 19, 2025): 此参数用于在输入prompt非常长时,将权重逐层转移到GPU上进行prefill,因为非常长的阈值很大,此功能有一段时间没有维护了,目前暂时通过设置0来禁用了。
Author
Owner

@riou-chen commented on GitHub (Mar 19, 2025):

通过这种方法可以加速prefill吗?目前的版本0.2.3开启这个功能会报错,有哪个版本或者方法开启这个功能吗?

<!-- gh-comment-id:2735862451 --> @riou-chen commented on GitHub (Mar 19, 2025): 通过这种方法可以加速prefill吗?目前的版本0.2.3开启这个功能会报错,有哪个版本或者方法开启这个功能吗?
Author
Owner

@Atream commented on GitHub (Mar 19, 2025):

只能在10K以上的prompt时加速prefill,目前我们不知道哪个版本可以开启此功能且能跑DeepSeek-V3/R1. 后续会修复此功能

<!-- gh-comment-id:2736031040 --> @Atream commented on GitHub (Mar 19, 2025): 只能在10K以上的prompt时加速prefill,目前我们不知道哪个版本可以开启此功能且能跑DeepSeek-V3/R1. 后续会修复此功能
Author
Owner

@KingZypp0821 commented on GitHub (Apr 7, 2025):

只能在10K以上的prompt时加速prefill,目前我们不知道哪个版本可以开启此功能且能跑DeepSeek-V3/R1. 后续会修复此功能

是否意味着,配置文件中的 prefill_device: "cuda" prefill_op: "KExpertsTorch"其实实际并没有生效呢?我走读代码发现,虽然配置了KExpertsTorch,但是实际参数加载和推理过程中,并没有执行到其中的load和forward逻辑。 @Atream

<!-- gh-comment-id:2781893622 --> @KingZypp0821 commented on GitHub (Apr 7, 2025): > 只能在10K以上的prompt时加速prefill,目前我们不知道哪个版本可以开启此功能且能跑DeepSeek-V3/R1. 后续会修复此功能 是否意味着,配置文件中的 prefill_device: "cuda" prefill_op: "KExpertsTorch"其实实际并没有生效呢?我走读代码发现,虽然配置了KExpertsTorch,但是实际参数加载和推理过程中,并没有执行到其中的load和forward逻辑。 @Atream
Author
Owner

@weiyongsen commented on GitHub (May 29, 2025):

只能在10K以上的prompt时加速prefill,目前我们不知道哪个版本可以开启此功能且能跑DeepSeek-V3/R1. 后续会修复此功能

是否意味着,配置文件中的 prefill_device: "cuda" prefill_op: "KExpertsTorch"其实实际并没有生效呢?我走读代码发现,虽然配置了KExpertsTorch,但是实际参数加载和推理过程中,并没有执行到其中的load和forward逻辑。 @Atream

应该是的,我看operators/models下的KDeepseekV2Model类中,设置不同层推理阶段是prefill还是generate的set_inference_mode函数只有load_layer_to()中有,但是per_layer_prefill_intput_threshold=0进不到这个load_layer_to()函数中。默认传的InferenceState好像都是Generate,只用到配置文件中的generate_op和generate_device,应该是这样吧。

<!-- gh-comment-id:2918914844 --> @weiyongsen commented on GitHub (May 29, 2025): > > 只能在10K以上的prompt时加速prefill,目前我们不知道哪个版本可以开启此功能且能跑DeepSeek-V3/R1. 后续会修复此功能 > > 是否意味着,配置文件中的 prefill_device: "cuda" prefill_op: "KExpertsTorch"其实实际并没有生效呢?我走读代码发现,虽然配置了KExpertsTorch,但是实际参数加载和推理过程中,并没有执行到其中的load和forward逻辑。 [@Atream](https://github.com/Atream) 应该是的,我看operators/models下的KDeepseekV2Model类中,设置不同层推理阶段是prefill还是generate的set_inference_mode函数只有load_layer_to()中有,但是per_layer_prefill_intput_threshold=0进不到这个load_layer_to()函数中。默认传的InferenceState好像都是Generate,只用到配置文件中的generate_op和generate_device,应该是这样吧。
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#660
No description provided.