hyperflow README

The project's README from github.com/Video-Rebirth/hyperflow. As one markdown file: README.md.

HyperFlow for MiniMax-H3

HyperFlow is Video Rebirth's 8-step LoRA for MiniMax-H3, obtained by data-free flow self-distillation and running on the official diffusers Modular Pipeline. Diffusers' default 50-point sigma schedule performs 49 model forwards; HyperFlow performs 8. The base weights, VAEs, conditioner and workflows (t2va, fl2va, ref2va, all video + audio) stay the official ones. Only the LoRA is released, on Hugging Face at huggingface.co/videorebirth/hyperflow; this repository holds the loader and the example scripts.

Showcase. See HyperFlow generated video examples and comparisons.

Base model MiniMaxAI/MiniMax-H3 (revision recorded in the file header)
Weights videorebirth/hyperflow on Hugging Face: the LoRA file and its hyperflow.json manifest, under the MiniMax H3 Community License
Adapter PEFT LoRA, rank 256 / alpha 256, on attention, feed-forward and both time embedders (316 modules); 2.8 GB
Sampling 8 forward passes on a fixed sigma grid stored in the file (video shift 12, audio shift 3)
Workflows t2va, fl2va and ref2va, one file for all three (ref2va loads it onto transformer_ref/)
Optional Ulysses context parallel on up to 4 GPUs; NVIDIA Sol-Attn sparse attention

Install

pip install "hyperflow-h3[examples] @ git+https://github.com/Video-Rebirth/hyperflow.git"

Python ≥ 3.10, diffusers ≥ 0.40.0 (the first release with the MiniMax-H3 Modular Pipeline and its context parallel plan), transformers ≥ 4.57 (Qwen3-VL). The examples extra adds PyAV for writing the output video.

Optional:

Quickstart

import torch
from diffusers import ComponentsManager
from diffusers.utils import load_image
from hyperflow_h3 import hyperflow_blocks, load_hyperflow_lora

manager = ComponentsManager()
blocks = hyperflow_blocks("fl2va")                              # official workflow, two blocks swapped
pipe = blocks.init_pipeline("MiniMaxAI/MiniMax-H3", components_manager=manager)
pipe.load_components(dtype=torch.bfloat16)
load_hyperflow_lora(pipe, "videorebirth/hyperflow")  # LoRA + two-time embedder + 8-step grid

# The official single-GPU recipe (auto CPU offload), armed only now: registering a component resets the margin.
# 24 GB is the margin validated on H200; the official recipe's 12 GB starves the denoiser there. See Performance.
manager.enable_auto_cpu_offload(device="cuda", memory_reserve_margin="24GB")

out = pipe(
    prompt="A red fox trotting through a snowy pine forest",
    image=load_image("first.png"),
    num_frames=124,
    generator=torch.Generator().manual_seed(42),
    output=["videos", "audio", "sampling_rate"],
)

Weights. load_hyperflow_lora takes a Hub repo id, a local directory or a .safetensors file. A repo or directory is resolved through its hyperflow.json manifest, whose default entry names the recommended file, so a bare id follows new versions as they ship. filename= pins one file (listed on the model card; a published name is never reused), revision= a tag or commit, token= a private repo. Manifest and weights are fetched once into the huggingface_hub cache and keep working under HF_HUB_OFFLINE=1.

load_hyperflow_lora(pipe, "videorebirth/hyperflow", filename="minimax_h3_hyperflow_8step_v1.0.safetensors")
load_hyperflow_lora(pipe, "/weights/hyperflow")  # from `hf download videorebirth/hyperflow --local-dir /weights/hyperflow`

Example commands

The package installs hyperflow-h3-fl2va and hyperflow-h3-ref2va; examples/ contains equivalent source-tree launchers. They add argument parsing, memory options and --baseline (the base pipeline with Diffusers' default 50 sigma points / 49 NFE, for an A/B on the same seed). --weights takes the three forms above (--weights-filename pins a file); --model also takes a local MiniMax-H3 snapshot, so a run can be fully offline.

# first frame -> video+audio; omit --image for t2va, add --last-image for first+last frame
hyperflow-h3-fl2va --prompt "..." --image first.png
# omni-reference: image / video / audio references, in order
hyperflow-h3-ref2va --prompt "..." --ref subject.png --ref clip.mp4 --ref voice.wav
# one GPU (the official CPU-offload recipe) instead of the default, up to 4
hyperflow-h3-fl2va --prompt "..." --image first.png --gpus 1
# FlashAttention-3 for the dense attention / Sol-Attn sparse attention (they combine)
hyperflow-h3-fl2va --prompt "..." --image first.png --attention-backend fa3
hyperflow-h3-fl2va --prompt "..." --image first.png --sol-attn
# fully offline: local weights file + local model snapshot
hyperflow-h3-fl2va --prompt "..." --image first.png \
    --weights /weights/hyperflow/minimax_h3_hyperflow_8step_v1.0.safetensors --model /models/MiniMax-H3

GPUs. By default a script runs on up to four GPUs, the degree MiniMax serves the model with, re-launching itself under torchrun when started with plain python. Rank 0 runs the text encoder and broadcasts the conditioned state (the official two-device split); every rank then runs the DiT Ulysses sequence-parallel (ContextParallelConfig(ulysses_degree=N)) with the DiT and VAEs resident on its own card. --gpus 1 is the official single-GPU recipe (ComponentsManager auto CPU offload).

Attention backends

--attention-backend, or transformer.set_attention_backend(...) in code, selects the dense attention kernel:

Performance

HyperFlow (8 NFE, 9 sigma points) against the base pipeline at Diffusers' default (49 NFE, 50 sigma points) on the same clip: fl2va, 124 frames, 1344x768, seed 0, dense SDPA attention. Pipeline time covers text encoding, denoising and decoding; process start-up and weight loading add ~30 s.

Base, 49 NFE HyperFlow, 8 NFE Speed-up
4x H200, Ulysses degree 4 ~175 s ~60 s 2.9x
1x H200, auto CPU offload ~395 s ~130 s 3.0x

The speed-up is below the 49:8 NFE ratio because text encoding and VAE decoding, which HyperFlow leaves unchanged, now take much of the run. Peak accelerator memory is ~80 GB per card either way (the LoRA adds 2.8 GB).

The single-GPU row runs the official auto CPU offload with memory_reserve_margin="24GB", the examples' default, not the official recipe's 12 GB: on a 141 GB H200 a margin under ~18 GB evicts the 10 GB VAE instead of the 62 GB text encoder when the DiT arrives and starves the denoiser. Below ~100 GB the text encoder and the DiT never fit together and the margin is irrelevant; an 80 GB card is untested.

With a fixed seed a run reproduces itself (audio bit-identical, video PSNR ≈ 43–50 dB, a residue of the VAE decode). Across GPU counts or attention backends the clip is only visibly similar (PSNR ≈ 27 dB and ≈ 34 dB): sharding and kernels change the bf16 reduction order.

Quality

HyperFlow is a self-distillation: the base model is the only teacher. In our internal comparisons against the base pipeline at 49 NFE, on the same seeds, four things stood out:

Judge on your own prompts: run the same command once as is and once with --baseline --output base.mp4; with the same --seed the two clips start from the same noise.

Sol-Attn

NVIDIA's sparse attention kernel on the DiT blocks, after two dense steps. It is an approximation: against the dense run the video differs at PSNR ≈ 23 dB and the audio waveform at cosine 0.88, on one GPU and on four alike. Check the output before adopting it.

from hyperflow_h3 import enable_sol_attention, sol_attn_available

if sol_attn_available():
    enable_sol_attention(pipe)  # after load_hyperflow_lora; the knobs are keyword arguments
Knob Default (the validated recipe) Flag
Dense steps before the kernel takes over dense_steps=2 --dense-steps
DiT blocks that always stay dense dense_layers=(0, 1) --dense-layers
Sparsity threshold tau=1.0 --sol-tau
Threshold type thresh_type="diag" —
Sink tokens none —

Works on one GPU and under Ulysses context parallel (the examples' 1 to 4 GPUs): the kernel runs inside diffusers' sequence exchange, per head on the full sequence, so a 4-GPU run matches a 1-GPU run up to the usual sharding noise. Ring attention is not supported (the kernel returns no log-sum-exp).

Kernel compilation (~10 s) is paid on the first sparse step of every process:

vs dense SDPA 1x H200 4x H200
Dense step 7.8 s 2.15 s
Sparse step 4.9 s 1.4 s
Kernel compilation (once per process) ~10 s ~10 s
First clip (compile included) ~8 s faster ~7 s slower
Later clips (compile already paid) ~13% faster ~7% faster (the DiT is 15 s of a 65 s pipeline)

--sol-attn combines with --attention-backend fa3, which then serves the dense share (4x H200, first clip: ~65 s; versus dense fa3: PSNR ≈ 25 dB, cosine 0.92).

How it works

Three additions to the official pipeline, all reversible (disable_hyperflow, disable_sol_attention):

One file, three workflows. t2va and fl2va share transformer/. ref2va runs the same file on transformer_ref/, which works because the adapter never touches adaln_proj, the carrier of the reference conditioning.

File format. A plain safetensors file: PEFT-style keys (transformer.<module>.lora_A.weight; bf16 for the DiT blocks, fp32 for the two time embedders) plus a self-describing header (hyperflow_sigmas, hyperflow_gate, lora_rank, lora_alpha, base_model_revision, …) that read_metadata() exposes. The hyperflow.json manifest next to it lists every file with its hyperflow_version and sha256. It is not a generic LoRA: the endpoint_time_embedder.* keys only exist once TwoTimeEmbedder is installed, so load it with load_hyperflow_lora, not diffusers' load_lora_adapter.

Repository layout

src/hyperflow_h3/   schedule.py (sigma grid + (t, r) planning) · embedder.py · lora.py (loader) ·
                    blocks.py (the two swapped pipeline blocks) · sol_attn.py · examples/ (installed CLIs)
examples/           source-tree launchers for the two installed example commands
tests/              CPU-only unit tests against a tiny MiniMaxH3Transformer3DModel (`make test`)

Acknowledgements

Thanks to their authors.

License

Code: Apache-2.0; the schedule, blocks and Sol-Attn processor derive from or rework diffusers code, see THIRD_PARTY_NOTICES.md. The LoRA weights are a Model Derivative of MiniMax-H3 and are distributed on their Hugging Face repo under the MiniMax H3 Community License Agreement. That Agreement, not this repository's license, governs any use of the weights: it excludes the EU, UK, South Korea and the US absent MiniMax's authorization and carries an Acceptable Use Policy. HyperFlow is developed by Video Rebirth and is not affiliated with or endorsed by MiniMax.

hyperflow (Video-Rebirth/hyperflow)

Searching Database…

这是什么?这是 MiniMax-H3(一个视频+音频生成模型)的 8 步 LoRA 适配器,通过无数据流自蒸馏(data-free flow self-distillation)训练。本仓库包含加载器以及在 diffusers Modular Pipeline 上运行它的示例脚本。
这是完整模型,还是只有适配器部分?只有适配器:发布的仅有 2.8 GB 的 LoRA,托管在 Hugging Face 的 videorebirth/hyperflow 上;基础权重、VAE、条件模块和工作流仍然是官方 MiniMax-H3 的。本仓库提供的是加载器和示例脚本。
我怎么把它跑起来?用 pip 安装这个包即可;它会安装 hyperflow-h3-fl2va 和 hyperflow-h3-ref2va 两个命令,examples/ 里还有等效的启动脚本。在代码中,load_hyperflow_lora 可以接受 Hub 仓库 id、本地目录或 .safetensors 文件。
要正常运行需要装哪些东西?需要 Python 3.10+、diffusers 0.40.0+(首次提供 MiniMax-H3 Modular Pipeline 的版本)和 transformers 4.57+(Qwen3-VL);examples extra 会额外装上用于写视频的 PyAV。可选:通过 pip install 'kernels>=0.12' 安装 FlashAttention-3,或安装 Sol-Attn(需要 PyTorch 2.10+、CUDA 12.8+、Triton 3.6+)。
我能在一张消费级显卡上跑吗?基本不行——无论哪种方式,单卡加速器显存峰值都约 80 GB,而显存低于 ~100 GB 时文本编码器和 DiT 无法同时装下。它是在 H200 上验证过的,80 GB 显卡未经测试。
我能完全离线运行吗?可以:manifest 和权重只需下载一次进入 Hugging Face 缓存,之后设置 HF_HUB_OFFLINE=1 也能正常工作,而且 --model 可以指向本地的 MiniMax-H3 快照,所以整个运行可以完全不需要网络。
Apache-2.0 就是全部的许可条款吗?不是——代码是 Apache-2.0,但 LoRA 权重属于 MiniMax-H3 的模型衍生品(Model Derivative),受 MiniMax H3 Community License 约束;未经 MiniMax 授权,该许可不适用于欧盟、英国、韩国和美国,并附加了一份可接受使用政策(Acceptable Use Policy)。
HyperFlow 到底改了 pipeline 里的什么?三处可逆的改动:一个 TwoTimeEmbedder,同时以步时刻 t 和它的终点 r 为条件(这是来自 AnyFlow 的 flow-map 思路);一个替换后的 timestep step,用来传入训练好的 8 点 sigma 网格;以及可选的 Sol-Attn 稀疏注意力。disable_hyperflow 和 disable_sol_attention 可以把这些全部撤销。
8 步的输出能和基础的 49 步一样好吗?这是一种自蒸馏,唯一的老师就是基础模型本身;在内部对比中,它表现出更均衡的能力、更好的镜头控制、更好的一致性,以及更好的材质和细节。你可以自己做 A/B 对比:用同样的命令加上 --baseline,并保持相同的种子。
我可以用 diffusers 常用的 load_lora_adapter 来加载这个文件吗?不行——endpoint time-embedder 的键只有在 TwoTimeEmbedder 装好后才存在,所以要用 load_hyperflow_lora 来加载。另外千万不要传 num_inference_steps:步数和 sigma 网格都来自权重文件,传入其他数值会直接报错。
它会用到多张 GPU 吗?默认会自动在最多四张 GPU 上运行:通过 torchrun 重新启动自身,用 Ulysses sequence parallel 切分 DiT,同时由 rank 0 运行文本编码器。--gpus 1 是官方的单卡方案,会自动进行 CPU offload。
Size
0.2 MB
Stars
143
Updated
CommitSep 18
Age
1mo
Commits · 90 Days