[AutoTP] Convert HF embedding_rowwise tp_plan entries to SKIP specs - #8294
Conversation
transformers injects "embed_tokens": "embedding_rowwise" into base_model_tp_plan for every tie_word_embeddings model since huggingface/transformers#47579, and the converter's strict allowlist rejected the whole plan, so AutoTP plan conversion failed for all tied-embedding models against transformers main. Recognize the style and map it to a SKIP spec, leaving the embedding replicated. The gathered-column tie fallback already keeps a tied lm_head replicated alongside it, so tied models behave as they do on a transformers release without the injection. grad_allreduce stays false because the parameter is never split. Refs deepspeedai#8290 Signed-off-by: Ehsan Barkhordar <realbarkhordar@gmail.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 79ef659526
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
|
||
| SUPPORTED_STYLES = {"colwise", "colwise_rep", "colwise_gather_output", "rowwise", "replicated_with_grad_allreduce"} | ||
| SUPPORTED_STYLES = { | ||
| "colwise", "colwise_rep", "colwise_gather_output", "rowwise", "replicated_with_grad_allreduce", "embedding_rowwise" |
There was a problem hiding this comment.
Add the required Signed-off-by trailer
This is a one-parent, non-merge commit, but its commit message has no Signed-off-by: trailer, so it does not satisfy the repository's mandatory commit requirement; recreate the commit with --signoff using the configured Git identity.
AGENTS.md reference: AGENTS.md:L8-L8
Useful? React with 👍 / 👎.
|
Hi @ebarkhordar , thanks for your timely fix to this issue. For your opens:
|
The docstring said unsupported styles become SKIP specs, which no code path has ever done: an unknown style raises and invalidates the plan. Document that as the intended strategy, per the maintainer decision in deepspeedai#8294, and name the two supported styles that do map to SKIP. Also correct the return line, which returns None only for an empty plan. Signed-off-by: Ehsan Barkhordar <realbarkhordar@gmail.com>
|
Thanks, both are settled in
The commit touches that docstring and nothing else. yapf, check-torchdist, check-license and codespell pass on the file, and flake8 5.0.4 exits 0 on it under Python 3.11. |
|
Hi @ebarkhordar , thanks for your timely fix. Now we can move tied tests to modal GPU CI. I have a question for you, do you think we should persue option 1 in the long run? What is pros and cons for option 1? Thanks! |
Problem
huggingface/transformers#47579 (on
mainsince861f4c41, 2026-08-21) makesPretrainedConfig.__init__inject"embed_tokens": "embedding_rowwise"intobase_model_tp_planwhenevertie_word_embeddingsis true.SUPPORTED_STYLESis a strict allowlist andconvert()raises on any style outside it, rejecting the whole plan, so AutoTP plan conversion now fails for every tied-embedding model (Qwen2/Qwen3, Llama, Gemma) built against transformersmain.Fix
Recognize
embedding_rowwiseand convert it to aSKIPspec, which is option 2 in #8290: the entry is understood and the embedding is deliberately left replicated.What follows is the behaviour DeepSpeed already implements rather than a new policy.
lm_headstill converts to a gathered column spec, and_configure_gathered_column_tie_fallbacksthen sees thatlm_head.weight is embed_tokens.weightand leaves both modules replicated, logging that coupled vocabulary-parallel embedding is not supported yet. A tied model is therefore left in the shape it has on a transformers release without the injection, with both modules replicated and the tie intact.The entry maps to
SKIPwithgrad_allreduceleft false, unlikereplicated_with_grad_allreduce. The parameter is never split, soregister_replicated_grad_hooksmust not register an all-reduce for it.Styles that are still unknown continue to reject the whole plan.
test_unsupported_style_rejects_whole_planis unchanged and still passes.Verification
Run on CPU in a container at
edaa7221, against transformersmain(5.16.0.dev0) and torch 2.13.0+cpu.ValueErrorand pass with this change.tests/unit/module_inject/andtests/unit/runtime/test_tp_plan_extraction.py: 47 passed, on Python 3.11 and on 3.12.pre-commit run --fileson the three changed files passes yapf, check-torchdist, check-license and codespell; flake8 5.0.4 exits 0 on them under Python 3.11.test_qwen2_tied_lm_head_falls_back_to_replicated, which needs 2 GPUs. That is the test HF transformers main injects 'embedding_rowwise' into tp_plan for tied-embedding models; AutoTP rejects the whole plan #8290 reports as failing and the one this change is meant to restore.Two things worth deciding separately
Scoping this to
embedding_rowwiseleaves the next transformers-side style to fail the same way, since the injection is unconditional and the allowlist is deny-by-default against a vocabulary DeepSpeed does not own. A general rule for unknown styles looks like a maintainer call rather than something to settle here.Related to that, the
convert()docstring says entries with an unsupported style become SKIP specs instead of invalidating the plan, but no code path does that, and none does after this change either: an unsupported style still raises before the loop is reached. The docstring and the raise arrived together in #8204, so I have left both alone. Happy to follow up once you have picked the policy.Refs #8290. This covers the conversion failure only, and does not implement vocabulary-parallel tied embeddings (option 1 or 3 in that issue), so I have not used a closing keyword.