Open
【11月贡献大赛-缺陷修复】fix(w8a8-llm-quant-npu): [Bug] compute scale product in fp32, drop consumed weight_scale keys, and support sharded safetensors in dequantize_w8a8.py #7334
【11月贡献大赛-缺陷修复】fix(w8a8-llm-quant-npu): [Bug] compute scale product in fp32, drop consumed weight_scale keys, and support sharded safetensors in dequantize_w8a8.py #7334
Open
liuhongweiAdd on 3 hours ago
liuhongwei
liuhongwei
3 hours ago

关联 Issue

  • 无(社区自测发现的脚本缺陷修复)

改动说明

  • 修复 skills/quantization/w8a8-llm-quant-npu/scripts/dequantize_w8a8.py 中小尺度 weight_scale 先转 float16 下溢归零的问题,改为 (t.float() * scale.float()).to(torch.float16) 在 FP32 完成缩放后再转回 float16。
  • 使用后缀精确匹配 *.weight / *.weight_scale(避免 .replace(".weight", ...) 误改中间层名),剔除已被消费的 *.weight_scale 键并同步清理 model.safetensors.index.json 中的 weight_map。
  • 新增 _find_weight_shards() 与 _index_shards_and_consumed_scales() 支持单分片 model.safetensors 与多分片 model-*.safetensors,同时防护 src == dst 同路径覆盖及缺失 config.json 场景。
  • 新增回归单元测试 skills/quantization/w8a8-llm-quant-npu/tests/test_dequantize_w8a8.py。

改动类型

自检清单

测试结果

python -m pytest -q skills/quantization/w8a8-llm-quant-npu/tests/test_dequantize_w8a8.py
# 3 passed in 1.79s
likedislike
Merge blocked
ascend-robotascend-robotCollaborators
3 hours ago Added label: ascend-cla/yes
ascend-robot
ascend-robotCollaborators
3 hours 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
sig-model-agent ❌ (0/2)(You can also ask: 花新宇, 张玉橙, starmountain, 焦泽昱, cookieyyds) ❌ (0/1)(You can also ask: 陈少宏, 胡晓曼, 顾梦沁, 张玉橙, 刘磊)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

liuhongwei-2026, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike