Open
fix: Float8Tensor NPU 融合量化增加设备门控,CPU 输入回落上游实现 #193
TTTIAN998Add on 2 days ago
fix: Float8Tensor NPU 融合量化增加设备门控,CPU 输入回落上游实现 #193
Open
Merge blocked
2 days ago Added label: ascend-cla/yes
ascend-robot
2 days ago Comments:
2 days ago Comments:
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.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
PR Approval Progress
⚠️ This PR does not yet meet the following requirements:lgtm (requires ≥ 2 person(s) per module)、approve (requires ≥ 1 person(s) per module)
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| repo-Ascend/torchao-ascend | ❌ (0/2)(You can also ask: wangzhenwu, ll-pen, weixin_38374194, liangsongwei, 楚浩田) | ❌ (0/1)(You can also ask: 褚博宁, 楚浩田, chengpeng25, wanglijun55, li_jing_hw) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
TTTIAN998, thanks for your pull request. All authors of the commits have signed the CLA. 👍


TTTIAN998
2 days ago Comments:
2 days ago Comments:
/ai review


TTTIAN998
2 days ago Comments:
2 days ago Comments:
/ai help


atomgit-bot
2 days ago Comments:
2 days ago Comments:
修改方案
F26(test_quant_api_npu.py)中 2 个用例 ERROR:
根因:torchao_ascend 的 Float8Tensor 融合量化入口
_try_npu_native_quant缺设备门控——上游 torchao 没有这段代码(它是 torchao_ascend 为 NPU 加的融合路径),CPU 输入也被送进npu_dynamic_quant/npu_dynamic_block_quant,而 torch_npu 的这两个算子只注册了 PrivateUse1(NPU)与 Meta 后端,无 CPU kernel,直接抛错。触发路径:上游 0.18 新增的
test_quantize_reapply_is_noop为 CPU 用例(CPU 模型直接 quantize_),镜像到 NPU 环境后经Float8Tensor.from_hppatch 走到融合路径时命中。修复(3 行):
_try_npu_native_quant开头增加设备门控——非 NPU 输入返回None,沿用该函数既有的回落机制走上游纯 torch 实现:if hp_tensor.device.type != "npu": return NoneNPU 输入路径零改动;CPU/Meta 输入回落上游实现(CPU 上本就可用)。
验证结论
验证环境:Ascend 950(A5)、CANN 9.2.0、torch 2.11.0+cpu、torch_npu 2.11.0.post3。
npu_dynamic_quantCPU 报错残留:0(修复前 2 处)