已合并
[feat] unify TorchAO quantization converter for LI and metadata #800
zx1029创建于 9月12日
[feat] unify TorchAO quantization converter for LI and metadata #800
已合并
Pull Request已成功合入, 合并人@CANN-robot
(感谢 zx1029 的贡献)9月12日 添加了label:stat/needs-squash
9月12日 添加了label:cann-cla/yes
CANN-robot
9月12日 评论:
9月12日 评论:
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.
For more, you also can visit HICANN.
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| repo-cann/torchtitan-npu | ✅ zhuofanshen, wanghui0 (2/2) | ✅ zhuofanshen (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
zhaoxi1029, thanks for your pull request. All authors of the commits have signed the CLA. 👍


9月12日 预合并成功(commit_id: 895a65cd42d787029cda996507ceae200108769d)
此处折叠了103条消息 查看更多
9月15日 删除了label:ci-pipeline-running
9月15日 添加了label:ci-pipeline-failed
26 天前 关联了issue:[RFC] DeepSeek-V4/V4.1 LI模块支持A4C4、A8C8(MXFP8/HiF8)
26 天前 删除了关联的issue:[RFC] DeepSeek-V4/V4.1 LI模块支持A4C4、A8C8(MXFP8/HiF8)
26 天前 关联了issue:[RFC] DeepSeek-V4/V4.1 LI模块支持A4C4、A8C8(MXFP8/HiF8)
refactor: unify TorchAO quantization converter for LI and metadata
背景
TorchAO-NPU 原有量化转换流程主要面向
Linear、BatchedLinear和GroupedExperts。LightningIndexer(LI)及其 metadata 仍需要单独的转换入口,导致量化配置、quant_mode映射和 metadata 替换逻辑分散,LI kernel 的接入和模型配置校验也容易出现不一致。本提交将量化 LI module 与 LI metadata 纳入统一的
NpuQuantizeConverter,在保留原有高精度 LI 路径的前提下,为 DeepSeek-V4 提供 MXFP4、MXFP8 和 FP8 LI 量化配置。主要改动
NpuQuantizeConverter:Linear、BatchedLinear、GroupedExperts、LightningIndexer及LightningIndexerMetadata配置节点。QuantLightningIndexerConfig:quant_mode映射:FP8=1、MXFP8=3、HiFloat8=4、MXFP4=5。quant_lightning_indexer和quant_lightning_indexer_metadata。LightningIndexerMetadata替换为量化 metadata adapter,使 metadata 构建与 LI kernel 的quant_mode、layout、mask mode 和 compression ratio 保持一致。QuantizationExtensionConfig中增加li_quantization配置,并校验其只能在量化训练开启时使用。LightningIndexerKernelConfig对固定TND / mask_mode=3 / cmp_ratio=4的强制校验,使其他模型能够提供自己的 LI kernel 参数;默认值保持不变。行为边界
enable_quantized_training=false或li_quantization=null时,不替换高精度 LI module 和 metadata。mxfp4、mxfp8和fp8配置值。验证
已完成功能验证:
MXFP8 + LI MXFP4 loss
MXFP8 + LI MXFP8 loss
MXFP8 + LI FP8 loss