Skip to content

Commit cdb3ea5

Browse files
Merge pull request #477 from AI-Hypercomputer:feat/fixed-m-kernel
PiperOrigin-RevId: 1007276103
2 parents f1d0faf + a0e1afc commit cdb3ea5

12 files changed

Lines changed: 2711 additions & 314 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
# Copyright 2026 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# https://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
# Runs the tests of the Wan fast-inference kernels and serving path on a TPU VM
17+
# (validated on v6e-8 and tpu7x-8). Convenience entry point for running the
18+
# Pallas kernel grids and multi-device ring/Ulysses tests natively on a TPU
19+
# generation other than the CI runner's; the same tests also run in CI (the
20+
# multi-device ones self-skip below their device count).
21+
#
22+
# Usage, from the repo root of an installed checkout:
23+
# bash end_to_end/tpu/run_wan_stack_tests.sh [extra pytest args, e.g. -x --durations=20]
24+
set -euo pipefail
25+
cd "$(dirname "$0")/../.."
26+
unset GITHUB_ACTIONS
27+
T=src/maxdiffusion/tests
28+
TESTS=(
29+
# Fixed-m custom splash kernel and ring (feat/fixed-m-kernel)
30+
"$T/custom_splash_fixed_m_test.py"
31+
"$T/ring_fixed_m_test.py"
32+
)
33+
PYTHONPATH="src${PYTHONPATH:+:$PYTHONPATH}" exec "${PYTHON:-python3}" -m pytest -q -rs "${TESTS[@]}" "$@"

‎src/maxdiffusion/configs/ltx2_3_video.yml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ hardware: 'tpu'
33
skip_jax_distributed_system: False
44
# Supported attention kernels:
55
# dot_product, flash, tokamax_flash, tokamax_ring, tokamax_ring_custom,
6-
# ulysses, ulysses_custom, ulysses_custom_fixed_m, ulysses_ring,
6+
# ulysses, ulysses_custom, ulysses_custom_fixed_m,
7+
# ulysses_custom_fixed_m_per_q_block, ulysses_ring,
78
# ulysses_ring_custom, ulysses_ring_custom_fixed_m, ulysses_ring_custom_bidir,
89
# and cudnn_flash_te (GPU only).
910
attention: 'flash'

‎src/maxdiffusion/configs/ltx2_video.yml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ hardware: 'tpu'
33
skip_jax_distributed_system: False
44
# Supported attention kernels:
55
# dot_product, flash, tokamax_flash, tokamax_ring, tokamax_ring_custom,
6-
# ulysses, ulysses_custom, ulysses_custom_fixed_m, ulysses_ring,
6+
# ulysses, ulysses_custom, ulysses_custom_fixed_m,
7+
# ulysses_custom_fixed_m_per_q_block, ulysses_ring,
78
# ulysses_ring_custom, ulysses_ring_custom_fixed_m, ulysses_ring_custom_bidir,
89
# and cudnn_flash_te (GPU only).
910
attention: 'flash'

‎src/maxdiffusion/configuration_utils.py‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -496,9 +496,7 @@ def extract_init_dict(cls, config_dict, **kwargs):
496496
diffusers_library = importlib.import_module(__name__.split(".")[0])
497497

498498
if cls.has_compatibles:
499-
compatible_classes = [
500-
c for c in cls._get_compatibles() if not isinstance(c, DummyObject) # type: ignore
501-
]
499+
compatible_classes = [c for c in cls._get_compatibles() if not isinstance(c, DummyObject)] # type: ignore
502500
else:
503501
compatible_classes = []
504502

‎src/maxdiffusion/kernels/custom_splash_attention.py‎

Lines changed: 479 additions & 122 deletions
Large diffs are not rendered by default.

‎src/maxdiffusion/kernels/splash_attention/ring_attention_kernel.py‎

Lines changed: 260 additions & 71 deletions
Large diffs are not rendered by default.

‎src/maxdiffusion/models/attention_flax.py‎

Lines changed: 311 additions & 79 deletions
Large diffs are not rendered by default.

‎src/maxdiffusion/models/ltx2/attention_ltx2.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,7 @@ def __init__(
479479
"ulysses_ring_custom_bidir",
480480
"ulysses_custom",
481481
"ulysses_custom_fixed_m",
482+
"ulysses_custom_fixed_m_per_q_block",
482483
)
483484
cross_attention_uses_local_kv = not is_self_attention and (
484485
cross_attention_remapped_to_flash or attention_kernel in ("flash", "tokamax_flash", "cudnn_flash_te")

0 commit comments

Comments
 (0)