causal_cd: consistency student of the released chain (10K steps from causal_teacher, past + future memory); code: stage 4 DMD with past + future memory
Browse files
code/README.md
CHANGED
|
@@ -118,8 +118,8 @@ DiT checkpoints fine-tuned from Wan2.2-TI2V-5B, in the `weights/` folder of
|
|
| 118 |
| `causal_teacher/dit_step11000.safetensors` | 2 · causal teacher | teacher of stage 3 |
|
| 119 |
| `bidirectional/dit_step35000.safetensors` | 1 · bidirectional teacher, all data incl. world-edit clips | `bidirectional`, 30 steps, CFG 3 |
|
| 120 |
|
| 121 |
-
|
| 122 |
-
`
|
| 123 |
|
| 124 |
**Other base models.** The approach is not tied to Wan: the visual proxy, the reference binding and the training recipe
|
| 125 |
carry over to other video backbones. We also trained it on [LTX-2.5](https://huggingface.co/Lightricks/LTX-2.5) (22B)
|
|
@@ -172,7 +172,7 @@ bash scripts/train/4_dmd.sh runs/cd/ema/ema_step10000.safetensors \
|
|
| 172 |
| 1 · bidirectional teacher | `wizard.train.bidirectional` | `scripts/train/1_bidirectional.sh` |
|
| 173 |
| 2 · causal teacher (teacher forcing + history self-augmentation) | `wizard.train.causal_selfaug` | `scripts/train/2_causal.sh` |
|
| 174 |
| 3 · consistency distillation | `wizard.distill.consistency_selfaug_future` | `scripts/train/3_consistency.sh` |
|
| 175 |
-
| 4 · distribution matching distillation | `wizard.distill.
|
| 176 |
|
| 177 |
Every stage can start from the released checkpoint of the previous one. Hyper-parameters, resuming and environment
|
| 178 |
switches: [docs/TRAINING.md](docs/TRAINING.md).
|
|
|
|
| 118 |
| `causal_teacher/dit_step11000.safetensors` | 2 · causal teacher | teacher of stage 3 |
|
| 119 |
| `bidirectional/dit_step35000.safetensors` | 1 · bidirectional teacher, all data incl. world-edit clips | `bidirectional`, 30 steps, CFG 3 |
|
| 120 |
|
| 121 |
+
`causal_cd` is the consistency student of the released chain (stage 3 run from `causal_teacher` with the scripts below).
|
| 122 |
+
`causal_dmd` still comes from an earlier run of the chain; the DMD student distilled from this `causal_cd` will replace it.
|
| 123 |
|
| 124 |
**Other base models.** The approach is not tied to Wan: the visual proxy, the reference binding and the training recipe
|
| 125 |
carry over to other video backbones. We also trained it on [LTX-2.5](https://huggingface.co/Lightricks/LTX-2.5) (22B)
|
|
|
|
| 172 |
| 1 · bidirectional teacher | `wizard.train.bidirectional` | `scripts/train/1_bidirectional.sh` |
|
| 173 |
| 2 · causal teacher (teacher forcing + history self-augmentation) | `wizard.train.causal_selfaug` | `scripts/train/2_causal.sh` |
|
| 174 |
| 3 · consistency distillation | `wizard.distill.consistency_selfaug_future` | `scripts/train/3_consistency.sh` |
|
| 175 |
+
| 4 · distribution matching distillation | `wizard.distill.dmd_future` | `scripts/train/4_dmd.sh` |
|
| 176 |
|
| 177 |
Every stage can start from the released checkpoint of the previous one. Hyper-parameters, resuming and environment
|
| 178 |
switches: [docs/TRAINING.md](docs/TRAINING.md).
|
code/docs/TRAINING.md
CHANGED
|
@@ -27,7 +27,7 @@ and was then warm-started from its 2k EMA (`STUDENT_INIT`, `STEP0=2000`, `SEED=1
|
|
| 27 |
| 1. Bidirectional | 35k | 8 | 1e-5 (condition layers 1e-4) | unknown cells without coordinates, `p_unk2 0.5`, memory loss weight 3; world-edit clips (`WEDIT=1`) |
|
| 28 |
| 2. Causal teacher | 11k | 8 | 1e-5 (condition layers 1e-5) | history window 20 + sink 1; history self-augmentation `SA_P 0.5 / SA_MAX 0.25` on revisit clips; memory from before and after the window |
|
| 29 |
| 3. Consistency distillation | 10k | 8 | 2e-6, EMA 0.99 | N = 48 levels, 2 sampling steps (1000, 500), teacher CFG 3, `SA_P 0.7 / SA_MAX 0.5`; memory before and after the window |
|
| 30 |
-
| 4. DMD | 500 | 32 (8 × accum 4) | 2e-6 / critic 4e-7 | critic : student = 5 : 1, real score = the stage-1 model with CFG 3; memory from the past
|
| 31 |
|
| 32 |
Hyper-parameters not set in the scripts keep the defaults of each module's argument parser.
|
| 33 |
|
|
|
|
| 27 |
| 1. Bidirectional | 35k | 8 | 1e-5 (condition layers 1e-4) | unknown cells without coordinates, `p_unk2 0.5`, memory loss weight 3; world-edit clips (`WEDIT=1`) |
|
| 28 |
| 2. Causal teacher | 11k | 8 | 1e-5 (condition layers 1e-5) | history window 20 + sink 1; history self-augmentation `SA_P 0.5 / SA_MAX 0.25` on revisit clips; memory from before and after the window |
|
| 29 |
| 3. Consistency distillation | 10k | 8 | 2e-6, EMA 0.99 | N = 48 levels, 2 sampling steps (1000, 500), teacher CFG 3, `SA_P 0.7 / SA_MAX 0.5`; memory before and after the window |
|
| 30 |
+
| 4. DMD | 500 | 32 (8 × accum 4) | 2e-6 / critic 4e-7 | critic : student = 5 : 1, real score = the stage-1 model with CFG 3; memory from the past and the future as stages 2–3 (`wizard.distill.dmd_future`), no world-edit clips |
|
| 31 |
|
| 32 |
Hyper-parameters not set in the scripts keep the defaults of each module's argument parser.
|
| 33 |
|
code/scripts/train/4_dmd.sh
CHANGED
|
@@ -1,12 +1,12 @@
|
|
| 1 |
#!/bin/bash
|
| 2 |
# Stage 4: DMD of the 2-step student; real score and the fake score's start = the bidirectional teacher (CFG 3). Batch = 8 GPUs x accum 4 = 32,
|
| 3 |
-
# lr 2e-6 / critic 4e-7, 5 critic updates per student update, levels 1000,500. Memory candidates past
|
| 4 |
-
# heavier mixing of the entry / revisit groups
|
| 5 |
# bash scripts/train/4_dmd.sh <consistency ema_step10000> <bidirectional dit_step35000> <out dir> [max steps]
|
| 6 |
# Ours: 500 steps, saving every 100 (an EMA, student_last and fake_last each time). To continue a run:
|
| 7 |
# EXTRA="--fake <out>/fake_last.safetensors --step0 <N>" bash scripts/train/4_dmd.sh <out>/ema/ema_step<N>.safetensors ...
|
| 8 |
set -e; source "$(dirname "$0")/common.sh"
|
| 9 |
-
launch fsdp_dmd.yaml wizard.distill.
|
| 10 |
--levels 1000,500 --num_workers 4 \
|
| 11 |
--group_rep e1o:8,e2o:8,e1n:8,e2n:8,e1x:8,turn:16,roam:4,sfly:8,sfly_replay:12,lookback:8,lookback0:2,ww:2,er:2,ue:2,bk:2 --rep_mem 16 \
|
| 12 |
-
--rep_keys $D/roam_memory/rep_keys_both30.json --mem_index
|
|
|
|
| 1 |
#!/bin/bash
|
| 2 |
# Stage 4: DMD of the 2-step student; real score and the fake score's start = the bidirectional teacher (CFG 3). Batch = 8 GPUs x accum 4 = 32,
|
| 3 |
+
# lr 2e-6 / critic 4e-7, 5 critic updates per student update, levels 1000,500. Memory candidates past + future as the teacher and the
|
| 4 |
+
# consistency student (wizard.distill.dmd_future, mem_index_both.pt), no world-edit clips (no WEDIT), heavier mixing of the entry / revisit groups.
|
| 5 |
# bash scripts/train/4_dmd.sh <consistency ema_step10000> <bidirectional dit_step35000> <out dir> [max steps]
|
| 6 |
# Ours: 500 steps, saving every 100 (an EMA, student_last and fake_last each time). To continue a run:
|
| 7 |
# EXTRA="--fake <out>/fake_last.safetensors --step0 <N>" bash scripts/train/4_dmd.sh <out>/ema/ema_step<N>.safetensors ...
|
| 8 |
set -e; source "$(dirname "$0")/common.sh"
|
| 9 |
+
launch fsdp_dmd.yaml wizard.distill.dmd_future --data $D/windows --student $1 --real $2 --out $3 --accum 4 --max_steps ${4:-500} --save_every 100 --cfg 3 \
|
| 10 |
--levels 1000,500 --num_workers 4 \
|
| 11 |
--group_rep e1o:8,e2o:8,e1n:8,e2n:8,e1x:8,turn:16,roam:4,sfly:8,sfly_replay:12,lookback:8,lookback0:2,ww:2,er:2,ue:2,bk:2 --rep_mem 16 \
|
| 12 |
+
--rep_keys $D/roam_memory/rep_keys_both30.json --mem_index mem_index_both.pt --extra_rows $ROWS,$LOOKBACK_ROWS --p_trueunk 0 --p_unk2 0.5 $EXTRA
|
code/wizard/distill/consistency_selfaug_future.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
"""Stage 3 entry point of the released chain: `wizard.distill.consistency_selfaug` with PAST + FUTURE memory candidates, as the
|
| 2 |
causal teacher was trained (`wizard.train.causal_selfaug` with MEM_FUTURE=1): SceneFly forward windows keep memory picks >= 3 s before
|
| 3 |
-
the window or >= 3 s after its end. `wizard.distill.consistency` alone
|
| 4 |
= past only. Inference is unchanged (past memory only). Also a free-disk guard for the periodic EMA saves (CD_FREE_GB, default 15):
|
| 5 |
an intermediate save is skipped rather than crash, the last one waits for space.
|
| 6 |
arguments and environment exactly as wizard.distill.consistency_selfaug"""
|
|
|
|
| 1 |
"""Stage 3 entry point of the released chain: `wizard.distill.consistency_selfaug` with PAST + FUTURE memory candidates, as the
|
| 2 |
causal teacher was trained (`wizard.train.causal_selfaug` with MEM_FUTURE=1): SceneFly forward windows keep memory picks >= 3 s before
|
| 3 |
+
the window or >= 3 s after its end. `wizard.distill.consistency` alone and `wizard.distill.dmd` alone use `wizard.train.causal.ARData`
|
| 4 |
= past only. Inference is unchanged (past memory only). Also a free-disk guard for the periodic EMA saves (CD_FREE_GB, default 15):
|
| 5 |
an intermediate save is skipped rather than crash, the last one waits for space.
|
| 6 |
arguments and environment exactly as wizard.distill.consistency_selfaug"""
|
code/wizard/distill/dmd_future.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Stage 4 entry point of the released chain: `wizard.distill.dmd` unchanged, with PAST + FUTURE memory candidates as the causal
|
| 2 |
+
teacher and the consistency student were trained (`wizard.distill.consistency_selfaug_future`): SceneFly forward windows keep memory
|
| 3 |
+
picks >= 3 s before the window or >= 3 s after its end. Use with --mem_index mem_index_both.pt (roaming picks from both directions).
|
| 4 |
+
Inference is unchanged (past memory only).
|
| 5 |
+
arguments and environment exactly as wizard.distill.dmd"""
|
| 6 |
+
import os, json
|
| 7 |
+
import wizard.train.causal as A
|
| 8 |
+
class ARDataFuture(A.ClipDataset):
|
| 9 |
+
def __init__(self, root, rows, a):
|
| 10 |
+
A.ClipDataset.__init__(self, root, rows, a)
|
| 11 |
+
info = json.load(open(f"{A.SFLY}/index.json")) if os.path.exists(f"{A.SFLY}/index.json") else {}
|
| 12 |
+
sf = A.lt(f"{A.SFLY}/mem_index.pt") if os.path.exists(f"{A.SFLY}/mem_index.pt") else {}
|
| 13 |
+
n0 = n1 = 0
|
| 14 |
+
for name in sf:
|
| 15 |
+
if name not in info or name not in self.mem_index: continue
|
| 16 |
+
f0 = int(info[name]["f0"]); e = dict(self.mem_index[name])
|
| 17 |
+
ch = [[(f, g) for f, g in c if f <= f0 - A.GAP_F or f >= f0 + 121 + A.GAP_F] for c in e["chunks"]]
|
| 18 |
+
n0 += sum(len(c) for c in e["chunks"]); n1 += sum(len(c) for c in ch); e["chunks"] = ch; self.mem_index[name] = e
|
| 19 |
+
self.past_info = (n0, n1); print(f"MEM_FUTURE SceneFly picks kept (>= 3 s before or after the window): {n1} of {n0}", flush=True)
|
| 20 |
+
A.ARData = ARDataFuture
|
| 21 |
+
import wizard.distill.dmd as D
|
| 22 |
+
if __name__ == "__main__": D.main()
|
weights/README.md
CHANGED
|
@@ -5,9 +5,9 @@ DiT weights fine-tuned from [Wan2.2-TI2V-5B](https://huggingface.co/Wan-AI/Wan2.
|
|
| 5 |
| file | model | sampling |
|
| 6 |
|---|---|---|
|
| 7 |
| `bidirectional/dit_step35000.safetensors` | bidirectional model, 35K steps, trained with the world-edit clips in addition (the full model of the ablation table; starting point of the current distillation chain) | 30 steps, guidance 3 |
|
| 8 |
-
| `causal_teacher/dit_step11000.safetensors` | stage 1: causal adaptation of `bidirectional` by teacher forcing with history corruption, 11K steps. The teacher for consistency distillation (`scripts/
|
| 9 |
-
| `causal_cd/ema_step10000.safetensors` | stage 2
|
| 10 |
-
| `causal_dmd/ema_step480.safetensors` | causal few-step student (causal adaptation → consistency distillation → DMD, 480 DMD steps, EMA), from an earlier run of the chain | 2 steps, streaming, 20-latent history window + first-frame anchor |
|
| 11 |
| `ltx25_lora/lora_weights_step_10000.safetensors` | the same approach on another base model: a rank-32 LoRA for [LTX-2.5](https://huggingface.co/Lightricks/LTX-2.5) (22B), trained 10K steps on the mixed synthetic + real data with reference images, with the earlier proxy format (skeletons on coarse scene geometry, no tiers / memory); `training_config.yaml` is its training configuration. Subject to the LTX-2.5 licence | LTX-2.5 bidirectional sampling, 30 steps |
|
| 12 |
|
| 13 |
Each file holds 829 tensors: the Wan2.2 DiT blocks plus the added `cond_embedding` (proxy video) and `gbuf_embedding` (world-coordinate tokens) layers. Resolution 832×480, 121 frames at 30 fps per window.
|
|
|
|
| 5 |
| file | model | sampling |
|
| 6 |
|---|---|---|
|
| 7 |
| `bidirectional/dit_step35000.safetensors` | bidirectional model, 35K steps, trained with the world-edit clips in addition (the full model of the ablation table; starting point of the current distillation chain) | 30 steps, guidance 3 |
|
| 8 |
+
| `causal_teacher/dit_step11000.safetensors` | stage 1: causal adaptation of `bidirectional` by teacher forcing with history corruption, 11K steps. The teacher for consistency distillation (`scripts/train/3_consistency.sh`) | many-step, guidance 3, 20-latent history window + first-frame anchor |
|
| 9 |
+
| `causal_cd/ema_step10000.safetensors` | stage 2: consistency-distilled EMA student, 10K steps from `causal_teacher` (`scripts/train/3_consistency.sh`, memory candidates from the past and the future). The student of the final DMD run; use it as the student of `scripts/train/4_dmd.sh` | 2–4 steps, no guidance |
|
| 10 |
+
| `causal_dmd/ema_step480.safetensors` | causal few-step student (causal adaptation → consistency distillation → DMD, 480 DMD steps, EMA), from an earlier run of the chain; will be replaced by the DMD student of the `causal_cd` above | 2 steps, streaming, 20-latent history window + first-frame anchor |
|
| 11 |
| `ltx25_lora/lora_weights_step_10000.safetensors` | the same approach on another base model: a rank-32 LoRA for [LTX-2.5](https://huggingface.co/Lightricks/LTX-2.5) (22B), trained 10K steps on the mixed synthetic + real data with reference images, with the earlier proxy format (skeletons on coarse scene geometry, no tiers / memory); `training_config.yaml` is its training configuration. Subject to the LTX-2.5 licence | LTX-2.5 bidirectional sampling, 30 steps |
|
| 12 |
|
| 13 |
Each file holds 829 tensors: the Wan2.2 DiT blocks plus the added `cond_embedding` (proxy video) and `gbuf_embedding` (world-coordinate tokens) layers. Resolution 832×480, 121 frames at 30 fps per window.
|
weights/causal_cd/ema_step10000.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 10021692456
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ca25249a88418a8b25b17d509ea8922db8cfbb80836aa2f2b1895d4941238f9b
|
| 3 |
size 10021692456
|