[diffusion] chore: keep the DiT off component offload under explicit multi-GPU fsdp (#41722)

Co-authored-by: Mick Qian <mickqian@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Mick
2026-10-05 21:56:52 +08:00
committed by GitHub
co-authored by Mick Qian Claude Opus 5.5
parent 23bf107469
commit c83c84b422
4 changed files with 59 additions and 3 deletions
@@ -940,6 +940,18 @@ class ServerArgs(DisaggServerArgsMixin):
self.vae_cpu_offload = False
return
if (
self.use_fsdp_inference
and self.num_gpus > 1
# with data parallelism the FSDP mesh would span the replicas
and self.dp_size == 1
and self.dit_cpu_offload is None
# a GGUF or pre-quantized override may not support FSDP
and self.transformer_weights_path is None
):
# FSDP shards only resident components; component offload would bypass it
self.dit_cpu_offload = False
# TODO: to be handled by each platform
if current_platform.get_device_total_memory() / BYTES_PER_GB < 30:
logger.info(
@@ -2536,7 +2548,8 @@ class ServerArgs(DisaggServerArgsMixin):
parser.add_argument(
"--dit-cpu-offload",
action=StoreBoolean,
help="Use CPU offload for DiT inference. Enable if run out of memory with FSDP.",
help="Keep DiT weights on the CPU and move them onto the GPU whole around each "
"use. This takes the DiT out of FSDP, which shards only resident components.",
)
parser.add_argument(
"--direct-gpu-weight-loading",
@@ -2156,6 +2156,49 @@ class TestOffloadDefaults(unittest.TestCase):
)
self.assertTrue(args.use_fsdp_inference)
def test_explicit_multi_gpu_fsdp_keeps_the_dit_out_of_component_offload(self):
"""Explicit multi-GPU FSDP shards the DiT unless its placement is set explicitly."""
for dit_cpu_offload in (None, True):
with self.subTest(dit_cpu_offload=dit_cpu_offload):
kwargs = {
"model_path": "Wan-AI/Wan2.1-I2V-14B-480P-Diffusers",
"num_gpus": 2,
"performance_mode": "auto",
"use_fsdp_inference": True,
}
if dit_cpu_offload is not None:
kwargs["dit_cpu_offload"] = dit_cpu_offload
args = self._from_dict_with_pipeline_config(
WanI2V480PConfig(), memory_gb=24, kwargs=kwargs
)
self.assertTrue(args.use_fsdp_inference)
self.assertEqual(args.dit_cpu_offload, dit_cpu_offload is True)
self.assertEqual(
args.should_use_fsdp_for_component("transformer"),
dit_cpu_offload is None,
)
def test_explicit_fsdp_keeps_the_dit_offload_default_where_it_cannot_shard(self):
for kwargs in (
{"dp_size": 2},
{"transformer_weights_path": "/models/wan-14b-q4.gguf"},
):
with self.subTest(**kwargs):
args = self._from_dict_with_pipeline_config(
WanI2V480PConfig(),
memory_gb=24,
kwargs={
"model_path": "Wan-AI/Wan2.1-I2V-14B-480P-Diffusers",
"num_gpus": 2,
"performance_mode": "auto",
"use_fsdp_inference": True,
**kwargs,
},
)
self.assertTrue(args.dit_cpu_offload)
def test_auto_wan_layerwise_offload_preserves_explicit_dit_cpu_offload(self):
args = self._from_dict_with_pipeline_config(
WanT2V480PConfig(),