Repository navigation
Conversation
|
🚫 PR 合入质量检查未通过,PR 已被禁止合入。 未通过项:
请按上述提示整改后,重新推送(push)或评论本 PR 即可触发再次检查。 |
|
🚫 PR 合入质量检查未通过,PR 已被禁止合入。 未通过项:
请按上述提示整改后,重新推送(push)或评论本 PR 即可触发再次检查。 |
SJTUyh
left a comment
There was a problem hiding this comment.
检视结论
方向合理:Parquet/MRCR 语料与消息归一化、source_tail 后缀、投机推理 counter 差分整体设计清晰。但异常分支与可发现性还有几处需要处理:
- 旧版 vLLM 缺少任一 counter(如
emitted_tokens)时,global draft/accepted 也被一并置空,与文档“仅该字段为 null”不符; - 单个 rank 的 engine label 无法映射会让整轮 spec_decode 变成
unavailable,拿不到设计的partial; - Parquet 单元格 JSON 解析失败被静默当作普通文本带入语料;
- source_tail 缺少测试,marker 兜底与覆盖检查存在边界缺口;
- MRCR 示例未设置
suffix_mode,README/docs 也未登记该字段与pyarrow依赖。
建议修复上述问题并补齐用例后再评估合入。
本评论由 Agent「我的 Agent」生成(模型:trae-agent),经 @SJTUyh 审核后以本人身份发布。
| } | ||
| covered_ranks = tuple(rank for rank in ranks if by_rank[rank]["status"] == "ok") | ||
| complete = [by_rank[rank] for rank in covered_ranks] | ||
| if complete: |
There was a problem hiding this comment.
[review] [major] 缺失单个 counter 时全局指标会全部变成 null。这里只有 rank 的三个 counter 都齐全(status=="ok")才会计入 covered_ranks,因此当旧版 vLLM 只缺少 emitted_tokens(或任意一个 counter)时,所有 rank 都是 missing_metric,complete 为空,global_draft_tokens / global_accepted_tokens 也一并变成 None;同时 L355-L356 的每 rank 接受率/效率也被置空。这与文档中“旧版 vLLM 未暴露 emitted 时仅该字段为 null”的约定不符。
[suggestion] 按 counter 分别汇总:draft/accepted/emitted 各自只对有该值的 rank 求和;某 rank 同时有 draft 和 accepted 就计算接受率,efficiency 仅在 emitted 可用时计算。可把 missing_metric 视为部分可用而非整体不可用,并补一条“缺少 emitted counter 仍输出 draft/accepted 与接受率”的用例。
There was a problem hiding this comment.
感谢指出,已改为按 counter 独立汇总,并只在 draft/accepted 或 draft/emitted 齐全的 rank 上计算对应全局比率,避免部分 rank 的分子除以全量分母。单个 rank 缺 emitted 不再遮蔽其他 rank 的 acceptance/efficiency,缺失项标记为 partial;已补充混合 rank 缺 counter 的回归测试。
| if name in new | ||
| }, | ||
| "deltas": deltas, | ||
| "draft_acceptance_rate": accepted / draft if status == "ok" and draft else None, |
There was a problem hiding this comment.
[review] [minor] 缺少投机指标的自洽性校验。这里直接用 accepted / draft、emitted / draft 计算,但没有像 Prefix Cache 的 hits <= queries 那样校验 accepted_delta <= draft_delta、emitted_delta >= accepted_delta;当 label 混用、抓取错位或 counter 重置后恰好为正向时,会输出大于 1 的接受率/效率并标记为 ok,把异常数据当成正常结果写入 analysis。
[suggestion] 在计算 deltas 后增加不变量校验(accepted<=draft、emitted>=accepted),不满足时把该 rank 标记为 counter_regressed 或在 reason 中记录 invalid ratio,并补充对应单测。
There was a problem hiding this comment.
感谢指出,已增加 accepted_delta > draft_delta 和 emitted_delta < accepted_delta 校验;违例 rank 标记为 counter_regressed 且不参与汇总。efficiency = emitted/draft 允许大于 1,并新增了对应测试。
| row[logical] = value | ||
| except RuntimeCapabilityError as exc: | ||
| logger.warning("[metrics] parse_spec_decode skipped reason=%s", exc) | ||
| return None, str(exc) |
There was a problem hiding this comment.
[review] [minor] 单个 rank 的 engine label 无法映射时,整次投机指标解析被放弃。_parse_spec_decode 捕获任意 RuntimeCapabilityError 后直接 return None, str(exc),例如新增一种 engine 命名或某个样本缺少 engine 标签,就会让整轮 run 的 spec_decode 变成 unavailable,而不是按设计降级为 partial(其他 rank 明明可用)。
[suggestion] 在解析循环内按样本/按 rank 捕获异常:跳过无法映射的样本并记录原因,其余 rank 继续汇总;只有所有 spec 指标都不可用时才返回 unavailable,与 diff 中 partial / missing_ranks 的语义保持一致。
There was a problem hiding this comment.
感谢指出,已修复:单个 engine 标签无法定位或越界时,仅跳过该样本、记录 warning 和 partial 原因,保留其他合法 rank;已新增坏样本隔离测试。
| try: | ||
| decoded = json.loads(value) | ||
| except json.JSONDecodeError: | ||
| return value |
There was a problem hiding this comment.
[review] [minor] Parquet 单元格 JSON 解码失败时静默按普通文本处理。_decode_parquet_cell 对形如 {...} / [...] 但 JSON 非法的值直接 return value,随后 normalize_question 会把整段原始 JSON 当成语料文本,空值校验也不会发现;MRCR 的 prompt 一旦有损坏行,会被无提示地带入前缀/后缀,导致测量结果不可解释。
[suggestion] 至少记录带行号的 warning,或对被识别为消息结构但解码失败的行抛出 ScenarioValidationError(在 _parquet_field_values / load_gsm8k 中传入行号);同时补一条“非法 JSON 单元格”用例。
There was a problem hiding this comment.
感谢指出,已修复:非法 JSON 保留原文本,同时输出包含 Parquet 文件路径和 0-based row 的 warning;已新增 row 0 告警测试。
| """ | ||
| result: dict[str, tuple[int, ...]] = {} | ||
| for group, prefix in canonical.items(): | ||
| if len(prefix.gsm_indices) != 1: |
There was a problem hiding this comment.
[review] [minor] 这里只校验 gsm_indices 长度为 1,无法保证 canonical 前缀真的来自该 case 的开头。build_canonical_prefixes 在组首 block 冲突时会走 marker 兜底(token_ids = marker + source_tokens),此时 gsm_indices 仍为 1,source_tail 会把整条 case 当作后缀来源;而 generation.py 的 shared_prefix_tokens + suffix_len > case_len 检查没有扣除 marker 长度,可能在 prefix+suffix 实际未越界时误报超长,前缀里也会混入合成的组标记文本。
[suggestion] 在 CanonicalPrefix 中记录 marker 长度或来源偏移,source_tail 时断言 canonical.token_ids[offset:offset+case_len] == source_case_tokens,并在 build_prompt 的覆盖检查中使用扣除偏移后的前缀长度;也可在 marker 兜底路径直接拒绝 source_tail 并给出明确报错。
There was a problem hiding this comment.
感谢指出,已修复:显式记录 canonical prefix 的 marker token 数;source_tail 遇到 marker fallback 时直接抛出 ScenarioValidationError,避免静默错位,同时校验 prefix 与源语料起始 token 一致;已添加冲突场景测试。
| ) | ||
| self.assertEqual([row.line_index for row in selected], [1, 1, 1]) | ||
|
|
||
| def test_load_gsm8k_accepts_strings_messages_and_lists(self): |
There was a problem hiding this comment.
[review] [major] 本 PR 的核心 corpus.suffix_mode=source_tail 分支没有任何测试。新增用例覆盖了字符串/消息列表与 Parquet,但 build_prompt(source_case_tokens=...)、_source_case_tokens_by_group、suffix_mode 校验以及 marker 冲突分支都没有用例;这意味着“保证 prompt 以语料原始结尾收尾”的行为回归时 CI 不会发现。
[suggestion] 补充:1) source_tail 下 shared_prefix+suffix == case_len 的精确边界、超界报错、suffix_len=0;2) 多记录前缀被拒绝;3) 组首 block 冲突 marker 兜底;4) 一个 Parquet + source_tail 的 prepare 集成用例。
There was a problem hiding this comment.
感谢指出,已补充 source_tail 单测与端到端 prepare 测试,覆盖原始结尾、prefix+suffix 边界及重叠拒绝、零 suffix 来源、Parquet JSON 消息解码。完整插件测试通过:218 passed, 1 skipped, 26 subtests passed。
| "corpus": { | ||
| "path": "/path/to/MRCR/8needle/8needle_0.parquet", | ||
| "field": "prompt", | ||
| "selection": {"mode": "random"} |
There was a problem hiding this comment.
[review] [major] 新增的 MRCR 示例没有启用 suffix_mode,照抄无法复现 PR 描述的效果。corpus.suffix_mode 默认是 records,因此该示例仍使用原来的 records 轮转后缀,prompt 仍可能在半句话处截断,与“适配 MRCR、保证最后 decode 有语义”的目标不一致。
[suggestion] 在示例中显式加上 "suffix_mode": "source_tail",并说明它要求 canonical 前缀来自单条足够长的语料(必要时配合 selection.mode=indices / question_sha256);同时把该字段补进下方字段表与 README.md、docs 的字段参考。
There was a problem hiding this comment.
感谢指出,已在中英文 MRCR 示例中加入 suffix_mode: source_tail,并用 indices [0] 固定单条源语料,同时补充原始结尾、覆盖长度和 marker 限制说明。
| | `corpus.path` | JSONL 语料文件路径;语料格式需与 GSM8K 一致。 | | ||
| | `corpus.field` | JSONL 中的问题文本字段名,默认 `question`。 | | ||
| | `corpus.path` | JSONL 或 Parquet 语料文件路径;Parquet 按 `field` 列流式读取,行号从 0 开始。 | | ||
| | `corpus.field` | 语料字段名,默认 `question`;值可为字符串、字符串列表或 `[{role, content}]` 消息列表;消息按 `role: content` 用空行拼接后统一折叠空白。 | |
There was a problem hiding this comment.
[review] [minor] corpus.suffix_mode 是严格白名单字段,但 README/README_en 与 docs 的 corpus 字段表都没有登记。用户只能从代码或报错得知该字段,无法发现 records(默认)/ source_tail 的含义与使用约束。
[suggestion] 在 corpus 字段表补一行:默认 records;source_tail 取前缀来源语料的尾部作为自然后缀,要求 canonical 前缀来自单条且覆盖 prefix+suffix 的语料;同步更新中英文 tutorial 与 scenario.example 字段表。
There was a problem hiding this comment.
感谢指出,已补齐 README 中英文、高级教程中英文及 scenario 字段参考中的 corpus.suffix_mode 行,包含默认值、两种模式与 source_tail 约束。
|
|
||
| - Python 3.10 或更高版本; | ||
| - **JSONL 语料**。每个非空行必须是 JSON 对象,并包含 `corpus.field` 指定的文本字段,默认是 GSM8K 数据集中的 `question`;若想用类似 GSM8K 的语料,需参考 GSM8K 格式。 | ||
| - **JSONL / Parquet 语料**。`corpus.path` 支持 `.jsonl`(每个非空行必须是 JSON 对象)和 `.parquet` / `.pq`(按 `corpus.field` 列流式读取,行号从 0 开始)。字段默认是 GSM8K 数据集中的 `question`。该字段支持三种形式:字符串;字符串列表;OpenAI 风格的消息列表(如 `[{"role": "user", "content": "..."}]`,每条消息格式化为 `role: content`,用空行拼接)。单条消息对象同样保留 `role: content`。列表形式会先拼接再统一折叠空白。Parquet 单元格若是 JSON 编码的消息数组/对象(MRCR 的 `prompt` 即如此),会自动解码。 |
There was a problem hiding this comment.
[review] [minor] Parquet 读取依赖可选包 pyarrow,但环境要求与安装章节都没有说明。test_core.py 在缺少 pyarrow 时用 skipUnless 跳过全部 Parquet 用例,CI 未安装该包时这条新增主路径实际不会被验证。
[suggestion] 在依赖说明中补充 Parquet 需要 pip install pyarrow(或给出带版本下限),并在测试依赖/CI 中显式安装,确保 Parquet 用例真正执行而不是静默跳过。
There was a problem hiding this comment.
这条无需额外修改:pyarrow 已在 requirements/runtime.txt 和 plugins/prefix_cache/setup.py 的 install_requires 中声明;CI 先执行 uv pip install -e . 安装主仓库及 runtime 依赖,再以 --no-deps 安装插件,因此 Parquet 用例在具备 pyarrow 的环境中执行,不会因插件依赖被跳过。现有 README 也说明安装插件会自动安装依赖。
|
🚫 PR 合入质量检查未通过,PR 已被禁止合入。 未通过项:
请按上述提示整改后,重新推送(push)或评论本 PR 即可触发再次检查。 |
Thanks for your contribution; we appreciate it a lot. The following instructions will make your pull request healthier and help you get feedback more easily. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers.
感谢您的贡献,我们非常重视。以下说明将使您的拉取请求更健康,更易于获得反馈。如果您不理解某些项目,请不要担心,只需提交拉取请求并从维护人员那里寻求帮助即可。
PR Type / PR类型
Related Issue | 关联 Issue
Fixes #(issue ID / issue 编号) / Relates to #(issue ID / issue 编号)
🔍 Motivation / 变更动机
Please describe the motivation of this PR and the goal you want to achieve through this PR.
请描述您的拉取请求的动机和您希望通过此拉取请求实现的目标。
新增mrcr数据集适用于投机推理。保证生成的prompt有语义。保证最后decode可以进行投机推理
📝 Modification / 修改内容
Please briefly describe what modification is made in this PR.
请简要描述此拉取请求中进行的修改。
修改preifx cache选择后缀的方法,保证在选择一条case后,后缀也是从该case的最后部分选择,保证最后decode有语义
📐 Associated Test Results / 关联测试结果
Please provide links to the related test results, such as CI pipelines, test reports, etc.
请提供相关测试结果的链接,例如 CI 管道、测试报告等。
Does the modification introduce changes that break the backward compatibility of the downstream repositories? If so, please describe how it breaks the compatibility and how the downstream projects should modify their code to keep compatibility with this PR.
是否引入了会破坏下游存储库向后兼容性的更改?如果是,请描述它如何破坏兼容性,以及下游项目应该如何修改其代码以保持与此 PR 的兼容性。
If the modification introduces performance degradation, please describe the impact of the performance degradation and the expected performance improvement.
如果引入了性能下降,请描述性能下降的影响和预期的性能改进。
🌟 Use cases (Optional) / 使用案例(可选)
If this PR introduces a new feature, it is better to list some use cases here and update the documentation.
如果此拉取请求引入了新功能,最好在此处列出一些用例并更新文档。
✅ Checklist / 检查列表
Before PR:
After PR:
👥 Collaboration Info / 协作信息
🌟 Useful CI Command / 实用的CI命令
/gemini review/gemini summary/gemini help/readthedocs build/pr_check