Repository navigation
Conversation
SplitInferMeta formatted the num_or_sections list for its error messages via make_ddim(sections_data), which builds a DDim. DDim is meant for a tensor shape and caps rank at 9 (DDim::kMaxRank). When num_or_sections has more than 9 entries and a validation check fails, constructing the error message itself throws an unrelated "Invalid dimension to be accessed ... received dimension is N" error, masking the real cause. Replace make_ddim(sections_data) with paddle::string::join_strings( sections_data, ", ") in the three enforce messages so the sections list is printed as a plain integer list with no rank limit. Validation logic is unchanged; only the error text formatting differs.
Paddle-Bot Review Board (review完成)
可维护性建议(总分 93.6 / 100,只给建议,不影响评审结论)
各维度得分(仅评本 PR 改动,点击展开)
Powered by Nyanpasu claude with Opus 5.5 默认推理级别, please check the suggestions carefully. |
| "along the split dimension. But received Attr(num_or_sections)" | ||
| " = [%s], input(X)'s shape = [%s], Attr(dim) = %d.", | ||
| make_ddim(sections_data), | ||
| paddle::string::join_strings(sections_data, ", "), |
There was a problem hiding this comment.
修复本身正确(
num_or_sections 长度 ≤ 9 时 join_strings(..., ", ") 与 DDim 的输出格式一致,长度 > 9 时不再在构造报错信息时触发 paddle/common/ddim.h 中 rank 0~9 的 PD_THROW),但 PR 没有附带回归测试。test/legacy_test/test_split_op.py 现有的错误用例(如 API_TestSplitZeroSizeInvalidSections 用 [1, 1])段数都 ≤ 9,旧实现也能通过,以后改回 make_ddim 不会被发现。
建议在 test/legacy_test/test_split_op.py 加一个段数 > 9 的动态图用例,并断言真实报错内容而不只是断言抛异常,例如:
x = paddle.zeros([5], dtype='float32')
with self.assertRaisesRegex(ValueError, r"Sum of Attr\(num_or_sections\) must be equal"):
paddle.split(x, [1] * 10)
with self.assertRaisesRegex(ValueError, r"Only one dimension value of Attr\(num_or_sections\)"):
paddle.split(x, [-1, -1] + [1] * 8)There was a problem hiding this comment.
已在 test_many_sections_error_message 中补充超过 9 段的回归测试,并断言了真实报错内容,此问题已解决。
…sage Guards against reverting to make_ddim(sections_data), whose DDim rank<=9 limit crashed error formatting when num_or_sections has more than 9 entries. Asserts the real messages (sum mismatch, multiple -1) in dygraph mode, which the old implementation could not produce.
| ValueError, | ||
| r"Only one dimension value of Attr\(num_or_sections\)", | ||
| ): | ||
| paddle.split(x, [-1, -1] + [1] * 8) |
There was a problem hiding this comment.
💡 可维护性建议(测试策略,不阻塞合入):本 PR 改了 SplitInferMeta 的三处报错格式化,这个用例覆盖了 PADDLE_ENFORCE_LE(多个 -1)和 PADDLE_ENFORCE_EQ(求和不等)两处,含 -1 时的 PADDLE_ENFORCE_LT(unary.cc:5074)还没有覆盖。可以再加一条超过 9 段的断言,例如:
with self.assertRaisesRegex(
ValueError, r"other than unknown section must be less than"
):
paddle.split(x, [-1] + [1] * 9)| "along the split dimension. But received Attr(num_or_sections)" | ||
| " = [%s], input(X)'s shape = [%s], Attr(dim) = %d.", | ||
| make_ddim(sections_data), | ||
| paddle::string::join_strings(sections_data, ", "), |
There was a problem hiding this comment.
已在 test_many_sections_error_message 中补充超过 9 段的回归测试,并断言了真实报错内容,此问题已解决。
|
/re-run all-failed |
2 similar comments
|
/re-run all-failed |
|
/re-run all-failed |
PR Category
Operator Mechanism
PR Types
Bug fixes
Description
SplitInferMeta在三处校验(num_or_sections含多个 -1、unknown 段求和、普通段求和)的报错信息里,用make_ddim(sections_data)把num_or_sections列表格式化成[...]。make_ddim返回的是表示张量 shape 的DDim,而DDim的 rank 上限是 9(DDim::kMaxRank)。当
num_or_sections的元素个数超过 9 且对应校验失败时,构造报错信息本身会抛出一个不相关的错误:Unimplemented error. Invalid dimension to be accessed. Now only supports access to dimension 0 to 9, but received dimension is N.
真实的 "Sum of Attr(num_or_sections) must be equal..." 原因反而被这条二次崩溃掩盖。
num_or_sections的长度语义是“切分段数”,可以远超 9,不应借用只为张量 shape 设计的DDim。本 PR 将三处
make_ddim(sections_data)替换为paddle::string::join_strings(sections_data, ", "),把段列表作为普通整数列表打印,不受 rank ≤ 9 限制。校验逻辑完全不变,仅改报错信息的格式化方式。复现配置(修复后给出正确的 sum 不匹配报错,而非 ddim 崩溃):
paddle.split(paddle.zeros([512, 0], "float32"), [192, 256] * 32, axis=1)
是否引起精度变化
否