Perf/minimax h3 dit swiglu rope cache npu (#6410)

Signed-off-by: Wenjia Li <wjialish@gmail.com>
Co-authored-by: WeiQing Chen <40507679+david6666666@users.noreply.github.com>
This commit is contained in:
Wenjia LiandWeiQing Chen authored and GitHub committed 2026-08-29 09:14:52 +00:00
1 parent bb5bf8fd0a
commit d9980c75e8
11 files changed
+920 -33

No files matched your search

@@ -1,4 +1,5 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
"""MiniMax H3 cfg-distilled full denoise loop.
Per step, the positive presentation is forwarded exactly once. Video and audio
@@ -19,6 +20,7 @@ from vllm_omni.diffusion.forward_context import (
set_forward_context_denoise_step_idx,
set_forward_context_denoise_timestep,
)
from vllm_omni.platforms import current_omni_platform
from .scheduling_minimax_h3_euler_ancestral import (
minimax_h3_euler_eta0_step,
@@ -137,6 +139,22 @@ class MiniMaxH3DenoiseBranch:
latent_grid=(int(grid[0]), int(grid[1]), int(grid[2])),
)
def prepare_rope_table(self, model: Any) -> None:
"""Materialize the branch-local DiT RoPE table once per denoise run.
``img_position_ids`` is immutable for this branch while latents and
timesteps change every scheduler step. Keeping the table in
``static_kwargs`` makes every model call reuse the exact same BF16
tensor without extending its lifetime beyond this request branch.
"""
prepare = getattr(model, "prepare_rope_table", None)
if not callable(prepare):
return
self.static_kwargs["rope_table"] = prepare(
self.static_kwargs["img_position_ids"],
seq_len=self.seq_len,
)
def forward_kwargs(
self,
*,
@@ -253,6 +271,11 @@ def minimax_h3_denoise_loop(
raise ValueError("video/audio sigma schedules must have equal length")
if len(sigmas_video) < 2:
raise ValueError("sigma schedules need at least 2 entries")
# Keep CUDA/CPU on the reference path: its accuracy CI compares the
# generated video against the official artifact. The table reuse is an
# Ascend-specific performance optimization and must not alter that path.
if current_omni_platform.is_npu():
positive.prepare_rope_table(model)
video_rows, audio_rows, cond_anchor, audio_anchor = minimax_h3_prepare_denoise_rows(
positive=positive,
initial_video_rows=initial_video_rows,