-Wizard is a real-time playable world model built on [Wan2.2-TI2V-5B](https://huggingface.co/Wan-AI/Wan2.2-TI2V-5B). A lightweight engine keeps the world state and renders a *proxy video* (character skeletons + scene geometry); the video model in this repository turns the proxy, a first frame, a text prompt, up to two character reference images and a few retrieved memory frames into the picture.
+# Wizard: Manipulate Any World in Real Time via Agentic Control
-This directory holds the model, the four training stages and offline inference. The code lives on GitHub at [wyzardWu/wizard](https://github.com/wyzardWu/wizard) (`code/`) and is mirrored in the `code/` folder of [`yuzhewu207/wizard`](https://huggingface.co/datasets/yuzhewu207/wizard), which also holds the raw data, the weights (`weights/`) and ready-made inference cases (`examples/`). The pre-encoded training data is in [`yuzhewu207/wizard-precoded`](https://huggingface.co/datasets/yuzhewu207/wizard-precoded).
+**Training and inference code for the Wizard video generator**
-## Method in one page
+[](https://arxiv.org/abs/2610.40339)
+[](https://wyzardwu.github.io/wizard/)
+[](https://huggingface.co/datasets/yuzhewu207/wizard)
+[](https://huggingface.co/datasets/yuzhewu207/wizard-precoded)
+
+
-| component | what it does | where |
-|---|---|---|
-| Proxy video | R = height, B = depth, G = geometry tier (sky / unknown / coarse / exact) for the scene and identity + facing for characters; injected by channel concatenation through a zero-initialised patch embedding | `wizard/models/proxy.py` |
-| Character-aware mask | each reference image is visible only to the video tokens inside its character's region, so two characters with the same skeleton stay distinct | `wizard/models/reference.py` |
-| World-anchored spatial condition | every background cell of the proxy and of the memory frames carries a world-coordinate token; unknown cells, sky and characters carry none | `wizard/models/wizard_dit.py`, `wizard/memory/gbuffer.py` |
-| Memory retrieval | per chunk of 4 latent frames, up to three earlier frames chosen greedily by how much of the currently visible scene each newly covers; one function for training and inference | `wizard/memory/retrieve.py` |
+

-Training runs in four stages; from stage 1 on the model reads a sliding history of 20 latent frames plus the first frame as a permanent anchor (sink).
+
-| stage | entry point | script | released run |
-|---|---|---|---|
-| 0. bidirectional | `wizard.train.bidirectional` | `scripts/train_bidirectional.sh` | 35K steps |
-| 1. causal adaptation (teacher forcing, history corruption) | `wizard.train.causal_selfaug` | `scripts/train_causal.sh` | 11K steps |
-| 2. consistency distillation | `wizard.distill.consistency_selfaug_future` | `scripts/distill_consistency.sh` | 10K steps |
-| 3. distribution matching distillation (DMD) | `wizard.distill.dmd` | `scripts/distill_dmd.sh` | 480 student updates |
+Wizard turns any scene image and any character references into a playable, real-time game world. An agent keeps the
+game state (scene geometry, character skeletons, combat logic) and renders it into a **visual proxy**; a video model
+built on [Wan2.2-TI2V-5B](https://github.com/Wan-Video/Wan2.2) turns the proxy into game frames, streaming at
+**24 FPS with 2 denoising steps**.
-The deployed model is the EMA student of stage 3, sampled in 2 steps with a KV cache (`wizard/streaming/kv_stream.py`).
+This repository contains the **video generator**: the four-stage training pipeline (bidirectional teacher → causal
+teacher → consistency distillation → DMD) and the three inference modes, including online world maintenance.
-## Layout
+## Highlights
-```text
-wizard/
- paths.py data root and base-model directory (environment variables)
- models/
- dit.py Wan2.2-TI2V-5B DiT (bidirectional and causal)
- flow_match.py flow-matching scheduler
- proxy.py proxy-video injection
- reference.py reference images with the character-aware mask
- wizard_dit.py the Wizard forward: references + memory frames + coordinate tokens
- wan/ Wan2.2 VAE and UMT5 encoder (unchanged upstream files)
- memory/ retrieval and per-cell scene geometry
- data/ depth completion behind characters, video reading
- train/ bidirectional.py, causal.py, causal_selfaug.py (base.py: classes they extend)
- distill/ consistency*.py, dmd.py, cd_utils.py
- streaming/ KV-cache streaming of the causal model
- inference/ bidirectional.py, causal.py
- utils/ attention diagnostic
-scripts/ one launch script per stage, with the released settings
-configs/ accelerate (FSDP) configurations
-```
+- **Proxy-driven control.** Scene geometry and articulated skeletons are rendered into one condition video and
+ concatenated with the video latents on the channels: precise camera and motion control, zero-shot to new scenes,
+ characters and motions.
+- **Identity binding.** Each reference image is visible only inside its character's skeleton box.
+- **Geometry you can trust.** The proxy marks every pixel as *exact*, *coarse* or *unknown*; the model follows exact
+ geometry and invents unknown regions.
+- **Spatial memory.** World-coordinate tokens and retrieved memory frames let the model redraw a place it has seen
+ when the camera comes back.
+- **Real time.** A causal 2-step student with a KV cache (20-frame window + attention sink), distilled with history
+ self-augmentation and DMD; the world is maintained online on a second GPU without blocking generation.
+
+## What is new compared with the paper
+
+| | Paper (arXiv v1) | This release |
+|---|---|---|
+| Visual proxy | height / depth, G = 0 | + per-pixel tier (sky / unknown / coarse / exact) with normal shading, outlined skeletons, weapons, shields |
+| World tokens | – | world coordinates + tier, added to every video and memory token |
+| Memory | – | per-chunk retrieved memory frames, all characters hidden |
+| Causal training | teacher forcing → CD → DMD | + history self-augmentation; memory and world tokens in every stage |
+| Beyond the first view | invented terrain | marked *unknown*, then filled online from the generated frames |
+
+