Skip to content

Re-export get_sequence_parallel_rank and get_sp_group from xfuser utils#1521

Open
HaozheZhang6 wants to merge 1 commit into
modelscope:mainfrom
HaozheZhang6:fix/xfuser-reexport-sp-apis
Open

Re-export get_sequence_parallel_rank and get_sp_group from xfuser utils#1521
HaozheZhang6 wants to merge 1 commit into
modelscope:mainfrom
HaozheZhang6:fix/xfuser-reexport-sp-apis

Conversation

@HaozheZhang6

Copy link
Copy Markdown
Contributor

Fixes #1520.

diffsynth/utils/xfuser/__init__.py re-exports get_sequence_parallel_world_size but not the two companion APIs get_sequence_parallel_rank and get_sp_group, even though all three are imported together from xfuser.core.distributed in xdit_context_parallel.py and used throughout it. This adds the two missing names to the re-export so they can be imported from diffsynth.utils.xfuser the same way as their sibling.

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request updates the __init__.py file in diffsynth/utils/xfuser to import get_sequence_parallel_rank and get_sp_group from .xdit_context_parallel. The reviewer recommended wrapping the extremely long import statement in parentheses to comply with PEP 8 line length guidelines and improve code readability.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@@ -1 +1 @@
from .xdit_context_parallel import usp_attn_forward, usp_dit_forward, usp_vace_forward, get_sequence_parallel_world_size, initialize_usp, get_current_chunk, gather_all_chunks
from .xdit_context_parallel import usp_attn_forward, usp_dit_forward, usp_vace_forward, get_sequence_parallel_world_size, get_sequence_parallel_rank, get_sp_group, initialize_usp, get_current_chunk, gather_all_chunks

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

The import line is extremely long (over 210 characters), which violates PEP 8 recommendations (maximum line length of 79 characters) and makes the code harder to read and maintain. Wrapping the imported names in parentheses allows them to be cleanly formatted across multiple lines.

Suggested change
from .xdit_context_parallel import usp_attn_forward, usp_dit_forward, usp_vace_forward, get_sequence_parallel_world_size, get_sequence_parallel_rank, get_sp_group, initialize_usp, get_current_chunk, gather_all_chunks
from .xdit_context_parallel import (
usp_attn_forward,
usp_dit_forward,
usp_vace_forward,
get_sequence_parallel_world_size,
get_sequence_parallel_rank,
get_sp_group,
initialize_usp,
get_current_chunk,
gather_all_chunks,
)
References
  1. PEP 8 recommends limiting all lines to a maximum of 79 characters and using parentheses for multi-line imports. (link)

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.

diffsynth.utils.xfuser.__init__ missing re-export of get_sequence_parallel_rank and get_sp_group

1 participant