Sharding of WAN 2.2 DiT #5081
Replies: 5 comments
|
Here we walk through how we shard the Wan 2.2 14B DiT ( DiT structure - what we're shardingThe model has Two sharding axesFollowing tt-metal's terminology:
We fix TP=4 on every production mesh because
|
Why Megatron is right for the DiTA DiT block is textbook Megatron-LM: two column→row matmul pairs (attention QKV+O, FFN up+down) with a non-linearity between. Same template the VAE residual block uses, just at transformer scale:
Three such pairs per block give us 3 all-reduces per block at minimum ( Block-level sharding strategyInside the block, the activation flips between two sharding states depending on whether we're inside or outside a Megatron pair: The transitions are baked into the matmul shapes:
The block's entry and exit both sit in STATE A, so the 40 blocks chain transparently. One block, end to endPer-block CCL bill at the largest mesh we care about (Galaxy 8×4, sp=8, tp=4):
On the 1×4 mesh, SP collapses to a no-op so the two K/V SP-AGs disappear - that block costs just 3 big + 4 small CCLs. Why cross-attention is "free" on the SP axisIn
|
Sequence parallelism - sharding the L axis of activationsSP shards the activation's L axis across The dataflow at runtime: The interesting part is the double constraint at the block-stack entry (and an analogous one inside The fix is two constraints back to back, both downstream of the reshape: We apply this pattern in two places: at the block-stack entry (after |
Full DiT layout - what's sharded wherePer forward at sp=2 we end up with ~5 large CCLs and ~4 small stats ARs per block (× 40 blocks), plus a handful of one-time CCLs in How we differ from tt-metal - and what we'd need to close the gaptt-metal's Wan 2.2 DiT (see metal implementation) is structurally very close to ours - Megatron col→row pairs, TP on heads, SP on L. The gap comes from two things they have and we don't: fused matmul-with-CCL kernels (plus ring SDPA) at the kernel level, and a hand-written model they're free to restructure however they like. Our diffusers-based path leaves the model untouched, so any equivalent of their model-side rewrites has to come from compiler pattern-matching - or from us monkey-patching diffusers. Side-by-side per-block
What we'd need to close the gapPure kernel / compiler work - model stays as-is:
Either compiler pattern-match or model rewrite:
Model rewrite only:
The split matters because items 1–4 keep |
Notes: 480p DiT slower after the SP tile-alignment paddingAdding the SP sequence-length padding to the DiT (pad The cost isn't the padding tokens (8 of them). To keep attention exact, the patch swaps the Anyone picking this up: the lever is the K/V slice-back, not the padding. |
Uh oh!
There was an error while loading. Please reload this page.
Here we discuss sharding of DiT through compiler, differences between compiler and
tt-metal's sharding and gaps we need to fill in order to catch up tott-metalfolks.All reactions