Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions end_to_end/tpu/run_wan_fast_inference.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
# WAN_ULYSSES_OUT_A2A
# override Wan fast-inference inverse Ulysses A2A layout switch
# WAN_PATCH_EMBED_MODE
# WAN_CROSS_ATTN_KERNEL
# override Wan fast-inference kernel/layout switches
# DP / CP / PER_DEVICE_BATCH / SEED
# override mesh parallelism, per-device batch, or RNG seed (default 12345)
Expand Down Expand Up @@ -185,6 +186,7 @@ case "$TPU_PROFILE" in
DEFAULT_FUSED_ROPE=true
DEFAULT_ULYSSES_OUT_A2A=chunked
DEFAULT_PATCH_EMBED_MODE=tokens
DEFAULT_CROSS_ATTN_KERNEL=pallas
;;
v7)
PLATFORM_LIBTPU="$V7_LIBTPU"
Expand All @@ -203,6 +205,7 @@ case "$TPU_PROFILE" in
DEFAULT_FUSED_ROPE=true
DEFAULT_ULYSSES_OUT_A2A=chunked
DEFAULT_PATCH_EMBED_MODE=tokens
DEFAULT_CROSS_ATTN_KERNEL=pallas
;;
*)
echo "== warning: unrecognised or non-v6e/v7 accelerator '${ACCEL_TYPE:-unknown}';" \
Expand All @@ -223,6 +226,7 @@ case "$TPU_PROFILE" in
DEFAULT_FUSED_ROPE=false
DEFAULT_ULYSSES_OUT_A2A=flat
DEFAULT_PATCH_EMBED_MODE=tokens
DEFAULT_CROSS_ATTN_KERNEL=xla
;;
esac

Expand Down Expand Up @@ -256,6 +260,7 @@ FUSED_ROPE_ARGS=()
[ -n "${FUSED_ROPE_HEAD_BLOCK:-}" ] && FUSED_ROPE_ARGS+=("fused_rope_head_block=$FUSED_ROPE_HEAD_BLOCK")
WAN_ULYSSES_OUT_A2A=${WAN_ULYSSES_OUT_A2A:-$DEFAULT_ULYSSES_OUT_A2A}
WAN_PATCH_EMBED_MODE=${WAN_PATCH_EMBED_MODE:-$DEFAULT_PATCH_EMBED_MODE}
WAN_CROSS_ATTN_KERNEL=${WAN_CROSS_ATTN_KERNEL:-$DEFAULT_CROSS_ATTN_KERNEL}

# Mesh: context parallelism carries the Ulysses shards, data parallelism takes
# whatever devices remain. Defaults to CP=4 / DP=2 on an 8-device slice. On a
Expand Down Expand Up @@ -324,6 +329,7 @@ python src/maxdiffusion/generate_wan.py "$CONFIG" \
${FUSED_ROPE_ARGS[@]+"${FUSED_ROPE_ARGS[@]}"} \
wan_ulysses_out_a2a="$WAN_ULYSSES_OUT_A2A" \
wan_patch_embed_mode="$WAN_PATCH_EMBED_MODE" \
wan_cross_attn_kernel="$WAN_CROSS_ATTN_KERNEL" \
fps=16 ${GUIDANCE_ARGS[@]+"${GUIDANCE_ARGS[@]}"} \
seed="${SEED:-12345}" \
flash_block_sizes="$FLASH_BLOCK_SIZES" \
Expand Down
2 changes: 2 additions & 0 deletions end_to_end/tpu/run_wan_stack_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,7 @@ TESTS=(
"$T/ulysses_out_a2a_test.py"
# Token-sharded patch embedding (feat/wan-token-patch-embed)
"$T/wan_patch_embed_test.py"
# Short-KV cross-attention Pallas kernel (feat/wan-cross-attn-pallas)
"$T/cross_attention_pallas_test.py"
)
PYTHONPATH="src${PYTHONPATH:+:$PYTHONPATH}" exec "${PYTHON:-python3}" -m pytest -q -rs "${TESTS[@]}" "$@"
4 changes: 4 additions & 0 deletions src/maxdiffusion/configs/base_wan_14b.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ wan_ulysses_out_a2a: "flat"
# token, an all-gather on tpu7x) or "tokens" (token-sharded patches times the
# replicated kernel, no activation collective; equal up to accumulation order).
wan_patch_embed_mode: "conv"
# Text cross-attention backend where it would otherwise fall back to XLA dot-product
# (KV shorter than flash_min_seq_length): "xla", or "pallas" for the fused kernel that
# keeps the KV in VMEM (within bf16 rounding of "xla", not bit-identical).
wan_cross_attn_kernel: "xla"
# For attention=ulysses_ring, hidden Ulysses shard count; ring shards are context / this.
ulysses_shards: -1
# Splits Ulysses all-to-all into head-group chunks. The last chunk carries any remainder.
Expand Down
4 changes: 4 additions & 0 deletions src/maxdiffusion/configs/base_wan_1_3b.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ wan_ulysses_out_a2a: "flat"
# token, an all-gather on tpu7x) or "tokens" (token-sharded patches times the
# replicated kernel, no activation collective; equal up to accumulation order).
wan_patch_embed_mode: "conv"
# Text cross-attention backend where it would otherwise fall back to XLA dot-product
# (KV shorter than flash_min_seq_length): "xla", or "pallas" for the fused kernel that
# keeps the KV in VMEM (within bf16 rounding of "xla", not bit-identical).
wan_cross_attn_kernel: "xla"
# For attention=ulysses_ring, hidden Ulysses shard count; ring shards are context / this.
ulysses_shards: -1
# Splits Ulysses all-to-all into head-group chunks. The last chunk carries any remainder.
Expand Down
4 changes: 4 additions & 0 deletions src/maxdiffusion/configs/base_wan_27b.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ wan_ulysses_out_a2a: "flat"
# token, an all-gather on tpu7x) or "tokens" (token-sharded patches times the
# replicated kernel, no activation collective; equal up to accumulation order).
wan_patch_embed_mode: "conv"
# Text cross-attention backend where it would otherwise fall back to XLA dot-product
# (KV shorter than flash_min_seq_length): "xla", or "pallas" for the fused kernel that
# keeps the KV in VMEM (within bf16 rounding of "xla", not bit-identical).
wan_cross_attn_kernel: "xla"
# For attention=ulysses_ring*, hidden Ulysses shard count; ring shards are context / this.
ulysses_shards: -1
# Splits Ulysses all-to-all into head-group chunks. The last chunk carries any remainder.
Expand Down
4 changes: 4 additions & 0 deletions src/maxdiffusion/configs/base_wan_animate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ wan_ulysses_out_a2a: "flat"
# token, an all-gather on tpu7x) or "tokens" (token-sharded patches times the
# replicated kernel, no activation collective; equal up to accumulation order).
wan_patch_embed_mode: "conv"
# Text cross-attention backend where it would otherwise fall back to XLA dot-product
# (KV shorter than flash_min_seq_length): "xla", or "pallas" for the fused kernel that
# keeps the KV in VMEM (within bf16 rounding of "xla", not bit-identical).
wan_cross_attn_kernel: "xla"
# For attention=ulysses_ring, hidden Ulysses shard count; ring shards are context / this.
ulysses_shards: -1
# Splits Ulysses all-to-all into head-group chunks. The last chunk carries any remainder.
Expand Down
4 changes: 4 additions & 0 deletions src/maxdiffusion/configs/base_wan_i2v_14b.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ wan_ulysses_out_a2a: "flat"
# token, an all-gather on tpu7x) or "tokens" (token-sharded patches times the
# replicated kernel, no activation collective; equal up to accumulation order).
wan_patch_embed_mode: "conv"
# Text cross-attention backend where it would otherwise fall back to XLA dot-product
# (KV shorter than flash_min_seq_length): "xla", or "pallas" for the fused kernel that
# keeps the KV in VMEM (within bf16 rounding of "xla", not bit-identical).
wan_cross_attn_kernel: "xla"
# For attention=ulysses_ring, hidden Ulysses shard count; ring shards are context / this.
ulysses_shards: -1
# Splits Ulysses all-to-all into head-group chunks. The last chunk carries any remainder.
Expand Down
4 changes: 4 additions & 0 deletions src/maxdiffusion/configs/base_wan_i2v_27b.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ wan_ulysses_out_a2a: "flat"
# token, an all-gather on tpu7x) or "tokens" (token-sharded patches times the
# replicated kernel, no activation collective; equal up to accumulation order).
wan_patch_embed_mode: "conv"
# Text cross-attention backend where it would otherwise fall back to XLA dot-product
# (KV shorter than flash_min_seq_length): "xla", or "pallas" for the fused kernel that
# keeps the KV in VMEM (within bf16 rounding of "xla", not bit-identical).
wan_cross_attn_kernel: "xla"
# For attention=ulysses_ring, hidden Ulysses shard count; ring shards are context / this.
ulysses_shards: -1
# Splits Ulysses all-to-all into head-group chunks. The last chunk carries any remainder.
Expand Down
Loading
Loading