Fix spec prefix capture on compressor-less Flash layers - #648
Open
gilbert-barajas wants to merge 1 commit into
Open
Fix spec prefix capture on compressor-less Flash layers#648gilbert-barajas wants to merge 1 commit into
gilbert-barajas wants to merge 1 commit into
Conversation
metal_graph_capture_prefix_attn_state() and _index_state() return false when the layer's prefix buffers are NULL. For the Flash variant the first two layers have an attention-compressor ratio of 0 (ds4_expected_layer_compress_ratio: "if (il < 2) return 0"), so those buffers are never allocated and the capture fails at il=0. The effect is that the strict decode2 verifier cannot run on any Flash model, with or without SSD streaming. spec_frontier_snapshot() and spec_frontier_commit_prefix() already skip these layers with an explicit "if (ratio == 0) continue". The two capture functions are the only places in the same code path that do not. This mirrors them: ratio 0 carries no attention frontier, and only ratio-4 layers carry an index frontier.
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.
metal_graph_capture_prefix_attn_state()andmetal_graph_capture_prefix_index_state()returnfalsewhen the layer'sspec_prefix1_*buffers are NULL.Those buffers are allocated only for layers that have a compressor: attention state under
ratio != 0, index state underratio == 4(ds4.c:17059-17139). For the Flash variant,ds4_expected_layer_compress_ratio()returns 0 for layers 0 and 1:So on any Flash model the buffers for layer 0 are NULL, and the strict decode2 verifier — which sets
spec_capture_prefixesand loops every layer with no ratio gating (ds4.c:34495, :34530) — fails atil=0and breaks out. The verifier can't run on Flash at all, independently of SSD streaming.spec_frontier_snapshot(),spec_frontier_restore()andspec_frontier_commit_prefix()already skip these layers withif (ratio == 0) continueand gate index work onif (ratio == 4). The two capture functions are the only ones in that path that don't. This mirrors them.Returning
truefor a skipped layer is safe because the write-gate and the read-gate are the same: the only reader of the prefix1 buffers andspec_prefix_n_compisspec_frontier_commit_prefix(), and each of its reads is already behind the matching predicate (:49754, :49763). The rollback path,spec_frontier_restore(), reads the main frontier buffers rather than the prefix1 ones. No consumer can observe uninitialised state for the layers now skipped.Six lines, two functions. Builds clean under
-Wall -Wextra.Found while testing MTP on DeepSeek-V4-Flash; the bug is independent of that work.