vllm_omni.diffusion.distributed.autoencoders.wan_spatial_shard ¶
Spatially-sharded Wan VAE decode.
The existing distributed Wan VAE path shards tiles. This module adds an opt-in decode backend that shards decoder feature maps along height or width and exchanges boundary rows/columns before spatial convolutions. It is intentionally decode-only and keeps checkpoint loading unchanged by patching the already-loaded decoder.
SpatialShardContext dataclass ¶
WanDistCausalConv3d ¶
Bases: Conv3d
WanDistConv2d ¶
Bases: Conv2d
WanDistZeroPad2d ¶
Bases: Module
Apply ZeroPad2d only at global split-dimension boundaries.
all_gather_along_dim ¶
all_gather_along_dim(
x: Tensor,
*,
group: ProcessGroup,
dim: int,
dst: int | None = None,
) -> Tensor
gather_and_trim_extent ¶
gather_and_trim_extent(
x: Tensor,
*,
expected_extent: int | None,
split_dim: str,
group: ProcessGroup,
dst: int | None = None,
) -> Tensor
halo_exchange ¶
halo_exchange(
x: Tensor,
*,
group: ProcessGroup,
halo_size: int,
split_dim: str = "height",
recv_top_buf: Tensor | None = None,
recv_bottom_buf: Tensor | None = None,
) -> tuple[Tensor, Tensor | None, Tensor | None]
install_wan_spatial_shard_decode ¶
install_wan_spatial_shard_decode(
vae: Any, group: ProcessGroup, split_dim: str = "height"
) -> None
Patch vae.decoder once for spatially-sharded decode.
This mutates the already-loaded decoder in place by swapping its spatial convolutions/padding for halo-exchanging variants and wrapping decoder.forward. The patch is permanent for the lifetime of the VAE instance and is applied only once (subsequent calls are no-ops). A given instance is bound to a single split_dim; switching between "height" and "width" requires a fresh VAE instance and raises here otherwise.
Only group-relative rank 0 assembles the final decoded frame, mirroring the distributed tiled-decode broadcast_result=False contract; the other ranks take part in the collectives but return an empty placeholder.
reshard_from_trimmed_extent ¶
reshard_from_trimmed_extent(
x: Tensor,
*,
local_extent: int,
split_dim: str,
group: ProcessGroup,
) -> Tensor
spatial_shard_decode ¶
spatial_shard_decode(
vae: Any,
z: Tensor,
*,
group: ProcessGroup,
return_dict: bool = True,
split_dim: str = "height",
) -> DecoderOutput | tuple[Tensor]
split_for_parallel_decode ¶
split_for_parallel_decode(
x: Tensor,
*,
upsample_count: int,
split_dim: str = "height",
group: ProcessGroup | None = None,
rank: int | None = None,
world_size: int | None = None,
) -> tuple[Tensor, int]
Shard latent/feature spatial extent and return expected full output extent.