| Files | Last commit | Last update |
|---|---|---|
style: fix all 46 code-check findings from the 20261110 rescan Co-authored-by: wanglijun55<wanglijun54@huawei.com> # message auto-generated for no-merge-commit merge: !97 merge 1110 into main style: fix all 46 code-check findings from the 20261110 rescan Created-by: wanglijun55 Commit-by: wanglijun55 Merged-by: ascend-robot Description: ## 问题背景 基于 torchao-ascend 最新代码(e2af3fc,含 11/10 下午合入的 PR #93/#94 QAT 示例与 PR #95)重新全量扫描,导出未解决问题 46 项,涉及 8 个文件。本 PR 修复其中 40 项(6 项 NAM.05 保留原状,见下)。 ## 修复内容 | 规则 | 数量 | 处理方式 | |---|---|---| | G.FMT.07 导入顺序 | 10 | 两个新 QAT 示例脚本与 test_mxfp8_recompute:标准库/第三方/第一方重排,torchao_npu 移至末尾 | | G.TYP.07 dict取值 | 10 | test_mx_gmm_quant 的 mock 捕获字典读取改用 captured.get("input")(mock 写入侧保留原赋值) | | G.CMT.02/03 文档字符串 | 7 | 多行 docstring 收尾引号移至独立行(6 个测试函数 + FSDPParamGroupProtocol 类) | | G.EXP.03 lambda赋值 | 5 | 改写为局部 def 函数 | | G.TES.01 生产assert | 2 | 示例脚本训练循环的 isfinite 断言改为显式 ValueError | | G.ERR.07 静默异常 | 2 | _reset_peak_mem 的 except pass 改为 logger.warning | | G.FNM.05 返回值过多 | 1 | grouped_matmul backward 的 16 值返回改为 gradients 元组变量(autograd 契约不变) | ## 保留不改(申请屏蔽) - **G.NAM.05 dunder命名(6项)**:__torch_dispatch__ / __tensor_flatten__ / __tensor_unflatten__ 是 torch.Tensor 子类协议的标准内部函数(torch 按名调用,无法重命名),pre_quant_weight.py 与 post_quant_weight.py 保持原始定义,6 项走检查器屏蔽流程。 ## 验证 - py_compile、自研 import 分层检查、pycodestyle(E203/E301/E302/E306)、flake8、pylint 目标规则全部清零 - **UT 全量回归(Ascend 950)**:test/unit 188 passed;test/npu 全量 303 passed + prototype/mxfp8_gmm_patch 86 passed + a2a 双卡 9 passed,合计 **586 passed**;仅有的 2 个失败(w4a8 block_size_128、K512 permute SQNR nan)为上游已存在问题(未含本 PR 的基线同样失败),与本次改动无关 See merge request: Ascend/torchao-ascend!97 | 19 days ago | |
adapt torchao_npu to torchao0.18.0 Co-authored-by: GotFusion<5ge@live.com> | 2 months ago |