已合并
修正qwen3.5-0.8b资料 #1188
xiongpan创建于 9月1日
修正qwen3.5-0.8b资料 #1188
已合并
Pull Request已成功合入, 合并人@MindSpore-Bot
(感谢 xiongpan 的贡献)atomgit-bot
9月1日 评论:
9月1日 评论:
变更摘要
本 PR 修正 Qwen3.5-0.8B 示例在 Atlas 300I Duo 与 Atlas 800I A2 上跨硬件部署的精度/可用性问题:此前 prefill 与 decode 强依赖 CANN 自定义算子(PromptFlashAttention、IncreFlashAttention),而这两类算子在两块卡上的支持情况不同(如 IFA 在 300I Duo 上受 headDim≤128 限制)。本次改动将自定义算子改为可开关,并补齐若干正确性修正,使同一套导出/推理代码可在两块卡上均正确运行。
主要改动
- 新增
--use-pfa/--use-ifa开关:在export_qwen3_5_0_8b_onnx.py的main()中新增两个argparse.BooleanOptionalAction参数(默认关闭),分别控制 prefill 全注意力是否使用PromptFlashAttention、decode 是否使用IncreFlashAttention;关闭时回落到标准算子实现的手动注意力(matmul+masked_fill布尔掩码 +softmax),不依赖 CANN 自定义算子。 - 修正 PFA 输入索引:
_CustomPromptFlashAttention的input_index_i由[0, 1, 2, 4]改为[0, 1, 2, 3],修正算子输入映射错位。 - 修正 prefill 取 last token 逻辑:
Qwen35LlmPrefill.forward不再直接取hidden_states[:, -1:, :](该位置可能是运行时向上对齐 16 产生的 padding),改为按attention_mask求有效长度后用torch.gather取最后一个有效 token,保证next_token预测正确。 - 透传开关参数:
export_llm_prefill_decode、Qwen35LlmPrefill、Qwen35LlmDecode新增并透传use_pfa/use_ifa,其中Qwen35LlmDecode在use_ifa=False时走手写注意力路径(含 GQA 的repeat_interleave展开与掩码masked_fill)。 - 配置与文档同步:
configs/config_prefill.ini中input_format引号由单引号'ND'改为双引号"ND",与同文件其它配置项保持一致;README.md按硬件分列导出命令并补充开关说明与性能数据。


不准确?
atomgit-bot
9月1日 评论:
9月1日 评论:
9月1日 添加了label:mindspore-cla/yes
此处折叠了66条消息 查看更多
9月1日 删除了label:ci-pipeline-passed
9月1日 添加了label:ci-pipeline-passed
9月1日 通过审查
9月1日 合入了pull request,合并节点 SHA:d9edcdbf4b130128d9f6696d317e8f61097e90cd
What type of PR is this?
/kind bug
What does this PR do / why do we need it:
背景
Qwen3.5-0.8B 示例原本强依赖 CANN 的 PromptFlashAttention(PFA) 与 IncreFlashAttention(IFA) 自定义算子,但这两个算子在 Atlas 300I Duo 与 Atlas 800I A2 上的支持情况不同,导致跨硬件部署时精度/可用性有问题。本提交将自定义算子改为可开关、并补齐了若干正确性修正,使同一套导出/推理代码能在两块卡上都正确跑通。
改动点
Which issue(s) this PR fixes:
Fixes #449
Test Plan and Test result:What scenarios were tested, and what were the verification results(Function, performance, reliability, etc.):
使用用例代码,无需新增用例
Self-checklist:(请自检,在[ ]内打上x,我们将检视你的完成情况,否则会导致pr无法合入)