Conversation
Valid Phi3ForCausalLM configs may set head_dim independently of hidden_size // num_attention_heads; HF sizes the fused qkv_proj as (n_heads + 2 * n_kv_heads) * head_dim. The generic config mapper already maps explicit head_dim to cfg.d_head, but Phi3ArchitectureAdapter re-derived d_head = d_model // n_heads in both its weight_processing_conversions split sizes and the live _split_phi3_qkv path, so bridge construction crashed in torch.split for such models (e.g. hidden_size=8192, 57 heads, head_dim=64 -> split_with_sizes expected [3648, 3648, 3648] rows but computed [8151, 8151, 8151]). Use cfg.d_head in both places. Models without an explicit head_dim keep the derived d_model // n_heads value via the existing mapper fallback. Tests: adapter unit tests with d_head deliberately decoupled from d_model // n_heads (MHA and GQA), mapper-precedence unit tests for explicit head_dim vs the derived fallback, and network-free integration tests booting tiny explicit-head_dim Phi-3 models end-to-end with HF eager logit parity. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 task
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
head_dimType of change
Checklist: