Merged
fix: expose KernelPreference members on Python 3.12 #116
pengpeng7872Add on 16 days ago
fix: expose KernelPreference members on Python 3.12 #116
Merged
Pull Request has been successfully merged by ascend-robot.
(Thank you for pengpeng7872's contribution.)16 days ago Created pull request, commit 5167d7e3
16 days ago Modify description of pull request
16 days ago Added label: ascend-cla/yes
ascend-robot
16 days ago Comments:
16 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 | ✅ wangzhenwu, 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
pengpeng7872, thanks for your pull request. All authors of the commits have signed the CLA. 👍


16 days ago Modify description of pull request
16 days ago Modify description of pull request
16 days ago Modify description of pull request
16 days ago Associated issue: [Feature]: MXFakeQuantizedLinear 不支持 weight-only(仅权重)量化
pengpeng7872
16 days ago Comments:
16 days ago Comments:
compile


16 days ago Added label: ci-pipeline-running
16 days ago Removed label: ci-pipeline-running
16 days ago Added label: ci-pipeline-passed
AtlasAccount
16 days ago Comments:
16 days ago Comments:
流水线 PR-pipeline_torchao_npu#170 [ commitID:3f25f8e7 ] 已完成
>>>代码风格自动修复执行成功(无修复内容)
| 阶段 | 任务名 | 状态 | 详情 |
|---|---|---|---|
| 编译构建 | Build_x86 | ✅ COMPLETED | >>> |
| 恶意代码检查 | Antipoison | ✅ COMPLETED | >>> |
| 编码安全与规范检查 | pre-commit | ✅ COMPLETED | >>> |
| 开源片段检查 | SCA | ✅ COMPLETED | >>> |
| 流水线 | PR-pipeline_torchao_npu | ✅ COMPLETED | >>> |
- compile : 运行流水线
- retry : 重试流水线所有失败子任务
- retry <任务名> : 仅重试指定失败子任务
- stop : 停止流水线


13 days ago Associated issue: [Bug]: KernelPreference 动态注入的成员在 Python 3.12 下无法通过属性访问
13 days ago Deleted associated issue: [Feature]: MXFakeQuantizedLinear 不支持 weight-only(仅权重)量化
13 days ago Deleted associated issue: [Feature]: MXFakeQuantizedLinear 不支持 weight-only(仅权重)量化
wanglijun55
12 days ago Comments:
12 days ago Comments:
/approve


12 days ago Added label: approved
9 days ago Modify description of pull request
pengpeng7872
9 days ago Comments:
9 days ago Comments:
@lizhihai137 @chujinjin 二位老师好,麻烦有空帮看下这个 MR:单文件 +7 行(在 _add_enum_member 写完枚举内部映射后,用 type.__setattr__ 补装类属性,修复 Python 3.12 下 KernelPreference.NPU 属性访问抛 AttributeError),对应 issue #58,复现与验证数据都在 MR 描述里。
目前 CI 已绿、wanglijun55 老师 11-17 已 /approve,仅差 1 个 lgtm。


Kuteriod
7 days ago Comments:
7 days ago Comments:
/lgtm


7 days ago Added label: lgtm
7 days ago Merged pull request
【合入来源】
【修改方案】
base 补丁
_add_enum_member为KernelPreference动态注入NPU/CPU成员时,只写入了枚举内部映射(_member_map_/_value2member_map_/_member_names_),没有安装类属性。Python 3.12 移除了
EnumType.__getattr__(属性查找不再回落查_member_map_),因此成员仅存在于映射中时,KernelPreference.NPU会抛AttributeError。受影响路径包括resolve_backend()的分发表与mx_formats的_validate_kernel_preference,即 Python 3.12 上所有 NPU MX 分发/校验场景。修复:在写入映射后,通过
type.__setattr__同时安装类属性。不能使用普通setattr(EnumType.__setattr__会拒绝已存在于_member_map_的名字);映射仍需保留,因为迭代、按值查找与 pickle 都依赖它。类对象身份不变,已有 checkpoint 的序列化/反序列化行为不变。【资料变更】
不涉及
【接口变更】
不涉及
【功能验证】
type.__setattr__后getattr/ 迭代 / 按值查找均正常;test/upstream/quantization/test_qat.py14 passed;回归子集mxfp8_training + mx_ops + w8a16_qat67 passed;【CheckList】