Repository navigation
Conversation
The Core AI/MPSGraph fused fp16 sliding-window SDPA kernel returns NaN on strided (non-contiguous) K/V views past ~3584 keys in deep dynamic graphs. Materialize contiguous K/V on sliding-window layers (window_size > 0) to sidestep the faulty lowering -- a numerical no-op that copies only when the input is actually strided. Global-attention layers are untouched. Workaround for apple#311 (framework kernel bug, tracked via Feedback Assistant).
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.
Fixes #311.
The fused fp16 sliding-window SDPA kernel (
is_causal+window_size) returns NaN on strided (non-contiguous) K/V views — e.g.narrowviews of a growing packed cache — for a short query chunk once the cache holds more than ~3584 keys in deep (28+ layer) dynamic graphs, which collapses the stream to<pad>. TheSDPAprimitive now materializes contiguous K/V on sliding-window layers (window_size > 0) — a numerical no-op that copies only when the input is actually strided; global-attention layers are untouched. This is one of the reporter's verified-clean variants; the runtime kernel defect is tracked via Feedback Assistant.Distinct from (but same kernel family as) #339/#314, which fixes Muse's ring write-order. This one covers the Gemma-family / gpt_oss sliding layers that drive the fused
is_causal+windowkernel directly with strided K/V.