Repository navigation
fix: MoE router hooks of GraniteMoe and Jamba on transformers >= 5.22 - #2064
Open
XiaoyuanWang111 wants to merge 1 commit into
Open
XiaoyuanWang111 wants to merge 1 commit into
XiaoyuanWang111 wants to merge 1 commit into
Conversation
transformers 5.22 reordered the GraniteMoe-family router output to (router_logits, top_k_weights, top_k_index) and replaced Jamba's nn.Linear router with a JambaTopKRouter that returns the same tuple. The Granite adapter still read the old positions, so the router's hook_out received the top-k indices and an edit on hook_expert_indices did not re-route; Jamba's router kept a LinearBridge, whose hook_out was handed the whole tuple. A helper in moe.py checks for transformers >= 5.22. There the Granite adapter uses MoERouterBridge's default positions and Jamba's router is a MoERouterBridge; older releases keep the previous mapping.
This branch has not been deployed
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
Thanks for maintaining the bridge! transformers 5.22 (huggingface/transformers#49206) reordered the GraniteMoe-family router output to
(router_logits, top_k_weights, top_k_index)and made Jamba's router aJambaTopKRouterthat returns the same tuple. The Granite adapter still reads the old positions, so the router'shook_outreceives the top-k indices andhook_expert_indicesthe logits; Jamba's router is still a plainLinearBridge, so itshook_outis handed the whole tuple. CI uses transformers 5.13 from the lock, so neither shows there.On transformers >= 5.22 (a small helper in
moe.py), the Granite adapter now usesMoERouterBridge's default positions and Jamba's router becomes aMoERouterBridge; older releases keep the current mapping.Reproducer (
dev, transformers 5.24.1, no download):On
devthis printstorch.int64 (6, 2),torch.float32andFalse; with this change (and on 5.13)torch.float32 (6, 4),torch.int64andTrue.Tested with a new
test_granite_moe_routing_hooks.py(fails ondevwith 5.23 and 5.24, passes with this change on 5.13, 5.23 and 5.24) and two Jamba cases. SwitchTransformers' router changed order too; it uses another bridge, so I left it out, but I'm glad to add it.Type of change
Checklist: