Pull Request has been successfully merged by CANN-robot.
(Thank you for guiruoyu's contribution.)变更摘要
此 PR 修复了 QBMMV3 量化算子中 batch 一致性校验粒度过粗的问题。原逻辑使用 GetDeterministic() == 1 判断是否启用确定性模式,导致普通确定性场景与 batch 一致性场景被等同处理。现统一改为 GetDeterministicLevel() > 1,仅在 batch 一致性等级下触发限制行为,保留普通确定性等级的正常执行路径。同时为 per-block 量化模板新增了 batch 一致性不支持的警告提示。
主要改动
- StreamK tiling 的 batch 一致性过滤条件收紧:在
QBMMV3StreamKTiling::IsCapable()中,将确定性判断从GetDeterministic() == 1改为GetDeterministicLevel() > 1,使得 StreamK 仅在 batch 一致性等级(level > 1)下被禁用,普通确定性模式下不再被错误过滤。 - Per-block tiling 新增 batch 一致性警告:在
AdaptiveSlidingWindowPerblockBasicAPITiling::IsCapable()中,当 tiling 模板被判定为可用且GetDeterministicLevel() > 1时,通过OP_LOGW输出警告,明确告知该量化模式天然不支持 batch 一致性。 - 日志信息细化:StreamK 禁用时的日志消息从原来的 "deterministic mode is enabled" 更新为 "deterministic level is greater than 1 for batch consistency",更准确地描述了触发条件。


代码审查
Now I have a complete picture. Both batch_matmul_v3_basic_streamk_tiling.cpp (line 72) and matmul_v3_basic_streamk_tiling.cpp (line 142) use the identical context_->GetDeterministicLevel() > 1 pattern without INT32_MAX guard. The QBMM files in this diff adopt the same established convention, and additionally add context_ != nullptr guards which are more defensive than the sibling files.
Let me do the final targeted sweep.
Final sweep (silent):
-
Boundary values for
> 1: Level 0 (disabled) → false ✓. Level 1 (normal deterministic) → false ✓. Level 2+ (batch consistency) → true ✓. No off-by-one. -
Hot-path costs:
IsCapable()is called once inDoTiling()(line 80 oftiling_base.h), not in any hot loop. The addedGetDeterministicLevel()call is a single attribute access — negligible. -
Co-located secondary defects around the changed lines:
- StreamK file line 889-892: The
return falsecorrectly exitsIsCapable(). The new check is placed BEFORE the expensiveEvaluateStreamKBenefitGate()call (line 898), which is an optimal placement since it short-circuits when batch consistency is detected. No issue. - Per-block file lines 57-64: The newly expanded
IsCapable()returnsisCapable(the local variable) on line 63 as it should; no risk of returning an uninitialized value sinceisCapableis initialized on line 59. The warning fires but does not block — this is by design per the PR description. No issue.
- StreamK file line 889-892: The
No issues found.
审查结论
此 diff 将 QBMMV3 的两个 tiling 模板中的确定性检查从 GetDeterministic() == 1 调整为 GetDeterministicLevel() > 1,与同仓库中 batch_matmul_v3_basic_streamk_tiling.cpp 和 matmul_v3_basic_streamk_tiling.cpp 的既有模式保持一致。变更语义正确、代码风格一致、无正确性/安全/可靠性问题。
变更文件审查结果:
adaptive_sliding_window_perblock_basic_api_tiling.cpp:无问题。新增的 warning 逻辑为纯增量行为,不影响模板选择结果;context_空指针检查到位。qbmm_streamk_tiling.cpp:无问题。确定性检查语义变更正确(普通确定性等级保留 StreamK,仅 batch 一致性等级过滤),日志信息与变更语义一致。
| 严重度 | 数量 |
|---|---|
| P0 | 0 |
| P1 | 0 |
| P2 | 0 |
| P3 | 0 |
整体风险评估:低风险。 此变更仅调整确定性等级判断的粒度,与仓库中其他同类 tiling 模板的既有模式完全一致,且增加了额外的空指针防护。
⚠️ 已识别出整体风险,但无法提取行内评论,请参考整体评估。


Thanks for your pull-request.
The full list of commands accepted by me can be found at here。
You can get sig-info at here
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| matmul | ✅ 范其瑞, 王子韬, 刘波 (3/2) | ✅ 范其瑞, 王子韬 (2/1) |
| tests | ✅ 范其瑞, 刘波 (2/2) | ✅ 范其瑞 (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
guiruoyu, thanks for your pull request. All authors of the commits have signed the CLA. 👍


The following label is not ready.
ci-pipeline-passed: The ci-pipeline-passed label is expired as added over 72 hours. Please use /compile to recompile.


The following label is not ready.
ci-pipeline-passed: The ci-pipeline-passed label is expired as added over 72 hours. Please use /compile to recompile.


描述
GetDeterministic() == 1调整为GetDeterministicLevel() > 1,仅在 batch 一致性等级下过滤 StreamK,保留普通确定性等级的行为。GetDeterministicLevel() > 1时输出 warning,提示该量化模式天然不支持 batch 一致性。关联的Issue
无。
测试
git diff --check HEAD^ HEAD通过。文档更新
无。
类型标签
AI/Agent生成声明