Eden 5B matrix-shooter 1-step student: graybox only, geometry into every block
A causal, 1-step video model that restyles matrix-shooter graybox (low-poly) renders into the game's looks,
one latent frame (4 video frames) at a time, for real-time streaming. Maps paris / tsinghua, looks
cartoon / war / punk / sakura, 960x544, 24 fps.
- Base: Eden 5B DiT (Wan 2.2 TI2V-5B architecture), distilled from a bidirectional 40-step graybox teacher with DMD plus a DMD2/One-Forcing-style adversarial term (weight 0.03), EMA 0.99.
- Input is the graybox only (plus one styled first frame, see below). The proxy-DINO features the Eden models normally take are not used (fed as zeros; the student was trained that way).
- The graybox latent is injected twice: concatenated at the patch embedding, and through
GeomInjectadded to the output of every transformer block (h = h + proj_i(enc(graybox)), zero-initialised residual, as in state2view's dense student). This is what keeps small, overlapping far characters apart.
Files
| path | what |
|---|---|
student/transformer/ | Diffusers WanTransformer3DModel, bf16, LoRA (rank 128) merged; patch embedding 1120 inputs = 48 latent + 1024 DINO (zeros) + 48 graybox latent |
student/geom.safetensors | GeomInject: per token the graybox latent's 2x2 patch (192) -> Linear+SiLU (512) -> per block Linear(512 -> 3072), 30 blocks |
student/text_embeds.safetensors | UMT5 embeddings [512, 4096] of the 8 (map, look) prompts, keys paris/cartoon ... (no text encoder needed) |
prompts.json | the prompts behind those embeddings |
code/sftrain/ | model / sampler code; entry point sftrain/infer_student.py |
taehv/ | TAEHV taew2_2 (MIT, madebyollin/taehv): the graybox encoder |
Not in this repo (same as the Eden teacher release): the Wan 2.2 VAE (EdenLive/vae-5b/Wan2.2_VAE.pth) and the
Eden flashdreams package that wraps it (EDEN_CODE).
Quick start
pip install torch diffusers==0.41.0 safetensors transformers accelerate opencv-python-headless pillow av loguru einops
pip install --no-deps -e /path/to/eden-code/realtime/flashdreams
export EDEN_MODEL_ROOT=/path/to/EdenLive # only vae-5b/ is read
export EDEN_CODE=/path/to/eden-code/realtime
export TAEHV_DIR=/path/to/this/repo/taehv
cd code
python -m sftrain.infer_student --model ../student --graybox graybox.mp4 --reference styled_first_frame.png \
--map paris --look cartoon --out out.mp4 [--frames 81] [--start 0] [--side-by-side] [--decoder wan|taew2_2]
--graybox is any length (rounded down to 4k+1 frames); the whole clip runs as one causal stream.
--decoder taew2_2 decodes with TAEHV (~2 ms per latent, little memory, ~3 dB lower PSNR than the Wan VAE): use it
for real time or when the GPU is shared. Set PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True on 24-32 GB cards.
What you provide, and how the features are assembled
You provide: the graybox video (960x544 or anything that center-crops to 16:9-ish; 24 fps), one styled first
frame of the same view, and the (map, look) name. Per latent frame L (video frames 4L-3 .. 4L, frame 0 alone):
graybox frames ──TAEHV taew2_2 encoder (causal, ~1.4 ms / 4 frames)──> graybox latent g [48, T, 34, 60]
styled first frame ──Wan 2.2 VAE encoder──> reference latent r [48, 1, 34, 60] (latent frame 0, kept clean)
(map, look) ──lookup──> text embedding [512, 4096]
control = concat( zeros[1024], g ) [1072, T, 34, 60]
input = concat( x_noisy[48], control ) [1120, T, 34, 60]
└─ patch embedding (1x2x2 conv) ─> 17x30 = 510 tokens per latent frame, width 3072
GeomInject: g ─(2x2 patch, 192)─> Linear+SiLU (512) ─> Linear_i (3072), added after transformer block i (i = 0..29)
30 blocks: self-attention over this frame + K/V arena (6 sink frames + 12 most recent), cross-attention to text
one step from pure noise (sigma 1, shift 5) ─> clean latent for frame L ─> its K/V re-computed at t=0 into the arena
latents ──Wan 2.2 VAE decoder (streaming)──> 4 RGB frames per latent
In code (sftrain/infer_student.py): encode_gray_long -> torch.cat([zeros, gray]) -> load_student
(Diffusers model + GeomInject attached as model.geom) -> dit.rollout(model, rope, ref_latent, control, ctx, sampling_sigmas(1, 5.0), chunk=1) -> conditions.decode. For a live stream, call the same per-frame step that
dit.rollout loops over, feeding one new graybox latent at a time.
The styled first frame is required: it is latent 0 and anchors the look (colours, character skins). Use a frame
rendered by the game in the target look, or one generated by the bidirectional graybox teacher.
It should show the same view as graybox frame --start.
Measured
RTX PRO 6000 (Blackwell), plain PyTorch bf16, this script:
| 81 frames (21 latents) | 2 min, 2877 frames (720 latents) | |
|---|---|---|
| conditions (TAEHV + VAE encode + load) | 15 s | 54 s |
| student, per latent (4 frames) | 108 ms | 151 ms |
RTX 5090 32 GB (with ~16 GB taken by another process): student 135 ms per latent (81 frames), conditions 6 s; Wan VAE and TAEHV decoding both fit.
Held-out quality (16 windows of 81 frames, 2 maps x 4 looks, vs game frames): PSNR 19.79, LPIPS 0.330, character sharpness ratio 0.81 (the bidirectional 40-step teacher: 22.51 / 0.188 / 0.81). 2-minute held-out PSNR per clip: paris cartoon 18.2, war 22.2, punk 18.6; tsinghua cartoon 19.0, war 23.4, sakura 17.5 (250-update checkpoint of the same run).
Known limits
- Far characters that walk in mid-clip keep their shape and stay separate, but their clothing colours can be wrong (the graybox carries no colour for them).
- Fine texture is softer than the teacher's.
- Trained on matrix-shooter
paris/tsinghuaonly.