|
| 1 | +# MagiHuman — Codebase Map Entry |
| 2 | + |
| 3 | +**Family:** daVinci-MagiHuman (joint audio-visual generative model) |
| 4 | +**Reference:** [GAIR-NLP/daVinci-MagiHuman](https://github.com/GAIR-NLP/daVinci-MagiHuman) |
| 5 | +**Architecture:** 15B-param single-stream DiT, 40 layers, hidden=5120, |
| 6 | +head_dim=128, GQA num_query_groups=8. Joint AV denoising in a unified token |
| 7 | +sequence; **no cross-attention**. |
| 8 | + |
| 9 | +## Variant Matrix |
| 10 | + |
| 11 | +| Variant | T2V | TI2V | DiT | Steps | CFG | Resolution | |
| 12 | +|---|---|---|---|---|---|---| |
| 13 | +| `base` | yes | yes | base | 32 | 2 | 480x256 | |
| 14 | +| `distill` | yes | yes | distill (DMD-2) | 8 | 1 (no CFG) | 480x256 | |
| 15 | +| `sr_540p` | yes | yes | base + sr_540p | 32 + 5 | 2 + cfg-trick | 896x512 | |
| 16 | +| `sr_1080p` | yes | yes | base + sr_1080p | 32 + 5 | 2 + cfg-trick | 1920x1056 | |
| 17 | + |
| 18 | +SR-1080p uses block-sparse video→video local-window attention on 32 of 40 |
| 19 | +SR DiT layers (`frame_receptive_field=11`), implemented as a 3-block SDPA |
| 20 | +accumulator that mirrors upstream `flex_flash_attn_func`. |
| 21 | + |
| 22 | +## File Locations |
| 23 | + |
| 24 | +| Role | Path | |
| 25 | +|---|---| |
| 26 | +| Pipeline class | `fastvideo/pipelines/basic/magi_human/magi_human_pipeline.py` | |
| 27 | +| Pipeline package AGENTS.md | `fastvideo/pipelines/basic/magi_human/AGENTS.md` | |
| 28 | +| Stages | `fastvideo/pipelines/basic/magi_human/stages/*.py` | |
| 29 | +| DiT | `fastvideo/models/dits/magi_human.py` | |
| 30 | +| Text encoder (T5-Gemma) | `fastvideo/models/encoders/t5gemma.py` | |
| 31 | +| Audio VAE wrapper | `fastvideo/models/vaes/sa_audio.py` (shared with `stable_audio` pipeline) | |
| 32 | +| Conversion script | `scripts/checkpoint_conversion/convert_magi_human_to_diffusers.py` | |
| 33 | +| Examples | `examples/inference/basic/basic_magi_human*.py` (8 files, one per variant × mode) | |
| 34 | +| SSIM regression | `fastvideo/tests/ssim/test_magi_human_similarity.py` | |
| 35 | +| Local parity battery | `tests/local_tests/magi_human/` (14 tests, GPU-gated) | |
| 36 | +| Port journal | `fastvideo/pipelines/basic/magi_human/JOURNAL.md` | |
| 37 | + |
| 38 | +## Canonical HF Repo |
| 39 | + |
| 40 | +[FastVideo/MagiHuman-Diffusers](https://huggingface.co/FastVideo/MagiHuman-Diffusers) |
| 41 | +— umbrella repo with sibling subfolders per variant. |
| 42 | + |
| 43 | +```python |
| 44 | +from fastvideo import VideoGenerator |
| 45 | +gen = VideoGenerator.from_pretrained("FastVideo/MagiHuman-Diffusers/base") |
| 46 | +gen.generate_video(prompt="...", output_path="out.mp4", save_video=True) |
| 47 | +``` |
| 48 | + |
| 49 | +Four shared upstream components are lazy-loaded by `MagiHumanPipeline.load_modules`: |
| 50 | + |
| 51 | +| Component | Upstream repo | |
| 52 | +|---|---| |
| 53 | +| Wan 2.2 VAE | `Wan-AI/Wan2.2-TI2V-5B` | |
| 54 | +| T5-Gemma 9B UL2 | `google/t5gemma-9b-9b-ul2` | |
| 55 | +| Stable Audio VAE | `stabilityai/stable-audio-open-1.0` | |
| 56 | +| MagiHuman DiT weights | `GAIR/daVinci-MagiHuman` (gated) | |
| 57 | + |
| 58 | +## Parity Invariants |
| 59 | + |
| 60 | +Three load-bearing invariants. See `fastvideo/pipelines/basic/magi_human/AGENTS.md` |
| 61 | +for the full discussion. |
| 62 | + |
| 63 | +1. **Channel-major video token packing** (`stages/latent_preparation.py`) |
| 64 | +2. **DiT dtype boundary**: residual stream stays fp32 across blocks |
| 65 | +3. **Conversion `_FP32_KEEP_SUFFIXES`** (`scripts/checkpoint_conversion/convert_magi_human_to_diffusers.py`) |
| 66 | + |
| 67 | +## Lessons |
| 68 | + |
| 69 | +- `.agents/lessons/2026-05-07_silent-channel-major-packing-bugs.md` |
| 70 | +- `.agents/lessons/2026-05-07_dit-dtype-boundary-with-flash-attn.md` |
| 71 | +- `.agents/lessons/2026-05-07_conversion-cast-bf16-suffix-allowlist.md` |
| 72 | + |
| 73 | +## Provenance |
| 74 | + |
| 75 | +Decomposed from PR [#1280](https://github.com/hao-ai-lab/FastVideo/pull/1280) |
| 76 | +(`will/magi` @ `4e1603634d27c8e1b5c4cc5d9387f046547f5c49`). See the package |
| 77 | +AGENTS.md for the full PR-stack table. |
0 commit comments