Closed
[Feature] 新增 W8A8 MXFP8 Linear QAT + 统一 MXFP8LinearQAT 类(weight_only 选模式) #70
weixuanAdd on 10 days agoClosed at 4 hours ago
10 days ago Added label: triage-review
TorchNPU-Bot
10 days ago Comments:
10 days ago Comments:
issue待分派,添加triage-review标签


10 days ago Added label: feature
10 days ago changed custom category from Bug-Report to 需求
10 days ago Associated pull request
10 days ago Assign sylvia_wei as responsible person
10 days ago Added label: bot-triaged; Removed label: triage-review
TorchNPU-Bot
10 days ago Comments:
10 days ago Comments:
检测到当前 issue 已关联 PR,自动添加标签:bot-triaged
自动设置issue责任人为PR提出人


3 days ago Associated pull request
4 hours ago changed custom state from TODO to DONE
4 hours ago Close issue
4 hours ago Added label: resolved
需求背景
torchao_npu 已有 W8A16 Linear QAT(仅权重伪量化到 MXFP8 grid,激活保持 BF16)。GMM 侧已通过
MXFP8GMMQATConfig.weight_only支持 W8A16/W8A8 双模式。Linear 侧需要补齐 W8A8 模式(激活和权重均伪量化),并统一命名与 GMM 侧对齐。目标
MXFP8LinearQATConfig(weight_only=False)启用,与 W8A16(weight_only=True,默认)共用同一MXFP8LinearQAT模块类。W8A16Linear→MXFP8LinearQAT、W8A16LinearConfig→MXFP8LinearQATConfig、w8a16_module_filter_fn→mxfp8_linear_qat_filter_fn、文件w8a16_linear.py→linear.py。block_size/weight_only与 prepare 不一致时报错。方案
linear.py(原w8a16_linear.py):MXFP8LinearQAT类,forward 读self.config.weight_only决定是否对激活做 FQ(FQ8(X) × FQ8(W)^T → BF16 F.linear)。config.py:MXFP8LinearQATConfig加weight_only: bool(默认 True,bool 类型校验),GMM config 基类改为MXFP8LinearQATConfig。freeze_weight_inplace;显式传入block_size或config时都先校验与 prepare 时一致,不传时使用module.config.block_size;重复 convert 幂等。filters.py:w8a16_module_filter_fn→mxfp8_linear_qat_filter_fn。F.linear(FQ8(X), FQ8(W), bias)对齐、dX 相同/dW 不同、convert 后仍在线 FQ、配置不一致报错)。验收标准
MXFP8LinearQATConfig(weight_only=False)的 prepare → forward → backward → convert 全链路无报错;W8A16 回归行为不变。weight_only、prepare/convert 的block_size/weight_only不一致、非nn.Linear目标均明确报错。