Skip to content

[distributed] Add Sequence Parallel mixin - #50796

Open
3outeille wants to merge 6 commits into
cp-3-cp-sizefrom
cp-4-tester-mixin
Open

3outeille wants to merge 6 commits into
cp-3-cp-sizefrom
cp-4-tester-mixin

Conversation

@3outeille

@3outeille 3outeille commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

🤗 Transformers CI

What does this PR do?

Stack: #50493 → #50496 → this PR → #50511 → #50514 → #50521 → #50522

We need to have a test_distributed_training_mixin after this PR stack is merged. It will be responsible to tests every interaction of parallelism together on every model

@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.

3outeille added a commit that referenced this pull request Nov 16, 2026
…on install

Restores the branch to its pre-merge scope: the tester mixin, CI job and test fetcher changes belong to #50796.
3outeille added a commit that referenced this pull request Nov 16, 2026
…on install

Restores the branch to its pre-merge scope: the tester mixin, CI job and test fetcher changes belong to #50796.
@3outeille
3outeille force-pushed the cp-4-tester-mixin branch 2 times, most recently from a84ba68 to 415471f Compare November 20, 2026 06:58
@3outeille 3outeille changed the title [distributed] Run the context parallel tests on every causal LM [] Run the sequence parallel tests on every causal LM Nov 20, 2026
@3outeille 3outeille changed the title [] Run the sequence parallel tests on every causal LM [distributed] Run the sequence parallel tests on every causal LM Nov 20, 2026
@3outeille
3outeille removed this pull request from stack #50797 November 20, 2026 08:49
@3outeille
3outeille added this pull request to stack #51004 November 20, 2026 08:50
3outeille added a commit that referenced this pull request Nov 30, 2026
…on install

Restores the branch to its pre-merge scope: the tester mixin, CI job and test fetcher changes belong to #50796.
@3outeille
3outeille removed this pull request from stack #51004 November 30, 2026 05:31
@3outeille 3outeille changed the title [distributed] Run the sequence parallel tests on every causal LM [distributed] Add Sequence Parallel mixin Nov 30, 2026
@3outeille
3outeille marked this pull request as ready for review December 1, 2026 11:10
@3outeille
3outeille added this pull request to stack #51606 December 2, 2026 05:05
@3outeille
3outeille force-pushed the cp-4-tester-mixin branch 5 times, most recently from 6c09e5c to 389d9c1 Compare December 3, 2026 07:38
…the sequence parallel tests

`RUN_SEQUENCE_PARALLEL_TESTS` gates them like the tensor and expert parallel ones, `sequence_parallel_ci` runs
them on 6 workers, and the regular jobs deselect them.
…e model

`SequenceParallelTesterMixin` joins the bases of `CausalLMModelTest`, next to the FSDP and tensor
parallel mixins: every causal language model test class loads its tester's tiny config with
`sp_size=2` on 2 CPU ranks, and compares the logits of this rank's slice, the loss and every
gradient with the same weights on the whole sequences, plain, packed (`position_ids` restart
mid-sequence) and padded (a 2D `attention_mask`, and a length the ranks cannot split evenly).

A tester config is only changed when the sequence parallel checks refuse it and the change is
harmless: the auxiliary load-balancing loss of the MoE models is turned off. A model the checks
still refuse is loaded with `sp_size=2` on both ranks and has to raise `ValueError`; the test then
skips with the reason. The allow list starts with 7 model types; set
`SEQUENCE_PARALLEL_TEST_MODEL_TYPES = None` to run every causal language model.

`_deterministic_init_model_dir` and `_distributed_tmpdir` move from the FSDP mixin to
`distributed_testing_utils`, and take the model class to build.

This branch has not been deployed

No deployments
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.

2 participants