Skip to content

remove ep_router - #49587

Closed
3outeille wants to merge 2 commits into
mainfrom
ep-plan-override
Closed

3outeille wants to merge 2 commits into
mainfrom
ep-plan-override

Conversation

@3outeille

@3outeille 3outeille commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

🤗 Transformers CI

For a model that has masked EP by default and want to be used with ep_dispatch through DistributedConfig, we need to remove the ep_router keys otherwise we find ourselves with ep_router + ep_dispatch which is not correct

@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@github-actions

Copy link
Copy Markdown
Contributor

CI recap

Dashboard: View test results in Grafana
Latest run: 38543244514:1
Result: success | Jobs: 15 | Tests: 200,514 | Failures: 0 | Duration: 15h 7m

@vasqu

vasqu commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator

Should we rather not fix this on all the models or is this more for custom models?

@vasqu

vasqu commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator

Let's also see whether #49429 makes more sense. It's a bit messy switching strategies and it feels like a bandaid to me rather than making sure inference/training can switch in a good way

@ArthurZucker ArthurZucker left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ty we do need this,

setattr(model, f"_{plan_name}", plan | override)
merged = plan | override
if plan_name == "ep_plan" and "ep_dispatch_experts" in override.values():
merged = {name: style for name, style in merged.items() if style != "ep_router" or name in override}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a fan of filtering a single key.
Can't we filter what appears in both?
Or module based only?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets clean this up

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what you mean by what appears in both. We are trying to remove keys from the same plan not different plans (ep is already taking precedence over tp keys)

Here it's more if ep_plan has ep_router + moe_tp_experts and we want to add expert_dispatch. We are forced to remove the key manually (as the PR does). Maybe we can specify None to a key through the ep_plan which will delete the key ? wdyt ?

@3outeille

Copy link
Copy Markdown
Member Author

In any case, this is a bug that need to be fixed. We should be able to trigger ep_dispatch properly through the DistributedConfig in the first place

@vasqu vasqu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets clean the key matching up 🫡

setattr(model, f"_{plan_name}", plan | override)
merged = plan | override
if plan_name == "ep_plan" and "ep_dispatch_experts" in override.values():
merged = {name: style for name, style in merged.items() if style != "ep_router" or name in override}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets clean this up

@qgallouedec qgallouedec left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-visiting this one: still needed, but the code moved. On main the plans resolve in _resolve_parallel_plans, which now raises when ep_dispatch_experts meets ep_router:

if "ep_dispatch_experts" in ep_plan.values() and "ep_router" in ep_plan.values():
raise ValueError(
"`ep_dispatch_experts` routes tokens itself; remove the `ep_router` rules from `ep_plan`."
)

That error can't be followed through DistributedConfig: overrides merge by key, so there is no way to remove one, and Gemma4, Llama4, HY-V4, Inkling, MiMo-V2-Flash and DiffusionGemma still can't switch to dispatch.

+1 for your None idea: in the merge at line 250, drop keys whose override is None, and have the error say to set the router keys to None.

@vasqu

vasqu commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

I think we move to a new EP strategy based on #49429, wouldn't this remove the issue all over if we go dispatch on all models then?

@qgallouedec

Copy link
Copy Markdown
Member

Right. #49429 alone doesn't switch any model, but once it lands with all_reduce at inference, there is no reason left for Gemma4, Llama4, etc to default to ep_router. Switching their default plans to dispatch removes the need for this PR, so let's close it once that switch is in. Happy to open it after #49429.

@qgallouedec

Copy link
Copy Markdown
Member

Actually it's already in flight:

@vasqu

vasqu commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

Yep exactly, I'd rather we go that route merging the stack and going all in on the dispatch strats everywhere. Then this is gone automatically

@qgallouedec

Copy link
Copy Markdown
Member

#49615 removed ep_router altogether, so closing as discussed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants