Fix gather and reduce scatter ops on sequence dimension #1260
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.
Fix issue where gather and reduce scatter operations are not correct when
seq_dim != 0
. This is becausereduce_scatter_tensor
andgather_tensor
only work correctly across the primary dimension of the tensor. This PR switches to usereduce_scatter
andgather
directly. This PR also adds support forno_weight_tying=False
whensequence_parallel=True
Tests
After this fix, the 410M test config converges correctly when
sequence_parallel=True
andsequence_parallel=False
on EnWiki8 on 2 GPUs without weight tying:Memory consumption is lower on WandB:
Works with weight tying:
Works with
pipe_parallel_size=0
andpipe_parallel_size=1
:Works with
use_qk_layernorm=True
anduse_qk_layernorm=False
:Works with MoE with
moe_type="deepspeed"
andmoe_num_experts=2
, but have not tested with any other settings includingmoe_type="megablocks"
,moe_expert_parallel_size > 1
orenable_expert_tensor_parallelism=True
. There's a lot of settings here, so for now, recommend not supporting.