7878
7979# Keep LIBTPU flags single-line (literal backslashes truncate libtpu flag parsing).
8080COMMON_LIBTPU=${COMMON_LIBTPU:-"--xla_tpu_spmd_rng_bit_generator_unsafe=true --xla_tpu_enable_async_collective_fusion=true --xla_tpu_enable_async_collective_fusion_fuse_all_gather=false --xla_tpu_enable_async_collective_fusion_multiple_steps=true --xla_tpu_memory_bound_loop_optimizer_options=enabled:true --xla_tpu_enable_dot_strength_reduction=true --xla_enable_async_collective_permute=true --xla_tpu_enable_data_parallel_all_reduce_opt=true --xla_tpu_data_parallel_opt_different_sized_ops=true --xla_tpu_overlap_compute_collective_tc=true --xla_enable_async_all_gather=true --xla_tpu_scoped_vmem_limit_kib=65536 --xla_tpu_enable_async_all_to_all=true --xla_tpu_enable_all_experimental_scheduler_features=true --xla_tpu_enable_scheduler_memory_pressure_tracking=true --xla_tpu_host_transfer_overlap_limit=24 --xla_tpu_aggressive_opt_barrier_removal=ENABLED --xla_lhs_prioritize_async_depth_over_stall=ENABLED --xla_should_allow_loop_variant_parameter_in_chain=ENABLED --xla_should_add_loop_invariant_op_in_chain=ENABLED --xla_tpu_enable_ici_ag_pipelining=true --xla_max_concurrent_host_send_recv=100 --xla_tpu_scheduler_percent_shared_memory_limit=100 --xla_latency_hiding_scheduler_rerun=2 --xla_tpu_use_minor_sharding_for_major_trivial_input=true --xla_tpu_relayout_group_size_threshold_for_reduce_scatter=1 --xla_tpu_enable_latency_hiding_scheduler=true --xla_tpu_enable_ag_backward_pipelining=true --xla_tpu_use_single_sparse_core_for_all_gather_offload=true --xla_tpu_sparse_core_all_gather_latency_multiplier=1 --xla_tpu_sparse_core_reduce_scatter_latency_multiplier=3 --xla_tpu_enable_sparse_core_collective_aggregator=true --xla_tpu_enable_sparse_core_offload_queuing_in_lhs=true --xla_tpu_enable_sparse_core_reduce_scatter_v2=true --xla_tpu_enable_sparse_core_collective_offload_all_gather=true --xla_tpu_enable_sparse_core_collective_offload_2d_all_gather=true --xla_tpu_enable_sparse_core_collective_offload_all_reduce=true --xla_tpu_enable_sparse_core_collective_offload_reduce_scatter=true --xla_tpu_enable_sparse_core_collective_offload_3d_all_gather=true --xla_tpu_enable_concurrent_sparse_core_offloading=true --xla_tpu_assign_all_reduce_scatter_layout=true"}
81- V6E_LIBTPU=${V6E_LIBTPU:- " --xla_tpu_enable_async_collective_fusion=true --xla_tpu_enable_async_collective_fusion_fuse_all_gather=false" }
81+ V6E_LIBTPU=${V6E_LIBTPU:- " --xla_tpu_enable_async_collective_fusion=true --xla_tpu_enable_async_collective_fusion_fuse_all_gather=false --xla_tpu_enable_ici_ag_pipelining=false --xla_tpu_enable_ag_backward_pipelining=false " }
8282# fuse_all_gather must stay false on v7: with true, libtpu fails backend init on
8383# tpu7x ("Continuation fusion for AllGather ... not supported ... other than
8484# Viperlite"). The tpu7x reference numbers below were measured with false.
85- V7_LIBTPU=${V7_LIBTPU:- " --xla_tpu_enable_async_collective_fusion=true --xla_tpu_enable_async_collective_fusion_fuse_all_gather=false --xla_tpu_enable_megacore_fusion=true --xla_tpu_megacore_fusion_allow_ags=true --xla_tpu_dvfs_p_state=7" }
85+ V7_LIBTPU=${V7_LIBTPU:- " --xla_tpu_enable_async_collective_fusion=true --xla_tpu_enable_async_collective_fusion_fuse_all_gather=false --xla_tpu_enable_megacore_fusion=true --xla_tpu_megacore_fusion_allow_ags=true --xla_tpu_dvfs_p_state=7 --xla_tpu_enable_offloading_copy_to_sparsecore=false " }
8686
8787# Reference benchmarks (Wan 2.2 T2V-A14B, 720p/81f/40-step, CP=4, DP=2):
88- # v6e-8: 131.7s e2e (denoise 129.6s )
89- # tpu7x-8: 99.4s e2e (denoise 96.7s )
88+ # v6e-8: 124.3s e2e (denoise 122.2s )
89+ # tpu7x-8: 95.7s e2e (denoise 93.2s )
9090case " $TPU_PROFILE " in
9191 v6e)
9292 PLATFORM_LIBTPU=" $V6E_LIBTPU "
@@ -102,12 +102,13 @@ case "$TPU_PROFILE" in
102102 DEFAULT_BATCHED_TE=true
103103 DEFAULT_VAE_CHUNK=1
104104 DEFAULT_VAE_SPATIAL=8
105+ DEFAULT_ULYSSES_OUT_A2A=chunked
105106 ;;
106107 v7)
107108 PLATFORM_LIBTPU=" $V7_LIBTPU "
108109 DEFAULT_ATTENTION=" ulysses_ring_custom_fixed_m"
109110 DEFAULT_U=2
110- DEFAULT_BQ=6400
111+ DEFAULT_BQ=4736
111112 DEFAULT_BKV=2048
112113 DEFAULT_BKV_COMPUTE=2048
113114 DEFAULT_BKV_COMPUTE_IN=2048
@@ -117,6 +118,7 @@ case "$TPU_PROFILE" in
117118 DEFAULT_BATCHED_TE=true
118119 DEFAULT_VAE_CHUNK=1
119120 DEFAULT_VAE_SPATIAL=8
121+ DEFAULT_ULYSSES_OUT_A2A=flat
120122 ;;
121123 * )
122124 echo " == warning: unrecognised accelerator '${ACCEL_TYPE:- unknown} ';" \
@@ -134,6 +136,7 @@ case "$TPU_PROFILE" in
134136 DEFAULT_BATCHED_TE=true
135137 DEFAULT_VAE_CHUNK=1
136138 DEFAULT_VAE_SPATIAL=8
139+ DEFAULT_ULYSSES_OUT_A2A=flat
137140 ;;
138141esac
139142
@@ -161,6 +164,7 @@ COMPILE_TE=${COMPILE_TE:-$DEFAULT_COMPILE_TE}
161164USE_BATCHED_TE=${USE_BATCHED_TE:- $DEFAULT_BATCHED_TE }
162165VAE_SPATIAL=${VAE_SPATIAL:- $DEFAULT_VAE_SPATIAL }
163166VAE_DECODE_CHUNK=${VAE_DECODE_CHUNK:- $DEFAULT_VAE_CHUNK }
167+ WAN_ULYSSES_OUT_A2A=${WAN_ULYSSES_OUT_A2A:- $DEFAULT_ULYSSES_OUT_A2A }
164168
165169# Mesh: context parallelism carries the Ulysses shards, data parallelism takes
166170# whatever chips remain. Defaults to CP=4 / DP=2 on an 8-chip slice. On a slice
@@ -222,6 +226,10 @@ python src/maxdiffusion/generate_wan.py "$CONFIG" \
222226 text_encoder_dtype=bfloat16 compile_text_encoder=" $COMPILE_TE " use_batched_text_encoder=" $USE_BATCHED_TE " \
223227 use_kv_cache=true use_base2_exp=true use_experimental_scheduler=true \
224228 use_fused_rope_kernel=true \
229+ wan_cross_attn_kernel=" ${WAN_CROSS_ATTN_KERNEL:- pallas} " \
230+ wan_patch_embed_mode=" ${WAN_PATCH_EMBED_MODE:- tokens} " \
231+ wan_ulysses_out_a2a=" ${WAN_ULYSSES_OUT_A2A} " \
232+ wan_seq_pad=" ${WAN_SEQ_PAD:- lane} " \
225233 fps=16 " ${GUIDANCE_ARGS[@]} " \
226234 seed=" ${SEED:- 12345} " \
227235 flash_block_sizes=" $FLASH_BLOCK_SIZES " \
0 commit comments