Commit 30a9d98
committed
fix(ascend): repair Qwen3.6 accuracy on Ascend (attention/moe/gdn)
修复 Qwen3.6 在 Ascend 上的精度问题(注意力/MoE/GDN 四项)
1. attention: drop the mathematically invalid head-split fallback for
head_size=256 prefill and call npu_fused_infer_attention_score (TND)
directly, matching vllm-ascend. Splitting a 256-dim head into two
independent 128-dim softmax attentions is not an identity transform
(measured max err 0.0076 direct vs 4.30 head-split on NPU).
注意力:删除 head_dim=256 时数学上不成立的拆头回退路径,prefill 直连
FIA(TND),与 vllm-ascend 一致。将 256 维头拆成两个独立 128 维
softmax 注意力并非恒等变换(NPU 实测直连误差 0.0076,旧路径 4.30)。
2. attention: derive attn_state from num_computed_tokens; use
PrefillNoCache only when every request starts at token 0. Pure-prefill
batches containing prefix-cache hits or chunked-prefill continuations
previously dropped all cached KV (few-shot context lost).
注意力:attn_state 依据 num_computed_tokens 判定,仅当所有请求从第 0
个 token 开始才走 PrefillNoCache。此前含 prefix 命中或续写 chunk 的
纯 prefill batch 会丢弃全部已缓存 KV(few-shot 上下文丢失)。
3. moe: cast router probs to hidden dtype (bf16) before
npu_moe_token_unpermute, matching vllm-ascend; the op expects bf16
probs.
MoE:npu_moe_token_unpermute 前将路由 probs 转为 hidden dtype
(bf16),与 vllm-ascend 一致;该算子 probs 期望 bf16。
4. gdn: default VLLM_FL_DISABLE_PTO_GDN to 1. The PTO megakernel carries
A/A_inv/recurrent state in fp16, while the Triton chunk path keeps fp32
state; the fp16 pipeline measurably degrades accuracy. Re-enable after
reworking the kernel state path to fp32.
GDN:VLLM_FL_DISABLE_PTO_GDN 默认改为 1。PTO megakernel 的
A/A_inv/循环状态均为 fp16,而 Triton chunk 路径保持 fp32 状态,fp16
链路实测显著拉低精度。待 kernel 状态链路 fp32 化后可重新开启。
Verified on 910B: op-level tests for FIA head256 / chunked-prefill FIA /
recurrent GDN decode / causal-conv1d decode all pass; gsm8k Qwen3.6-27B
(128 samples) recovers to 0.9453 (previously in the 0.47-0.88 range).
验证:FIA head256 / chunked prefill FIA / GDN recurrent decode /
causal-conv1d decode 算子级测试全部通过;gsm8k Qwen3.6-27B(128 样本)
恢复至 0.9453(此前在 0.47-0.88 区间)。1 parent 27cc2ff commit 30a9d98
3 files changed
Lines changed: 22 additions & 146 deletions
File tree
- vllm_fl/dispatch/backends/vendor/ascend
- impl
- patches
Lines changed: 13 additions & 143 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | 56 | | |
61 | 57 | | |
62 | 58 | | |
| |||
324 | 320 | | |
325 | 321 | | |
326 | 322 | | |
327 | | - | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
328 | 326 | | |
329 | 327 | | |
330 | 328 | | |
| |||
368 | 366 | | |
369 | 367 | | |
370 | 368 | | |
| 369 | + | |
371 | 370 | | |
372 | 371 | | |
373 | 372 | | |
374 | 373 | | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
375 | 382 | | |
376 | | - | |
377 | | - | |
| 383 | + | |
378 | 384 | | |
379 | 385 | | |
380 | 386 | | |
| |||
563 | 569 | | |
564 | 570 | | |
565 | 571 | | |
566 | | - | |
567 | | - | |
568 | | - | |
569 | | - | |
570 | | - | |
571 | | - | |
572 | | - | |
573 | 572 | | |
574 | 573 | | |
575 | 574 | | |
| |||
707 | 706 | | |
708 | 707 | | |
709 | 708 | | |
710 | | - | |
711 | | - | |
712 | | - | |
713 | | - | |
714 | | - | |
715 | | - | |
716 | | - | |
717 | | - | |
718 | | - | |
719 | | - | |
720 | | - | |
721 | | - | |
722 | | - | |
723 | | - | |
724 | | - | |
725 | | - | |
726 | | - | |
727 | | - | |
728 | | - | |
729 | | - | |
730 | | - | |
731 | | - | |
732 | | - | |
733 | | - | |
734 | | - | |
735 | | - | |
736 | | - | |
737 | | - | |
738 | | - | |
739 | | - | |
740 | | - | |
741 | | - | |
742 | | - | |
743 | | - | |
744 | | - | |
745 | | - | |
746 | | - | |
747 | | - | |
748 | | - | |
749 | | - | |
750 | | - | |
751 | | - | |
752 | | - | |
753 | | - | |
754 | | - | |
755 | | - | |
756 | | - | |
757 | | - | |
758 | | - | |
759 | | - | |
760 | | - | |
761 | | - | |
762 | | - | |
763 | | - | |
764 | | - | |
765 | | - | |
766 | | - | |
767 | | - | |
768 | | - | |
769 | | - | |
770 | | - | |
771 | | - | |
772 | | - | |
773 | | - | |
774 | | - | |
775 | | - | |
776 | | - | |
777 | | - | |
778 | | - | |
779 | | - | |
780 | | - | |
781 | | - | |
782 | | - | |
783 | | - | |
784 | | - | |
785 | | - | |
786 | | - | |
787 | | - | |
788 | | - | |
789 | | - | |
790 | | - | |
791 | | - | |
792 | | - | |
793 | | - | |
794 | | - | |
795 | | - | |
796 | | - | |
797 | | - | |
798 | | - | |
799 | | - | |
800 | | - | |
801 | | - | |
802 | | - | |
803 | | - | |
804 | | - | |
805 | | - | |
806 | | - | |
807 | | - | |
808 | | - | |
809 | | - | |
810 | | - | |
811 | | - | |
812 | | - | |
813 | | - | |
814 | | - | |
815 | | - | |
816 | | - | |
817 | | - | |
818 | | - | |
819 | | - | |
820 | | - | |
821 | | - | |
822 | | - | |
823 | | - | |
824 | | - | |
825 | | - | |
826 | | - | |
827 | | - | |
828 | | - | |
829 | | - | |
830 | | - | |
831 | | - | |
832 | | - | |
833 | | - | |
834 | 709 | | |
835 | 710 | | |
836 | 711 | | |
| |||
840 | 715 | | |
841 | 716 | | |
842 | 717 | | |
843 | | - | |
844 | | - | |
845 | | - | |
846 | | - | |
847 | | - | |
848 | 718 | | |
849 | 719 | | |
850 | 720 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
228 | 228 | | |
229 | 229 | | |
230 | 230 | | |
| 231 | + | |
231 | 232 | | |
232 | 233 | | |
233 | 234 | | |
234 | | - | |
| 235 | + | |
235 | 236 | | |
236 | 237 | | |
237 | 238 | | |
| |||
357 | 358 | | |
358 | 359 | | |
359 | 360 | | |
| 361 | + | |
360 | 362 | | |
361 | 363 | | |
362 | 364 | | |
363 | | - | |
| 365 | + | |
364 | 366 | | |
365 | 367 | | |
366 | 368 | | |
| |||
Lines changed: 5 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
274 | 274 | | |
275 | 275 | | |
276 | 276 | | |
277 | | - | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
278 | 282 | | |
279 | 283 | | |
280 | 284 | | |
| |||
0 commit comments