| w8a8sc权重加载逻辑迁移至权重预加载路线
Co-authored-by: frost_mourne<suyuxuan3@h-partners.com>
# message auto-generated for no-merge-commit merge:
!406 merge dev into dev
w8a8sc权重加载逻辑迁移至权重预加载路线
Created-by: frost_mourne
Commit-by: frost_mourne
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20251225
-->
# 合入背景
w8a8sc量化权重加载逻辑从原有路线迁移至显存预分配路线。
Fixes #176 #238
# 修改内容
1.quant_method_adapter.py添加W8A8SCLinearMethod。
2.qwen2_config.py中增加权重文件与模型结构的双向映射表及格式转换的方法。
3.embedding.py处理lmhead分别对应linear和embedding的转换。
4.w8a8sc.py处理w8a8sc权重注册和格式判断。
5.default_model_loader.py和weight_utils.py增加w8a8sc格式权重加载逻辑。
6.前作https://gitcode.com/Ascend/MindIE-LLM/pull/266/在default_model_loader.py中误将get_mapper_cls函数放在w8a8sc判断之外,导致非Qwen3模型会误入get_mapper_cls函数并报NotImplementedError: The model type of qwen2 has not implemented W8A8SC quant method yet错误,本作将get_mapper_cls函数移入w8a8sc判断内,并测试其他模型功能正常。
# 资料变更
不涉及
# 接口变更
不涉及
# 测试结果
对比同一个版本原始代码与加上本PR后的代码,分别开启服务化用aisbench测gsm8k数据集。开启前与开启后精度分别为25.40、25.70。测试不影响Qwen3 w8a8、Qwen3 浮点、Qwen2.5浮点、Qwen2.5 w8a8sc功能。
# CheckList
> PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x]。
- [x] 代码注释完备
- [x] 正确记录错误日志
- [x] 进行了返回值校验 (禁止使用void屏蔽安全函数、自研函数返回值;考虑接口的异常场景;调用底层组件接口时,需要进行返回值校验)
- [x] 进行了空指针校验
- [x] 若存在资源申请,使用后资源被正确的释放了
- [x] 若涉及多线程场景,考虑了并发场景,不存在死锁问题
- [x] 按照[代码仓中提供的格式模板](https://gitcode.com/Ascend/MindIE-LLM/blob/master/.clang-format),使用clang-format工具格式化代码
- [x] 符合Ascend社区的编码规范。[C++ 语言编程指导](https://gitcode.com/Ascend/community/blob/master/docs/contributor/Ascend-cpp-coding-style-guide.md) | [C++ 语言安全编程指导](https://gitcode.com/Ascend/community/blob/master/docs/contributor/Ascend-cpp-secure-coding-guide.md)
See merge request: Ascend/MindIE-LLM!406 | 2 个月前 |