Fix Stage 0 + Ulysses crash: make bwc_tensor_model_parallel_rank() resilient to MP API absence#7888
Open
nathon-lee wants to merge 8 commits intodeepspeedai:masterfrom
Open
Fix Stage 0 + Ulysses crash: make bwc_tensor_model_parallel_rank() resilient to MP API absence#7888nathon-lee wants to merge 8 commits intodeepspeedai:masterfrom
nathon-lee wants to merge 8 commits intodeepspeedai:masterfrom
Conversation
Collaborator
|
Hi @nathon-lee, I found that we already have a fallback from |
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.
Title
Fix Stage 0 + Ulysses crash: make
bwc_tensor_model_parallel_rank()resilient to MP API absenceSummary
This PR fixes a hard crash when using Ulysses sequence parallelism with ZeRO Stage 0 (BF16_Optimizer).
In this configuration, DeepSpeed calls
deepspeed.utils.bwc.bwc_tensor_model_parallel_rank(mpu=...), and the passedmpuobject can bedeepspeed.runtime.sequence_parallel.parallel_state_sp, which does not implement the deprecatedget_model_parallel_rank()API. The current fallback path unconditionally callsmpu.get_model_parallel_rank(), raisingAttributeError.The fix adds a defensive capability check before calling the deprecated API. If the provided
mpudoes not expose any known tensor/model-parallel rank API, we treat it as “no tensor model parallelism” and return rank0.Motivation / Context
AttributeError: ... parallel_state_sp has no attribute get_model_parallel_rankbwc_tensor_model_parallel_rank()falls back to a deprecated API without anhasattr()check.This change keeps the original priority order intact:
get_tensor_model_parallel_rank()get_slice_parallel_rank()get_model_parallel_rank()(deprecated)0if none existChanges
deepspeed/utils/bwc.pybwc_tensor_model_parallel_rank()to checkhasattr(mpu, "get_model_parallel_rank")before calling it.mpuprovides none of the expected tensor/model-parallel rank APIs, return0(no TP).Why this is safe
get_tensor_model_parallel_rank()orget_slice_parallel_rank()orget_model_parallel_rank(), behavior is unchanged.mpuobject does not provide any of these methods.Reproduction
Using the Ulysses ALST tutorial flow, switching ZeRO stage from 3 to 0 triggers the crash during optimizer step when grad norm is computed.
Testing
bwc_tensor_model_parallel_rank(mpu=deepspeed.runtime.sequence_parallel.parallel_state_sp)should no longer raise.References