Conversation
suppress(Exception) is used at indexer.py:515 (inside an except handler, just before the re-raise) and at indexer.py:543 (the whole body of _discard_prefill_k_cache_gather), but the module never imports it. _discard_prefill_k_cache_gather is called from two finally: blocks (indexer.py:1190 and indexer.py:1398). An exception raised inside finally: replaces the exception being propagated, so a prefill failure with a live CP all-gather handle surfaces as NameError: name 'suppress' is not defined and the assembler handle is leaked instead of discarded. The sibling module in the same package already imports it the same way (dsv4/fp8/attention.py:19). Signed-off-by: Tai An <antai12232931@outlook.com>
|
|
| from __future__ import annotations | ||
|
|
||
| import os | ||
| from contextlib import suppress |
There was a problem hiding this comment.
[P3] import 顺序不符合 isort 规范
补丁中新增行 +from contextlib import suppress 位于上下文行 import os 之后。按 isort 默认排序(按模块名字母序,不区分 import/from-import),contextlib < os < typing,因此 from contextlib import suppress 应排在 import os 之前。若仓库启用了 ruff isort 检查可能触发 lint 失败。
建议:将 from contextlib import suppress 移到 import os 之前,保持 stdlib import 按字母序排列。
评审版本:cdf9a9779fb6
PR #1412 评审:未发现阻塞项,等待人工审核
无阻塞项非阻塞发现
自动代码评审 · head |
LLLLKKKK
left a comment
There was a problem hiding this comment.
AI Code Review - PR #1412
Status: LGTM
Summary: P0/0 · P1/0 · P2/1 · P3/0
Reviewed: commit cdf9a9779fb6 · 2026-09-09 21:37 UTC+8
lgtm ready to ci
Non-blocking Suggestions
P2
- 缺少异常清理路径的回归测试 @
rtp_llm/models_py/modules/dsv4/fp8/indexer.py:25- 建议:增加 mock 单测:让 prepare 与 discard 分别抛出不同异常,断言 discard 被调用且最终传播 prepare 的原始异常;同时验证
_discard_prefill_k_cache_gather会吞掉清理异常。
- 建议:增加 mock 单测:让 prepare 与 discard 分别抛出不同异常,断言 discard 被调用且最终传播 prepare 的原始异常;同时验证
Checklist Findings (1 fail / 75 total)
General Principles Checklist
- [6.1] Tests — 新逻辑有聚焦单测 + 相关集成/smoke 测试 → issue
缺少异常清理路径的回归测试
本次修复针对异常清理时suppress未定义而掩盖原始错误的问题,但现有测试未覆盖prepare_assemble_indexer_k_async失败后的回收分支,也未验证 discard 同时失败时仍传播原始异常,因此该故障可能再次引入而未被自动化测试发现。
Strengths
- 修改范围准确且最小,正常推理路径与资源生命周期不变。
- 清理失败不再覆盖主异常,同时保留尽力回收异步资源的语义。
- 模块级导入不会增加热路径开销。
| from __future__ import annotations | ||
|
|
||
| import os | ||
| from contextlib import suppress |
There was a problem hiding this comment.
[P2] 缺少异常清理路径的回归测试
本次修复针对异常清理时 suppress 未定义而掩盖原始错误的问题,但现有测试未覆盖 prepare_assemble_indexer_k_async 失败后的回收分支,也未验证 discard 同时失败时仍传播原始异常,因此该故障可能再次引入而未被自动化测试发现。
建议: 增加 mock 单测:让 prepare 与 discard 分别抛出不同异常,断言 discard 被调用且最终传播 prepare 的原始异常;同时验证 _discard_prefill_k_cache_gather 会吞掉清理异常。
Checklist: [6.1] 新逻辑有聚焦单测 + 相关集成/smoke 测试
rtp-llm-review-bot
left a comment
There was a problem hiding this comment.
lgtm ready to ci
评审版本:cdf9a9779fb62e76425ff8432c49d48cfc3f9a31
What
rtp_llm/models_py/modules/dsv4/fp8/indexer.pyusessuppress(Exception)in twoplaces but never imports it:
except Exception:in_gather_prefill_k_cache, right beforeraise_discard_prefill_k_cache_gathercontextlibnever appears in the file.pyflakeson currentmain:Why it matters
Both uses sit on error/cleanup paths, so the missing import turns a real failure
into a misleading
NameErrorand skips the cleanup it was guarding._discard_prefill_k_cache_gatheris called from twofinally:blocks(
indexer.py:1190andindexer.py:1398). An exception raised insidefinally:replaces the exception being propagated, so whenever a prefill fails while a CP
all-gather handle is still live, the caller never sees the actual error — and the
assembler handle is leaked because
discard_assemble_indexer_k_asyncis neverreached.
The
except Exception:handler at 511-517 has the same shape: thesuppress-guarded discard is supposed to run before theraisere-raises theoriginal
prepare_assemble_indexer_k_asyncfailure; instead the handler itselfdies with
NameError.Verification
The two methods were lifted verbatim out of
mainwithast.get_source_segmentand driven with a stub assembler (no GPU needed), before and after the import:
Fix
One import line, matching how the sibling module in the same package already does
it (
rtp_llm/models_py/modules/dsv4/fp8/attention.py:19:from contextlib import contextmanager, suppress), placed in isort order betweenimport osand thetypingimport.🤖 Generated with Claude Code