[Cherry-Pick][Feature] Support glm yarn scaling rope (#7893)#7894
[Cherry-Pick][Feature] Support glm yarn scaling rope (#7893)#7894Sunny-bot1 wants to merge 1 commit into
Conversation
|
Thanks for your contribution! |
PaddlePaddle-bot
left a comment
There was a problem hiding this comment.
🤖 Paddle-CI-Agent | pr_review |
2026-05-22 12:24:29
📋 Review 摘要
PR 概述:为 GLM 架构新增 YaRN RoPE 缩放支持,并将 GptOssScalingRotaryEmbedding 重命名为 YarnScalingRotaryEmbedding 以统一命名
变更范围:fastdeploy/model_executor/layers/rotary_embedding.py
影响面 Tag:[OP] [Models]
问题
| 级别 | 文件 | 概述 |
|---|---|---|
| ❓ 疑问 | rotary_embedding.py:354 |
original_max_position_embeddings 键缺少存在性检查,可能 KeyError |
| 📝 PR 规范 | — | 标题拼写错误(Supoort);描述各段均为空 |
📝 PR 规范检查
问题一:标题拼写错误 — Supoort 应为 Support,同时 Cherry-Pick 格式整体合规(Tag 正确、末尾含原 PR 号)。
标题建议(可直接复制):
[Cherry-Pick][Feature] Support glm yarn scaling rope (#7893)
问题二:描述各段均为空/仅占位符,不符合模板要求。
PR 描述建议(可直接复制):
## Motivation
为 GLM 系列模型(如 GLM4)新增 YaRN(Yet another RoPE extensioN)位置编码缩放支持,以适配在更长上下文场景下部署的模型配置(`rope_scaling.type == "yarn"`)。
## Modifications
- 将 `GptOssScalingRotaryEmbedding` 类重命名为 `YarnScalingRotaryEmbedding`,统一命名风格
- 在 `get_rope_impl` 的 `Glm` 分支中新增 rope_scaling 检测逻辑:当 `rope_scaling` 配置类型为 `yarn` 且含 `factor` 字段时,使用 `YarnScalingRotaryEmbedding` 替代原 `GlmRotaryEmbedding`
## Usage or Command
N/A
## Accuracy Tests
N/A
## Checklist
- [x] 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.
- [x] 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.总体评价
整体实现思路清晰,GLM yarn RoPE 的条件分支逻辑合理,类重命名也无遗留引用风险。建议修复 original_max_position_embeddings 的键存在性检查,以提高配置容错性;PR 标题拼写和描述模板请一并补全。
| rotary_emb_layer = YarnScalingRotaryEmbedding( | ||
| rotary_dim=yarn_rotary_dim, | ||
| base=base, | ||
| original_max_position_embeddings=rope_scaling["original_max_position_embeddings"], |
There was a problem hiding this comment.
❓ 疑问 original_max_position_embeddings 键无存在性检查
代码已通过 "factor" in rope_scaling 进行了部分校验,但 rope_scaling["original_max_position_embeddings"] 是直接下标访问,若 GLM 模型配置中缺少该键(例如旧版 config.json),将在运行时抛出 KeyError。
建议修复方式:
original_max_position_embeddings=rope_scaling.get("original_max_position_embeddings", 8192),或在前置条件判断中一并检查该键是否存在:
and "original_max_position_embeddings" in rope_scaling
CI报告基于以下代码生成(30分钟更新一次): 1 任务总览Required 任务当前 1 个失败、0 个运行中、0 个等待中;阻塞合并的是覆盖率门禁,建议补齐新增分支单测后重跑。
2 任务状态汇总日志列说明:失败任务直接使用日志链接;运行中/等待中任务展示 Job 或 Workflow 链接。 2.1 Required任务 : 9/10 通过
2.2 可选任务 — 22/26 通过
3 失败详情(仅 required)Run FastDeploy Unit Tests and Coverage / run_tests_with_coverage — 覆盖率门禁(置信度: 高)Run FastDeploy Unit Tests and Coverage / run_tests_with_coverage
失败用例:
根因详情: 关键日志: 修复建议:
修复建议摘要: 补充 get_rope_impl 分支单测 关联变更: |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## release/2.6 #7894 +/- ##
==============================================
Coverage ? 72.40%
==============================================
Files ? 381
Lines ? 54229
Branches ? 8474
==============================================
Hits ? 39266
Misses ? 12203
Partials ? 2760
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Motivation
支持GLM 256K 长上下文推理
Modifications
Usage or Command
Accuracy Tests
结果
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.