Repository navigation
feat: support KV-group destinations in direct path patching - #1956
Merged
jlarson4 merged 1 commit intoOct 30, 2026
Merged
Conversation
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.
Description
Closes #1954.
Enable native KV-group destinations in the existing direct-path patching functions, following the approved scope. Q destinations and all source indices remain query/output-head indices. K/V sweeps use the uniform destination KV count, returning
[n_layers, n_kv_heads]for a single source and[n_layers, n_heads, n_layers, n_kv_heads]for all sources. MHA retains its existing shapes and results.Destination counts honor
per_layer_num_key_value_heads, falling back to the scalar KV count or query-head count. Heterogeneous destination counts are refused before any forward; earlier source layers do not determine the destination axis. The underlying input forks, raw-norm routing and existing source-architecture restrictions are unchanged.Tests replace the former GQA refusal cases with positive coverage and check raw/compatibility MQA, GQA and MHA against an independent projection-level oracle, including out-of-group invariance, zero-delta interventions, all-sources consistency, flag restoration, metadata handling and heterogeneous-count refusal. The analysis-tools guide now explains the result axes and includes a pinned SmolLM2 example outside the unit suite.
Type of change
Validation
git diff --checkpassed.[30, 3]and restored flags.The complete unit/test-pr suite and GPU/MPS validation were not run locally.
Checklist
The full-suite item is unchecked because only the affected regression surface was run. The GQA refusal tests were updated as requested for the newly supported behavior; existing MHA oracle coverage remains.