| [feature] support step3p5-flash model_apapter and w8a8 int8 best pratice Co-authored-by: yejiajun<yejiajun4@huawei.com> # message auto-generated for no-merge-commit merge: !362 merge step3p5_adapter_and_w8a8 into master [feature] support step3p5-flash model_apapter and w8a8 int8 best pratice Created-by: yejiajun Commit-by: yejiajun Merged-by: ascend-robot Description: 感谢您贡献的Pull Request! 在提交之前,请务必阅读 [CONTRIBUTING.md](https://gitcode.com/Ascend/msmodelslim/blob/master/CONTRIBUTING.md)。 ## PR描述 (What this PR does / why we need it?) 为 Step-3.5-Flash 模型提供 msmodelslim 量化支持,包括模型适配器、MoE 层转换工具、MTP 层实现以及 W8A8 最佳实践配置。 Step-3.5-Flash 是 MoE(Mixture-of-Experts)架构模型,权重以 experts 合并形式存储(单权重张量含多个 expert),无法直接被线性量化算子处理。需要通过适配器中的 moe_utils代码将合并格式转换为展开的独立 expert 结构,才能正确量化。 - **ModelAdapter** (Step3_5FlashModelAdapter):实现量化所需的各接口,驱动 layer-wise 前向和子图配置 - **MoE Utils** (moe_utils.py):提供 Step3p5MoEMLPWithUnpackExperts 类及转换函数,将合并的 MoELinear 权重展开为 nn.ModuleList 形式,适配线性量化流程 - **MTP Module** (step3p5_mtp.py):自定义 Multi-Token Prediction 层组件(RotaryEmbedding、RMSNorm、Attention、SharedHead),用于扩展模型层数,用于保存mtp层权重 - **Best Practice** (step3_5_moe_w8a8.yaml):定义 W8A8 量化配置,仅对 *moe.experts* 层应用 linear_quant,使用 ascendv1_saver 导出 ## 面向用户的变更 (Does this PR introduce _any_ user-facing change)? - 请注意,这里指的是**任何**面向用户的变更,包括但不限于API、用户界面或其他使用方式上的变更。 - Note that it means *any* user-facing change including all aspects such as API, interface or other behavior changes. ## 功能验证 (How was this patch tested?) 相关权重已在modelscope平台上传,https://www.modelscope.cn/models/Eco-Tech/Step-3.5-Flash-w8a8-mtp/summary  - [_] 功能自验 - [_] 本地自验截图(涉及个人标识符等敏感信息请注意脱敏) - [_] 新增/变更内容是否已新增/适配UT测试用例看护 See merge request: Ascend/msmodelslim!362 | 1 个月前 |