[Feature] Add AllGather-KV sequence-parallel attention str… (#4968)
Signed-off-by: zhuhh97 <zhuhonghan@huawei.com> Signed-off-by: dph97 <nenbaying@163.com> Signed-off-by: zhuhh97 <zhh@unknown> Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com> Co-authored-by: dengyunyang <584797741@qq.com>
This commit is contained in:
33 files changed
+1181
-135
No files matched your search
@@ -464,18 +464,25 @@ def _apply_sequence_parallel_if_enabled(model, od_config: OmniDiffusionConfig) -
|
||||
if plan is None:
|
||||
continue
|
||||
|
||||
# Create SP config
|
||||
sp_config = SequenceParallelConfig(
|
||||
ulysses_degree=od_config.parallel_config.ulysses_degree,
|
||||
ring_degree=od_config.parallel_config.ring_degree,
|
||||
)
|
||||
# AllGather-KV reuses the Ulysses sequence-sharding hooks.
|
||||
allgather_degree = getattr(od_config.parallel_config, "allgather_degree", 1)
|
||||
if allgather_degree > 1:
|
||||
sp_config = SequenceParallelConfig(
|
||||
allgather_degree=allgather_degree,
|
||||
)
|
||||
mode = "allgather_kv"
|
||||
else:
|
||||
sp_config = SequenceParallelConfig(
|
||||
ulysses_degree=od_config.parallel_config.ulysses_degree,
|
||||
ring_degree=od_config.parallel_config.ring_degree,
|
||||
)
|
||||
# Apply hooks according to the plan
|
||||
mode = (
|
||||
"hybrid"
|
||||
if sp_config.ulysses_degree > 1 and sp_config.ring_degree > 1
|
||||
else ("ulysses" if sp_config.ulysses_degree > 1 else "ring")
|
||||
)
|
||||
|
||||
# Apply hooks according to the plan
|
||||
mode = (
|
||||
"hybrid"
|
||||
if sp_config.ulysses_degree > 1 and sp_config.ring_degree > 1
|
||||
else ("ulysses" if sp_config.ulysses_degree > 1 else "ring")
|
||||
)
|
||||
logger.info(
|
||||
f"Applying sequence parallelism to {transformer.__class__.__name__} ({attr}) "
|
||||
f"(sp_size={sp_size}, mode={mode}, ulysses={sp_config.ulysses_degree}, ring={sp_config.ring_degree})"
|
||||
|
||||
Reference in new issue
Block a user