Skip to content

[NPU] [Diffusion] Support MiniMax H3 on Ascend NPU's - #33569

Merged
ping1jing2 merged 137 commits into
sgl-project:mainfrom
OrangeRedeng:minimax-h3-on-npu-support
Aug 25, 2026
Merged

ping1jing2 merged 137 commits into
sgl-project:mainfrom
OrangeRedeng:minimax-h3-on-npu-support

Conversation

@OrangeRedeng

@OrangeRedeng OrangeRedeng commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Motivation

Extend the native MiniMax-H3 pipeline from #33275 to Ascend NPU, including packed variable-length attention, NPU-safe runtime paths, media dependencies, documentation, and CI coverage.

MiniMax-H3 packs real multimodal tokens together with sequence-parallel alignment padding, so the NPU attention path must keep the real-token and padding segments isolated. The implementation also needs device-generic RNG/autocast/residency handling and safe fallbacks for CUDA/ROCm-specific fused kernels.

Changes

  • Add MiniMax-H3 full-loop denoising support on Ascend NPU.
  • Enable laser_attn with packed variable-length handling: compute attention only for real tokens, preserve the padded shape, and zero-fill alignment-padding outputs.
  • Preserve BF16 activation range around the FP16 Laser kernel by compensating Q/K and value/output scaling.
  • Use torch_sdpa for the Qwen3-VL text encoder when the MiniMax-H3 transformer uses laser_attn.
  • Generalize keyframe RNG forking, decode autocast, and device checks to the active platform; reuse the existing NPU SiluAndMul path and generic fallbacks where CUDA/ROCm fused kernels are unavailable.
  • Install and validate ffmpeg/ffprobe for MiniMax-H3 media output on Ascend; provide actionable errors/fallbacks for missing runtime dependencies.
  • Add Ascend cookbook examples and validated TP2+SP4 (8 NPU) / TP2+SP2 (4 NPU) topologies with Cache-DiT.
  • Add minimax_h3_t2va_2npu to Ascend CI with performance and consistency checks, refresh the NPU diffusion baselines, and make baseline generation/diagnostics target the platform-specific baseline file.

Related work: #33827 adds Cache-DiT support for MiniMax-H3; #33927 tracks the FFmpeg-related output issue; #33366 is the related XPU enablement.

Ascend CI

minimax_h3_t2va_2npu uses 2 NPUs (TP2 + SP1), laser_attn, a resident DiT, layerwise-offloaded text encoder, Cache-DiT, 5-second 1344×768 T2VA generation, 50 inference steps, and seed 1101. Performance and visual consistency checks are enabled against Ascend GT pinned to ci-data-diffusion@7df858ead07940ff4d9489230fa9f040dd186789.

MiniMax-H3 2-NPU baseline: e2e=155106.21 ms, avg_denoise=2749.56 ms, median_denoise=613.17 ms.

All CI baselines were updated based on the latest results as part of the CI fixing started in #34855

Accuracy Tests

Validated end-to-end 5-second MiniMax-H3 T2VA generation with both Ascend Flash Attention and Laser Attention on 8 Ascend NPUs. Image-conditioned FL2VA was also validated with Laser Attention.

The automated 2-NPU NPU CI case runs both performance and visual consistency checks against the pinned Ascend GT revision.

Server startup:

SGLANG_CACHE_DIT_ENABLED=true \
SGLANG_CACHE_DIT_FN=2 \
SGLANG_CACHE_DIT_BN=1 \
SGLANG_CACHE_DIT_WARMUP=4 \
SGLANG_CACHE_DIT_RDT=0.4 \
SGLANG_CACHE_DIT_MC=4 \
SGLANG_CACHE_DIT_TAYLORSEER=true \
SGLANG_CACHE_DIT_TS_ORDER=2 \
HCCL_BUFFSIZE=256 sglang serve \
  --model-path ./weights/MiniMax-H3/ \
  --model-type diffusion \
  --model-variant fl2va \
  --dit-cpu-offload false \
  --num-gpus 8 \
  --tp-size 2 \
  --sp-degree 4 \
  --attention-backend laser_attn \
  --port 30088 \
  --component-residency text_encoder=layerwise-offload

For a four-NPU host, use TP2 + SP2:

SGLANG_CACHE_DIT_ENABLED=true \
SGLANG_CACHE_DIT_FN=2 \
SGLANG_CACHE_DIT_BN=1 \
SGLANG_CACHE_DIT_WARMUP=4 \
SGLANG_CACHE_DIT_RDT=0.4 \
SGLANG_CACHE_DIT_MC=4 \
SGLANG_CACHE_DIT_TAYLORSEER=true \
SGLANG_CACHE_DIT_TS_ORDER=2 \
HCCL_BUFFSIZE=256 sglang serve \
  --model-path ./weights/MiniMax-H3/ \
  --model-type diffusion \
  --model-variant fl2va \
  --dit-cpu-offload false \
  --num-gpus 4 \
  --tp-size 2 \
  --sp-degree 2 \
  --attention-backend laser_attn \
  --port 30088 \
  --component-residency text_encoder=layerwise-offload

Use --attention-backend fa to validate the Ascend Flash Attention path.

T2VA request:

curl -sS -X POST http://127.0.0.1:30088/v1/videos \
  -H "Content-Type: application/json" \
  -d '{
    "model": "MiniMaxAI/MiniMax-H3",
    "prompt": "At night, while their owner sleeps in a bedroom, three cats march in loudly playing tiny brass instruments, then abruptly file out.",
    "seconds": 5,
    "task": "t2va",
    "conditions": [],
    "target": {
      "short_edge": 768,
      "aspect_ratio": "16:9",
      "duration_seconds": 5.0
    },
    "num_outputs_per_prompt": 1,
    "num_inference_steps": 50,
    "flow_shift": 12.0,
    "audio_flow_shift": 3.0,
    "seed": 1101
  }'

Result:

78894a1d-fc7c-46c6-92a5-d2e87ad5062a.mp4

FL2VA request:

curl -sS -X POST http://127.0.0.1:30088/v1/videos \
  -H "Content-Type: application/json" \
  -d '{
    "model": "MiniMaxAI/MiniMax-H3",
    "prompt": "The supplied frame continues with calm, natural motion and synchronized ambient sound.",
    "seconds": 5,
    "task": "fl2va",
    "conditions": [
      {
        "type": "image",
        "uri": "./Forest.jpg",
        "role": "keyframe",
        "frame_index": 0
      }
    ],
    "target": {
      "short_edge": 768,
      "aspect_ratio": "auto",
      "duration_seconds": 5.0
    },
    "num_outputs_per_prompt": 1,
    "num_inference_steps": 50,
    "flow_shift": 12.0,
    "audio_flow_shift": 3.0,
    "seed": 2101
  }'

Forest.jpg

Forest

Result:

47d01bb6-3f72-4130-8623-0e309d987b08.mp4

Speed Tests and Profiling

Laser Attention computes only the real-token segment and zero-fills alignment-padding outputs, avoiding work on the padding segment while preserving packed-sequence semantics.

FA vs Laser Attention on the manually measured T2VA workload:

Attention backend Topology End-to-end generation time Speedup
Ascend Flash Attention 8 NPUs, TP2 + SP4 69.51 s 1.00×
Laser Attention 8 NPUs, TP2 + SP4 55.07 s 1.26×
Ascend Flash Attention 4 NPUs, TP2 + SP2 150.44 s 1.00×
Laser Attention 4 NPUs, TP2 + SP2 103.57 s 1.45x
Ascend Flash Attention 2 NPUs, TP2 + SP1 274.44 s 1.00×
Laser Attention 2 NPUs, TP2 + SP1 190.20 s 1.44x

CACHE-DiT on the manually measured T2VA workload:

Attention backend Topology End-to-end generation time Speedup
Laser Attention 8 NPUs, TP2 + SP4 158.71 s 1.00×
Laser Attention + CACHE-DiT 8 NPUs, TP2 + SP4 55.07 s 2.88×

The manual measurements use the same 5-second T2VA request at 1344×768, 124 frames, 24 FPS, 50 inference steps, and seed 1101. The launch commands list the measured Cache-DiT configuration explicitly: FN=2, BN=1, WARMUP=4, RDT=0.4, MC=4, TaylorSeer enabled, and TaylorSeer order 2. They also pass --dit-cpu-offload false so the transformer remains resident on the NPUs and --component-residency text_encoder=layerwise-offload to avoid keeping the full text encoder resident on every device.

The automated 2-NPU CI performance baseline is:

Metric Baseline
End-to-end 155.11 s
Average denoise step 2749.56 ms
Median denoise step 613.17 ms

This CI baseline is used for regression detection and is kept separate from the manual 4/8-NPU topology comparison.

Laser Attention performance:

T2VA:
image

FL2VA:
image

Checklist

Review and Merge Process

  1. Ping Merge Oncalls to start the process. See the PR Merge Process.
  2. Get approvals from CODEOWNERS and other reviewers.
  3. Trigger CI tests with comments or contact authorized users to do so.
    • Common commands include /tag-and-rerun-ci, /tag-run-ci-label, /rerun-failed-ci.
  4. After green CI and required approvals, ask Merge Oncalls or people with Write permission to merge the PR.

CI States

Latest PR Test (Base): ✅ Run #32739983138
Latest PR Test (Extra): ❌ Run #32739982111
Latest PR Test (AMD ROCm 7.2): ❌ Run #32739982696

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@github-actions github-actions Bot added npu diffusion SGLang Diffusion labels Aug 4, 2026
@OrangeRedeng
OrangeRedeng force-pushed the minimax-h3-on-npu-support branch from d537de8 to 6f0837a Compare August 4, 2026 15:47
@OrangeRedeng OrangeRedeng changed the title [NPU] [Diffusion] Support MiniMax H3 on Ascend NPU's [WIP] [NPU] [Diffusion] Support MiniMax H3 on Ascend NPU's Aug 4, 2026
@ping1jing2 ping1jing2 self-assigned this Aug 5, 2026
Comment thread python/sglang/multimodal_gen/runtime/layers/attention/backends/ascend_fa.py Outdated
Comment thread python/sglang/multimodal_gen/runtime/layers/attention/backends/ascend_fa.py Outdated
Comment thread python/sglang/multimodal_gen/runtime/models/dits/minimax_h3.py Outdated
@OrangeRedeng OrangeRedeng changed the title [WIP] [NPU] [Diffusion] Support MiniMax H3 on Ascend NPU's [NPU] [Diffusion] Support MiniMax H3 on Ascend NPU's Aug 5, 2026
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Aug 5, 2026
@OrangeRedeng
OrangeRedeng marked this pull request as ready for review August 5, 2026 14:25
OrangeRedeng and others added 7 commits August 23, 2026 10:36
@OrangeRedeng

Copy link
Copy Markdown
Collaborator Author

/rerun-failed-ci

@OrangeRedeng

Copy link
Copy Markdown
Collaborator Author

/rerun-failed-ci

@OrangeRedeng

OrangeRedeng commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator Author

CI failure analysis

  • NPU — not PR-related.

    • The root failure is an unrelated MiniMax-M2.5 SRT/EAGLE3 perf test (npu_fused_infer_attention_score: TND sequence-length mismatch, queryT=100 vs actualSequenceLengthQ=104).
    • The MiniMax-H3 NPU multimodal suites pass.
    • The remaining NPU failures are fast-fail cascades.
  • AMD ROCm 7.2 — not PR-related.

    • Both failed jobs are 2-GPU shards.
    • MiniMax-H3 t2va / ref2va cases hit the pre-existing ROCm-unsupported full-loop path (requires CUDA, MPS, or Ascend NPU). Tryed to modify - got jit kernel compile error. This PR only adds Ascend NPU support; ROCm behavior is unchanged.
    • The other failures are Z-Image disaggregated tests where height=None reaches zimage.py:get_freqs_cis; that code path is unrelated to this PR.
    • All four 1-GPU AMD shards pass.
  • Extra / Extra AMD — not PR-related.

    • Gated by missing run-ci-extra.

Conclusion: no PR-related CI failures.

@ping1jing2
ping1jing2 dismissed mickqian’s stale review August 25, 2026 06:44

we addressed all the comments

@ping1jing2
ping1jing2 merged commit 61b6731 into sgl-project:main Aug 25, 2026
161 of 184 checks passed
saturn-acc pushed a commit to saturn-acc/sglang that referenced this pull request Aug 31, 2026
nzr-niu pushed a commit to nzr-niu/sglang that referenced this pull request Sep 1, 2026
Co-authored-by: ronnie_zheng <zl19940307@163.com>
jakki-amd pushed a commit to jakki-amd/sglang that referenced this pull request Sep 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

amd diffusion SGLang Diffusion documentation Improvements or additions to documentation jit-kernel npu quant LLM Quantization run-ci

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants