[Bugfix][Cosmos3] Support multi-chunk transfer with distributed VAE (#6920)
Signed-off-by: Rahul Steiger <rsteiger@nvl72d147-T16.cm.cluster> Co-authored-by: Rahul Steiger <rsteiger@nvl72d147-T16.cm.cluster>
This commit is contained in:
1 parent
63ed0fdef4
commit
376b28aced
2 files changed
+127
-9
No files matched your search
@@ -1150,6 +1150,72 @@ def test_transfer_fps_matches_resolved_frame_rate_precedence() -> None:
|
||||
assert cfg.fps == sp.resolved_frame_rate == 12.0
|
||||
|
||||
|
||||
def test_transfer_vae_executor_requires_distributed_vae() -> None:
|
||||
from vllm_omni.diffusion.models.cosmos3.pipeline_cosmos3 import Cosmos3OmniDiffusersPipeline
|
||||
|
||||
pipeline = object.__new__(Cosmos3OmniDiffusersPipeline)
|
||||
executor = object()
|
||||
pipeline.vae = SimpleNamespace(distributed_executor=executor, is_distributed_enabled=lambda: True)
|
||||
assert pipeline._transfer_vae_executor() is executor
|
||||
|
||||
pipeline.vae = SimpleNamespace(distributed_executor=executor, is_distributed_enabled=lambda: False)
|
||||
assert pipeline._transfer_vae_executor() is None
|
||||
|
||||
|
||||
def test_sync_transfer_overlap_slices_output_rank_and_broadcasts() -> None:
|
||||
from vllm_omni.diffusion.models.cosmos3.pipeline_cosmos3 import Cosmos3OmniDiffusersPipeline
|
||||
|
||||
class RecordingExecutor:
|
||||
rank = 0
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.value = None
|
||||
|
||||
def broadcast_tensor(self, value):
|
||||
self.value = value
|
||||
return value
|
||||
|
||||
pipeline = object.__new__(Cosmos3OmniDiffusersPipeline)
|
||||
output = torch.arange(1 * 3 * 5 * 2 * 2).reshape(1, 3, 5, 2, 2)
|
||||
executor = RecordingExecutor()
|
||||
|
||||
overlap = pipeline._sync_transfer_overlap(
|
||||
output,
|
||||
overlap_frames=2,
|
||||
reference_video=output,
|
||||
vae_executor=executor,
|
||||
)
|
||||
|
||||
assert overlap is not None
|
||||
torch.testing.assert_close(overlap, output[:, :, -2:])
|
||||
assert executor.value is overlap
|
||||
|
||||
|
||||
def test_sync_transfer_overlap_allocates_receive_buffer_on_non_output_rank() -> None:
|
||||
from vllm_omni.diffusion.models.cosmos3.pipeline_cosmos3 import Cosmos3OmniDiffusersPipeline
|
||||
|
||||
class ReceivingExecutor:
|
||||
rank = 1
|
||||
|
||||
def broadcast_tensor(self, value):
|
||||
assert value.shape == (1, 3, 2, 4, 5)
|
||||
return torch.ones_like(value)
|
||||
|
||||
pipeline = SimpleNamespace(device=torch.device("cpu"), vae=SimpleNamespace(dtype=torch.float32))
|
||||
reference = torch.zeros(1, 3, 6, 4, 5)
|
||||
|
||||
overlap = Cosmos3OmniDiffusersPipeline._sync_transfer_overlap(
|
||||
pipeline,
|
||||
torch.empty(0),
|
||||
overlap_frames=2,
|
||||
reference_video=reference,
|
||||
vae_executor=ReceivingExecutor(),
|
||||
)
|
||||
|
||||
assert overlap is not None
|
||||
assert torch.equal(overlap, torch.ones_like(overlap))
|
||||
|
||||
|
||||
def test_transfer_edge_uses_rgb_canny(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
from vllm_omni.diffusion.models.cosmos3 import transfer
|
||||
|
||||
|
||||
Reference in new issue
Block a user