Skip to content

[FEAT] Ascend NPU: Support and optimize MiniMax-H3 1-8x inference on 910B2 - #60

Open
yx0716 wants to merge 4 commits into
Tele-AI:mainfrom
yx0716:pr/ascend-npu-minimax-h3
Open

yx0716 wants to merge 4 commits into
Tele-AI:mainfrom
yx0716:pr/ascend-npu-minimax-h3

Conversation

@yx0716

@yx0716 yx0716 commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Note: Stacked on top of #59 (Ascend NPU qualification suite & bilingual performance board). Please merge #59 first; the MiniMax-H3 commits start directly above it.

Description

Adapts and optimizes MiniMax-H3 joint audio-video generation (T2VA / FL2VA / Ref2VA) on Huawei Ascend 910B2 (64GB) across 1×, 2×, 4×, and 8× cards (x86_64 · CANN 9.3.0 · quay.io/ascend/vllm-omni:v0.34.0 base), surpassing vLLM-Omni v0.34.0 across every topology (2.06× on 1×, 1.04× on 2×, 1.12× on 4×, and 1.12× on 8×) under lossless BF16 execution, and populates the verified MiniMax-H3 rows on the Ascend NPU Performance Board.

Motivation

  • MiniMax-H3 combines a 48-layer joint audio-video DiT (~36.9k packed tokens at 768p 5s), a 50-layer Qwen3-VL multimodal encoder, and spatiotemporal Video/Audio VAEs: naive resident loading (~62 GB DiT + 26 GB AdaLN projections) exceeds 64 GB HBM, while default MindIE-SD opt_mode="runtime" falls back to slower attention kernels on NPU.
  • Deliver out-of-the-box 1× / 2× / 4× / 8× Ascend 910B2 support verified through G0–G4 clean-room reproduction (env -i, zero source mounts) and head-to-head parity against vLLM-Omni v0.34.0.

Type of Change

  • New feature (non-breaking change which adds functionality)
  • Performance improvement
  • Documentation update

Changes Made

  1. Manual AscendLaserAttention Dispatch & Power-of-Two Pre-Scaling (telefuser/ops/attention/backends.py, minimax_h3_dit.py)
    • Explicitly dispatch opt_mode="manual", op_type="ascend_laser_attention", layout="BNSD" for >= 4000-token self-attention shapes with head_dim <= 128 (2.03 ms vs. 5.25 ms runtime default — 2.59× faster), paired with exact power-of-two (1/256) Q/K input pre-scaling and packed live-token prefix slicing.
  2. CPU-Staged Block-Streaming Online AdaLN Cache (telefuser/models/minimax_h3_dit.py, denoising.py)
    • Stage adaln_proj / time_embedder weights on CPU and materialize the schedule cache one block (~520 MB) at a time on step 0 before releasing the projection weights, reducing resident DiT HBM from 62 GB → 36 GB so 4× and 8× run pure Resident Ulysses4 / Ulysses8 without per-layer TP all_reduce, and bypass unsupported torch._assert_async on NPU.
  3. Batched Ulysses Q/K/V Collective & Pinned Zero-D2H Offload (minimax_h3_dit.py, text_encoding.py, examples/minimax_h3/)
    • Batch NPU Ulysses Q/K/V scatter into a single ulysses_scatter_qkv all_to_all_single collective (3× fewer scatter collectives across 48 blocks × 50 steps).
    • Enable MODEL_CPU_OFFLOAD with pin_cpu_memory=True for TP-sharded Qwen3-VL text encoding (0.40s onload+forward on 8×) and single-card stage offload (2.06× faster than vLLM-Omni on 1×).
  4. NPU Fused Primitives & Worker / Video VAE Memory Hygiene (telefuser/ops/, parallel_worker.py, vae.py)
    • Add torch_npu.npu_swiglu, partial NeoX Q/K RMSNorm+RoPE (npu_rms_norm + npu_rotary_mul), and addcmul-fused indexed scale-shift/gate modulations.
    • Release non-rank-0 and host-queue worker return references and move decoded NPU video frames to CPU before empty_cache(), raise worker RLIMIT_NOFILE, and enable HCCL_NPU_SOCKET_PORT_RANGE=auto.
  5. Harness Extension, Verified Records & Bilingual Guides (benchmarks/ascend_npu/, docs/{en,zh}/, docker/Dockerfile.ascend)
    • Extend bench_vs_vllm_omni.py and cleanroom_repro.sh for MiniMax-H3 T2VA video + 32 kHz stereo AAC audio verification, add 1× / 2× / 4× / 8× verified JSON records, and update docs/{en,zh}/benchmark_ascend_npu.md, docs/{en,zh}/ascend_910b.md, and examples/minimax_h3/README.md.

Performance Impact

Measured on Ascend 910B2 (64GB) (x86_64, CANN 9.3.0, shared quay.io/ascend/vllm-omni:v0.34.0 runtime), MiniMax-H3 (T2VA) (1344×768, 124 frames @ 24 fps + 32 kHz 2ch AAC audio, 50 steps, pure BF16), 1 Cold + 3 Warm serial requests:

Accelerator SKU & Cards Parallelism TeleFuser Warm (DiT) vLLM-Omni v0.34.0 Warm (DiT) Speedup vs. vLLM-Omni Peak HBM / Card Quality Gate
1× Ascend 910B2 (64GB) Offload (Single-Card) 783.39 s (758.4 s) 1615.90 s (1590.9 s) 2.06× (-51.5%) 54,653 MB PSNR 18.83 dB, AudioCos 0.9753, Finite
2× Ascend 910B2 (64GB) Resident TP2 498.34 s (482.7 s) 517.26 s (502.2 s) 1.04× (-3.7%) 44,435 MB PSNR 17.77 dB, AudioCos 0.9655, Finite
4× Ascend 910B2 (64GB) Resident Ulysses4 220.88 s (211.2 s) 246.38 s (236.5 s) 1.12× (-10.3%) 63,514 MB PSNR 25.07 dB, AudioCos 0.9950, Finite
8× Ascend 910B2 (64GB) Resident Ulysses8 109.53 s (102.6 s) 122.90 s (115.5 s) 1.12× (-10.9%) 58,299 MB PSNR 15.67 dB, AudioCos 0.7675, Finite

Testing

  • Unit tests pass (pytest tests/unit/ops/test_npu_optimizations.py tests/unit/benchmarks/test_ascend_npu_board.py tests/unit/pipelines/minimax_h3/ tests/unit/worker/)
  • Manual testing performed (G0–G4 hardware qualification across 1× / 2× / 4× / 8× Ascend 910B2, including env -i zero-mount CLEANROOM_PASS on 1× and 4×)
  • Benchmarks added/updated (benchmarks/ascend_npu/render_board.py & python scripts/docs/prepare_cookbook.py build)

Checklist

  • Code follows the project's coding standards (ruff check, ruff format --check, ruff check --select I)
  • All tests pass (pytest & tests/docs)
  • New tests added for new functionality
  • Documentation updated (docs/en/, docs/zh/, examples/minimax_h3/README.md)
  • Commit messages are clear and descriptive
  • PR title follows the convention: [TYPE] Brief description

Related Issues

Related to #52

…-Omni

Optimize single-card and multi-card Ascend NPU execution paths under strict
BF16 model-level CPU offload parity:
- Promote eligible eager non-causal TORCH_SDPA calls on Ascend NPU to
  MindIE-SD attention when installed, and propagate set_attention_config to
  both SelfAttention and CrossAttention instances in WanModel
- Add step-scoped static text-embedding and CrossAttention K/V caching in
  WanModel/TI2VDenoisingStage across denoising steps, cleared automatically on
  stage exit and model offload
- Pre-unsqueeze 4D RoPE cos/sin once per block stack on NPU and add a
  zero-allocation fast path in _apply_rotary_emb_npu
- Fuse DiTBlock and Head scale/shift modulation via torch.addcmul on NPU
- Dispatch WanTextEncoder GELU and T5LayerNorm to native NPU kernels
- Eliminate O(T^2) frame concatenation in Wan22VideoVAE.decode and FP32
  nearest-neighbor upsample round-trips on NPU

Verified with unit tests in tests/unit/ops/test_attention_backends.py and
tests/unit/ops/test_npu_optimizations.py.
…rformance board

Add reproducible five-gate (G0-G4) Ascend NPU qualification harness under
benchmarks/ascend_npu/, sanitized head-to-head benchmark records across 1x,
2x, 4x, and 8x Ascend 910B2 (64GB) vs. vLLM-Omni v0.34.0, and bilingual
MkDocs pages (docs/{en,zh}/benchmark_ascend_npu.md) enforcing explicit chip
SKU and card-count reporting with zero host metadata leakage.
…nd 910B

- Explicitly select manual MindIE-SD ascend_laser_attention (BNSD) with exact power-of-two input pre-scaling on >=4k self-attention shapes (2.59x faster than runtime default).
- Stage MiniMax-H3 online AdaLN projection weights on CPU and materialize the schedule cache block-by-block before step 0 (62 GB -> 36 GB resident DiT), bypassing unsupported NPU _assert_async.
- Batch NPU Ulysses Q/K/V scatter into a single all_to_all_single collective via ulysses_scatter_qkv and enable pinned CPU parameter offload for TP-sharded Qwen3-VL text encoding and single-card stages.
- Dispatch Ascend NPU fused primitives (npu_swiglu, partial NeoX Q/K RoPE, addcmul indexed modulation), release host-queue ParallelWorker and Video VAE buffers before empty_cache(), and raise worker RLIMIT_NOFILE.
- Add 1/2/4/8-card Ascend 910B2 MiniMax-H3 execution profiles, container assets, bilingual Ascend 910B documentation, and CPU-mocked unit tests.
…x Ascend 910B2 records

- Extend bench_vs_vllm_omni.py and cleanroom_repro.sh (G0-G4) for MiniMax-H3 joint audio-video (T2VA) benchmarking and standalone reproduction.
- Add sanitized 50-step (1 Cold + 3 Warm) head-to-head benchmark records across 1x, 2x, 4x, and 8x Ascend 910B2 (64GB) on x86_64 CANN 9.3.0 vs. vLLM-Omni v0.34.0 (2.06x, 1.04x, 1.12x, and 1.12x speedups) and regenerate bilingual MkDocs boards.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant