Run this model with HF Jobs

Run MATLOWAI/MiniMax-H3-Variable-Clock on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.

Paste one of these prompts into your coding agent:

Fine-tune on my dataset

Use HF Jobs to fine-tune https://huggingface.co/MATLOWAI/MiniMax-H3-Variable-Clock. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.

Run batch inference

Use HF Jobs to run batch inference with https://huggingface.co/MATLOWAI/MiniMax-H3-Variable-Clock on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
File size: 15,129 Bytes
fbe7516
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9165f4a
fbe7516
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9165f4a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fbe7516
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# Stage-2 DeRoPE Clock Guide β€” What Works Well & How to Use It

This guide covers the **experimental Stage-2 DeRoPE stack** shipped on this branch (`H3Stage2Clock` + ready-to-drop workflows in `examples/experimental/`). Every default here comes from 80+ controlled ablations across 6 test clips (live-action panning shots and fast anime sword/vault action).

If you want the full story of what broke, which hypotheses failed, and how we found these fixes, read [`docs/STAGE2_CLOCK_JOURNEY.md`](STAGE2_CLOCK_JOURNEY.md).

---

## 1. The Four Levers That Actually Work

### Lever 1 β€” Pop-Free `K=3` Fine-Band Splice (`keep_fine_bands = 3`)
MiniMax-H3's temporal RoPE spectrum has periods:
- Band 0: **3.8 frames**
- Band 1: **6.7 frames**
- Band 2: **11.9 frames** (1.43 turns inside one 17-frame VAE chunk)
- Band 3: **21.2 frames** (first band slower than a 17-frame chunk)

Keeping **3 fine bands** (`keep_fine_bands = 3`) leaves Bands 0–2 on the native stock grid while putting Band 3+ on the True Clock. That single change eliminates:
- Chunk-start white exposure flashes (`t % 5 == 0` singletons jumping 25–30 luma levels under `K=2`),
- Translucent multi-exposure ghosting on static backgrounds, and
- The 8-frame vertical camera bob that `K=2` excites and `hold = 4` aliases into an every-other-frame buzz.

### Lever 2 β€” Two-Pass Split (`Οƒ β‰₯ 0.80` Clock β†’ `Οƒ ≀ 0.571` Pure Native Stock)
Leaving *any* compressed temporal RoPE active during the final low-sigma detail steps (`Οƒ = 0.571, 0.333`) causes adjacent held frames to blend edges across time (blurry ghost boots, soft limbs).

Splitting the denoise cleanly at `handoff_sigma = 0.65` solves it with **zero extra steps**:
- **Pass 1 (`Οƒ β‰₯ 0.80`):** `H3Stage2Clock` (`K=3` + optional RYS loop, with **no LoRA** or a `K=3` clock LoRA).
- **Pass 2 (`Οƒ ≀ 0.571`, final 2 steps):** Pure native stock model + `euler` + `DisableNoise` β€” **no True Clock, no clock LoRA, no RYS loop**.

On Pika's 6-step schedule (`[1.0, 0.973, 0.923, 0.80, 0.571, 0.333, 0.0]`), `handoff_sigma = 0.65` automatically splits every common entry point:
- Enter at **`Οƒ = 0.973`**: 3 Pass-1 steps (`0.973 β†’ 0.923 β†’ 0.80 β†’ 0.571`) + 2 Pass-2 stock steps (`0.571 β†’ 0.333 β†’ 0.0`).
- Enter at **`Οƒ = 0.923`**: 2 Pass-1 steps (`0.923 β†’ 0.80 β†’ 0.571`) + 2 Pass-2 stock steps.
- Enter at **`Οƒ = 0.800`**: 1 Pass-1 step (`0.80 β†’ 0.571`) + 2 Pass-2 stock steps.

### Lever 3 β€” Deterministic `euler` + Zero-Training Damped RYS Middle-Block Loop
Switching from stochastic `lcm` to deterministic **`euler`** removes re-noising jitter during the short Pass-1 window. Adding a zero-training **RYS ("Repeat Your Self") middle-block loop** during Pass 1 only β€” adapted from the LLM middle-layer duplication trick (David Noel Ng, 2024) into a DiT-safe damped residual loop that runs a middle window of DiT blocks once more and blends `h = h_save + 0.20 * (h_loop - h_save)` β€” dramatically improves spatial/temporal lock without retraining or the contrast/color overshoot of raw 100% looping:
- **`16-32` (`Ξ± = 0.20`):** Best general balance and **best when paired with `SelfRefiningSamplerPlus`** (tight velocity control, razor-sharp anime swords, 3–4Γ— calmer horizons).
- **`20-36` (`Ξ± = 0.20`):** Best **without** `SelfRefiningSamplerPlus` on live-action walking/panning shots (preserves original warm palette and unlocks freer natural stride fluidity while keeping 3Γ— calmer vertical stability than source).
- **Keep Pass 2 loop OFF:** Looping both passes showed no benefit over Pass-1-only.

### Lever 4 β€” Optional `ComfyUI-SelfRefiningSamplerPlus` at Fixed `Οƒ` (`perturb_strength_scale = 1.0`)
If you install [`ComfyUI-SelfRefiningSamplerPlus`](https://github.com/Alex240z/ComfyUI-SelfRefiningSamplerPlus) (implements arXiv:2601.18577 Predict-and-Perturb self-refinement and natively supports H3's `NestedTensor` audio-video latents), wiring `SamplerSelfRefinePlus` into `H3Stage2Clock`'s `sampler` input gives a major jump in edge crispness and fast-action coherence (e.g. solid katana blades instead of smears, clean sparks, sharp tiles).

Two rules are critical when using `SelfRefiningSamplerPlus` on H3:
1. **Always set `perturb_strength_scale = 1.0`** (fixed-`Οƒ` P&P, `uncertainty_metric = "l1_mean"`, `uncertainty_threshold = 0.20`, `max_substeps = 2`). Values `> 1.0` shift anime colors and can push dilated clips across the `Οƒ > 0.92` speed-up cliff.
2. **Use the Identity-Locked curve when entering at `Οƒ = 0.973` on character/anime shots:**
   - Standard curve (best on `Οƒ = 0.973` live-action silhouettes or `Οƒ = 0.80`):
     `[[0.0, 1.0], [0.5, 0.5], [1.0, 0.5]]` (`[2, 1, 1]` substeps on 3 Pass-1 steps)
   - **Identity-Locked curve** (skips P&P on `Οƒ = 0.973` so 97.3% noise cannot re-roll face/gender/camera angle, then refines on `Οƒ = 0.923 & 0.800`):
     `[[0.0, 0.0], [0.5, 1.0], [1.0, 0.5]]` (`[0, 2, 1]` substeps on 3 Pass-1 steps)

---

## 2. Quick-Reference Recipe Matrix

| Scenario | Entry `Οƒ` | Clock & Loop (`H3Stage2Clock`) | Sampler | LoRA (Pass 1) | Why This Works |
| :--- | :--- | :--- | :--- | :--- | :--- |
| **Live-action high-denoise (max smoothness + sharpness)** | `0.973` | `K=3`, RYS `16-32`, `Ξ±=0.20`, `handoff=0.65` | `SelfRefine+` (`scale=1.0`, standard curve) + `euler` | **None** *(or `K=3` LoRA)* | Best overall temporal smoothness, calm horizon, zero ghost boots, no `K=2` LoRA drag. |
| **Live-action high-denoise (zero extra node packs / freer stride)** | `0.973` | `K=3`, RYS `20-36`, `Ξ±=0.20`, `handoff=0.65` | Plain `euler` | **None** *(or `K=3` LoRA)* | Exact original warm lighting, fluid walking stride, 3Γ— calmer horizon than source, core nodes only. |
| **Anime / complex framing at high denoise (`Οƒ = 0.973`)** | `0.973` | `K=3`, RYS `16-32`, `Ξ±=0.20`, `handoff=0.65` | `SelfRefine+` (`scale=1.0`, **Identity-Locked** `[0,2,1]` curve) + `euler` | **None** *(or `K=3` LoRA)* | Prevents `Οƒ=0.973` camera/identity flips while sharpening swords, sparks, and flying debris and halving stutter. |
| **Fast-action anime at medium denoise (`Οƒ = 0.80`)** | `0.800` | `K=3`, RYS `16-32`, `Ξ±=0.20`, `handoff=0.65` | `SelfRefine+` (`scale=1.0`, `1` Pass-1 step) + `euler` *(or plain `euler`)* | **None** *(or `K=3` LoRA)* | Solid sharp blades, zero background ghosting, exact source pose & palette. |
| **Maximum source identity & color lock** | `0.923` | `K=3`, RYS `16-32`, `Ξ±=0.20`, `handoff=0.65` | `SelfRefine+` (`scale=1.0`, 2 Pass-1 steps) + `euler` | **None** | Locks original face, silhouette, golden-hour warmth, and ~1.0Γ— natural speed without touching `Οƒ=0.973`. |

> **Recommended `K=3` Pass-1 LoRAs (optional β€” download from [`MATLOWAI/MiniMax-H3-Variable-Clock`](https://huggingface.co/MATLOWAI/MiniMax-H3-Variable-Clock)):**
> Everything in the table works with **no clock LoRA at all**. Legacy `run f` was trained at `K=2`, so inside `K=3 + SelfRefine+ + RYS 16-32`, dropping `run f` actually improved smoothness. Three dedicated **`K=3` sustained-hold LoRAs** (trained across 108 clips / 27 live-action + anime sources with chunk starts inside `hold=4` plateaus) beat both `NO LoRA` and `run f` across all 4 benchmark scenes β€” always load on **Pass 1 only** and keep **Pass 2 pure native stock**:
>
> | LoRA file (Pass 1 only, strength `1.0`) | Trained on | Best for | Key measured wins (1 seed/scene) |
> | :--- | :--- | :--- | :--- |
> | **`minimax_h3_variable_clock_k3_hisigma_flow_step1000_lateattn_r16.safetensors`** | High-sigma only (`Οƒ ∈ [0.55, 1.00]`), DIS smooth-flow `K=3`, blocks `0-34` + late attention (`lateattn` trim) | **Best all-around Pass-1 LoRA** (calmest horizon + lowest exit stutter + clean anime) | `pier`: `dy_hf 0.113 px`, `exSt 1.63`, `sharp 2.17`; `bamboo`: solid red katana + `held_dy_hf 0.354` (2.7Γ— calmer than `run f`); `panrun`: `chunk 1.14` |
> | **`minimax_h3_variable_clock_k3_flow_step400_r16.safetensors`** | Full-sigma DIS smooth-flow `K=3`, step 400 sweet spot | **Smoothest overall motion** across live + anime | `pier`: `midSt 1.48` (smoother than source `1.51`), `f147pk 2.15Γ—`, clean RYS `dy_hf 0.110 px`; `bamboo`: `1.004Γ—` sharp, `held_dy_hf 0.348`; `panrun`: `stutter 3.30`; `rooftop`: `chunk 0.41` |
> | **`minimax_h3_variable_clock_k3_hisigma_flow_step1000_r16.safetensors`** | High-sigma only (`Οƒ ∈ [0.55, 1.00]`), DIS smooth-flow `K=3`, all 50 blocks | **Maximum sharpness & lowest chunk jump** | `pier`: `sharp 2.323`, `chunk 0.41`, `f147pk 2.28Γ—`; `panrun`: `chunk 1.12` |
> | **`minimax_h3_variable_clock_k3_repeat_step1000_r16.safetensors`** | Full-sigma repeated-frame `K=3`, step 1000 | **Tightest horizon lock** on panning shots | `pier`: `dy_hf 0.111 px / dy_mx 0.23 px` (3.3Γ— calmer than source `0.75 px`); `rooftop`: `sharp 2.265` |

### Leaderboard Comparison Across Top Methods (1 Seed/Scene, Two-Pass `handoff_sigma = 0.65`, Pass 2 Pure Stock `euler`)

*`dy_hf / dy_mx` = vertical horizon jitter in px (`pier` source `0.171 / 0.75`); `midSt / exSt` = mid-hold / exit-ramp stutter (`pier` source `midSt = 1.51`); `chunk` = 17f chunk-boundary luma jump; `sharp` = Laplacian fine-detail ratio vs source; `held_dy_hf` = `bamboo` held-span background jitter. `panrun` `K=3` LoRA rows use Identity-Locked `SRP` (`[0, 2, 1]`).*

| Method / Stack (Pass 1 β†’ Pure Stock Pass 2) | Extra Deps | `pier` `dy_hf / dy_mx` | `pier` `midSt / exSt` | `pier` `chunk / sharp` | `bamboo` `PSNR / held_dy_hf` | `panrun` `chunk / stutter` | `rooftop` `chunk / stutter` |
| :--- | :--- | ---: | ---: | ---: | ---: | ---: | ---: |
| *Source clip (`pier`)* | β€” | *`0.171 / 0.75`* | *`1.51 / β€”`* | *`β€” / 1.00`* | β€” | β€” | β€” |
| **Plain `K=3` Two-Pass (`euler`, no RYS, no SRP)** | Core only | `0.361 / 0.68` | β€” | **`0.36`** / β€” | β€” | β€” | β€” |
| **`K=3` + `RYS 16–32` (`euler`, no SRP, `+run f`)** | Core only | **`0.103 / 0.19`** | β€” | **`0.29`** / `1.68` | **`21.48 dB`** / `0.943` | `1.70 / 5.48` | **`0.41`** / `4.34` |
| **`K=3` + `RYS 20–36` (`euler`, no SRP, NO LoRA)** | Core only | `0.150 / 0.31` | `5.08 / 3.32` | `0.56 / 1.71` | `21.26 dB`† / `0.721`† | β€” | β€” |
| **`K=3` + `RYS 20–36` (`euler`, no SRP, `+k3_flow_s400`)** | + `K=3` LoRA | **`0.110 / 0.27`** | `5.25 / 3.51` | `0.53 / 1.64` | β€” | β€” | β€” |
| **`K=3` + `RYS 16–32` + `SRP 1.0` (NO LoRA)** | + `SRP` | `0.215 / 0.59` | `1.75 / 1.64` | `0.49 / 2.06` | `19.87 dB / 0.459` | β€” | `0.45` / **`2.45`** |
| `K=3` + `RYS 16–32` + `SRP 1.0` + Legacy `run f` (`K=2`) | + `SRP` + `K=2` | `0.176 / 0.40` | `1.59 / 1.92` | `0.51 / 2.04` | `20.14 dB / 0.955` | β€” | β€” |
| **`K=3` + `RYS 16–32` + `SRP 1.0` + `k3_hisigma_flow_step1000_lateattn`** *(Best All-Around)* | + `SRP` + `K=3` | **`0.113 / 0.36`** | `2.03` / **`1.63`** | `0.56 / 2.17` | `19.91 dB` / **`0.354`** | `1.14 / 4.38` | `0.95 / 2.92` |
| **`K=3` + `RYS 16–32` + `SRP 1.0` + `k3_flow_step400`** *(Smoothest Overall)* | + `SRP` + `K=3` | `0.341 / 0.70` | **`1.48`** / `1.77` | `0.58 / 2.13` | `19.89 dB` / **`0.348`** | `1.25` / **`3.30`** | **`0.41`** / `2.73` |
| **`K=3` + `RYS 16–32` + `SRP 1.0` + `k3_hisigma_flow_step1000`** *(Sharpest / Lowest Chunk)* | + `SRP` + `K=3` | `0.169 / 0.47` | `2.10 / 1.91` | **`0.41` / `2.32`** | `19.91 dB / 0.385` | **`1.12`** / `6.11` | `1.03 / 3.37` |
| **`K=3` + `RYS 16–32` + `SRP 1.0` + `k3_repeat_step1000`** *(Tightest Horizon Lock)* | + `SRP` + `K=3` | **`0.111 / 0.23`** | `2.43 / 2.13` | `0.55 / 2.06` | `19.94 dB / 0.426` | `1.39 / 4.55` | `0.83 / 3.66` |

*†`bamboo` `RYS 20–36` row measured with `run f` (`Wave 6`); `RYS 16–32` `NO LoRA` on `bamboo` hit `21.37 dB / 0.727`.*

---

## 3. Included Experimental Workflows

All three workflows live in `examples/experimental/` (each with a ComfyUI UI `.json` and headless `_api.json`):

1. **`examples/experimental/stage2_derope_k3_rys_twopass.json`**
   - **Dependencies:** Core ComfyUI + `ComfyUI-MAINodes` only (no third-party sampler, no clock LoRA required).
   - **Default setup:** `H3Stage2Clock` (`K=3`, RYS `20-36`, `Ξ±=0.20`, `handoff_sigma=0.65`) β†’ `SamplerCustomAdvanced` Pass 1 β†’ `SamplerCustomAdvanced` Pass 2 (pure stock `euler` + `DisableNoise`).
   - Change the `SplitSigmas` entry step to switch between `Οƒ = 0.973` (`step = 1`), `Οƒ = 0.923` (`step = 2`), and `Οƒ = 0.800` (`step = 3`) β€” `H3Stage2Clock` splits Pass 1 and Pass 2 automatically.

2. **`examples/experimental/stage2_derope_k3_rys_selfrefine.json`**
   - **Dependencies:** Core ComfyUI + `ComfyUI-MAINodes` + [`ComfyUI-SelfRefiningSamplerPlus`](https://github.com/Alex240z/ComfyUI-SelfRefiningSamplerPlus) (no clock LoRA required).
   - **Default setup:** `SamplerSelfRefinePlus` (`perturb_strength_scale=1.0`, `l1_mean`, Identity-Locked curve `[[0.0, 0.0], [0.5, 1.0], [1.0, 0.5]]`) β†’ `H3Stage2Clock` (`K=3`, RYS `16-32`, `Ξ±=0.20`, `handoff_sigma=0.65`) β†’ two-pass `euler` finishing.

3. **`examples/experimental/stage2_derope_k3_rys_selfrefine_lora.json`** *(Full Champion Stack)*
   - **Dependencies:** Core ComfyUI + `ComfyUI-MAINodes` + `ComfyUI-SelfRefiningSamplerPlus` + [`minimax_h3_variable_clock_k3_hisigma_flow_step1000_lateattn_r16.safetensors`](https://huggingface.co/MATLOWAI/MiniMax-H3-Variable-Clock) (or `k3_flow_step400`).
   - **Default setup:** Loads the `K=3` clock LoRA **only onto Pass 1** (`Pass-1 Guider`) while keeping **Pass 2 strictly on the stock Pika model** (`Pass-2 Guider`, `DisableNoise`).

---

## 4. Hold-Map Tips for `K=3`

- **Keep `hold` uniform across `17k` chunk-start singletons (`S(1)`) and 4-frame tokens (`G4`):** Use standard `H3ManualHoldMap` / `H3JerkOracle` ramps (`1 β†’ 2 β†’ 3 β†’ 4 β†’ 3 β†’ 2 β†’ 1`). Do **not** force `hold = 1` on every `17k` singleton under `K=3` β€” that breaks the uniform `world_step / stock_step` ratio against `K=3`'s stock Bands 0–2 and creates a 5-frame periodic stutter.
- **If you notice faint microstutters specifically on `hold = 2` exit ramps:** H3's 4-frame causal VAE decoder has a periodic 4-frame velocity wave that aliases at Nyquist under `hold = 2` and cancels cleanly under `hold = 4`. Testing `ramp = False` (`hold = 4` uniform across the held span) halves exit microstutter, at the trade-off of a sharper single step at the `1 β†’ 4` entry/exit seam.

---

## 5. Additional Fixes Included on This Branch

While building and testing `H3Stage2Clock`, three source-level bugs in `motion.py` were confirmed and fixed with unit tests:
1. **Same-length reference-video collision:** `_install_true_clock_patch` previously matched solely on token count (`len(spans) == n`), allowing a reference video with the same latent length as the target to inherit the target's clock. Reference blocks now stay strictly on the stock grid.
2. **Stale `_GUIDE_LAYOUTS` cache:** `_install_guide_layout_patch` now clears `_GUIDE_LAYOUTS[seq_len]` when a later layout of the same sequence length carries no guide condition rows.
3. **True Clock + DyRoPE patch-stacking crash:** Patch guards now walk the `_h3_prev` wrapper chain so running `H3TrueClock`, then `H3DyRoPE`, then `H3TrueClock` again in one ComfyUI session never double-wraps `rope_freqs`.