[CANN] fix flash-attn mask: use BOOL attenMask instead of F16 -Inf pseShift - #89
Open
July-h5kf3 wants to merge 4 commits into
Open
[CANN] fix flash-attn mask: use BOOL attenMask instead of F16 -Inf pseShift#89July-h5kf3 wants to merge 4 commits into
July-h5kf3 wants to merge 4 commits into
Conversation
…-mb#83) Signed-off-by: tc-mb <tianchi_cai@icloud.com>
* “feat:simply e2e profiling” (tc-mb#71) * fix(omni): harden duplex perf turn matching and RTF verdict Signed-off-by: tc-mb <tianchi_cai@icloud.com> --------- Signed-off-by: tc-mb <tianchi_cai@icloud.com> Co-authored-by: Han Qingzhe <95479277+hNSBQZ@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
FusedInferAttentionScoreV2 was receiving llama.cpp's additive F16 attention mask (-Inf for masked positions) via
pseShiftOptional. Ascend documentspseShiftas position encoding (F16/BFLOAT16) andattenMaskas BOOL/INT8/UINT8.On long KV lengths (e.g. multi-image MiniCPM-o, Sk≈768), putting -Inf intopseShiftproduced NaNs in the fused op and garbled generation (?floods).This change:
attenMask(True = do not attend) and passes it viaattenMaskOptionalpseShift(clamped so PSE never contains -Inf)max_bias != 0(ALiBi), multiplies the finite PSE by the ALiBi slopesAdditional information
aclnnFusedInferAttentionScoreV2:attenMaskOptional: BOOL / INT8 / UINT8pseShiftOptional: F16 / BF16 position encoding / additive biasllama-context.cpp(can revisit in a follow-up after this lands)ggml-org/llama.cppTest plan
test-backend-ops -b CANN0 -o FLASH_ATTN_EXT -p "mask=1,sinks=0,max_bias=0"→ 320/320 OK--flash-attn on: no NaN / no?flood--flash-attn on(llama-cli --single-turn): OKggml-cannwith this changeRequirements