Merged
[feat] unify TorchAO quantization converter for LI and metadata #800
zx1029Add on Sep 12
[feat] unify TorchAO quantization converter for LI and metadata #800
Merged
Pull Request has been successfully merged by CANN-robot.
(Thank you for zx1029's contribution.)Sep 12 Added label: stat/needs-squash
Sep 12 Added label: cann-cla/yes
CANN-robot
Sep 12 Comments:
Sep 12 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.
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. 👍


Sep 12 Pre merge succeeded (commit_id: 895a65cd42d787029cda996507ceae200108769d)
103 messages are collapsed here。 See more
Sep 15 Removed label: ci-pipeline-running
Sep 15 Added label: ci-pipeline-failed
26 days ago Associated issue: [RFC] DeepSeek-V4/V4.1 LI模块支持A4C4、A8C8(MXFP8/HiF8)
26 days ago Deleted associated issue: [RFC] DeepSeek-V4/V4.1 LI模块支持A4C4、A8C8(MXFP8/HiF8)
26 days ago Associated 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