[Cherry-Pick][Loader] Add values natural order check to layers grouped validation#7822
Conversation
|
Thanks for your contribution! |
PaddlePaddle-bot
left a comment
There was a problem hiding this comment.
🤖 Paddle-CI-Agent | pr_review |
2026-05-14 20:28:35
📋 Review 摘要
PR 概述:在 get_all_weights_file 中新增 values 自然序校验,确保 is_layers_are_grouped 标志同时满足 keys 分组和 values 自然序两个条件。
变更范围:fastdeploy/model_executor/load_weight_utils.py
影响面 Tag:[Loader]
📝 PR 规范检查
PR 存在两处不合规:① Cherry-Pick 标题缺少原始 PR 编号;② Motivation/Modifications 等描述章节内容为空。
标题建议(可直接复制):
[Cherry-Pick][Loader] Add values natural order check to layers grouped validation(#原PR号)
PR 描述建议(可直接复制,必须复刻 checklist §D2 模板的完整结构):
## Motivation
当 `weight_map` 的 values(safetensors 分片文件名)不满足自然序时,`layers_are_grouped` 仅检查 keys 分组而不检查文件名顺序,可能导致在不应使用逐文件迭代器的场景下误用 `safetensors_weights_iterator`,从而引发权重加载顺序错误。本次变更在 layers 分组检查之外,增加对 values 自然序的校验。
## Modifications
- 新增 `values_are_naturally_ordered(values)` 函数(`load_weight_utils.py`):检查 weight_map 的 values 列表是否满足自然序
- 修改 `get_all_weights_file` 函数中多文件 safetensors 分支:将 `is_layers_are_grouped` 改为 `is_keys_grouped AND is_values_naturally_ordered` 的联合判断
## 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.问题
| 级别 | 文件 | 概述 |
|---|---|---|
| ❓ 疑问 | fastdeploy/model_executor/load_weight_utils.py:541 |
变量名 is_keys_orders 与 layers_are_grouped 函数语义不匹配,建议改为 is_keys_grouped |
总体评价
逻辑变更合理,补充了文件名自然序校验,提升了分组判断的健壮性。建议补充 PR 描述信息并修正 Cherry-Pick 标题格式(需补充原始 PR 编号)。
| keys = list(weight_map.keys()) | ||
| is_layers_are_grouped = layers_are_grouped(keys) | ||
| values = list(weight_map.values()) | ||
| is_keys_orders = layers_are_grouped(keys) |
There was a problem hiding this comment.
❓ 疑问 变量名 is_keys_orders 语义略显模糊,与 layers_are_grouped 函数名所表达的"分组"含义不一致。
建议改为 is_keys_grouped 与函数名保持一致:
is_keys_grouped = layers_are_grouped(keys)
is_values_naturally_ordered = values_are_naturally_ordered(values)
is_layers_are_grouped = is_keys_grouped and is_values_naturally_ordered
CI报告基于以下代码生成(30分钟更新一次): 1 任务总览⏳ CI 进行中,Required 任务尚未完成(1个运行中,1个等待中),请等待结果。
2 任务状态汇总2.1 Required任务 : 0/2 通过
2.2 可选任务 — 12/15 通过
3 失败详情(仅 required)无 |
Motivation
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.