Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import torch
import torch.distributed as dist

from sglang.multimodal_gen.runtime.distributed.parallel_state import get_sp_group
from sglang.multimodal_gen.runtime.utils.logging_utils import init_logger

logger = init_logger(__name__)
Expand Down Expand Up @@ -107,15 +108,15 @@ def _build_parallelism_config(
ulysses_size = None
ring_size = None
if sp_group is not None:
ulysses_size = getattr(sp_group, "ulysses_world_size", None)
ring_size = getattr(sp_group, "ring_world_size", None)
ulysses_size = get_sp_group().ulysses_world_size

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why not just use sp_group? It's no longer None.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Are you sure? I test it now and it still doesn't work on the latest version of slang from the main

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Which PR fix this issue?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

image

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

In my case (and #19955) the sp_group has no attributes "ulysses_world_size" and "ring_world_size"

@DefTruth DefTruth Mar 6, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In my case (and #19955) the sp_group has no attributes "ulysses_world_size" and "ring_world_size"

Wired, @BBuf could you please also take a look? thanks~

@DefTruth DefTruth Mar 9, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In my case (and #19955) the sp_group has no attributes "ulysses_world_size" and "ring_world_size"

@OrangeRedeng Hi~ I think you are right, the sp/tp_group inside _build_parallelism_config are assumed to be torch.distributed.ProcessGroup, but ProcessGroup has no attributes "ulysses_world_size" and "ring_world_size". The bug #19955 you has encountered maybe cause by errored sp/tp_group assigning logics at:

sp_group = sp_group_candidate.device_group if has_sp else None
tp_group = tp_group_candidate.device_group if has_tp else None

Maybe we should change these code snippets to:

 sp_group = sp_group_candidate if has_sp else None 
 tp_group = tp_group_candidate if has_tp else None 

By the way, we should also fix the signature of _build_parallelism_config to avoid misleading developers with the wrong usage. From the old one:

def _build_parallelism_config(
sp_group: Optional[torch.distributed.ProcessGroup],
tp_group: Optional[torch.distributed.ProcessGroup],
):

to the correctly signature:

def _build_parallelism_config( 
     sp_group: Optional[GroupCoordinator], 
     tp_group: Optional[GroupCoordinator], 
 ): 

@OrangeRedeng Could you please take a try?
Also cc @mickqian

ring_size = get_sp_group().ring_world_size

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

To improve readability and avoid calling get_sp_group() twice, you can store its result in a local variable and reuse it.

Suggested change
ulysses_size = get_sp_group().ulysses_world_size
ring_size = get_sp_group().ring_world_size
sp_coord = get_sp_group()
ulysses_size = sp_coord.ulysses_world_size
ring_size = sp_coord.ring_world_size


tp_size = None
if tp_group is not None:
tp_size = dist.get_world_size(tp_group)

return ParallelismConfig(
backend=ParallelismBackend.NATIVE_PYTORCH,
backend=ParallelismBackend.AUTO,
ulysses_size=ulysses_size,
ring_size=ring_size,
tp_size=tp_size,
Expand Down
Loading