Bug/mixtral transformers 5.x - #1668
Merged
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
convert_mixtral_weightsstill read the pre-5.x module layout, every HookedTransformer Mixtral load raisedAttributeError: 'MixtralDecoderLayer' object has no attribute 'block_sparse_moe'. 5.x renamed the MoE block (block_sparse_moe→mlp) and replaced the per-expertw1/w2/w3Linears with batched Parameters on a singleMixtralExperts(gate_up_proj[n_experts, 2*d_mlp, d_model],down_proj[n_experts, d_model, d_mlp]). Reachable via all fourmistralai/Mixtral-8x7B*aliases in the registry. The converter now reads that layout, mirroring the already-migratedolmoe.py.gate_up_proj[e, :d_mlp, :]→W_gate,[d_mlp:, :]→W_in). Confirmed three independent ways, because getting it backwards is silent:MixtralExperts.forwarddoes.chunk(2, dim=-1)after the linear; HF's own legacy-checkpoint conversion concatenatesw1(the gate) first; and a round-trip against HF's expert math is bit-exact while the swapped assignment is off by ~51.MixtralTopKRouterrenormalizes the top-k routing weights, while TL's MoE gates that behindcfg.norm_topk_prob, which defaults to False and which the Mixtral config branch never set.MixtralConfighas no such field to read it from, so the branch now pins it to HF's behavior.NotImplementedErrornaming the fix.transformers>=5.9floor, and on-disk legacy checkpoints are rewritten to the fused parameters during loading, so ahasattrbranch would be unreachable.norm_topk_prob; TL's MoE block matching HF's; and end-to-end logits parity after loading into aHookedTransformer.olmoe.pyandopenai.pyare current and their split directions were re-verified numerically; every other HF-backed converter's attribute paths were walked on 5.13 with no failures (notablyphi.py'sself_attn.denseandneox.py'squery_key_valueare not renamed and must be left alone), andcoder.py'sq_attn/kv_attnis a false positive — it is dispatched only for santacoder'strust_remote_codeclass.Type of change
Checklist: