Skip to content

[Iluvatar] Fix cannot import name mtp_save_first_token#7495

Merged
EmmonsCurse merged 2 commits intoPaddlePaddle:developfrom
wuyujiji:yuzhe_dev
Apr 21, 2026
Merged

[Iluvatar] Fix cannot import name mtp_save_first_token#7495
EmmonsCurse merged 2 commits intoPaddlePaddle:developfrom
wuyujiji:yuzhe_dev

Conversation

@wuyujiji
Copy link
Copy Markdown
Contributor

@wuyujiji wuyujiji commented Apr 20, 2026

Motivation

pr导入了mtp_save_first_token和mtp_save_first_token_with_topk两个gpu算子,其他硬件执行到这里会报错,所以需要移到gpu分支里

Modifications

Pass

Usage or Command

Pass>

Accuracy Tests

Pass

Checklist

  • Add at least a tag in the PR title.
    • Tag list: [[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]]
    • You can add new tags based on the PR content, but the semantics must be clear.
  • Format your code, run pre-commit before commit.
  • Add unit tests. Please write the reason in this PR if no unit tests.
  • Provide accuracy results.
  • If the current PR is submitting to the release branch, make sure the PR has been submitted to the develop branch, then cherry-pick it to the release branch with the [Cherry-Pick] PR tag.

@paddle-bot
Copy link
Copy Markdown

paddle-bot Bot commented Apr 20, 2026

Thanks for your contribution!

@paddle-bot paddle-bot Bot added the contributor External developers label Apr 20, 2026
PaddlePaddle-bot

This comment was marked as outdated.

@wuyujiji
Copy link
Copy Markdown
Contributor Author

/re-run all-failed

@wuyujiji
Copy link
Copy Markdown
Contributor Author

/re-run all-failed

@EmmonsCurse
Copy link
Copy Markdown
Collaborator

/skip-ci ci_hpu
/skip-ci build_gpu
/skip-ci build_xpu

Copy link
Copy Markdown

@PaddlePaddle-bot PaddlePaddle-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 AI Code Review | 2026-04-21 11:35:41

📋 Review 摘要

PR 概述:将 mtp_save_first_tokenmtp_save_first_token_with_topk 两个 GPU 算子的导入从顶层无条件导入移至平台判断的 GPU(else)分支内,修复非 GPU 硬件平台的导入报错。
变更范围model_executor/pre_and_post_process.py
影响面 TagIluvatar OP

📝 PR 规范检查

PR 描述中 Modifications 部分填写为 "Pass",建议补充具体的修改内容说明。

描述建议(可直接复制):

Modifications

mtp_save_first_tokenmtp_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_tokenmtp_save_first_token_with_topk 是 GPU 专属自定义算子(定义在 custom_ops/gpu_ops/ 下),原先被无条件导入会导致非 GPU 平台(如 Iluvatar)启动时报 ImportError。本次修改将其移入 else: 分支(即 CUDA/GPU 默认路径),与同分支内其他 GPU 算子(如 custom_numpy_to_tensorspeculate_limit_thinking_content_length 等)导入方式保持一致,修复合理。

@EmmonsCurse EmmonsCurse merged commit e4a4573 into PaddlePaddle:develop Apr 21, 2026
37 of 38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor External developers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants