[Iluvatar] Fix cannot import name mtp_save_first_token#7495
[Iluvatar] Fix cannot import name mtp_save_first_token#7495EmmonsCurse merged 2 commits intoPaddlePaddle:developfrom
Conversation
|
Thanks for your contribution! |
|
/re-run all-failed |
|
/re-run all-failed |
|
/skip-ci ci_hpu |
PaddlePaddle-bot
left a comment
There was a problem hiding this comment.
🤖 AI Code Review |
2026-04-21 11:35:41
📋 Review 摘要
PR 概述:将 mtp_save_first_token 和 mtp_save_first_token_with_topk 两个 GPU 算子的导入从顶层无条件导入移至平台判断的 GPU(else)分支内,修复非 GPU 硬件平台的导入报错。
变更范围:model_executor/pre_and_post_process.py
影响面 Tag:Iluvatar OP
📝 PR 规范检查
PR 描述中 Modifications 部分填写为 "Pass",建议补充具体的修改内容说明。
描述建议(可直接复制):
Modifications
将
mtp_save_first_token和mtp_save_first_token_with_topk的导入从文件顶层的无条件导入(from fastdeploy.model_executor.ops.gpu import ...)移至current_platform条件分支的else(GPU/CUDA)分支内,避免 Iluvatar、GCU、HPU 等非 GPU 平台执行到该导入时因找不到 GPU 算子而报错。
问题
未发现阻塞性问题。
总体评价
修复逻辑正确且影响面很小。mtp_save_first_token 和 mtp_save_first_token_with_topk 是 GPU 专属自定义算子(定义在 custom_ops/gpu_ops/ 下),原先被无条件导入会导致非 GPU 平台(如 Iluvatar)启动时报 ImportError。本次修改将其移入 else: 分支(即 CUDA/GPU 默认路径),与同分支内其他 GPU 算子(如 custom_numpy_to_tensor、speculate_limit_thinking_content_length 等)导入方式保持一致,修复合理。
Motivation
该pr导入了mtp_save_first_token和mtp_save_first_token_with_topk两个gpu算子,其他硬件执行到这里会报错,所以需要移到gpu分支里
Modifications
Pass
Usage or Command
Pass>
Accuracy Tests
Pass
Checklist
[FDConfig],[APIServer],[Engine],[Scheduler],[PD Disaggregation],[Executor],[Graph Optimization],[Speculative Decoding],[RL],[Models],[Quantization],[Loader],[OP],[KVCache],[DataProcessor],[BugFix],[Docs],[CI],[Optimization],[Feature],[Benchmark],[Others],[XPU],[HPU],[GCU],[DCU],[Iluvatar],[Metax]]pre-commitbefore commit.releasebranch, make sure the PR has been submitted to thedevelopbranch, then cherry-pick it to thereleasebranch with the[Cherry-Pick]PR tag.