code: DMD with world-edit clips, --ema_init resume
Browse files- code/docs/DATA.md +1 -1
- code/docs/TRAINING.md +4 -4
- code/scripts/train/4_dmd.sh +8 -6
- code/wizard/distill/dmd.py +4 -3
code/docs/DATA.md
CHANGED
|
@@ -26,7 +26,7 @@ Each row belongs to a **group**, used for the mixing weights (`--group_rep group
|
|
| 26 |
| `roam` | roaming recordings |
|
| 27 |
| `sfly`, `sfly_replay`, `lookback`, `lookback0` | revisits: the camera comes back to a place it has seen |
|
| 28 |
| `ww`, `er`, `ue`, `bk` | duels |
|
| 29 |
-
| `wedit` | world edits (stages 1, 2 and
|
| 30 |
|
| 31 |
The pre-encoded data is released in [`yuzhewu207/wizard-precoded`](https://huggingface.co/datasets/yuzhewu207/wizard-precoded) (the exact files the models were trained on, minus the WildWorld windows; see the WildWorld note in the README): group `ww` has no rows). Restore it with
|
| 32 |
|
|
|
|
| 26 |
| `roam` | roaming recordings |
|
| 27 |
| `sfly`, `sfly_replay`, `lookback`, `lookback0` | revisits: the camera comes back to a place it has seen |
|
| 28 |
| `ww`, `er`, `ue`, `bk` | duels |
|
| 29 |
+
| `wedit` | world edits (stages 1, 2, 3 and 4) |
|
| 30 |
|
| 31 |
The pre-encoded data is released in [`yuzhewu207/wizard-precoded`](https://huggingface.co/datasets/yuzhewu207/wizard-precoded) (the exact files the models were trained on, minus the WildWorld windows; see the WildWorld note in the README): group `ww` has no rows). Restore it with
|
| 32 |
|
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 and the future as stages 2–3 (`wizard.distill.dmd_future`),
|
| 31 |
|
| 32 |
Hyper-parameters not set in the scripts keep the defaults of each module's argument parser.
|
| 33 |
|
|
@@ -36,8 +36,8 @@ never learns that memory should override a drifting history. With probability `S
|
|
| 36 |
one-step estimate from a noised copy (`σ ~ U(0, SA_MAX)`); frame 0, the memory frames and the target stay clean. In
|
| 37 |
stage 3 the teacher keeps the clean history and only the student / EMA read the augmented one.
|
| 38 |
|
| 39 |
-
**Resuming DMD.** Every save also writes `student_last.safetensors` and `fake_last.safetensors`:
|
| 40 |
-
`EXTRA="--fake runs/dmd/fake_last.safetensors --step0 <N>" bash scripts/train/4_dmd.sh runs/dmd/
|
| 41 |
|
| 42 |
## Training-time switches (environment)
|
| 43 |
|
|
@@ -45,7 +45,7 @@ stage 3 the teacher keeps the clean history and only the student / EMA read the
|
|
| 45 |
|---|---|---|
|
| 46 |
| `UNK_NOCOORD=1` | all | unknown cells carry no world coordinates |
|
| 47 |
| `MEMW_COVER=1` | all | cells the window's first frame has not seen but a retrieved memory frame has get loss weight `--mem_loss_w`; "seen" by projected coverage |
|
| 48 |
-
| `WEDIT=1` | 1, 2, 3 | add the world-edit clips' memory index and banks (`worldedit/`); their rows come with `--extra_rows worldedit/rows_train.jsonl` |
|
| 49 |
| `MEMW_HISTW`, `MEMW_SINK` | 2 | "seen" also by every clean history frame the noisy frame reads (window + sink), so the weight sits where only memory can tell |
|
| 50 |
| `MEM_FUTURE=1` | 2 | SceneFly windows may also retrieve frames after the window (stage 3 does the same through `wizard.distill.consistency_selfaug_future`) |
|
| 51 |
| `SA_P`, `SA_MAX`, `SA_GROUPS` | 2, 3 | history self-augmentation |
|
|
|
|
| 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`), world-edit clips (`WEDIT=1`, `wedit:16`) |
|
| 31 |
|
| 32 |
Hyper-parameters not set in the scripts keep the defaults of each module's argument parser.
|
| 33 |
|
|
|
|
| 36 |
one-step estimate from a noised copy (`σ ~ U(0, SA_MAX)`); frame 0, the memory frames and the target stay clean. In
|
| 37 |
stage 3 the teacher keeps the clean history and only the student / EMA read the augmented one.
|
| 38 |
|
| 39 |
+
**Resuming DMD.** Every save also writes `student_last.safetensors` and `fake_last.safetensors`; resume the student, the EMA and the critic:
|
| 40 |
+
`EXTRA="--ema_init runs/dmd/ema/ema_step<N>.safetensors --fake runs/dmd/fake_last.safetensors --step0 <N>" bash scripts/train/4_dmd.sh runs/dmd/student_last.safetensors ...`
|
| 41 |
|
| 42 |
## Training-time switches (environment)
|
| 43 |
|
|
|
|
| 45 |
|---|---|---|
|
| 46 |
| `UNK_NOCOORD=1` | all | unknown cells carry no world coordinates |
|
| 47 |
| `MEMW_COVER=1` | all | cells the window's first frame has not seen but a retrieved memory frame has get loss weight `--mem_loss_w`; "seen" by projected coverage |
|
| 48 |
+
| `WEDIT=1` | 1, 2, 3, 4 | add the world-edit clips' memory index and banks (`worldedit/`); their rows come with `--extra_rows worldedit/rows_train.jsonl` |
|
| 49 |
| `MEMW_HISTW`, `MEMW_SINK` | 2 | "seen" also by every clean history frame the noisy frame reads (window + sink), so the weight sits where only memory can tell |
|
| 50 |
| `MEM_FUTURE=1` | 2 | SceneFly windows may also retrieve frames after the window (stage 3 does the same through `wizard.distill.consistency_selfaug_future`) |
|
| 51 |
| `SA_P`, `SA_MAX`, `SA_GROUPS` | 2, 3 | history self-augmentation |
|
code/scripts/train/4_dmd.sh
CHANGED
|
@@ -1,12 +1,14 @@
|
|
| 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),
|
|
|
|
| 5 |
# bash scripts/train/4_dmd.sh <consistency ema_step10000> <bidirectional dit_step35000> <out dir> [max steps]
|
| 6 |
-
# Ours: 500 steps, saving every
|
| 7 |
-
# EXTRA="--
|
|
|
|
| 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
|
| 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
|
|
|
|
| 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), the world-edit clips (WEDIT=1, repeated 16x), heavier mixing of the entry /
|
| 5 |
+
# revisit groups. (Our released run had no world-edit clips for its first 200 steps; they joined from step 201 with this mix.)
|
| 6 |
# bash scripts/train/4_dmd.sh <consistency ema_step10000> <bidirectional dit_step35000> <out dir> [max steps]
|
| 7 |
+
# Ours: 500 steps, saving every 50 (an EMA, student_last and fake_last each time). To continue a run from its save at step N:
|
| 8 |
+
# EXTRA="--ema_init <out>/ema/ema_step<N>.safetensors --fake <out>/fake_last.safetensors --step0 <N>" \
|
| 9 |
+
# bash scripts/train/4_dmd.sh <out>/student_last.safetensors ...
|
| 10 |
set -e; source "$(dirname "$0")/common.sh"
|
| 11 |
+
WEDIT=1 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 50 --cfg 3 \
|
| 12 |
--levels 1000,500 --num_workers 4 \
|
| 13 |
+
--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,wedit:16 --rep_mem 16 \
|
| 14 |
+
--rep_keys $D/roam_memory/rep_keys_both30.json --mem_index mem_index_both.pt --extra_rows $ROWS,$LOOKBACK_ROWS,$WEDIT_ROWS --p_trueunk 0 --p_unk2 0.5 $EXTRA
|
code/wizard/distill/dmd.py
CHANGED
|
@@ -6,7 +6,8 @@ memory, real score with CFG. Critic : student updates = 5 : 1, gradient accumula
|
|
| 6 |
|
| 7 |
accelerate launch --config_file configs/accelerate/fsdp_dmd.yaml --num_processes 8 -m wizard.distill.dmd \
|
| 8 |
--data $WIZARD_DATA/windows --student <cd ema> --real <bidirectional dit> --out runs/dmd --accum 4 --cfg 3
|
| 9 |
-
resume: --student <dmd
|
|
|
|
| 10 |
import os, sys, glob, json, time, argparse, random, collections
|
| 11 |
import torch
|
| 12 |
import torch.nn.functional as F
|
|
@@ -131,7 +132,7 @@ def main():
|
|
| 131 |
ap.add_argument("--out", required=True); ap.add_argument("--levels", default="1000,500", help="the student's sampling levels, e.g. 1000,500")
|
| 132 |
ap.add_argument("--cfg", type=float, default=3.0, help="guidance of the real score (the bidirectional model is sampled at 3)")
|
| 133 |
ap.add_argument("--lr", type=float, default=2e-6); ap.add_argument("--lr_critic", type=float, default=4e-7); ap.add_argument("--critic_steps", type=int, default=5, help="critic updates per student update")
|
| 134 |
-
ap.add_argument("--max_steps", type=int, default=400, help="STUDENT updates"); ap.add_argument("--step0", type=int, default=0, help="step count to continue from"); ap.add_argument("--fake", default="", help="fake score init, default = --real"); ap.add_argument("--warmup", type=int, default=20)
|
| 135 |
ap.add_argument("--ema_decay", type=float, default=0.99); ap.add_argument("--ema_start", type=int, default=20)
|
| 136 |
ap.add_argument("--windowed_train", type=int, default=20); ap.add_argument("--windowed_sink", type=int, default=1)
|
| 137 |
ap.add_argument("--save_every", type=int, default=25); ap.add_argument("--log_every", type=int, default=1); ap.add_argument("--num_workers", type=int, default=4)
|
|
@@ -145,7 +146,7 @@ def main():
|
|
| 145 |
accel = Accelerator(step_scheduler_with_optimizer=False); set_seed(a.seed, device_specific=True); random.seed(a.seed + accel.process_index); main_ = accel.is_main_process; os.makedirs(a.out, exist_ok=True)
|
| 146 |
log = (lambda *x: (print(*x, flush=True), open(os.path.join(a.out, "train.log"), "a").write(" ".join(map(str, x)) + "\n"))) if main_ else (lambda *x: None)
|
| 147 |
levels = [float(v) for v in a.levels.split(",")]
|
| 148 |
-
student = A.build_model(a); load(student, a.student); ema = A.build_model(a); load(ema, a.student) # causal + proxy + world tokens, window / sink
|
| 149 |
real = WizardDiT(**ti2v_5b_config(), causal=False, zero_init_head=False); attach_cond(real); attach_world(real); load(real, a.real)
|
| 150 |
fake = WizardDiT(**ti2v_5b_config(), causal=False, zero_init_head=False); attach_cond(fake); attach_world(fake); load(fake, a.fake or a.real)
|
| 151 |
real_core, fake_core = real, fake # _gb_in lives on the bare modules
|
|
|
|
| 6 |
|
| 7 |
accelerate launch --config_file configs/accelerate/fsdp_dmd.yaml --num_processes 8 -m wizard.distill.dmd \
|
| 8 |
--data $WIZARD_DATA/windows --student <cd ema> --real <bidirectional dit> --out runs/dmd --accum 4 --cfg 3
|
| 9 |
+
resume: --student <runs/dmd/student_last.safetensors> --ema_init <runs/dmd/ema/ema_step<N>.safetensors> \
|
| 10 |
+
--fake <runs/dmd/fake_last.safetensors> --step0 <N>"""
|
| 11 |
import os, sys, glob, json, time, argparse, random, collections
|
| 12 |
import torch
|
| 13 |
import torch.nn.functional as F
|
|
|
|
| 132 |
ap.add_argument("--out", required=True); ap.add_argument("--levels", default="1000,500", help="the student's sampling levels, e.g. 1000,500")
|
| 133 |
ap.add_argument("--cfg", type=float, default=3.0, help="guidance of the real score (the bidirectional model is sampled at 3)")
|
| 134 |
ap.add_argument("--lr", type=float, default=2e-6); ap.add_argument("--lr_critic", type=float, default=4e-7); ap.add_argument("--critic_steps", type=int, default=5, help="critic updates per student update")
|
| 135 |
+
ap.add_argument("--max_steps", type=int, default=400, help="STUDENT updates"); ap.add_argument("--step0", type=int, default=0, help="step count to continue from"); ap.add_argument("--fake", default="", help="fake score init, default = --real"); ap.add_argument("--ema_init", default="", help="EMA init when resuming, default = --student"); ap.add_argument("--warmup", type=int, default=20)
|
| 136 |
ap.add_argument("--ema_decay", type=float, default=0.99); ap.add_argument("--ema_start", type=int, default=20)
|
| 137 |
ap.add_argument("--windowed_train", type=int, default=20); ap.add_argument("--windowed_sink", type=int, default=1)
|
| 138 |
ap.add_argument("--save_every", type=int, default=25); ap.add_argument("--log_every", type=int, default=1); ap.add_argument("--num_workers", type=int, default=4)
|
|
|
|
| 146 |
accel = Accelerator(step_scheduler_with_optimizer=False); set_seed(a.seed, device_specific=True); random.seed(a.seed + accel.process_index); main_ = accel.is_main_process; os.makedirs(a.out, exist_ok=True)
|
| 147 |
log = (lambda *x: (print(*x, flush=True), open(os.path.join(a.out, "train.log"), "a").write(" ".join(map(str, x)) + "\n"))) if main_ else (lambda *x: None)
|
| 148 |
levels = [float(v) for v in a.levels.split(",")]
|
| 149 |
+
student = A.build_model(a); load(student, a.student); ema = A.build_model(a); load(ema, a.ema_init or a.student) # causal + proxy + world tokens, window / sink
|
| 150 |
real = WizardDiT(**ti2v_5b_config(), causal=False, zero_init_head=False); attach_cond(real); attach_world(real); load(real, a.real)
|
| 151 |
fake = WizardDiT(**ti2v_5b_config(), causal=False, zero_init_head=False); attach_cond(fake); attach_world(fake); load(fake, a.fake or a.real)
|
| 152 |
real_core, fake_core = real, fake # _gb_in lives on the bare modules
|