File size: 6,834 Bytes
92c71e5
51ef915
 
44fc2d8
 
92c71e5
 
 
fbc8888
443b651
92c71e5
 
 
 
 
fbc8888
92c71e5
 
44fc2d8
08ed344
51ef915
 
 
 
 
 
 
92c71e5
51ef915
 
443b651
51ef915
 
 
 
 
44fc2d8
 
 
 
 
 
 
 
 
 
fbc8888
92c71e5
fbc8888
 
443b651
 
fbc8888
92c71e5
fbc8888
92c71e5
fbc8888
92c71e5
fbc8888
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92c71e5
 
 
443b651
fbc8888
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92c71e5
 
fbc8888
 
443b651
fbc8888
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51ef915
 
443b651
92c71e5
fbc8888
92c71e5
51ef915
 
 
 
 
 
 
 
 
 
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
129
130
131
132
133
134
135
136
137
138
---
license: other
license_name: research-only
language:
  - en
library_name: diffsynth
pipeline_tag: image-to-video
base_model: Wan-AI/Wan2.2-TI2V-5B
datasets:
  - YeyingLab/MaLiang-Data
tags:
  - world-model
  - game
  - video-generation
  - semantic-map
  - real-time
---

<div align="center">

# MaLiang: Painting Playable Game Worlds from Numbers

[Zhiyang Deng](https://teawhite.cn/)<sup>1,2,\*</sup>, [Shushan Xu](https://github.com/sylvana20)<sup>1,3,\*</sup>, [Yeying Jin](https://github.com/jinyeying)<sup>1,2,β™’</sup>

<sup>1</sup>Tencent, <sup>2</sup>National University of Singapore, <sup>3</sup>Nanyang Technological University

<sup>\*</sup>Equal contribution Β· <sup>β™’</sup>Corresponding author and project leader

[![Project Page](https://img.shields.io/badge/Project-Page-4b8bbe)](https://sylvana20.github.io/maliang/)
[![Code](https://img.shields.io/badge/GitHub-Code-black?logo=github)](https://github.com/YeyingLab/MaLiang)
[![Data](https://img.shields.io/badge/%F0%9F%A4%97-Data-ffcc4d)](https://huggingface.co/datasets/YeyingLab/MaLiang-Data)
[![License](https://img.shields.io/badge/weights-research%20only-lightgrey)](#licence)

<img src="assets/teaser.jpg" alt="MaLiang teaser" width="95%">

**A game hands a video model one integer per pixel, and the model paints the world, live.**

</div>

## Highlights

- **Numerical proxy** β€” the game rasterises its state (terrain, buildings, vegetation, the player's and the boss's body parts, attack effects) into one `uint8` class id per pixel. No render pass and no visual encoder.
- **Native numerical conditioning** β€” a 9.4M-parameter class-pooling encoder turns each 4Γ—4 block into class shares that are added to the patch embedding of Wan2.2-TI2V-5B.
- **Real time** β€” a three-stage distillation (teacher forcing β†’ consistency distillation β†’ DMD) gives a causal four-step student that streams at 22 frames per second on one GPU.
- **Numerical canvas** β€” anything a game rule writes into the map is painted in the next step, and one map can be replayed from any first frame to give a new world.

## What is here

| Repository | Content | Size |
|---|---|---:|
| [`YeyingLab/MaLiang`](https://huggingface.co/YeyingLab/MaLiang) (this repo) | the five checkpoints of the paper and `models.sha256` | 5 Γ— 10 GB |
| [`YeyingLab/MaLiang-Data`](https://huggingface.co/datasets/YeyingLab/MaLiang-Data) | the raw game recordings the model is trained on: RGB, integer class map, whitebox, condition image, actions and per-frame metadata; 256 runs, 1,228,800 frames, 21.3 h | 482 GB |
| [`YeyingLab/MaLiang`](https://github.com/YeyingLab/MaLiang) | training, distillation, inference and evaluation code | |

## Checkpoints

All checkpoints are bf16 safetensors, `vocab=parts_fx`, 832Γ—480.

| File | Role | Used by |
|---|---|---|
| `fxcond_v1_stage3_ema_step500.safetensors` | **Deployed causal student**, 4 steps (stage-3 DMD, EMA, step 500); the real-time model of the paper | `gcdistill/eval_rollout.py`, `sample_user.py` |
| `sft_fxcond_v1_step-10667.safetensors` | Bidirectional teacher, 10,667 SFT steps; the starting point and the DMD teacher of the distillation | `sample.py`, distillation stages 1 and 3 |
| `abl_color_vae_step-5000.safetensors` | Interface ablation β‘ : colour-coded video encoded by the Wan VAE | `experiments/abl/` |
| `abl_color_light_step-5000.safetensors` | Interface ablation β‘‘: colour-coded video through a light encoder of the same cost as ours | `experiments/abl/` |
| `abl_v3_ids_step-5000.safetensors` | Interface ablation β‘’/β‘£: integer map, step-5000 snapshot of the teacher run (same budget as β‘  and β‘‘) | `experiments/abl/` |

### Integer map vocabulary (`parts_fx`)

Seven static scene classes (sky/background, terrain, paving, architecture, rock, vegetation, prop), the body
parts of the player and of the boss, four boss attack-effect classes (light and heavy attacks of two bosses), and
`255` for unknown. The exact table is in the code (`code/gc25d/model.py`).

## Quick start

```bash
pip install -U huggingface_hub
hf download YeyingLab/MaLiang --local-dir models
cd models && sha256sum -c models.sha256 && cd ..
```

Install the code as described in the [GitHub README](https://github.com/YeyingLab/MaLiang#installation), download
`Wan-AI/Wan2.2-TI2V-5B` into `models/Wan2.2-TI2V-5B`, then render your own first frame and integer maps with the
real-time student:

```bash
python code/gc25d/sample_user.py \
  --ckpt models/fxcond_v1_stage3_ema_step500.safetensors \
  --first_frame first.png --ids ids.npz --prompts prompts.json \
  --out outputs/user_demo --name demo --steps 50
```

`ids.npz` holds a `uint8` array of shape `[81, 480, 832]` in the `parts_fx` vocabulary; `--export_clip <clip_id>`
exports a prepared clip's first frame, maps and prompts as a template. A long streaming rollout on held-out clips:

```bash
python code/gc25d/gcdistill/eval_rollout.py \
  --ckpt models/fxcond_v1_stage3_ema_step500.safetensors \
  --data_root data/gc25d_v10_fxcond --text_table assets/text_table_gc25d.pt \
  --n_clips 10 --chain_cells 241 --vae tae --out outputs/deploy_eval
```

## Reproducing the model

1. **Data**: download [`YeyingLab/MaLiang-Data`](https://huggingface.co/datasets/YeyingLab/MaLiang-Data) to
   `data/recordings`, then build the training cache with `code/gc25d/prep_v10.py` (VAE latents, integer maps and
   metadata per 81-frame clip; see the code README β†’ *Data*).
2. **Base model**: `Wan-AI/Wan2.2-TI2V-5B`.
3. **Teacher**: `scripts/train_sft.sh`, 10,667 steps, global batch 16, `lr=1e-5`, `cond_lr=1e-4`
   β†’ `sft_fxcond_v1_step-10667`.
4. **Distillation**: `gcdistill/run_stage{1,2,3}.sh`: teacher forcing 8,000 steps β†’ consistency distillation
   8,000 steps β†’ DMD 500 steps β†’ `fxcond_v1_stage3_ema_step500`.
5. **Evaluation**: the 100-clip test manifest and the metric scripts are in `experiments/`.

## Hardware

The teacher is trained with DeepSpeed ZeRO-2 on 8 GPUs; distillation stage 3 uses FSDP. Inference runs on one
GPU with room for the 5B DiT in bf16. With the TAEHV decoder and a 17-cell KV window the four-step student streams
in real time on one GPU.

## Licence

The checkpoints are released for **research use only**. The code in [YeyingLab/MaLiang](https://github.com/YeyingLab/MaLiang) is Apache-2.0.
The base model Wan2.2-TI2V-5B and the third-party components used by the code keep their own licences. The training data is also for
research use only; see [`YeyingLab/MaLiang-Data`](https://huggingface.co/datasets/YeyingLab/MaLiang-Data).

## Citation

```bibtex
@misc{maliang2026,
  title  = {MaLiang: Painting Playable Game Worlds from Numbers},
  author = {Deng, Zhiyang and Xu, Shushan and Jin, Yeying},
  year   = {2026},
  url    = {https://github.com/YeyingLab/MaLiang}
}
```

The arXiv entry will be added once the paper is public.