rh-runninghub/minimax-h3-multigpu-lightning/sglang-diffusion-performance

Claude Code and agent skill by rh-runninghub/minimax-h3-multigpu-lightning

Trust tier 2
  • community
LLM review pending
Source check pending

Checking that the SKILL.md file is still in the repository.

Use when choosing the fastest SGLang Diffusion flags for a model, GPU, and VRAM budget.

Install

npx vskill@latest install rh-runninghub/minimax-h3-multigpu-lightning/sglang-diffusion-performance

SKILL.md

The same SKILL.md was published earlier as rh-runninghub/minimax-h3-multigpu-lightning/sglang-diffusion-performance.

SGLang Diffusion Performance Tuning

Use this skill when the user wants the fastest command line, lower VRAM, or the right performance flags for a specific model and GPU setup.

Start from the model's cookbook page

Tune from the deployment we already recommend, not from scratch: read docs/cookbook/diffusion/<Family>/ for the model first, take its command as the baseline, then apply the options below. The cookbook page is what users follow, so a recipe that silently disagrees with it on GPU count, parallelism degrees, or offload flags is a recipe for a configuration nobody runs.

Families with a cookbook page: Cosmos, Ernie-Image, FLUX, Ideogram, JoyEcho, Krea, LTX, LingBot-Video, LingBot-World, LongLive, MOVA, MiniMax, Qwen-Image, SANA-Video, SANA-WM, Wan, Z-Image.

test/ configs are pinned CI setups for correctness and regression checks, not deployment advice. Use them when you need an exactly reproducible run, and note which cookbook flags you diverged from.

Before running any sglang generate command below inside the diffusion container:

  • use python/sglang/multimodal_gen/.claude/skills/sglang-diffusion-benchmark-profile/scripts/diffusion_skill_env.py to derive the repo root, verify write access, and choose idle GPU(s)
  • export HF_TOKEN first when the selected model lives in a gated Hugging Face repo such as black-forest-labs/FLUX.*
  • export FLASHINFER_DISABLE_VERSION_CHECK=1
  • when a run downloads weights, use a task-owned cache and delete that model's

cache after its eager/BCG/quality/profile group finishes; the benchmark skill's --quality-bcg-matrix --model-cache-root --cleanup-model-cache keeps one cache for the group and writes a zero-residual cleanup ledger

  • hold one idle GPU set for the complete A/B matrix and verify no foreign

process appears at run boundaries

  • cd to the repo root resolved from sglang.__file__

Native Backend Gate

Performance numbers are useful only when the intended backend actually ran.

  • Treat any log containing Falling back to diffusers backend, Using diffusers backend, or Loaded diffusers pipeline as invalid for native SGLang performance tuning.
  • Use --backend diffusers only for an explicit diffusers baseline. For native recipes, leave the default backend or pin --backend sglang.
  • If a fallback happened, fix pipeline registration/model-path/config issues first, then rerun. Do not compare perf dumps collected from a fallback run.
  • When the runtime auto-selects parallel settings because the user omitted them, keep the result as an auto-tuned baseline. For reproducible tuning, pin --num-gpus, --ulysses-degree, --ring-degree, and --enable-cfg-parallel explicitly.

Reference: SGLang-Diffusion Advanced Optimizations Blog


Section 1: Lossless Optimizations

These options are intended to preserve output quality. In practice, some paths (most notably torch.compile) can still introduce small floating-point drift, so validate on your target model when numerical parity matters.

OptionCLI Flag / Env VarWhat It DoesSpeedupLimitations / Notes
Performance Mode`--performance-mode auto\speed\memory\manual (--mode` alias)Applies model-aware residency, FSDP/CFG, and compile defaults without overriding explicit flags. auto is the safe default; speed favors GPU residency; memory favors offload; manual leaves performance args explicit.Fastest way to establish a sensible deployment baselinespeed may OOM and enables torch.compile only when the model deployment config allows it. Explicit offload/FSDP/parallelism/compile flags win. Use manual for controlled A/B benchmarks.
torch.compile--enable-torch-compileApplies torch.compile to the DiT forward pass. Treat it as a measured comparator, not an assumed upgrade.Model- and shape-dependent; recent B300 coverage found eager or valid BCG faster or within 1% for every valid compile controlFirst request is slow and some models time out or drift numerically. Keep eager as the ground truth, use a warmup watchdog, and validate the target model. See the H200/B300 survey.
Breakable CUDA Graph--enable-breakable-cuda-graph plus optional --warmup-resolutions <WxH...> and --bcg-text-buckets ...Captures fixed-resolution DiT segments while leaving attention/collectives eager, reducing launch overhead on supported pipelines.Large on launch-bound paths; merged SANA and LTX-2 cases show material e2e gainsMutually exclusive with torch.compile and Cache-DiT; BCG takes priority. The model's default resolution is captured automatically; declare every additional production resolution. Current support is model-specific (Ideogram4, LTX-2/2.3, LongCat-Image, MiniMax-H3, Qwen-Image, SANA1.5, SANA-Video, Z-Image, GLM-Image), but an allowlisted model is not automatically a validated recipe. A valid run must log capture and no disable/failure/signature miss. --warmup-resolutions covers only WxH; video frame/conditioning mismatches can still fall back to Eager. MiniMax-H3 remains eager in the validated deployment because prompt-dependent packed host boundaries can miss the captured signature.
Warmup--warmup-mode requestRuns dummy forward passes to warm up CUDA caches, JIT, and torch.compile. Eliminates cold-start penalty.Removes first-request latency spikeAdds startup time. Without --warmup-resolutions, warmup happens on first request.
Warmup Resolutions--warmup-resolutions 256x256 720x720Pre-compiles and warms up specific resolutions at server startup (instead of lazily on first request).Faster first request per resolutionEach resolution adds to startup time. Serving mode only; useful when you know your target resolutions in advance.
Multi-GPU (SP)--num-gpus N --ulysses-degree NSequence parallelism across GPUs. Shards sequence tokens (not frames) to minimize padding.Near-linear scaling with N GPUsRequires NCCL; inter-GPU bandwidth matters. ulysses_degree * ring_degree = sp_degree. For Wan2.2 video, start by benchmarking pure Ulysses before assuming a mixed Ulysses/Ring layout is fastest.
Cross-node SP--nnodes, --node-rank, --dist-init-addr with total --num-gpus; combine node-local Ulysses with cross-node RingExtends sequence parallel groups across multiple nodes.Capacity and long-sequence scaling beyond one hostPrefer Ulysses within a node and Ring across nodes; all-to-all is usually the least cross-node-friendly. Use --encoder-parallel replicate today and verify the model's Ring admission and determinism. MiniMax-H3 is the current end-to-end validated recipe.
CFG Parallel--enable-cfg-parallelRuns conditional and unconditional CFG branches in parallel across GPUs. For CFG models on multi-GPU, benchmark this against pure Ulysses on your topology instead of assuming one always wins.Often faster than pure SP for CFG modelsRequires num_gpus >= 2. Halves the Ulysses group size (e.g. 8 GPU → two 4-GPU groups). Only for models that use CFG. Nightly coverage configs may intentionally use smaller Ulysses groups to keep ring behavior exercised; that does not automatically make them the lowest-latency choice.
Layerwise Offload--dit-layerwise-offloadAsync layer-by-layer H2D prefetch with compute overlap. Only ~2 DiT layers reside on GPU at a time, dramatically reducing VRAM. For some video models the copy stream can be almost fully hidden behind compute.Saves VRAM (40 GB → ~11 GB for Wan A14B); can be near-zero speed cost on the right workloadEnabled by default for Wan/MOVA video models. Compatible with Cache-DiT (skipped blocks are not streamed). For image models or highly parallelized setups (many GPUs, small per-GPU compute), the copy stream may not be fully hidden and can cause slowdown.
Offload Prefetch Size--dit-offload-prefetch-size FFine-grained control over layerwise offload: how many layers to prefetch ahead. 0.0 = 1 layer (min VRAM), 0.1 = 10% of layers, ≥1 = absolute layer count.Tune for cases where default offload has copy stream interference (e.g. image models). 0.05–0.1 is a good starting point.Values ≥ 0.5 approach no-offload VRAM with worse performance. Use lower values when copy overlap is weak; disable offload when memory allows and latency dominates.
FSDP Inference--use-fsdp-inferenceUses PyTorch FSDP to shard model weights across GPUs with prefetch. Low latency, low VRAM.Reduces per-GPU VRAMMutually exclusive with --dit-layerwise-offload. More overhead than SP on high-bandwidth interconnects.
CPU Offload (components)--text-encoder-cpu-offload, --image-encoder-cpu-offload, --vae-cpu-offload, --dit-cpu-offloadOffloads specific pipeline components to CPU when not in use.Reduces peak VRAMAdds H2D transfer latency when the component is needed. Auto-enabled for low-VRAM GPUs (<30 GB). Tip: after the first request completes, the console prints a peak VRAM analysis with suggestions on which offload flags can be safely disabled — look for the "Components that could stay resident" log line.
Pin CPU Memory--pin-cpu-memoryUses pinned (page-locked) memory for CPU offload transfers.Faster H2D transfersSlightly higher host memory usage. Enabled by default; disable only as workaround for CUDA errors.
Attention Backend (lossless)--attention-backend faSelects a lossless attention kernel for SGLang-native pipelines: fa (FlashAttention 2/3/4 alias) or torch_sdpa.FA is usually faster than SDPA on long sequencesFA requires compatible GPU (Ampere+). For --backend diffusers, valid backend names differ; use the names documented in docs/docs/sglang-diffusion/attention_backends.mdx.
Parallel Folding(automatic when SP > 1)Reuses the SP process group as TP for the T5 text encoder, so text encoding is parallelized "for free".Faster text encoding on multi-GPUAutomatic; no user action needed. Only applies to T5-based pipelines.
Choosing what goes in --layerwise-offload-components

Layerwise offload pays one H2D of a component's weights per pass over that component, overlapped with that pass's compute. So the question is not how big the component is, it is how many passes per request it makes — counted from the code, not from the pipeline diagram:

ComponentPasses per requestPlacement
DiTone per denoising stepStream it. The transfer amortizes over every step and hides behind attention/FFN.
Video VAEone per temporal chunk, not oneDeclare it streamed and keep its blocks resident.
Text / image encoderoneResident if it fits; otherwise streamed with its blocks resident.
Vocab tablea gather, one row per tokenNeither. Declare it in host_resident_table_names and leave it in host memory.

"One-shot" is a property of the code, not of the diagram. _decode_temporal_streaming in runtime/models/vaes/minimax_h3_video_vae/klvae.py calls the whole video decoder once per temporal chunk, so streaming its 36 blocks pays 36 block transfers per chunk. On MiniMax-H3 at 864x480 / 124 frames that is 150 s of decode against 13 s with the blocks held.

There are three placements, not two. A component can be declared streamed and still hold its blocks:

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewNot runA model review is scheduled for the next rescan.

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
123
Repository forks
19
7-day trend score
23

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/rh-runninghub/minimax-h3-multigpu-lightning/sglang-diffusion-performance/badge)](https://verified-skill.com/skills/rh-runninghub/minimax-h3-multigpu-lightning/sglang-diffusion-performance)

Something wrong with this skill or its page? Tell us.