Merged
feat: 新增 FP8 PTQ 精度评测(对齐上游 lm_eval 流程) #159
Chun LiAdd on 4 days ago
feat: 新增 FP8 PTQ 精度评测(对齐上游 lm_eval 流程) #159
Merged
Pull Request has been successfully merged by ascend-robot.
(Thank you for Chun Li's contribution.)4 days ago Added label: ascend-cla/yes
ascend-robot
4 days ago Comments:
4 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
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| repo-Ascend/torchao-ascend | ✅ culechan, wanglijun55 (2/2) | ✅ wanglijun55 (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
PlatformLC, thanks for your pull request. All authors of the commits have signed the CLA. 👍


4 days ago Associated issue: 新增 FP8 PTQ 精度评测基准(950DT,对齐上游 lm_eval 流程)
Chun Li
4 days ago Comments:
4 days ago Comments:
compile


42 messages are collapsed here。 See more
4 days ago Resolved final issue
wanglijun55
4 days ago Comments:
4 days ago Comments:
/approve


4 days ago Added label: approvedlgtm
4 days ago Merged pull request
ascend-robot
4 days ago Comments:
4 days ago Comments:
Pull Request 已合并或已关闭。
If you want to solve this problem, you can click here to do it in the FAQs.


【合入来源】
【修改方案】
新增
benchmarks/quantization/FP8 PTQ 精度评测 benchmark,对齐上游 torchaobenchmarks/quantization/measure_accuracy_and_performance.sh的精度评测流程(lm_eval),用于验证 torchao FP8 PTQ recipe 在 NPU 上的精度:.gitignore两行):measure_accuracy_and_performance.sh:orchestrator,按 recipe(None基线 /float8_rowwise)循环 create → eval → parse,日志开头记录 torch/torch_npu/torchao/torchao_ascend/transformers 版本;create_quantized_model.py:加载 bf16 模型 →quantize_量化 → 落盘;eval_accuracy.py:lm_eval 精度评测(支持--ckpt_dir直载或--model_path+--recipe进程内量化);utils.py:recipe 映射 / 模型加载 / 量化,importtorch_npu、torchao_ascend激活 NPU 补丁;parse_log.py:解析日志输出精度汇总表(含 ckpt 体积列、库版本头);README.md:使用说明与依赖。pytorch_model.bin(pickle 的 Float8Tensor 子类权重)+config.json(quantization_config)+ tokenizer;from_pretrained直载时 transformers quantizer 触发的quantize_对已量子类权重为 no-op(torchao 显式行为),量化值零重算。create_quantized_model.py内 Gap 1/2/3 注释逐条说明:①量化在加载后手动执行(该版本 quantize-at-load 流程被 loading report raise);②torch.save直写 state_dict(save_pretrained的 tied-weights 清理对无 storage 的 wrapper 子类崩溃);③保存的 config 中tie_word_embeddings=False(tie_weights用aten.equal比较,Float8Tensor 未实现)。npu_dynamic_quant,无 CPU 后端);lm_eval 设备须写带索引的npu:x(valid-device 列表无裸npu);ASCEND_RT_VISIBLE_DEVICES选卡。.gitignore新增benchmarks/data(运行产物,镜像上游);运行依赖lm-eval==0.4.13(见README.md)。【资料变更】
不涉及(新增仓内
benchmarks/quantization/README.md作为使用说明,无对外资料变更)。【接口变更】
不涉及。
【功能验证】
在 950DT 单卡上按 README 用法实测(lm_eval 任务 wikitext + winogrande,对照物为同会话 bf16 基线):
Qwen2.5-7B-Instruct,limit 500:
精度持平(acc 在 stderr 内;ppl Δ +2.5% word / +1.1% bits);权重体积 0.54x。与上游 inference.md 的 Llama-3.1-8B 结论同量级(上游 Δppl +1.2%、winogrande 持平)。
量化 ckpt 落盘往返验证:
from_pretrained直载与进程内量化模型同输入 logits 逐位一致(diff 0.0),确认零重量化。Qwen2.5-0.5B 全链冒烟(create 落盘 → ckpt 直载 lm_eval → 汇总表输出),exit 0;跨卡复现一致(卡 2 与卡 4 word_ppl 均为 18.6339);另按 README 手动复测通过。
任务数据离线验证:数据集缓存后
HF_HUB_OFFLINE=1可完全离线运行。测试命令(详见 README):
本次为 benchmark 脚本新增(不改库代码),未新增 UT 用例,以真实模型实测验证(如上);
【CheckList】