Amshaker commited on
Commit
e46af48
·
verified ·
1 Parent(s): 37aa897

Upload all Matrix-Game evaluation results

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. results/worldmem-baseline-evals/matrix-game2/diagnostic_full_original_job85088_task1/case0_full_original.json +81 -0
  2. results/worldmem-baseline-evals/matrix-game2/diagnostic_full_original_job85088_task1/case1_full_original.json +81 -0
  3. results/worldmem-baseline-evals/matrix-game2/diagnostic_full_original_job85088_task1/complete.json +1 -0
  4. results/worldmem-baseline-evals/matrix-game2/diagnostic_full_original_job85088_task1/launcher.sh +35 -0
  5. results/worldmem-baseline-evals/matrix-game2/diagnostic_full_original_job85088_task1/manifest.json +59 -0
  6. results/worldmem-baseline-evals/matrix-game2/diagnostic_full_original_job85088_task1/node.json +7 -0
  7. results/worldmem-baseline-evals/matrix-game2/diagnostic_full_original_job85088_task1/probe.py +113 -0
  8. results/worldmem-baseline-evals/matrix-game2/diagnostic_full_weighted_job85088_task2/case0_full_weighted.json +81 -0
  9. results/worldmem-baseline-evals/matrix-game2/diagnostic_full_weighted_job85088_task2/case1_full_weighted.json +81 -0
  10. results/worldmem-baseline-evals/matrix-game2/diagnostic_full_weighted_job85088_task2/complete.json +1 -0
  11. results/worldmem-baseline-evals/matrix-game2/diagnostic_full_weighted_job85088_task2/launcher.sh +35 -0
  12. results/worldmem-baseline-evals/matrix-game2/diagnostic_full_weighted_job85088_task2/manifest.json +59 -0
  13. results/worldmem-baseline-evals/matrix-game2/diagnostic_full_weighted_job85088_task2/node.json +7 -0
  14. results/worldmem-baseline-evals/matrix-game2/diagnostic_full_weighted_job85088_task2/probe.py +113 -0
  15. results/worldmem-baseline-evals/matrix-game2/diagnostic_i2v_original_job85088_task3/case0_i2v_original.json +81 -0
  16. results/worldmem-baseline-evals/matrix-game2/diagnostic_i2v_original_job85088_task3/case1_i2v_original.json +81 -0
  17. results/worldmem-baseline-evals/matrix-game2/diagnostic_i2v_original_job85088_task3/complete.json +1 -0
  18. results/worldmem-baseline-evals/matrix-game2/diagnostic_i2v_original_job85088_task3/launcher.sh +35 -0
  19. results/worldmem-baseline-evals/matrix-game2/diagnostic_i2v_original_job85088_task3/manifest.json +59 -0
  20. results/worldmem-baseline-evals/matrix-game2/diagnostic_i2v_original_job85088_task3/node.json +7 -0
  21. results/worldmem-baseline-evals/matrix-game2/diagnostic_i2v_original_job85088_task3/probe.py +113 -0
  22. results/worldmem-baseline-evals/matrix-game2/diagnostic_i2v_weighted_job85088_task4/case0_i2v_weighted.json +81 -0
  23. results/worldmem-baseline-evals/matrix-game2/diagnostic_i2v_weighted_job85088_task4/case1_i2v_weighted.json +81 -0
  24. results/worldmem-baseline-evals/matrix-game2/diagnostic_i2v_weighted_job85088_task4/complete.json +1 -0
  25. results/worldmem-baseline-evals/matrix-game2/diagnostic_i2v_weighted_job85088_task4/launcher.sh +35 -0
  26. results/worldmem-baseline-evals/matrix-game2/diagnostic_i2v_weighted_job85088_task4/manifest.json +59 -0
  27. results/worldmem-baseline-evals/matrix-game2/diagnostic_i2v_weighted_job85088_task4/node.json +7 -0
  28. results/worldmem-baseline-evals/matrix-game2/diagnostic_i2v_weighted_job85088_task4/probe.py +113 -0
  29. results/worldmem-baseline-evals/matrix-game2/diagnostic_native_demo_actions_job85112_task1/case0/comparison.json +81 -0
  30. results/worldmem-baseline-evals/matrix-game2/diagnostic_native_demo_actions_job85112_task1/case0/inputs.npz +3 -0
  31. results/worldmem-baseline-evals/matrix-game2/diagnostic_native_demo_actions_job85112_task1/case1/comparison.json +81 -0
  32. results/worldmem-baseline-evals/matrix-game2/diagnostic_native_demo_actions_job85112_task1/case1/inputs.npz +3 -0
  33. results/worldmem-baseline-evals/matrix-game2/diagnostic_native_demo_actions_job85112_task1/complete.json +1 -0
  34. results/worldmem-baseline-evals/matrix-game2/diagnostic_native_demo_actions_job85112_task1/inference.py +169 -0
  35. results/worldmem-baseline-evals/matrix-game2/diagnostic_native_demo_actions_job85112_task1/inference_universal.yaml +21 -0
  36. results/worldmem-baseline-evals/matrix-game2/diagnostic_native_demo_actions_job85112_task1/launcher.sh +38 -0
  37. results/worldmem-baseline-evals/matrix-game2/diagnostic_native_demo_actions_job85112_task1/manifest.json +50 -0
  38. results/worldmem-baseline-evals/matrix-game2/diagnostic_native_demo_actions_job85112_task1/node.json +7 -0
  39. results/worldmem-baseline-evals/matrix-game2/diagnostic_native_demo_actions_job85112_task1/probe.py +106 -0
  40. results/worldmem-baseline-evals/matrix-game2/diagnostic_native_neutral_job85112_task2/case0/comparison.json +81 -0
  41. results/worldmem-baseline-evals/matrix-game2/diagnostic_native_neutral_job85112_task2/case0/inputs.npz +3 -0
  42. results/worldmem-baseline-evals/matrix-game2/diagnostic_native_neutral_job85112_task2/case1/comparison.json +81 -0
  43. results/worldmem-baseline-evals/matrix-game2/diagnostic_native_neutral_job85112_task2/case1/inputs.npz +3 -0
  44. results/worldmem-baseline-evals/matrix-game2/diagnostic_native_neutral_job85112_task2/complete.json +1 -0
  45. results/worldmem-baseline-evals/matrix-game2/diagnostic_native_neutral_job85112_task2/inference.py +169 -0
  46. results/worldmem-baseline-evals/matrix-game2/diagnostic_native_neutral_job85112_task2/inference_universal.yaml +21 -0
  47. results/worldmem-baseline-evals/matrix-game2/diagnostic_native_neutral_job85112_task2/launcher.sh +38 -0
  48. results/worldmem-baseline-evals/matrix-game2/diagnostic_native_neutral_job85112_task2/manifest.json +50 -0
  49. results/worldmem-baseline-evals/matrix-game2/diagnostic_native_neutral_job85112_task2/node.json +7 -0
  50. results/worldmem-baseline-evals/matrix-game2/diagnostic_native_neutral_job85112_task2/probe.py +106 -0
results/worldmem-baseline-evals/matrix-game2/diagnostic_full_original_job85088_task1/case0_full_original.json ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "case": "case0_full_original",
3
+ "raw_rgb_psnr": [
4
+ 25.77519416809082,
5
+ 4.8833327293396,
6
+ 4.636667251586914,
7
+ 5.688905715942383,
8
+ 7.4164934158325195,
9
+ 7.8217339515686035,
10
+ 8.03274154663086,
11
+ 8.007763862609863,
12
+ 8.02673625946045,
13
+ 8.09578800201416,
14
+ 8.218385696411133,
15
+ 8.326114654541016,
16
+ 7.63754940032959,
17
+ 7.489852428436279,
18
+ 7.3153157234191895,
19
+ 7.299378395080566,
20
+ 7.418322563171387,
21
+ 7.375185012817383,
22
+ 7.256275177001953,
23
+ 7.181506156921387,
24
+ 7.253871917724609,
25
+ 7.2649149894714355,
26
+ 7.2623491287231445,
27
+ 7.290315628051758
28
+ ],
29
+ "raw_rgb_mse": [
30
+ 0.002645334927365184,
31
+ 0.32483792304992676,
32
+ 0.3438216745853424,
33
+ 0.2698419392108917,
34
+ 0.18128031492233276,
35
+ 0.16513024270534515,
36
+ 0.1572989672422409,
37
+ 0.1582062542438507,
38
+ 0.15751661360263824,
39
+ 0.1550319343805313,
40
+ 0.15071670711040497,
41
+ 0.14702408015727997,
42
+ 0.17228403687477112,
43
+ 0.178243950009346,
44
+ 0.18555320799350739,
45
+ 0.18623535335063934,
46
+ 0.18120399117469788,
47
+ 0.18301282823085785,
48
+ 0.1880929172039032,
49
+ 0.19135920703411102,
50
+ 0.1881970316171646,
51
+ 0.18771910667419434,
52
+ 0.18783006072044373,
53
+ 0.18662439286708832
54
+ ],
55
+ "mean_rgb": [
56
+ 0.6862332224845886,
57
+ 0.1697441190481186,
58
+ 0.156618133187294,
59
+ 0.2281637042760849,
60
+ 0.31492793560028076,
61
+ 0.33408209681510925,
62
+ 0.34403756260871887,
63
+ 0.3432576060295105,
64
+ 0.3432428538799286,
65
+ 0.34543678164482117,
66
+ 0.35083115100860596,
67
+ 0.357102632522583,
68
+ 0.3239423930644989,
69
+ 0.3186531066894531,
70
+ 0.3103964030742645,
71
+ 0.3092810809612274,
72
+ 0.3162357807159424,
73
+ 0.31385642290115356,
74
+ 0.30743733048439026,
75
+ 0.3035033941268921,
76
+ 0.3069319725036621,
77
+ 0.3079564869403839,
78
+ 0.30708178877830505,
79
+ 0.30761298537254333
80
+ ]
81
+ }
results/worldmem-baseline-evals/matrix-game2/diagnostic_full_original_job85088_task1/case1_full_original.json ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "case": "case1_full_original",
3
+ "raw_rgb_psnr": [
4
+ 20.75506591796875,
5
+ 5.314362525939941,
6
+ 4.540973663330078,
7
+ 5.3272600173950195,
8
+ 5.330643653869629,
9
+ 5.8266520500183105,
10
+ 5.940614223480225,
11
+ 6.0602803230285645,
12
+ 6.2254180908203125,
13
+ 6.322708606719971,
14
+ 6.403367042541504,
15
+ 6.356753826141357,
16
+ 6.32526159286499,
17
+ 6.268328666687012,
18
+ 6.2384490966796875,
19
+ 6.203701496124268,
20
+ 6.242549896240234,
21
+ 6.298856735229492,
22
+ 6.294210433959961,
23
+ 6.316972732543945,
24
+ 6.402440547943115,
25
+ 6.451478481292725,
26
+ 6.471812725067139,
27
+ 6.447417736053467
28
+ ],
29
+ "raw_rgb_mse": [
30
+ 0.00840414222329855,
31
+ 0.2941465377807617,
32
+ 0.3514816462993622,
33
+ 0.29327428340911865,
34
+ 0.29304590821266174,
35
+ 0.26141756772994995,
36
+ 0.25464698672294617,
37
+ 0.2477262318134308,
38
+ 0.23848342895507812,
39
+ 0.2332003265619278,
40
+ 0.22890923917293549,
41
+ 0.23137935996055603,
42
+ 0.23306328058242798,
43
+ 0.23613868653774261,
44
+ 0.23776891827583313,
45
+ 0.23967893421649933,
46
+ 0.23754450678825378,
47
+ 0.23448461294174194,
48
+ 0.23473559319972992,
49
+ 0.23350851237773895,
50
+ 0.22895805537700653,
51
+ 0.22638735175132751,
52
+ 0.22532984614372253,
53
+ 0.22659912705421448
54
+ ],
55
+ "mean_rgb": [
56
+ 0.6869287490844727,
57
+ 0.22597603499889374,
58
+ 0.16900615394115448,
59
+ 0.21825699508190155,
60
+ 0.21941502392292023,
61
+ 0.248577281832695,
62
+ 0.2554280757904053,
63
+ 0.26183179020881653,
64
+ 0.27177396416664124,
65
+ 0.27722224593162537,
66
+ 0.281747430562973,
67
+ 0.27876004576683044,
68
+ 0.27639126777648926,
69
+ 0.2728942036628723,
70
+ 0.2711937129497528,
71
+ 0.2694670855998993,
72
+ 0.2724168300628662,
73
+ 0.27583178877830505,
74
+ 0.2756144106388092,
75
+ 0.27678048610687256,
76
+ 0.2816024720668793,
77
+ 0.284187912940979,
78
+ 0.2853650152683258,
79
+ 0.283825546503067
80
+ ]
81
+ }
results/worldmem-baseline-evals/matrix-game2/diagnostic_full_original_job85088_task1/complete.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"mode": "full_original", "cases": 2, "frames": 24}
results/worldmem-baseline-evals/matrix-game2/diagnostic_full_original_job85088_task1/launcher.sh ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ #SBATCH --job-name=matrix-game2-diagnostic
3
+ #SBATCH --array=0-4
4
+ #SBATCH --nodes=1
5
+ #SBATCH --ntasks=1
6
+ #SBATCH --cpus-per-task=14
7
+ #SBATCH --gres=gpu:1
8
+ #SBATCH --time=01:00:00
9
+ #SBATCH --account=berzelius-2026-196
10
+ #SBATCH --chdir=/proj/cvl/users/x_fahkh2/worldmem-baseline-evals
11
+ #SBATCH --output=slurm_logs/%x-%A_%a.out
12
+ #SBATCH --error=slurm_logs/%x-%A_%a.out
13
+ set -euo pipefail
14
+ module load buildenv-gcccuda/12.9.1-gcc11
15
+ ROOT=/proj/cvl/users/x_fahkh2/worldmem-baseline-evals
16
+ PYTHON=/proj/cvl/users/x_fahkh2/envs/matrix-game2-eval/bin/python
17
+ DATA_ROOT=/proj/cvl/users/x_fahkh2/WorldMem_Repro/datasets/minecraft
18
+ MODES=(wan_oracle full_original full_weighted i2v_original i2v_weighted)
19
+ MODE=${MODES[$SLURM_ARRAY_TASK_ID]}
20
+ OUTPUT=$ROOT/Matrix-Game/Matrix-Game-2/outputs/diagnostic_${MODE}_job${SLURM_ARRAY_JOB_ID}_task${SLURM_ARRAY_TASK_ID}
21
+ export TMPDIR=$ROOT/cache
22
+ export TRITON_CACHE_DIR=$ROOT/cache
23
+ export HF_HOME=$ROOT/cache/huggingface
24
+ export TORCH_HOME=$ROOT/cache/torch
25
+ export XDG_CACHE_HOME=$ROOT/cache
26
+ export MPLCONFIGDIR=$ROOT/cache/matplotlib
27
+ export PYTHONNOUSERSITE=1 PYTHONUNBUFFERED=1 OMP_NUM_THREADS=4 MKL_NUM_THREADS=4
28
+ export WANDB_MODE=disabled HF_HUB_OFFLINE=1 TRANSFORMERS_OFFLINE=1
29
+ mkdir -p "$TMPDIR" "$OUTPUT"
30
+ "$PYTHON" "$ROOT/deployment/verify_node.py" --expected-gpus 1 --output "$OUTPUT"
31
+ cp "$0" "$OUTPUT/launcher.sh"
32
+ cp "$ROOT/deployment/diagnose_matrix_game2.py" "$OUTPUT/probe.py"
33
+ srun --ntasks=1 --gpus-per-task=1 --cpus-per-task=14 --cpu-bind=cores \
34
+ "$PYTHON" "$ROOT/deployment/diagnose_matrix_game2.py" \
35
+ --mode "$MODE" --data-root "$DATA_ROOT" --output "$OUTPUT"
results/worldmem-baseline-evals/matrix-game2/diagnostic_full_original_job85088_task1/manifest.json ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "diagnostic_only": true,
3
+ "mode": "full_original",
4
+ "checkpoint": "/proj/cvl/users/x_fahkh2/worldmem-baseline-evals/checkpoints/matrix-game2",
5
+ "weight_source": "released raw distilled",
6
+ "optimizer": null,
7
+ "lr": null,
8
+ "lora": null,
9
+ "activation_checkpointing": false,
10
+ "batch_size": 1,
11
+ "trainable_parameters": 0,
12
+ "denoising_steps": 3,
13
+ "shift": 5,
14
+ "local_attention_latents": 6,
15
+ "selector": "native sliding cache",
16
+ "reference": "raw RGB resized352x640, not benchmark Oasis references",
17
+ "targets": [
18
+ 700,
19
+ 724
20
+ ],
21
+ "full_history": [
22
+ 100,
23
+ 700
24
+ ],
25
+ "full_prefix_latents": 153,
26
+ "oracle": "9copies+RGB100:724 encodedonce;159latents; discard153latent prefix",
27
+ "i2v": {
28
+ "anchor": 699,
29
+ "decoded_slice": [
30
+ 1,
31
+ 25
32
+ ],
33
+ "controls": [
34
+ 700,
35
+ 724
36
+ ],
37
+ "right_noops": 9
38
+ },
39
+ "normalization_change": "weighted modes apply scales and accumulate RMS in fp32",
40
+ "cases": [
41
+ {
42
+ "index": "0",
43
+ "path": "test/val_plains/2/000034.mp4",
44
+ "seed": 42000000
45
+ },
46
+ {
47
+ "index": "1",
48
+ "path": "test/val_desert/1/000029.mp4",
49
+ "seed": 42000001
50
+ }
51
+ ],
52
+ "parameter_counts": {
53
+ "generator_total": 1619242304,
54
+ "generator_trainable": 0,
55
+ "vae_total": 126892531,
56
+ "clip_total": 1193014785
57
+ },
58
+ "action_norm_instances": 60
59
+ }
results/worldmem-baseline-evals/matrix-game2/diagnostic_full_original_job85088_task1/node.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "devices": [
3
+ "NVIDIA H200"
4
+ ],
5
+ "torch": "2.7.0+cu126",
6
+ "slurm_job_id": "85090"
7
+ }
results/worldmem-baseline-evals/matrix-game2/diagnostic_full_original_job85088_task1/probe.py ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Frozen Matrix diagnostics; raw-RGB PSNR is separate from benchmark scoring."""
2
+ import argparse
3
+ import json
4
+ import sys
5
+ from pathlib import Path
6
+ import torch
7
+ import torch.nn.functional as F
8
+ from PIL import Image
9
+
10
+ ROOT = Path(__file__).resolve().parents[1]
11
+ sys.path[:0] = [str(ROOT / 'shared'), str(ROOT / 'Matrix-Game/Matrix-Game-2')]
12
+ from protocol import load_minecraft_case, select_cases
13
+ from worldmem_adapter import MatrixGameAdapter, map_actions
14
+ from demo_utils.constant import ZERO_VAE_CACHE
15
+
16
+ MODES = ['wan_oracle', 'full_original', 'full_weighted', 'i2v_original', 'i2v_weighted']
17
+ parser = argparse.ArgumentParser(description=__doc__)
18
+ parser.add_argument('--mode', choices=MODES, required=True)
19
+ parser.add_argument('--data-root', type=Path, required=True)
20
+ parser.add_argument('--output', type=Path, required=True)
21
+ parser.add_argument('--dry-run', action='store_true')
22
+
23
+ def weighted_norm(self, x):
24
+ y = x.float()
25
+ return (y * torch.rsqrt(y.square().mean(-1, keepdim=True) + self.eps)).to(x.dtype) * self.weight
26
+
27
+ def save_result(output, name, prediction, reference):
28
+ prediction = prediction.float().cpu()
29
+ if prediction.shape != reference.shape or not torch.isfinite(prediction).all():
30
+ raise ValueError(f'Invalid Matrix prediction: {name}, shape={tuple(prediction.shape)}')
31
+ prediction = prediction.clamp(0, 1)
32
+ mse = (prediction - reference).square().mean((1, 2, 3))
33
+ report = {'case': name, 'raw_rgb_psnr': (-10 * mse.clamp_min(1e-12).log10()).tolist(),
34
+ 'raw_rgb_mse': mse.tolist(), 'mean_rgb': prediction.mean((1, 2, 3)).tolist()}
35
+ (output / f'{name}.json').write_text(json.dumps(report, indent=2))
36
+ grid = torch.cat([torch.cat([v[t] for t in [0, 1, 2, 5, 11, 23]], dim=2)
37
+ for v in (reference, prediction)], dim=1)
38
+ Image.fromarray(grid.mul(255).byte().permute(1, 2, 0).numpy()).save(output / f'{name}.jpg')
39
+ print(json.dumps({'case': name, 'mean_psnr': sum(report['raw_rgb_psnr']) / 24,
40
+ 'first_psnr': report['raw_rgb_psnr'][:3]}), flush=True)
41
+
42
+ @torch.inference_mode()
43
+ def main():
44
+ args = parser.parse_args()
45
+ rows = select_cases(ROOT / 'deployment/manifests/minecraft_test_300.csv', limit=2)
46
+ checkpoint = ROOT / 'checkpoints/matrix-game2'
47
+ manifest = {'diagnostic_only': True, 'mode': args.mode, 'checkpoint': str(checkpoint),
48
+ 'weight_source': 'released raw distilled', 'optimizer': None, 'lr': None, 'lora': None,
49
+ 'activation_checkpointing': False, 'batch_size': 1, 'trainable_parameters': 0,
50
+ 'denoising_steps': 3, 'shift': 5, 'local_attention_latents': 6,
51
+ 'selector': 'native sliding cache', 'reference': 'raw RGB resized352x640, not benchmark Oasis references',
52
+ 'targets': [700, 724], 'full_history': [100, 700], 'full_prefix_latents': 153,
53
+ 'oracle': '9copies+RGB100:724 encodedonce;159latents; discard153latent prefix',
54
+ 'i2v': {'anchor': 699, 'decoded_slice': [1, 25], 'controls': [700, 724], 'right_noops': 9},
55
+ 'normalization_change': 'weighted modes apply scales and accumulate RMS in fp32',
56
+ 'cases': [{'index': r['global_test_index'], 'path': r['relative_path'],
57
+ 'seed': 42000000 + int(r['global_test_index'])} for r in rows]}
58
+ if args.dry_run:
59
+ print(json.dumps(manifest, indent=2))
60
+ return
61
+ args.output.mkdir(parents=True, exist_ok=True)
62
+ (args.output / 'manifest.json').write_text(json.dumps(manifest, indent=2))
63
+ from wan.modules.action_module import WanRMSNorm
64
+ adapter = MatrixGameAdapter(checkpoint)
65
+ manifest['parameter_counts'] = adapter.parameter_counts
66
+ manifest['action_norm_instances'] = sum(isinstance(m, WanRMSNorm) for m in adapter.pipeline.modules())
67
+ (args.output / 'manifest.json').write_text(json.dumps(manifest, indent=2))
68
+ if args.mode.endswith('weighted'):
69
+ WanRMSNorm.forward = weighted_norm
70
+ for row in rows:
71
+ row.update(target_end='724', target_frames='24')
72
+ case = load_minecraft_case(row, args.data_root)
73
+ reference = F.interpolate(case['rgb'][600:624], (352, 640), mode='bilinear', align_corners=False, antialias=True)
74
+ seed = 42000000 + int(row['global_test_index'])
75
+ if args.mode == 'wan_oracle':
76
+ rgb = F.interpolate(case['rgb'].cuda(), (352, 640), mode='bilinear', align_corners=False, antialias=True)
77
+ rgb = torch.cat([rgb[:1].expand(9, -1, -1, -1), rgb])
78
+ latent = adapter.vae.encode(rgb.transpose(0, 1)[None].mul(2).sub(1).bfloat16(), device=adapter.device, tiled=False)
79
+ cache, chunks = [None] * len(ZERO_VAE_CACHE), []
80
+ for start in range(0, latent.shape[2], 3):
81
+ decoded, cache = adapter.pipeline.vae_decoder(latent[:, :, start:start + 3].transpose(1, 2).half(), *cache)
82
+ if start >= 153:
83
+ chunks.append(decoded.cpu())
84
+ prediction = torch.cat(chunks, dim=1)[0].float().add(1).div(2)
85
+ del latent, rgb, cache, decoded, chunks
86
+ elif args.mode.startswith('full'):
87
+ prediction, _ = adapter.generate(case, target_frames=24, seed=seed)
88
+ else:
89
+ torch.manual_seed(seed)
90
+ torch.cuda.manual_seed_all(seed)
91
+ anchor = F.interpolate(case['rgb'][599:600].cuda(), (352, 640), mode='bilinear', align_corners=False, antialias=True)
92
+ anchor = anchor.transpose(0, 1)[None].mul(2).sub(1).bfloat16()
93
+ image = anchor.new_zeros((1, 3, 33, 352, 640))
94
+ image[:, :, :1] = anchor
95
+ image_latents = adapter.vae.encode(image, device=adapter.device, tiled=False)
96
+ mask = torch.zeros_like(image_latents[:, :4])
97
+ mask[:, :, :1] = 1
98
+ actions = torch.cat([case['actions'][600:624], torch.zeros(9, 25)]).cuda().bfloat16()
99
+ keyboard, mouse = map_actions(actions, 1.0)
100
+ condition = {'cond_concat': torch.cat([mask, image_latents], dim=1),
101
+ 'visual_context': adapter.vae.clip.encode_video(anchor).bfloat16(),
102
+ 'keyboard_cond': keyboard[None], 'mouse_cond': mouse[None]}
103
+ noise = torch.randn((1, 16, 9, 44, 80), device='cuda', dtype=torch.bfloat16)
104
+ videos = adapter.pipeline.inference(noise, condition, initial_latent=None, mode='universal')
105
+ prediction = torch.cat(videos, dim=1)[0, 1:25].float().add(1).div(2)
106
+ del image, anchor, image_latents, condition, videos, noise
107
+ save_result(args.output, f"case{row['global_test_index']}_{args.mode}", prediction, reference)
108
+ del prediction, reference, case
109
+ (args.output / 'complete.json').write_text(json.dumps({'mode': args.mode, 'cases': 2, 'frames': 24}))
110
+ print('DIAGNOSTICS_COMPLETE', flush=True)
111
+
112
+ if __name__ == '__main__':
113
+ main()
results/worldmem-baseline-evals/matrix-game2/diagnostic_full_weighted_job85088_task2/case0_full_weighted.json ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "case": "case0_full_weighted",
3
+ "raw_rgb_psnr": [
4
+ 25.945024490356445,
5
+ 4.916481018066406,
6
+ 4.617745876312256,
7
+ 5.818724632263184,
8
+ 7.579941272735596,
9
+ 7.90878963470459,
10
+ 8.117096900939941,
11
+ 8.039791107177734,
12
+ 8.028121948242188,
13
+ 8.168718338012695,
14
+ 8.279888153076172,
15
+ 8.406937599182129,
16
+ 7.733737945556641,
17
+ 7.428074359893799,
18
+ 7.25970983505249,
19
+ 7.244600296020508,
20
+ 7.345211505889893,
21
+ 7.292293548583984,
22
+ 7.148654937744141,
23
+ 7.099469184875488,
24
+ 7.157524108886719,
25
+ 7.194796085357666,
26
+ 7.167351245880127,
27
+ 7.1892571449279785
28
+ ],
29
+ "raw_rgb_mse": [
30
+ 0.0025438847951591015,
31
+ 0.32236796617507935,
32
+ 0.34532293677330017,
33
+ 0.26189520955085754,
34
+ 0.17458458244800568,
35
+ 0.1618531197309494,
36
+ 0.1542731374502182,
37
+ 0.15704382956027985,
38
+ 0.1574663519859314,
39
+ 0.15245023369789124,
40
+ 0.14859738945960999,
41
+ 0.1443132609128952,
42
+ 0.16851019859313965,
43
+ 0.1807975471019745,
44
+ 0.187944233417511,
45
+ 0.18859927356243134,
46
+ 0.18428027629852295,
47
+ 0.1865394413471222,
48
+ 0.19281220436096191,
49
+ 0.1950082778930664,
50
+ 0.19241884350776672,
51
+ 0.19077451527118683,
52
+ 0.19198393821716309,
53
+ 0.1910180002450943
54
+ ],
55
+ "mean_rgb": [
56
+ 0.6870425343513489,
57
+ 0.1719239205121994,
58
+ 0.1551111340522766,
59
+ 0.23643054068088531,
60
+ 0.32379114627838135,
61
+ 0.3390358090400696,
62
+ 0.3493805527687073,
63
+ 0.3448195159435272,
64
+ 0.3432111144065857,
65
+ 0.349094033241272,
66
+ 0.3539511561393738,
67
+ 0.360940158367157,
68
+ 0.32845252752304077,
69
+ 0.3160686194896698,
70
+ 0.3070259988307953,
71
+ 0.30618816614151,
72
+ 0.3123764097690582,
73
+ 0.3096041679382324,
74
+ 0.30161795020103455,
75
+ 0.29898521304130554,
76
+ 0.30154550075531006,
77
+ 0.3034396171569824,
78
+ 0.3025643229484558,
79
+ 0.302489310503006
80
+ ]
81
+ }
results/worldmem-baseline-evals/matrix-game2/diagnostic_full_weighted_job85088_task2/case1_full_weighted.json ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "case": "case1_full_weighted",
3
+ "raw_rgb_psnr": [
4
+ 20.358261108398438,
5
+ 5.021709442138672,
6
+ 4.7442827224731445,
7
+ 5.203425407409668,
8
+ 5.046121597290039,
9
+ 5.245299339294434,
10
+ 5.384633541107178,
11
+ 5.533613681793213,
12
+ 5.719480514526367,
13
+ 5.826648712158203,
14
+ 5.863295078277588,
15
+ 5.830295085906982,
16
+ 5.900106906890869,
17
+ 5.944562911987305,
18
+ 6.028284072875977,
19
+ 5.974111080169678,
20
+ 6.014407157897949,
21
+ 6.091710090637207,
22
+ 6.0647077560424805,
23
+ 6.101002216339111,
24
+ 6.22338342666626,
25
+ 6.275542259216309,
26
+ 6.29188346862793,
27
+ 6.269043922424316
28
+ ],
29
+ "raw_rgb_mse": [
30
+ 0.009208180010318756,
31
+ 0.3146509528160095,
32
+ 0.33540669083595276,
33
+ 0.3017570674419403,
34
+ 0.3128872513771057,
35
+ 0.298861563205719,
36
+ 0.28942540287971497,
37
+ 0.27966535091400146,
38
+ 0.2679488956928253,
39
+ 0.26141780614852905,
40
+ 0.2592211663722992,
41
+ 0.26119837164878845,
42
+ 0.25703325867652893,
43
+ 0.2544155716896057,
44
+ 0.24955807626247406,
45
+ 0.25269049406051636,
46
+ 0.2503567337989807,
47
+ 0.24593989551067352,
48
+ 0.2474737912416458,
49
+ 0.24541424214839935,
50
+ 0.2385951578617096,
51
+ 0.23574677109718323,
52
+ 0.23486140370368958,
53
+ 0.23609979450702667
54
+ ],
55
+ "mean_rgb": [
56
+ 0.6835651397705078,
57
+ 0.20514607429504395,
58
+ 0.18633019924163818,
59
+ 0.21573315560817719,
60
+ 0.20562198758125305,
61
+ 0.21696747839450836,
62
+ 0.2257290482521057,
63
+ 0.23421454429626465,
64
+ 0.24657680094242096,
65
+ 0.2528727352619171,
66
+ 0.25491902232170105,
67
+ 0.25266510248184204,
68
+ 0.25558704137802124,
69
+ 0.25767818093299866,
70
+ 0.26240184903144836,
71
+ 0.25888851284980774,
72
+ 0.2621479630470276,
73
+ 0.26704472303390503,
74
+ 0.2655029892921448,
75
+ 0.267596572637558,
76
+ 0.2748774290084839,
77
+ 0.27775564789772034,
78
+ 0.2788831293582916,
79
+ 0.2775684595108032
80
+ ]
81
+ }
results/worldmem-baseline-evals/matrix-game2/diagnostic_full_weighted_job85088_task2/complete.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"mode": "full_weighted", "cases": 2, "frames": 24}
results/worldmem-baseline-evals/matrix-game2/diagnostic_full_weighted_job85088_task2/launcher.sh ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ #SBATCH --job-name=matrix-game2-diagnostic
3
+ #SBATCH --array=0-4
4
+ #SBATCH --nodes=1
5
+ #SBATCH --ntasks=1
6
+ #SBATCH --cpus-per-task=14
7
+ #SBATCH --gres=gpu:1
8
+ #SBATCH --time=01:00:00
9
+ #SBATCH --account=berzelius-2026-196
10
+ #SBATCH --chdir=/proj/cvl/users/x_fahkh2/worldmem-baseline-evals
11
+ #SBATCH --output=slurm_logs/%x-%A_%a.out
12
+ #SBATCH --error=slurm_logs/%x-%A_%a.out
13
+ set -euo pipefail
14
+ module load buildenv-gcccuda/12.9.1-gcc11
15
+ ROOT=/proj/cvl/users/x_fahkh2/worldmem-baseline-evals
16
+ PYTHON=/proj/cvl/users/x_fahkh2/envs/matrix-game2-eval/bin/python
17
+ DATA_ROOT=/proj/cvl/users/x_fahkh2/WorldMem_Repro/datasets/minecraft
18
+ MODES=(wan_oracle full_original full_weighted i2v_original i2v_weighted)
19
+ MODE=${MODES[$SLURM_ARRAY_TASK_ID]}
20
+ OUTPUT=$ROOT/Matrix-Game/Matrix-Game-2/outputs/diagnostic_${MODE}_job${SLURM_ARRAY_JOB_ID}_task${SLURM_ARRAY_TASK_ID}
21
+ export TMPDIR=$ROOT/cache
22
+ export TRITON_CACHE_DIR=$ROOT/cache
23
+ export HF_HOME=$ROOT/cache/huggingface
24
+ export TORCH_HOME=$ROOT/cache/torch
25
+ export XDG_CACHE_HOME=$ROOT/cache
26
+ export MPLCONFIGDIR=$ROOT/cache/matplotlib
27
+ export PYTHONNOUSERSITE=1 PYTHONUNBUFFERED=1 OMP_NUM_THREADS=4 MKL_NUM_THREADS=4
28
+ export WANDB_MODE=disabled HF_HUB_OFFLINE=1 TRANSFORMERS_OFFLINE=1
29
+ mkdir -p "$TMPDIR" "$OUTPUT"
30
+ "$PYTHON" "$ROOT/deployment/verify_node.py" --expected-gpus 1 --output "$OUTPUT"
31
+ cp "$0" "$OUTPUT/launcher.sh"
32
+ cp "$ROOT/deployment/diagnose_matrix_game2.py" "$OUTPUT/probe.py"
33
+ srun --ntasks=1 --gpus-per-task=1 --cpus-per-task=14 --cpu-bind=cores \
34
+ "$PYTHON" "$ROOT/deployment/diagnose_matrix_game2.py" \
35
+ --mode "$MODE" --data-root "$DATA_ROOT" --output "$OUTPUT"
results/worldmem-baseline-evals/matrix-game2/diagnostic_full_weighted_job85088_task2/manifest.json ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "diagnostic_only": true,
3
+ "mode": "full_weighted",
4
+ "checkpoint": "/proj/cvl/users/x_fahkh2/worldmem-baseline-evals/checkpoints/matrix-game2",
5
+ "weight_source": "released raw distilled",
6
+ "optimizer": null,
7
+ "lr": null,
8
+ "lora": null,
9
+ "activation_checkpointing": false,
10
+ "batch_size": 1,
11
+ "trainable_parameters": 0,
12
+ "denoising_steps": 3,
13
+ "shift": 5,
14
+ "local_attention_latents": 6,
15
+ "selector": "native sliding cache",
16
+ "reference": "raw RGB resized352x640, not benchmark Oasis references",
17
+ "targets": [
18
+ 700,
19
+ 724
20
+ ],
21
+ "full_history": [
22
+ 100,
23
+ 700
24
+ ],
25
+ "full_prefix_latents": 153,
26
+ "oracle": "9copies+RGB100:724 encodedonce;159latents; discard153latent prefix",
27
+ "i2v": {
28
+ "anchor": 699,
29
+ "decoded_slice": [
30
+ 1,
31
+ 25
32
+ ],
33
+ "controls": [
34
+ 700,
35
+ 724
36
+ ],
37
+ "right_noops": 9
38
+ },
39
+ "normalization_change": "weighted modes apply scales and accumulate RMS in fp32",
40
+ "cases": [
41
+ {
42
+ "index": "0",
43
+ "path": "test/val_plains/2/000034.mp4",
44
+ "seed": 42000000
45
+ },
46
+ {
47
+ "index": "1",
48
+ "path": "test/val_desert/1/000029.mp4",
49
+ "seed": 42000001
50
+ }
51
+ ],
52
+ "parameter_counts": {
53
+ "generator_total": 1619242304,
54
+ "generator_trainable": 0,
55
+ "vae_total": 126892531,
56
+ "clip_total": 1193014785
57
+ },
58
+ "action_norm_instances": 60
59
+ }
results/worldmem-baseline-evals/matrix-game2/diagnostic_full_weighted_job85088_task2/node.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "devices": [
3
+ "NVIDIA H200"
4
+ ],
5
+ "torch": "2.7.0+cu126",
6
+ "slurm_job_id": "85091"
7
+ }
results/worldmem-baseline-evals/matrix-game2/diagnostic_full_weighted_job85088_task2/probe.py ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Frozen Matrix diagnostics; raw-RGB PSNR is separate from benchmark scoring."""
2
+ import argparse
3
+ import json
4
+ import sys
5
+ from pathlib import Path
6
+ import torch
7
+ import torch.nn.functional as F
8
+ from PIL import Image
9
+
10
+ ROOT = Path(__file__).resolve().parents[1]
11
+ sys.path[:0] = [str(ROOT / 'shared'), str(ROOT / 'Matrix-Game/Matrix-Game-2')]
12
+ from protocol import load_minecraft_case, select_cases
13
+ from worldmem_adapter import MatrixGameAdapter, map_actions
14
+ from demo_utils.constant import ZERO_VAE_CACHE
15
+
16
+ MODES = ['wan_oracle', 'full_original', 'full_weighted', 'i2v_original', 'i2v_weighted']
17
+ parser = argparse.ArgumentParser(description=__doc__)
18
+ parser.add_argument('--mode', choices=MODES, required=True)
19
+ parser.add_argument('--data-root', type=Path, required=True)
20
+ parser.add_argument('--output', type=Path, required=True)
21
+ parser.add_argument('--dry-run', action='store_true')
22
+
23
+ def weighted_norm(self, x):
24
+ y = x.float()
25
+ return (y * torch.rsqrt(y.square().mean(-1, keepdim=True) + self.eps)).to(x.dtype) * self.weight
26
+
27
+ def save_result(output, name, prediction, reference):
28
+ prediction = prediction.float().cpu()
29
+ if prediction.shape != reference.shape or not torch.isfinite(prediction).all():
30
+ raise ValueError(f'Invalid Matrix prediction: {name}, shape={tuple(prediction.shape)}')
31
+ prediction = prediction.clamp(0, 1)
32
+ mse = (prediction - reference).square().mean((1, 2, 3))
33
+ report = {'case': name, 'raw_rgb_psnr': (-10 * mse.clamp_min(1e-12).log10()).tolist(),
34
+ 'raw_rgb_mse': mse.tolist(), 'mean_rgb': prediction.mean((1, 2, 3)).tolist()}
35
+ (output / f'{name}.json').write_text(json.dumps(report, indent=2))
36
+ grid = torch.cat([torch.cat([v[t] for t in [0, 1, 2, 5, 11, 23]], dim=2)
37
+ for v in (reference, prediction)], dim=1)
38
+ Image.fromarray(grid.mul(255).byte().permute(1, 2, 0).numpy()).save(output / f'{name}.jpg')
39
+ print(json.dumps({'case': name, 'mean_psnr': sum(report['raw_rgb_psnr']) / 24,
40
+ 'first_psnr': report['raw_rgb_psnr'][:3]}), flush=True)
41
+
42
+ @torch.inference_mode()
43
+ def main():
44
+ args = parser.parse_args()
45
+ rows = select_cases(ROOT / 'deployment/manifests/minecraft_test_300.csv', limit=2)
46
+ checkpoint = ROOT / 'checkpoints/matrix-game2'
47
+ manifest = {'diagnostic_only': True, 'mode': args.mode, 'checkpoint': str(checkpoint),
48
+ 'weight_source': 'released raw distilled', 'optimizer': None, 'lr': None, 'lora': None,
49
+ 'activation_checkpointing': False, 'batch_size': 1, 'trainable_parameters': 0,
50
+ 'denoising_steps': 3, 'shift': 5, 'local_attention_latents': 6,
51
+ 'selector': 'native sliding cache', 'reference': 'raw RGB resized352x640, not benchmark Oasis references',
52
+ 'targets': [700, 724], 'full_history': [100, 700], 'full_prefix_latents': 153,
53
+ 'oracle': '9copies+RGB100:724 encodedonce;159latents; discard153latent prefix',
54
+ 'i2v': {'anchor': 699, 'decoded_slice': [1, 25], 'controls': [700, 724], 'right_noops': 9},
55
+ 'normalization_change': 'weighted modes apply scales and accumulate RMS in fp32',
56
+ 'cases': [{'index': r['global_test_index'], 'path': r['relative_path'],
57
+ 'seed': 42000000 + int(r['global_test_index'])} for r in rows]}
58
+ if args.dry_run:
59
+ print(json.dumps(manifest, indent=2))
60
+ return
61
+ args.output.mkdir(parents=True, exist_ok=True)
62
+ (args.output / 'manifest.json').write_text(json.dumps(manifest, indent=2))
63
+ from wan.modules.action_module import WanRMSNorm
64
+ adapter = MatrixGameAdapter(checkpoint)
65
+ manifest['parameter_counts'] = adapter.parameter_counts
66
+ manifest['action_norm_instances'] = sum(isinstance(m, WanRMSNorm) for m in adapter.pipeline.modules())
67
+ (args.output / 'manifest.json').write_text(json.dumps(manifest, indent=2))
68
+ if args.mode.endswith('weighted'):
69
+ WanRMSNorm.forward = weighted_norm
70
+ for row in rows:
71
+ row.update(target_end='724', target_frames='24')
72
+ case = load_minecraft_case(row, args.data_root)
73
+ reference = F.interpolate(case['rgb'][600:624], (352, 640), mode='bilinear', align_corners=False, antialias=True)
74
+ seed = 42000000 + int(row['global_test_index'])
75
+ if args.mode == 'wan_oracle':
76
+ rgb = F.interpolate(case['rgb'].cuda(), (352, 640), mode='bilinear', align_corners=False, antialias=True)
77
+ rgb = torch.cat([rgb[:1].expand(9, -1, -1, -1), rgb])
78
+ latent = adapter.vae.encode(rgb.transpose(0, 1)[None].mul(2).sub(1).bfloat16(), device=adapter.device, tiled=False)
79
+ cache, chunks = [None] * len(ZERO_VAE_CACHE), []
80
+ for start in range(0, latent.shape[2], 3):
81
+ decoded, cache = adapter.pipeline.vae_decoder(latent[:, :, start:start + 3].transpose(1, 2).half(), *cache)
82
+ if start >= 153:
83
+ chunks.append(decoded.cpu())
84
+ prediction = torch.cat(chunks, dim=1)[0].float().add(1).div(2)
85
+ del latent, rgb, cache, decoded, chunks
86
+ elif args.mode.startswith('full'):
87
+ prediction, _ = adapter.generate(case, target_frames=24, seed=seed)
88
+ else:
89
+ torch.manual_seed(seed)
90
+ torch.cuda.manual_seed_all(seed)
91
+ anchor = F.interpolate(case['rgb'][599:600].cuda(), (352, 640), mode='bilinear', align_corners=False, antialias=True)
92
+ anchor = anchor.transpose(0, 1)[None].mul(2).sub(1).bfloat16()
93
+ image = anchor.new_zeros((1, 3, 33, 352, 640))
94
+ image[:, :, :1] = anchor
95
+ image_latents = adapter.vae.encode(image, device=adapter.device, tiled=False)
96
+ mask = torch.zeros_like(image_latents[:, :4])
97
+ mask[:, :, :1] = 1
98
+ actions = torch.cat([case['actions'][600:624], torch.zeros(9, 25)]).cuda().bfloat16()
99
+ keyboard, mouse = map_actions(actions, 1.0)
100
+ condition = {'cond_concat': torch.cat([mask, image_latents], dim=1),
101
+ 'visual_context': adapter.vae.clip.encode_video(anchor).bfloat16(),
102
+ 'keyboard_cond': keyboard[None], 'mouse_cond': mouse[None]}
103
+ noise = torch.randn((1, 16, 9, 44, 80), device='cuda', dtype=torch.bfloat16)
104
+ videos = adapter.pipeline.inference(noise, condition, initial_latent=None, mode='universal')
105
+ prediction = torch.cat(videos, dim=1)[0, 1:25].float().add(1).div(2)
106
+ del image, anchor, image_latents, condition, videos, noise
107
+ save_result(args.output, f"case{row['global_test_index']}_{args.mode}", prediction, reference)
108
+ del prediction, reference, case
109
+ (args.output / 'complete.json').write_text(json.dumps({'mode': args.mode, 'cases': 2, 'frames': 24}))
110
+ print('DIAGNOSTICS_COMPLETE', flush=True)
111
+
112
+ if __name__ == '__main__':
113
+ main()
results/worldmem-baseline-evals/matrix-game2/diagnostic_i2v_original_job85088_task3/case0_i2v_original.json ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "case": "case0_i2v_original",
3
+ "raw_rgb_psnr": [
4
+ 28.51933479309082,
5
+ 5.62062931060791,
6
+ 6.261198997497559,
7
+ 7.325035095214844,
8
+ 7.525331497192383,
9
+ 7.780514240264893,
10
+ 7.777151107788086,
11
+ 7.821002006530762,
12
+ 7.603299617767334,
13
+ 7.544827461242676,
14
+ 7.494100570678711,
15
+ 7.490266799926758,
16
+ 7.607268810272217,
17
+ 7.717894554138184,
18
+ 7.877525329589844,
19
+ 7.909063816070557,
20
+ 7.8667497634887695,
21
+ 7.888334274291992,
22
+ 7.912131309509277,
23
+ 7.934691905975342,
24
+ 7.701882839202881,
25
+ 6.664777755737305,
26
+ 7.160373687744141,
27
+ 7.919079780578613
28
+ ],
29
+ "raw_rgb_mse": [
30
+ 0.001406263094395399,
31
+ 0.27411770820617676,
32
+ 0.23652665317058563,
33
+ 0.18513838946819305,
34
+ 0.17679372429847717,
35
+ 0.16670498251914978,
36
+ 0.16683414578437805,
37
+ 0.16515807807445526,
38
+ 0.17364810407161713,
39
+ 0.17600186169147491,
40
+ 0.17806968092918396,
41
+ 0.17822694778442383,
42
+ 0.17348946630954742,
43
+ 0.16912606358528137,
44
+ 0.1630224734544754,
45
+ 0.16184288263320923,
46
+ 0.1634274572134018,
47
+ 0.16261722147464752,
48
+ 0.1617286056280136,
49
+ 0.16089065372943878,
50
+ 0.16975075006484985,
51
+ 0.2155371904373169,
52
+ 0.19229261577129364,
53
+ 0.16147007048130035
54
+ ],
55
+ "mean_rgb": [
56
+ 0.7052807807922363,
57
+ 0.22267355024814606,
58
+ 0.26383358240127563,
59
+ 0.31955206394195557,
60
+ 0.3294263184070587,
61
+ 0.3413337469100952,
62
+ 0.34034264087677,
63
+ 0.3422088921070099,
64
+ 0.3322543799877167,
65
+ 0.3306882083415985,
66
+ 0.32795271277427673,
67
+ 0.32645344734191895,
68
+ 0.32989341020584106,
69
+ 0.33399924635887146,
70
+ 0.34038686752319336,
71
+ 0.34092986583709717,
72
+ 0.33980700373649597,
73
+ 0.3406497836112976,
74
+ 0.3414357602596283,
75
+ 0.3423357307910919,
76
+ 0.3307926654815674,
77
+ 0.2806178331375122,
78
+ 0.30535194277763367,
79
+ 0.34129393100738525
80
+ ]
81
+ }
results/worldmem-baseline-evals/matrix-game2/diagnostic_i2v_original_job85088_task3/case1_i2v_original.json ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "case": "case1_i2v_original",
3
+ "raw_rgb_psnr": [
4
+ 15.054824829101562,
5
+ 11.44872760772705,
6
+ 9.014760971069336,
7
+ 7.8256916999816895,
8
+ 6.933335781097412,
9
+ 6.524610996246338,
10
+ 6.566136360168457,
11
+ 6.591427803039551,
12
+ 6.48160982131958,
13
+ 6.368434906005859,
14
+ 4.373075008392334,
15
+ 5.369548320770264,
16
+ 5.37614631652832,
17
+ 5.41501522064209,
18
+ 5.501518726348877,
19
+ 5.463625907897949,
20
+ 5.47122859954834,
21
+ 5.503015041351318,
22
+ 5.575506210327148,
23
+ 5.547548294067383,
24
+ 5.560653209686279,
25
+ 5.55626106262207,
26
+ 5.5676751136779785,
27
+ 5.580542087554932
28
+ ],
29
+ "raw_rgb_mse": [
30
+ 0.031226083636283875,
31
+ 0.07163531333208084,
32
+ 0.12546537816524506,
33
+ 0.16497983038425446,
34
+ 0.20261257886886597,
35
+ 0.22260703146457672,
36
+ 0.22048871219158173,
37
+ 0.21920840442180634,
38
+ 0.22482208907604218,
39
+ 0.23075786232948303,
40
+ 0.36533603072166443,
41
+ 0.29043248295783997,
42
+ 0.289991557598114,
43
+ 0.2874077558517456,
44
+ 0.281739741563797,
45
+ 0.284208744764328,
46
+ 0.28371164202690125,
47
+ 0.28164270520210266,
48
+ 0.27698060870170593,
49
+ 0.27876943349838257,
50
+ 0.27792951464653015,
51
+ 0.27821075916290283,
52
+ 0.27748051285743713,
53
+ 0.27665963768959045
54
+ ],
55
+ "mean_rgb": [
56
+ 0.6844472289085388,
57
+ 0.6284617781639099,
58
+ 0.5540845394134521,
59
+ 0.49505874514579773,
60
+ 0.4436206817626953,
61
+ 0.41198185086250305,
62
+ 0.4130478501319885,
63
+ 0.41542676091194153,
64
+ 0.406199187040329,
65
+ 0.39254048466682434,
66
+ 0.16926062107086182,
67
+ 0.22599884867668152,
68
+ 0.22546076774597168,
69
+ 0.22791211307048798,
70
+ 0.23338943719863892,
71
+ 0.23143425583839417,
72
+ 0.23280683159828186,
73
+ 0.23524777591228485,
74
+ 0.23973938822746277,
75
+ 0.23811960220336914,
76
+ 0.23764897882938385,
77
+ 0.2369965761899948,
78
+ 0.23754198849201202,
79
+ 0.23855453729629517
80
+ ]
81
+ }
results/worldmem-baseline-evals/matrix-game2/diagnostic_i2v_original_job85088_task3/complete.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"mode": "i2v_original", "cases": 2, "frames": 24}
results/worldmem-baseline-evals/matrix-game2/diagnostic_i2v_original_job85088_task3/launcher.sh ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ #SBATCH --job-name=matrix-game2-diagnostic
3
+ #SBATCH --array=0-4
4
+ #SBATCH --nodes=1
5
+ #SBATCH --ntasks=1
6
+ #SBATCH --cpus-per-task=14
7
+ #SBATCH --gres=gpu:1
8
+ #SBATCH --time=01:00:00
9
+ #SBATCH --account=berzelius-2026-196
10
+ #SBATCH --chdir=/proj/cvl/users/x_fahkh2/worldmem-baseline-evals
11
+ #SBATCH --output=slurm_logs/%x-%A_%a.out
12
+ #SBATCH --error=slurm_logs/%x-%A_%a.out
13
+ set -euo pipefail
14
+ module load buildenv-gcccuda/12.9.1-gcc11
15
+ ROOT=/proj/cvl/users/x_fahkh2/worldmem-baseline-evals
16
+ PYTHON=/proj/cvl/users/x_fahkh2/envs/matrix-game2-eval/bin/python
17
+ DATA_ROOT=/proj/cvl/users/x_fahkh2/WorldMem_Repro/datasets/minecraft
18
+ MODES=(wan_oracle full_original full_weighted i2v_original i2v_weighted)
19
+ MODE=${MODES[$SLURM_ARRAY_TASK_ID]}
20
+ OUTPUT=$ROOT/Matrix-Game/Matrix-Game-2/outputs/diagnostic_${MODE}_job${SLURM_ARRAY_JOB_ID}_task${SLURM_ARRAY_TASK_ID}
21
+ export TMPDIR=$ROOT/cache
22
+ export TRITON_CACHE_DIR=$ROOT/cache
23
+ export HF_HOME=$ROOT/cache/huggingface
24
+ export TORCH_HOME=$ROOT/cache/torch
25
+ export XDG_CACHE_HOME=$ROOT/cache
26
+ export MPLCONFIGDIR=$ROOT/cache/matplotlib
27
+ export PYTHONNOUSERSITE=1 PYTHONUNBUFFERED=1 OMP_NUM_THREADS=4 MKL_NUM_THREADS=4
28
+ export WANDB_MODE=disabled HF_HUB_OFFLINE=1 TRANSFORMERS_OFFLINE=1
29
+ mkdir -p "$TMPDIR" "$OUTPUT"
30
+ "$PYTHON" "$ROOT/deployment/verify_node.py" --expected-gpus 1 --output "$OUTPUT"
31
+ cp "$0" "$OUTPUT/launcher.sh"
32
+ cp "$ROOT/deployment/diagnose_matrix_game2.py" "$OUTPUT/probe.py"
33
+ srun --ntasks=1 --gpus-per-task=1 --cpus-per-task=14 --cpu-bind=cores \
34
+ "$PYTHON" "$ROOT/deployment/diagnose_matrix_game2.py" \
35
+ --mode "$MODE" --data-root "$DATA_ROOT" --output "$OUTPUT"
results/worldmem-baseline-evals/matrix-game2/diagnostic_i2v_original_job85088_task3/manifest.json ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "diagnostic_only": true,
3
+ "mode": "i2v_original",
4
+ "checkpoint": "/proj/cvl/users/x_fahkh2/worldmem-baseline-evals/checkpoints/matrix-game2",
5
+ "weight_source": "released raw distilled",
6
+ "optimizer": null,
7
+ "lr": null,
8
+ "lora": null,
9
+ "activation_checkpointing": false,
10
+ "batch_size": 1,
11
+ "trainable_parameters": 0,
12
+ "denoising_steps": 3,
13
+ "shift": 5,
14
+ "local_attention_latents": 6,
15
+ "selector": "native sliding cache",
16
+ "reference": "raw RGB resized352x640, not benchmark Oasis references",
17
+ "targets": [
18
+ 700,
19
+ 724
20
+ ],
21
+ "full_history": [
22
+ 100,
23
+ 700
24
+ ],
25
+ "full_prefix_latents": 153,
26
+ "oracle": "9copies+RGB100:724 encodedonce;159latents; discard153latent prefix",
27
+ "i2v": {
28
+ "anchor": 699,
29
+ "decoded_slice": [
30
+ 1,
31
+ 25
32
+ ],
33
+ "controls": [
34
+ 700,
35
+ 724
36
+ ],
37
+ "right_noops": 9
38
+ },
39
+ "normalization_change": "weighted modes apply scales and accumulate RMS in fp32",
40
+ "cases": [
41
+ {
42
+ "index": "0",
43
+ "path": "test/val_plains/2/000034.mp4",
44
+ "seed": 42000000
45
+ },
46
+ {
47
+ "index": "1",
48
+ "path": "test/val_desert/1/000029.mp4",
49
+ "seed": 42000001
50
+ }
51
+ ],
52
+ "parameter_counts": {
53
+ "generator_total": 1619242304,
54
+ "generator_trainable": 0,
55
+ "vae_total": 126892531,
56
+ "clip_total": 1193014785
57
+ },
58
+ "action_norm_instances": 60
59
+ }
results/worldmem-baseline-evals/matrix-game2/diagnostic_i2v_original_job85088_task3/node.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "devices": [
3
+ "NVIDIA H200"
4
+ ],
5
+ "torch": "2.7.0+cu126",
6
+ "slurm_job_id": "85092"
7
+ }
results/worldmem-baseline-evals/matrix-game2/diagnostic_i2v_original_job85088_task3/probe.py ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Frozen Matrix diagnostics; raw-RGB PSNR is separate from benchmark scoring."""
2
+ import argparse
3
+ import json
4
+ import sys
5
+ from pathlib import Path
6
+ import torch
7
+ import torch.nn.functional as F
8
+ from PIL import Image
9
+
10
+ ROOT = Path(__file__).resolve().parents[1]
11
+ sys.path[:0] = [str(ROOT / 'shared'), str(ROOT / 'Matrix-Game/Matrix-Game-2')]
12
+ from protocol import load_minecraft_case, select_cases
13
+ from worldmem_adapter import MatrixGameAdapter, map_actions
14
+ from demo_utils.constant import ZERO_VAE_CACHE
15
+
16
+ MODES = ['wan_oracle', 'full_original', 'full_weighted', 'i2v_original', 'i2v_weighted']
17
+ parser = argparse.ArgumentParser(description=__doc__)
18
+ parser.add_argument('--mode', choices=MODES, required=True)
19
+ parser.add_argument('--data-root', type=Path, required=True)
20
+ parser.add_argument('--output', type=Path, required=True)
21
+ parser.add_argument('--dry-run', action='store_true')
22
+
23
+ def weighted_norm(self, x):
24
+ y = x.float()
25
+ return (y * torch.rsqrt(y.square().mean(-1, keepdim=True) + self.eps)).to(x.dtype) * self.weight
26
+
27
+ def save_result(output, name, prediction, reference):
28
+ prediction = prediction.float().cpu()
29
+ if prediction.shape != reference.shape or not torch.isfinite(prediction).all():
30
+ raise ValueError(f'Invalid Matrix prediction: {name}, shape={tuple(prediction.shape)}')
31
+ prediction = prediction.clamp(0, 1)
32
+ mse = (prediction - reference).square().mean((1, 2, 3))
33
+ report = {'case': name, 'raw_rgb_psnr': (-10 * mse.clamp_min(1e-12).log10()).tolist(),
34
+ 'raw_rgb_mse': mse.tolist(), 'mean_rgb': prediction.mean((1, 2, 3)).tolist()}
35
+ (output / f'{name}.json').write_text(json.dumps(report, indent=2))
36
+ grid = torch.cat([torch.cat([v[t] for t in [0, 1, 2, 5, 11, 23]], dim=2)
37
+ for v in (reference, prediction)], dim=1)
38
+ Image.fromarray(grid.mul(255).byte().permute(1, 2, 0).numpy()).save(output / f'{name}.jpg')
39
+ print(json.dumps({'case': name, 'mean_psnr': sum(report['raw_rgb_psnr']) / 24,
40
+ 'first_psnr': report['raw_rgb_psnr'][:3]}), flush=True)
41
+
42
+ @torch.inference_mode()
43
+ def main():
44
+ args = parser.parse_args()
45
+ rows = select_cases(ROOT / 'deployment/manifests/minecraft_test_300.csv', limit=2)
46
+ checkpoint = ROOT / 'checkpoints/matrix-game2'
47
+ manifest = {'diagnostic_only': True, 'mode': args.mode, 'checkpoint': str(checkpoint),
48
+ 'weight_source': 'released raw distilled', 'optimizer': None, 'lr': None, 'lora': None,
49
+ 'activation_checkpointing': False, 'batch_size': 1, 'trainable_parameters': 0,
50
+ 'denoising_steps': 3, 'shift': 5, 'local_attention_latents': 6,
51
+ 'selector': 'native sliding cache', 'reference': 'raw RGB resized352x640, not benchmark Oasis references',
52
+ 'targets': [700, 724], 'full_history': [100, 700], 'full_prefix_latents': 153,
53
+ 'oracle': '9copies+RGB100:724 encodedonce;159latents; discard153latent prefix',
54
+ 'i2v': {'anchor': 699, 'decoded_slice': [1, 25], 'controls': [700, 724], 'right_noops': 9},
55
+ 'normalization_change': 'weighted modes apply scales and accumulate RMS in fp32',
56
+ 'cases': [{'index': r['global_test_index'], 'path': r['relative_path'],
57
+ 'seed': 42000000 + int(r['global_test_index'])} for r in rows]}
58
+ if args.dry_run:
59
+ print(json.dumps(manifest, indent=2))
60
+ return
61
+ args.output.mkdir(parents=True, exist_ok=True)
62
+ (args.output / 'manifest.json').write_text(json.dumps(manifest, indent=2))
63
+ from wan.modules.action_module import WanRMSNorm
64
+ adapter = MatrixGameAdapter(checkpoint)
65
+ manifest['parameter_counts'] = adapter.parameter_counts
66
+ manifest['action_norm_instances'] = sum(isinstance(m, WanRMSNorm) for m in adapter.pipeline.modules())
67
+ (args.output / 'manifest.json').write_text(json.dumps(manifest, indent=2))
68
+ if args.mode.endswith('weighted'):
69
+ WanRMSNorm.forward = weighted_norm
70
+ for row in rows:
71
+ row.update(target_end='724', target_frames='24')
72
+ case = load_minecraft_case(row, args.data_root)
73
+ reference = F.interpolate(case['rgb'][600:624], (352, 640), mode='bilinear', align_corners=False, antialias=True)
74
+ seed = 42000000 + int(row['global_test_index'])
75
+ if args.mode == 'wan_oracle':
76
+ rgb = F.interpolate(case['rgb'].cuda(), (352, 640), mode='bilinear', align_corners=False, antialias=True)
77
+ rgb = torch.cat([rgb[:1].expand(9, -1, -1, -1), rgb])
78
+ latent = adapter.vae.encode(rgb.transpose(0, 1)[None].mul(2).sub(1).bfloat16(), device=adapter.device, tiled=False)
79
+ cache, chunks = [None] * len(ZERO_VAE_CACHE), []
80
+ for start in range(0, latent.shape[2], 3):
81
+ decoded, cache = adapter.pipeline.vae_decoder(latent[:, :, start:start + 3].transpose(1, 2).half(), *cache)
82
+ if start >= 153:
83
+ chunks.append(decoded.cpu())
84
+ prediction = torch.cat(chunks, dim=1)[0].float().add(1).div(2)
85
+ del latent, rgb, cache, decoded, chunks
86
+ elif args.mode.startswith('full'):
87
+ prediction, _ = adapter.generate(case, target_frames=24, seed=seed)
88
+ else:
89
+ torch.manual_seed(seed)
90
+ torch.cuda.manual_seed_all(seed)
91
+ anchor = F.interpolate(case['rgb'][599:600].cuda(), (352, 640), mode='bilinear', align_corners=False, antialias=True)
92
+ anchor = anchor.transpose(0, 1)[None].mul(2).sub(1).bfloat16()
93
+ image = anchor.new_zeros((1, 3, 33, 352, 640))
94
+ image[:, :, :1] = anchor
95
+ image_latents = adapter.vae.encode(image, device=adapter.device, tiled=False)
96
+ mask = torch.zeros_like(image_latents[:, :4])
97
+ mask[:, :, :1] = 1
98
+ actions = torch.cat([case['actions'][600:624], torch.zeros(9, 25)]).cuda().bfloat16()
99
+ keyboard, mouse = map_actions(actions, 1.0)
100
+ condition = {'cond_concat': torch.cat([mask, image_latents], dim=1),
101
+ 'visual_context': adapter.vae.clip.encode_video(anchor).bfloat16(),
102
+ 'keyboard_cond': keyboard[None], 'mouse_cond': mouse[None]}
103
+ noise = torch.randn((1, 16, 9, 44, 80), device='cuda', dtype=torch.bfloat16)
104
+ videos = adapter.pipeline.inference(noise, condition, initial_latent=None, mode='universal')
105
+ prediction = torch.cat(videos, dim=1)[0, 1:25].float().add(1).div(2)
106
+ del image, anchor, image_latents, condition, videos, noise
107
+ save_result(args.output, f"case{row['global_test_index']}_{args.mode}", prediction, reference)
108
+ del prediction, reference, case
109
+ (args.output / 'complete.json').write_text(json.dumps({'mode': args.mode, 'cases': 2, 'frames': 24}))
110
+ print('DIAGNOSTICS_COMPLETE', flush=True)
111
+
112
+ if __name__ == '__main__':
113
+ main()
results/worldmem-baseline-evals/matrix-game2/diagnostic_i2v_weighted_job85088_task4/case0_i2v_weighted.json ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "case": "case0_i2v_weighted",
3
+ "raw_rgb_psnr": [
4
+ 28.400230407714844,
5
+ 5.406888008117676,
6
+ 6.059108257293701,
7
+ 7.271352767944336,
8
+ 7.498164653778076,
9
+ 7.74724006652832,
10
+ 7.7596211433410645,
11
+ 7.7729315757751465,
12
+ 7.52515983581543,
13
+ 7.486701488494873,
14
+ 7.524697303771973,
15
+ 7.638741493225098,
16
+ 7.781850814819336,
17
+ 7.818033695220947,
18
+ 7.900123119354248,
19
+ 7.916782379150391,
20
+ 7.866796493530273,
21
+ 7.875070095062256,
22
+ 7.894111633300781,
23
+ 7.932208061218262,
24
+ 7.702528953552246,
25
+ 7.582130432128906,
26
+ 7.766695976257324,
27
+ 7.993913650512695
28
+ ],
29
+ "raw_rgb_mse": [
30
+ 0.0014453631592914462,
31
+ 0.28794607520103455,
32
+ 0.2477930635213852,
33
+ 0.18744103610515594,
34
+ 0.17790310084819794,
35
+ 0.16798712313175201,
36
+ 0.16750890016555786,
37
+ 0.1669963002204895,
38
+ 0.17680072784423828,
39
+ 0.1783733069896698,
40
+ 0.1768195480108261,
41
+ 0.17223675549030304,
42
+ 0.16665369272232056,
43
+ 0.16527098417282104,
44
+ 0.16217641532421112,
45
+ 0.16155549883842468,
46
+ 0.16342569887638092,
47
+ 0.16311465203762054,
48
+ 0.16240103542804718,
49
+ 0.16098269820213318,
50
+ 0.16972550749778748,
51
+ 0.1744966059923172,
52
+ 0.16723622381687164,
53
+ 0.15871158242225647
54
+ ],
55
+ "mean_rgb": [
56
+ 0.7053292989730835,
57
+ 0.20904700458049774,
58
+ 0.2530539929866791,
59
+ 0.3162554204463959,
60
+ 0.3277013599872589,
61
+ 0.33897286653518677,
62
+ 0.3385704457759857,
63
+ 0.3386596143245697,
64
+ 0.32705172896385193,
65
+ 0.3246579170227051,
66
+ 0.32665011286735535,
67
+ 0.33084917068481445,
68
+ 0.33509644865989685,
69
+ 0.335825651884079,
70
+ 0.34004831314086914,
71
+ 0.34061479568481445,
72
+ 0.338895708322525,
73
+ 0.339072585105896,
74
+ 0.33963221311569214,
75
+ 0.3410741984844208,
76
+ 0.3300783038139343,
77
+ 0.32414621114730835,
78
+ 0.33280378580093384,
79
+ 0.3427526652812958
80
+ ]
81
+ }
results/worldmem-baseline-evals/matrix-game2/diagnostic_i2v_weighted_job85088_task4/case1_i2v_weighted.json ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "case": "case1_i2v_weighted",
3
+ "raw_rgb_psnr": [
4
+ 15.572078704833984,
5
+ 11.67737865447998,
6
+ 9.182900428771973,
7
+ 7.9456071853637695,
8
+ 6.916970729827881,
9
+ 6.555791854858398,
10
+ 6.522993564605713,
11
+ 6.507280349731445,
12
+ 6.314092636108398,
13
+ 6.2913408279418945,
14
+ 6.392267227172852,
15
+ 6.423827171325684,
16
+ 6.575774669647217,
17
+ 4.436397075653076,
18
+ 4.66413688659668,
19
+ 4.843669414520264,
20
+ 4.8888068199157715,
21
+ 4.991722106933594,
22
+ 5.058438301086426,
23
+ 5.032224178314209,
24
+ 5.076114654541016,
25
+ 5.092604637145996,
26
+ 5.115626335144043,
27
+ 5.137517929077148
28
+ ],
29
+ "raw_rgb_mse": [
30
+ 0.027719931676983833,
31
+ 0.06796137243509293,
32
+ 0.12070075422525406,
33
+ 0.16048678755760193,
34
+ 0.20337752997875214,
35
+ 0.22101451456546783,
36
+ 0.22268995642662048,
37
+ 0.22349712252616882,
38
+ 0.2336634248495102,
39
+ 0.23489077389240265,
40
+ 0.22949503362178802,
41
+ 0.2278333306312561,
42
+ 0.21999992430210114,
43
+ 0.3600479066371918,
44
+ 0.34165385365486145,
45
+ 0.32781821489334106,
46
+ 0.3244287371635437,
47
+ 0.3168310821056366,
48
+ 0.31200113892555237,
49
+ 0.31389009952545166,
50
+ 0.3107338547706604,
51
+ 0.3095562160015106,
52
+ 0.30791962146759033,
53
+ 0.3063713610172272
54
+ ],
55
+ "mean_rgb": [
56
+ 0.6906836032867432,
57
+ 0.6348850727081299,
58
+ 0.5620357394218445,
59
+ 0.5025600790977478,
60
+ 0.4471380114555359,
61
+ 0.41820263862609863,
62
+ 0.4126875400543213,
63
+ 0.41116610169410706,
64
+ 0.3962208926677704,
65
+ 0.3935016095638275,
66
+ 0.3975541591644287,
67
+ 0.39638906717300415,
68
+ 0.40340858697891235,
69
+ 0.16516827046871185,
70
+ 0.18019184470176697,
71
+ 0.19274631142616272,
72
+ 0.1964321732521057,
73
+ 0.20392490923404694,
74
+ 0.20804454386234283,
75
+ 0.2059834748506546,
76
+ 0.20835448801517487,
77
+ 0.20949353277683258,
78
+ 0.21102812886238098,
79
+ 0.2126505970954895
80
+ ]
81
+ }
results/worldmem-baseline-evals/matrix-game2/diagnostic_i2v_weighted_job85088_task4/complete.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"mode": "i2v_weighted", "cases": 2, "frames": 24}
results/worldmem-baseline-evals/matrix-game2/diagnostic_i2v_weighted_job85088_task4/launcher.sh ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ #SBATCH --job-name=matrix-game2-diagnostic
3
+ #SBATCH --array=0-4
4
+ #SBATCH --nodes=1
5
+ #SBATCH --ntasks=1
6
+ #SBATCH --cpus-per-task=14
7
+ #SBATCH --gres=gpu:1
8
+ #SBATCH --time=01:00:00
9
+ #SBATCH --account=berzelius-2026-196
10
+ #SBATCH --chdir=/proj/cvl/users/x_fahkh2/worldmem-baseline-evals
11
+ #SBATCH --output=slurm_logs/%x-%A_%a.out
12
+ #SBATCH --error=slurm_logs/%x-%A_%a.out
13
+ set -euo pipefail
14
+ module load buildenv-gcccuda/12.9.1-gcc11
15
+ ROOT=/proj/cvl/users/x_fahkh2/worldmem-baseline-evals
16
+ PYTHON=/proj/cvl/users/x_fahkh2/envs/matrix-game2-eval/bin/python
17
+ DATA_ROOT=/proj/cvl/users/x_fahkh2/WorldMem_Repro/datasets/minecraft
18
+ MODES=(wan_oracle full_original full_weighted i2v_original i2v_weighted)
19
+ MODE=${MODES[$SLURM_ARRAY_TASK_ID]}
20
+ OUTPUT=$ROOT/Matrix-Game/Matrix-Game-2/outputs/diagnostic_${MODE}_job${SLURM_ARRAY_JOB_ID}_task${SLURM_ARRAY_TASK_ID}
21
+ export TMPDIR=$ROOT/cache
22
+ export TRITON_CACHE_DIR=$ROOT/cache
23
+ export HF_HOME=$ROOT/cache/huggingface
24
+ export TORCH_HOME=$ROOT/cache/torch
25
+ export XDG_CACHE_HOME=$ROOT/cache
26
+ export MPLCONFIGDIR=$ROOT/cache/matplotlib
27
+ export PYTHONNOUSERSITE=1 PYTHONUNBUFFERED=1 OMP_NUM_THREADS=4 MKL_NUM_THREADS=4
28
+ export WANDB_MODE=disabled HF_HUB_OFFLINE=1 TRANSFORMERS_OFFLINE=1
29
+ mkdir -p "$TMPDIR" "$OUTPUT"
30
+ "$PYTHON" "$ROOT/deployment/verify_node.py" --expected-gpus 1 --output "$OUTPUT"
31
+ cp "$0" "$OUTPUT/launcher.sh"
32
+ cp "$ROOT/deployment/diagnose_matrix_game2.py" "$OUTPUT/probe.py"
33
+ srun --ntasks=1 --gpus-per-task=1 --cpus-per-task=14 --cpu-bind=cores \
34
+ "$PYTHON" "$ROOT/deployment/diagnose_matrix_game2.py" \
35
+ --mode "$MODE" --data-root "$DATA_ROOT" --output "$OUTPUT"
results/worldmem-baseline-evals/matrix-game2/diagnostic_i2v_weighted_job85088_task4/manifest.json ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "diagnostic_only": true,
3
+ "mode": "i2v_weighted",
4
+ "checkpoint": "/proj/cvl/users/x_fahkh2/worldmem-baseline-evals/checkpoints/matrix-game2",
5
+ "weight_source": "released raw distilled",
6
+ "optimizer": null,
7
+ "lr": null,
8
+ "lora": null,
9
+ "activation_checkpointing": false,
10
+ "batch_size": 1,
11
+ "trainable_parameters": 0,
12
+ "denoising_steps": 3,
13
+ "shift": 5,
14
+ "local_attention_latents": 6,
15
+ "selector": "native sliding cache",
16
+ "reference": "raw RGB resized352x640, not benchmark Oasis references",
17
+ "targets": [
18
+ 700,
19
+ 724
20
+ ],
21
+ "full_history": [
22
+ 100,
23
+ 700
24
+ ],
25
+ "full_prefix_latents": 153,
26
+ "oracle": "9copies+RGB100:724 encodedonce;159latents; discard153latent prefix",
27
+ "i2v": {
28
+ "anchor": 699,
29
+ "decoded_slice": [
30
+ 1,
31
+ 25
32
+ ],
33
+ "controls": [
34
+ 700,
35
+ 724
36
+ ],
37
+ "right_noops": 9
38
+ },
39
+ "normalization_change": "weighted modes apply scales and accumulate RMS in fp32",
40
+ "cases": [
41
+ {
42
+ "index": "0",
43
+ "path": "test/val_plains/2/000034.mp4",
44
+ "seed": 42000000
45
+ },
46
+ {
47
+ "index": "1",
48
+ "path": "test/val_desert/1/000029.mp4",
49
+ "seed": 42000001
50
+ }
51
+ ],
52
+ "parameter_counts": {
53
+ "generator_total": 1619242304,
54
+ "generator_trainable": 0,
55
+ "vae_total": 126892531,
56
+ "clip_total": 1193014785
57
+ },
58
+ "action_norm_instances": 60
59
+ }
results/worldmem-baseline-evals/matrix-game2/diagnostic_i2v_weighted_job85088_task4/node.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "devices": [
3
+ "NVIDIA H200"
4
+ ],
5
+ "torch": "2.7.0+cu126",
6
+ "slurm_job_id": "85088"
7
+ }
results/worldmem-baseline-evals/matrix-game2/diagnostic_i2v_weighted_job85088_task4/probe.py ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Frozen Matrix diagnostics; raw-RGB PSNR is separate from benchmark scoring."""
2
+ import argparse
3
+ import json
4
+ import sys
5
+ from pathlib import Path
6
+ import torch
7
+ import torch.nn.functional as F
8
+ from PIL import Image
9
+
10
+ ROOT = Path(__file__).resolve().parents[1]
11
+ sys.path[:0] = [str(ROOT / 'shared'), str(ROOT / 'Matrix-Game/Matrix-Game-2')]
12
+ from protocol import load_minecraft_case, select_cases
13
+ from worldmem_adapter import MatrixGameAdapter, map_actions
14
+ from demo_utils.constant import ZERO_VAE_CACHE
15
+
16
+ MODES = ['wan_oracle', 'full_original', 'full_weighted', 'i2v_original', 'i2v_weighted']
17
+ parser = argparse.ArgumentParser(description=__doc__)
18
+ parser.add_argument('--mode', choices=MODES, required=True)
19
+ parser.add_argument('--data-root', type=Path, required=True)
20
+ parser.add_argument('--output', type=Path, required=True)
21
+ parser.add_argument('--dry-run', action='store_true')
22
+
23
+ def weighted_norm(self, x):
24
+ y = x.float()
25
+ return (y * torch.rsqrt(y.square().mean(-1, keepdim=True) + self.eps)).to(x.dtype) * self.weight
26
+
27
+ def save_result(output, name, prediction, reference):
28
+ prediction = prediction.float().cpu()
29
+ if prediction.shape != reference.shape or not torch.isfinite(prediction).all():
30
+ raise ValueError(f'Invalid Matrix prediction: {name}, shape={tuple(prediction.shape)}')
31
+ prediction = prediction.clamp(0, 1)
32
+ mse = (prediction - reference).square().mean((1, 2, 3))
33
+ report = {'case': name, 'raw_rgb_psnr': (-10 * mse.clamp_min(1e-12).log10()).tolist(),
34
+ 'raw_rgb_mse': mse.tolist(), 'mean_rgb': prediction.mean((1, 2, 3)).tolist()}
35
+ (output / f'{name}.json').write_text(json.dumps(report, indent=2))
36
+ grid = torch.cat([torch.cat([v[t] for t in [0, 1, 2, 5, 11, 23]], dim=2)
37
+ for v in (reference, prediction)], dim=1)
38
+ Image.fromarray(grid.mul(255).byte().permute(1, 2, 0).numpy()).save(output / f'{name}.jpg')
39
+ print(json.dumps({'case': name, 'mean_psnr': sum(report['raw_rgb_psnr']) / 24,
40
+ 'first_psnr': report['raw_rgb_psnr'][:3]}), flush=True)
41
+
42
+ @torch.inference_mode()
43
+ def main():
44
+ args = parser.parse_args()
45
+ rows = select_cases(ROOT / 'deployment/manifests/minecraft_test_300.csv', limit=2)
46
+ checkpoint = ROOT / 'checkpoints/matrix-game2'
47
+ manifest = {'diagnostic_only': True, 'mode': args.mode, 'checkpoint': str(checkpoint),
48
+ 'weight_source': 'released raw distilled', 'optimizer': None, 'lr': None, 'lora': None,
49
+ 'activation_checkpointing': False, 'batch_size': 1, 'trainable_parameters': 0,
50
+ 'denoising_steps': 3, 'shift': 5, 'local_attention_latents': 6,
51
+ 'selector': 'native sliding cache', 'reference': 'raw RGB resized352x640, not benchmark Oasis references',
52
+ 'targets': [700, 724], 'full_history': [100, 700], 'full_prefix_latents': 153,
53
+ 'oracle': '9copies+RGB100:724 encodedonce;159latents; discard153latent prefix',
54
+ 'i2v': {'anchor': 699, 'decoded_slice': [1, 25], 'controls': [700, 724], 'right_noops': 9},
55
+ 'normalization_change': 'weighted modes apply scales and accumulate RMS in fp32',
56
+ 'cases': [{'index': r['global_test_index'], 'path': r['relative_path'],
57
+ 'seed': 42000000 + int(r['global_test_index'])} for r in rows]}
58
+ if args.dry_run:
59
+ print(json.dumps(manifest, indent=2))
60
+ return
61
+ args.output.mkdir(parents=True, exist_ok=True)
62
+ (args.output / 'manifest.json').write_text(json.dumps(manifest, indent=2))
63
+ from wan.modules.action_module import WanRMSNorm
64
+ adapter = MatrixGameAdapter(checkpoint)
65
+ manifest['parameter_counts'] = adapter.parameter_counts
66
+ manifest['action_norm_instances'] = sum(isinstance(m, WanRMSNorm) for m in adapter.pipeline.modules())
67
+ (args.output / 'manifest.json').write_text(json.dumps(manifest, indent=2))
68
+ if args.mode.endswith('weighted'):
69
+ WanRMSNorm.forward = weighted_norm
70
+ for row in rows:
71
+ row.update(target_end='724', target_frames='24')
72
+ case = load_minecraft_case(row, args.data_root)
73
+ reference = F.interpolate(case['rgb'][600:624], (352, 640), mode='bilinear', align_corners=False, antialias=True)
74
+ seed = 42000000 + int(row['global_test_index'])
75
+ if args.mode == 'wan_oracle':
76
+ rgb = F.interpolate(case['rgb'].cuda(), (352, 640), mode='bilinear', align_corners=False, antialias=True)
77
+ rgb = torch.cat([rgb[:1].expand(9, -1, -1, -1), rgb])
78
+ latent = adapter.vae.encode(rgb.transpose(0, 1)[None].mul(2).sub(1).bfloat16(), device=adapter.device, tiled=False)
79
+ cache, chunks = [None] * len(ZERO_VAE_CACHE), []
80
+ for start in range(0, latent.shape[2], 3):
81
+ decoded, cache = adapter.pipeline.vae_decoder(latent[:, :, start:start + 3].transpose(1, 2).half(), *cache)
82
+ if start >= 153:
83
+ chunks.append(decoded.cpu())
84
+ prediction = torch.cat(chunks, dim=1)[0].float().add(1).div(2)
85
+ del latent, rgb, cache, decoded, chunks
86
+ elif args.mode.startswith('full'):
87
+ prediction, _ = adapter.generate(case, target_frames=24, seed=seed)
88
+ else:
89
+ torch.manual_seed(seed)
90
+ torch.cuda.manual_seed_all(seed)
91
+ anchor = F.interpolate(case['rgb'][599:600].cuda(), (352, 640), mode='bilinear', align_corners=False, antialias=True)
92
+ anchor = anchor.transpose(0, 1)[None].mul(2).sub(1).bfloat16()
93
+ image = anchor.new_zeros((1, 3, 33, 352, 640))
94
+ image[:, :, :1] = anchor
95
+ image_latents = adapter.vae.encode(image, device=adapter.device, tiled=False)
96
+ mask = torch.zeros_like(image_latents[:, :4])
97
+ mask[:, :, :1] = 1
98
+ actions = torch.cat([case['actions'][600:624], torch.zeros(9, 25)]).cuda().bfloat16()
99
+ keyboard, mouse = map_actions(actions, 1.0)
100
+ condition = {'cond_concat': torch.cat([mask, image_latents], dim=1),
101
+ 'visual_context': adapter.vae.clip.encode_video(anchor).bfloat16(),
102
+ 'keyboard_cond': keyboard[None], 'mouse_cond': mouse[None]}
103
+ noise = torch.randn((1, 16, 9, 44, 80), device='cuda', dtype=torch.bfloat16)
104
+ videos = adapter.pipeline.inference(noise, condition, initial_latent=None, mode='universal')
105
+ prediction = torch.cat(videos, dim=1)[0, 1:25].float().add(1).div(2)
106
+ del image, anchor, image_latents, condition, videos, noise
107
+ save_result(args.output, f"case{row['global_test_index']}_{args.mode}", prediction, reference)
108
+ del prediction, reference, case
109
+ (args.output / 'complete.json').write_text(json.dumps({'mode': args.mode, 'cases': 2, 'frames': 24}))
110
+ print('DIAGNOSTICS_COMPLETE', flush=True)
111
+
112
+ if __name__ == '__main__':
113
+ main()
results/worldmem-baseline-evals/matrix-game2/diagnostic_native_demo_actions_job85112_task1/case0/comparison.json ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "case": "comparison",
3
+ "raw_rgb_psnr": [
4
+ 28.761943817138672,
5
+ 24.894990921020508,
6
+ 5.066094875335693,
7
+ 6.884883880615234,
8
+ 7.142206192016602,
9
+ 7.228761196136475,
10
+ 7.280294895172119,
11
+ 7.196128845214844,
12
+ 7.207036972045898,
13
+ 7.207610130310059,
14
+ 7.2647624015808105,
15
+ 7.177729606628418,
16
+ 7.162692546844482,
17
+ 7.2452826499938965,
18
+ 7.280104637145996,
19
+ 7.2675628662109375,
20
+ 7.268505096435547,
21
+ 7.322355270385742,
22
+ 7.28434944152832,
23
+ 7.270142555236816,
24
+ 7.088680267333984,
25
+ 6.997251510620117,
26
+ 6.956180572509766,
27
+ 7.0359296798706055
28
+ ],
29
+ "raw_rgb_mse": [
30
+ 0.0013298585545271635,
31
+ 0.0032396710012108088,
32
+ 0.3114515542984009,
33
+ 0.20488570630550385,
34
+ 0.19309870898723602,
35
+ 0.18928833305835724,
36
+ 0.18705551326274872,
37
+ 0.1907159984111786,
38
+ 0.19023756682872772,
39
+ 0.19021247327327728,
40
+ 0.1877257078886032,
41
+ 0.1915256828069687,
42
+ 0.1921899914741516,
43
+ 0.18856962025165558,
44
+ 0.18706370890140533,
45
+ 0.18760469555854797,
46
+ 0.18756400048732758,
47
+ 0.18525265157222748,
48
+ 0.186880961060524,
49
+ 0.18749330937862396,
50
+ 0.19549334049224854,
51
+ 0.1996525377035141,
52
+ 0.20154961943626404,
53
+ 0.19788235425949097
54
+ ],
55
+ "mean_rgb": [
56
+ 0.7190113663673401,
57
+ 0.7229689359664917,
58
+ 0.19768567383289337,
59
+ 0.296479195356369,
60
+ 0.30714768171310425,
61
+ 0.31132906675338745,
62
+ 0.31336742639541626,
63
+ 0.3084028661251068,
64
+ 0.3105626106262207,
65
+ 0.3106946647167206,
66
+ 0.3127269446849823,
67
+ 0.3085455596446991,
68
+ 0.30667993426322937,
69
+ 0.3099704384803772,
70
+ 0.31143423914909363,
71
+ 0.31037086248397827,
72
+ 0.31108224391937256,
73
+ 0.3149312436580658,
74
+ 0.3144523501396179,
75
+ 0.31461331248283386,
76
+ 0.30496296286582947,
77
+ 0.3001496493816376,
78
+ 0.2973284423351288,
79
+ 0.30110853910446167
80
+ ]
81
+ }
results/worldmem-baseline-evals/matrix-game2/diagnostic_native_demo_actions_job85112_task1/case0/inputs.npz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:493fc4dd35246cc265ebffe2892af27a49cb3021a298008755a8cf455b536125
3
+ size 952269
results/worldmem-baseline-evals/matrix-game2/diagnostic_native_demo_actions_job85112_task1/case1/comparison.json ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "case": "comparison",
3
+ "raw_rgb_psnr": [
4
+ 19.81435775756836,
5
+ 18.266035079956055,
6
+ 17.720809936523438,
7
+ 17.051300048828125,
8
+ 17.8521785736084,
9
+ 17.96320152282715,
10
+ 17.770442962646484,
11
+ 17.66672706604004,
12
+ 17.461271286010742,
13
+ 17.219820022583008,
14
+ 17.17270851135254,
15
+ 17.01397132873535,
16
+ 16.4091739654541,
17
+ 16.703092575073242,
18
+ 17.036758422851562,
19
+ 16.95575523376465,
20
+ 16.949073791503906,
21
+ 16.948787689208984,
22
+ 16.964191436767578,
23
+ 17.009931564331055,
24
+ 16.958953857421875,
25
+ 16.964096069335938,
26
+ 16.84088134765625,
27
+ 16.837522506713867
28
+ ],
29
+ "raw_rgb_mse": [
30
+ 0.010436725802719593,
31
+ 0.014907212927937508,
32
+ 0.01690126210451126,
33
+ 0.019718321040272713,
34
+ 0.016397668048739433,
35
+ 0.01598379760980606,
36
+ 0.016709202900528908,
37
+ 0.01711304485797882,
38
+ 0.01794208399951458,
39
+ 0.018967844545841217,
40
+ 0.01917472667992115,
41
+ 0.019888538867235184,
42
+ 0.02286033146083355,
43
+ 0.021364402025938034,
44
+ 0.019784456118941307,
45
+ 0.02015693485736847,
46
+ 0.020187973976135254,
47
+ 0.020189296454191208,
48
+ 0.02011781372129917,
49
+ 0.019907046109437943,
50
+ 0.020142091438174248,
51
+ 0.020118258893489838,
52
+ 0.0206972137093544,
53
+ 0.02071322314441204
54
+ ],
55
+ "mean_rgb": [
56
+ 0.7137359976768494,
57
+ 0.7148902416229248,
58
+ 0.7157489061355591,
59
+ 0.7161552906036377,
60
+ 0.713788628578186,
61
+ 0.7127888202667236,
62
+ 0.7122524976730347,
63
+ 0.7112450003623962,
64
+ 0.7104371786117554,
65
+ 0.7100856900215149,
66
+ 0.7079524397850037,
67
+ 0.7049611210823059,
68
+ 0.700785756111145,
69
+ 0.7041963934898376,
70
+ 0.7078825831413269,
71
+ 0.7077915668487549,
72
+ 0.7052977085113525,
73
+ 0.7040800452232361,
74
+ 0.7037867903709412,
75
+ 0.7034406065940857,
76
+ 0.7064051628112793,
77
+ 0.7068390846252441,
78
+ 0.7078206539154053,
79
+ 0.7080984115600586
80
+ ]
81
+ }
results/worldmem-baseline-evals/matrix-game2/diagnostic_native_demo_actions_job85112_task1/case1/inputs.npz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:000846f182a7383bde76fede303b37ca054efd047e17d6f941aeb95bd24cb7e5
3
+ size 951982
results/worldmem-baseline-evals/matrix-game2/diagnostic_native_demo_actions_job85112_task1/complete.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"mode": "demo_actions", "complete": true}
results/worldmem-baseline-evals/matrix-game2/diagnostic_native_demo_actions_job85112_task1/inference.py ADDED
@@ -0,0 +1,169 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import argparse
3
+ import torch
4
+ import numpy as np
5
+
6
+ from omegaconf import OmegaConf
7
+ from torchvision.transforms import v2
8
+ from diffusers.utils import load_image
9
+ from einops import rearrange
10
+ from pipeline import CausalInferencePipeline
11
+ from wan.vae.wanx_vae import get_wanx_vae_wrapper
12
+ from demo_utils.vae_block3 import VAEDecoderWrapper
13
+ from utils.visualize import process_video
14
+ from utils.misc import set_seed
15
+ from utils.conditions import *
16
+ from utils.wan_wrapper import WanDiffusionWrapper
17
+ from safetensors.torch import load_file
18
+
19
+ def parse_args():
20
+ parser = argparse.ArgumentParser()
21
+ parser.add_argument("--config_path", type=str, default="configs/inference_yaml/inference_universal.yaml", help="Path to the config file")
22
+ parser.add_argument("--checkpoint_path", type=str, default="", help="Path to the checkpoint")
23
+ parser.add_argument("--img_path", type=str, default="demo_images/universal/0000.png", help="Path to the image")
24
+ parser.add_argument("--output_folder", type=str, default="outputs/", help="Output folder")
25
+ parser.add_argument("--num_output_frames", type=int, default=150,
26
+ help="Number of output latent frames")
27
+ parser.add_argument("--seed", type=int, default=0, help="Random seed")
28
+ parser.add_argument("--pretrained_model_path", type=str, default="Matrix-Game-2.0", help="Path to the VAE model folder")
29
+ args = parser.parse_args()
30
+ return args
31
+
32
+ class InteractiveGameInference:
33
+ def __init__(self, args):
34
+ self.args = args
35
+ self.device = torch.device("cuda")
36
+ self.weight_dtype = torch.bfloat16
37
+
38
+ self._init_config()
39
+ self._init_models()
40
+
41
+ self.frame_process = v2.Compose([
42
+ v2.Resize(size=(352, 640), antialias=True),
43
+ v2.ToTensor(),
44
+ v2.Normalize(mean=[0.5, 0.5, 0.5], std=[0.5, 0.5, 0.5]),
45
+ ])
46
+
47
+ def _init_config(self):
48
+ self.config = OmegaConf.load(self.args.config_path)
49
+
50
+ def _init_models(self):
51
+ # Initialize pipeline
52
+ generator = WanDiffusionWrapper(
53
+ **getattr(self.config, "model_kwargs", {}), is_causal=True)
54
+ current_vae_decoder = VAEDecoderWrapper()
55
+ vae_state_dict = torch.load(os.path.join(self.args.pretrained_model_path, "Wan2.1_VAE.pth"), map_location="cpu")
56
+ decoder_state_dict = {}
57
+ for key, value in vae_state_dict.items():
58
+ if 'decoder.' in key or 'conv2' in key:
59
+ decoder_state_dict[key] = value
60
+ current_vae_decoder.load_state_dict(decoder_state_dict)
61
+ current_vae_decoder.to(self.device, torch.float16)
62
+ current_vae_decoder.requires_grad_(False)
63
+ current_vae_decoder.eval()
64
+ current_vae_decoder.compile(mode="max-autotune-no-cudagraphs")
65
+ pipeline = CausalInferencePipeline(self.config, generator=generator, vae_decoder=current_vae_decoder)
66
+ if self.args.checkpoint_path:
67
+ print("Loading Pretrained Model...")
68
+ state_dict = load_file(self.args.checkpoint_path)
69
+ pipeline.generator.load_state_dict(state_dict)
70
+
71
+ self.pipeline = pipeline.to(device=self.device, dtype=self.weight_dtype)
72
+ self.pipeline.vae_decoder.to(torch.float16)
73
+
74
+ vae = get_wanx_vae_wrapper(self.args.pretrained_model_path, torch.float16)
75
+ vae.requires_grad_(False)
76
+ vae.eval()
77
+ self.vae = vae.to(self.device, self.weight_dtype)
78
+
79
+ def _resizecrop(self, image, th, tw):
80
+ w, h = image.size
81
+ if h / w > th / tw:
82
+ new_w = int(w)
83
+ new_h = int(new_w * th / tw)
84
+ else:
85
+ new_h = int(h)
86
+ new_w = int(new_h * tw / th)
87
+ left = (w - new_w) / 2
88
+ top = (h - new_h) / 2
89
+ right = (w + new_w) / 2
90
+ bottom = (h + new_h) / 2
91
+ image = image.crop((left, top, right, bottom))
92
+ return image
93
+
94
+ def generate_videos(self):
95
+ mode = self.config.pop('mode')
96
+ assert mode in ['universal', 'gta_drive', 'templerun']
97
+
98
+ image = load_image(self.args.img_path)
99
+ image = self._resizecrop(image, 352, 640)
100
+ image = self.frame_process(image)[None, :, None, :, :].to(dtype=self.weight_dtype, device=self.device)
101
+ # Encode the input image as the first latent
102
+ padding_video = torch.zeros_like(image).repeat(1, 1, 4 * (self.args.num_output_frames - 1), 1, 1)
103
+ img_cond = torch.concat([image, padding_video], dim=2)
104
+ tiler_kwargs={"tiled": True, "tile_size": [44, 80], "tile_stride": [23, 38]}
105
+ img_cond = self.vae.encode(img_cond, device=self.device, **tiler_kwargs).to(self.device)
106
+ mask_cond = torch.ones_like(img_cond)
107
+ mask_cond[:, :, 1:] = 0
108
+ cond_concat = torch.cat([mask_cond[:, :4], img_cond], dim=1)
109
+ visual_context = self.vae.clip.encode_video(image)
110
+ sampled_noise = torch.randn(
111
+ [1, 16,self.args.num_output_frames, 44, 80], device=self.device, dtype=self.weight_dtype
112
+ )
113
+ num_frames = (self.args.num_output_frames - 1) * 4 + 1
114
+
115
+ conditional_dict = {
116
+ "cond_concat": cond_concat.to(device=self.device, dtype=self.weight_dtype),
117
+ "visual_context": visual_context.to(device=self.device, dtype=self.weight_dtype)
118
+ }
119
+
120
+ if mode == 'universal':
121
+ cond_data = Bench_actions_universal(num_frames)
122
+ mouse_condition = cond_data['mouse_condition'].unsqueeze(0).to(device=self.device, dtype=self.weight_dtype)
123
+ conditional_dict['mouse_cond'] = mouse_condition
124
+ elif mode == 'gta_drive':
125
+ cond_data = Bench_actions_gta_drive(num_frames)
126
+ mouse_condition = cond_data['mouse_condition'].unsqueeze(0).to(device=self.device, dtype=self.weight_dtype)
127
+ conditional_dict['mouse_cond'] = mouse_condition
128
+ else:
129
+ cond_data = Bench_actions_templerun(num_frames)
130
+ keyboard_condition = cond_data['keyboard_condition'].unsqueeze(0).to(device=self.device, dtype=self.weight_dtype)
131
+ conditional_dict['keyboard_cond'] = keyboard_condition
132
+
133
+ with torch.no_grad():
134
+ videos = self.pipeline.inference(
135
+ noise=sampled_noise,
136
+ conditional_dict=conditional_dict,
137
+ return_latents=False,
138
+ mode=mode,
139
+ profile=False
140
+ )
141
+
142
+ videos_tensor = torch.cat(videos, dim=1)
143
+ videos = rearrange(videos_tensor, "B T C H W -> B T H W C")
144
+ videos = ((videos.float() + 1) * 127.5).clip(0, 255).cpu().numpy().astype(np.uint8)[0]
145
+ video = np.ascontiguousarray(videos)
146
+ mouse_icon = 'assets/images/mouse.png'
147
+ if mode != 'templerun':
148
+ config = (
149
+ keyboard_condition[0].float().cpu().numpy(),
150
+ mouse_condition[0].float().cpu().numpy()
151
+ )
152
+ else:
153
+ config = (
154
+ keyboard_condition[0].float().cpu().numpy()
155
+ )
156
+ process_video(video.astype(np.uint8), self.args.output_folder+f'/demo.mp4', config, mouse_icon, mouse_scale=0.1, process_icon=False, mode=mode)
157
+ process_video(video.astype(np.uint8), self.args.output_folder+f'/demo_icon.mp4', config, mouse_icon, mouse_scale=0.1, process_icon=True, mode=mode)
158
+ print("Done")
159
+
160
+ def main():
161
+ """Main entry point for video generation."""
162
+ args = parse_args()
163
+ set_seed(args.seed)
164
+ os.makedirs(args.output_folder, exist_ok=True)
165
+ pipeline = InteractiveGameInference(args)
166
+ pipeline.generate_videos()
167
+
168
+ if __name__ == "__main__":
169
+ main()
results/worldmem-baseline-evals/matrix-game2/diagnostic_native_demo_actions_job85112_task1/inference_universal.yaml ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ denoising_step_list:
2
+ - 1000
3
+ - 666
4
+ - 333
5
+ warp_denoising_step: true
6
+ ts_schedule: false
7
+ mixed_precision: true
8
+ seed: 42
9
+ image_or_video_shape:
10
+ - 1
11
+ - 16
12
+ - 15
13
+ - 44
14
+ - 80
15
+ num_frame_per_block: 3
16
+ context_noise: 0
17
+ mode: universal
18
+ causal: true
19
+ model_kwargs:
20
+ timestep_shift: 5.0
21
+ model_config: configs/distilled_model/universal
results/worldmem-baseline-evals/matrix-game2/diagnostic_native_demo_actions_job85112_task1/launcher.sh ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ #SBATCH --job-name=matrix-game2-native-control
3
+ #SBATCH --array=0-4
4
+ #SBATCH --nodes=1
5
+ #SBATCH --ntasks=1
6
+ #SBATCH --cpus-per-task=14
7
+ #SBATCH --gres=gpu:1
8
+ #SBATCH --time=02:00:00
9
+ #SBATCH --account=berzelius-2026-196
10
+ #SBATCH --chdir=/proj/cvl/users/x_fahkh2/worldmem-baseline-evals
11
+ #SBATCH --output=slurm_logs/%x-%A_%a.out
12
+ #SBATCH --error=slurm_logs/%x-%A_%a.out
13
+ set -euo pipefail
14
+ module load buildenv-gcccuda/12.9.1-gcc11
15
+ ROOT=/proj/cvl/users/x_fahkh2/worldmem-baseline-evals
16
+ PYTHON=/proj/cvl/users/x_fahkh2/envs/matrix-game2-eval/bin/python
17
+ DATA_ROOT=/proj/cvl/users/x_fahkh2/WorldMem_Repro/datasets/minecraft
18
+ MODES=(official_demo demo_actions neutral recorded small_mouse)
19
+ MODE=${MODES[$SLURM_ARRAY_TASK_ID]}
20
+ OUTPUT=$ROOT/Matrix-Game/Matrix-Game-2/outputs/diagnostic_native_${MODE}_job${SLURM_ARRAY_JOB_ID}_task${SLURM_ARRAY_TASK_ID}
21
+ export TMPDIR=$ROOT/cache
22
+ export TRITON_CACHE_DIR=$ROOT/cache
23
+ export TORCHINDUCTOR_CACHE_DIR=$ROOT/cache/torchinductor
24
+ export HF_HOME=$ROOT/cache/huggingface
25
+ export TORCH_HOME=$ROOT/cache/torch
26
+ export XDG_CACHE_HOME=$ROOT/cache
27
+ export MPLCONFIGDIR=$ROOT/cache/matplotlib
28
+ export PYTHONPATH=$ROOT/Matrix-Game/Matrix-Game-2
29
+ export PYTHONNOUSERSITE=1 PYTHONUNBUFFERED=1 OMP_NUM_THREADS=4 MKL_NUM_THREADS=4
30
+ export WANDB_MODE=disabled HF_HUB_OFFLINE=1 TRANSFORMERS_OFFLINE=1
31
+ mkdir -p "$TMPDIR" "$TORCHINDUCTOR_CACHE_DIR" "$OUTPUT"
32
+ "$PYTHON" "$ROOT/deployment/verify_node.py" --expected-gpus 1 --output "$OUTPUT"
33
+ cp "$0" "$OUTPUT/launcher.sh"
34
+ cp "$ROOT/deployment/matrix_native_controls.py" "$OUTPUT/probe.py"
35
+ cp "$ROOT/Matrix-Game/Matrix-Game-2/inference.py" "$ROOT/Matrix-Game/Matrix-Game-2/configs/inference_yaml/inference_universal.yaml" "$OUTPUT/"
36
+ srun --ntasks=1 --gpus-per-task=1 --cpus-per-task=14 --cpu-bind=cores \
37
+ "$PYTHON" "$ROOT/deployment/matrix_native_controls.py" \
38
+ --mode "$MODE" --data-root "$DATA_ROOT" --output "$OUTPUT"
results/worldmem-baseline-evals/matrix-game2/diagnostic_native_demo_actions_job85112_task1/manifest.json ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "mode": "demo_actions",
3
+ "diagnostic_only": true,
4
+ "checkpoint": "/proj/cvl/users/x_fahkh2/worldmem-baseline-evals/checkpoints/matrix-game2",
5
+ "upstream_revision": "71c3cd7f741311f8100f6cf9cde942b6c1378d11",
6
+ "weight_policy": "released raw distilled; original normalization; no optimizer or updates",
7
+ "expected_generator_parameters": 1619242304,
8
+ "expected_vae_parameters": 126892531,
9
+ "expected_clip_parameters": 1193014785,
10
+ "batch_size": 1,
11
+ "lora": null,
12
+ "lr": null,
13
+ "activation_checkpointing": false,
14
+ "steps": 3,
15
+ "shift": 5,
16
+ "cache_latents": 6,
17
+ "decoder": "official compiled max-autotune-no-cudagraphs",
18
+ "official_demo": "unchanged inference.py; supplied painting0000.png; seed0;150latents=597RGB",
19
+ "minecraft": {
20
+ "anchor": 699,
21
+ "native_latents": 9,
22
+ "native_rgb": 33,
23
+ "scored_slice": [
24
+ 1,
25
+ 25
26
+ ],
27
+ "targets": [
28
+ 700,
29
+ 724
30
+ ],
31
+ "recorded_control_alignment": "incoming700:724 plus9noops; small_mouse scales camera only",
32
+ "reference": "rawRGB with official center crop and frame_process"
33
+ },
34
+ "score_caveat": "Only recorded controls replay GT actions; other modes test stability, not benchmark accuracy",
35
+ "cases": [
36
+ {
37
+ "index": "0",
38
+ "path": "test/val_plains/2/000034.mp4",
39
+ "seed": 42000000
40
+ },
41
+ {
42
+ "index": "1",
43
+ "path": "test/val_desert/1/000029.mp4",
44
+ "seed": 42000001
45
+ }
46
+ ],
47
+ "output_frames_per_case": 33,
48
+ "generator_requires_grad_parameters": 1619242304,
49
+ "inference_grad_policy": "unchanged native no_grad; parameter flags unmodified"
50
+ }
results/worldmem-baseline-evals/matrix-game2/diagnostic_native_demo_actions_job85112_task1/node.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "devices": [
3
+ "NVIDIA H200"
4
+ ],
5
+ "torch": "2.7.0+cu126",
6
+ "slurm_job_id": "85114"
7
+ }
results/worldmem-baseline-evals/matrix-game2/diagnostic_native_demo_actions_job85112_task1/probe.py ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Official Matrix demo and native-image controls; all scores are diagnostic."""
2
+ import argparse
3
+ import json
4
+ import os
5
+ import subprocess
6
+ import sys
7
+ from pathlib import Path
8
+ import numpy as np
9
+ import torch
10
+ from PIL import Image
11
+ from diagnose_matrix_game2 import save_result
12
+ from protocol import minecraft_actions, read_frames, select_cases
13
+ from worldmem_adapter import map_actions
14
+
15
+ ROOT = Path(__file__).resolve().parents[1]
16
+ REPO = ROOT / 'Matrix-Game/Matrix-Game-2'
17
+ MODES = ['official_demo', 'demo_actions', 'neutral', 'recorded', 'small_mouse']
18
+
19
+ def replay_controls(raw, mode, length):
20
+ keyboard, mouse = map_actions(minecraft_actions(raw), 1.0)
21
+ keys, turns = torch.zeros(length, 4), torch.zeros(length, 2)
22
+ if mode != 'neutral':
23
+ keys[:24], turns[:24] = keyboard, mouse * (0.1 if mode == 'small_mouse' else 1.0)
24
+ return {'keyboard_condition': keys, 'mouse_condition': turns}
25
+
26
+ def main():
27
+ parser = argparse.ArgumentParser(description=__doc__)
28
+ parser.add_argument('--mode', choices=MODES, required=True)
29
+ parser.add_argument('--data-root', type=Path, required=True)
30
+ parser.add_argument('--output', type=Path, required=True)
31
+ parser.add_argument('--dry-run', action='store_true')
32
+ args = parser.parse_args()
33
+ checkpoint = ROOT / 'checkpoints/matrix-game2'
34
+ rows = select_cases(ROOT / 'deployment/manifests/minecraft_test_300.csv', limit=2)
35
+ manifest = {'mode': args.mode, 'diagnostic_only': True, 'checkpoint': str(checkpoint),
36
+ 'upstream_revision': '71c3cd7f741311f8100f6cf9cde942b6c1378d11',
37
+ 'weight_policy': 'released raw distilled; original normalization; no optimizer or updates',
38
+ 'expected_generator_parameters': 1619242304, 'expected_vae_parameters': 126892531,
39
+ 'expected_clip_parameters': 1193014785, 'batch_size': 1, 'lora': None, 'lr': None,
40
+ 'activation_checkpointing': False, 'steps': 3, 'shift': 5, 'cache_latents': 6,
41
+ 'decoder': 'official compiled max-autotune-no-cudagraphs',
42
+ 'official_demo': 'unchanged inference.py; supplied painting0000.png; seed0;150latents=597RGB',
43
+ 'minecraft': {'anchor': 699, 'native_latents': 9, 'native_rgb': 33, 'scored_slice': [1, 25],
44
+ 'targets': [700, 724], 'recorded_control_alignment': 'incoming700:724 plus9noops; small_mouse scales camera only',
45
+ 'reference': 'rawRGB with official center crop and frame_process'},
46
+ 'score_caveat': 'Only recorded controls replay GT actions; other modes test stability, not benchmark accuracy',
47
+ 'cases': ([{'image': 'demo_images/universal/0000.png', 'seed': 0}] if args.mode == 'official_demo'
48
+ else [{'index': r['global_test_index'], 'path': r['relative_path'],
49
+ 'seed': 42000000 + int(r['global_test_index'])} for r in rows]),
50
+ 'output_frames_per_case': 597 if args.mode == 'official_demo' else 33}
51
+ if args.dry_run:
52
+ print(json.dumps(manifest, indent=2))
53
+ return
54
+ args.output.mkdir(parents=True, exist_ok=True)
55
+ (args.output / 'manifest.json').write_text(json.dumps(manifest, indent=2))
56
+ os.chdir(REPO)
57
+ if args.mode == 'official_demo':
58
+ subprocess.run([sys.executable, 'inference.py', '--checkpoint_path', str(checkpoint / 'base_distilled_model/base_distill.safetensors'),
59
+ '--pretrained_model_path', str(checkpoint), '--img_path', 'demo_images/universal/0000.png',
60
+ '--config_path', 'configs/inference_yaml/inference_universal.yaml', '--seed', '0',
61
+ '--num_output_frames', '150', '--output_folder', str(args.output)], check=True)
62
+ from torchvision.io import read_video
63
+ video, _, _ = read_video(str(args.output / 'demo.mp4'), pts_unit='sec')
64
+ assert len(video) == 597
65
+ Image.fromarray(torch.cat([video[t] for t in [0, 1, 2, 24, 100, 596]], dim=1).numpy()).save(args.output / 'samples.jpg')
66
+ else:
67
+ import inference as native
68
+ native.set_seed(0)
69
+ model_args = argparse.Namespace(config_path='configs/inference_yaml/inference_universal.yaml',
70
+ checkpoint_path=str(checkpoint / 'base_distilled_model/base_distill.safetensors'),
71
+ pretrained_model_path=str(checkpoint), num_output_frames=9, seed=0, img_path='', output_folder='')
72
+ engine = native.InteractiveGameInference(model_args)
73
+ manifest['generator_requires_grad_parameters'] = sum(p.numel() for p in engine.pipeline.generator.parameters() if p.requires_grad)
74
+ manifest['inference_grad_policy'] = 'unchanged native no_grad; parameter flags unmodified'
75
+ (args.output / 'manifest.json').write_text(json.dumps(manifest, indent=2))
76
+ original_inference, native_controls = engine.pipeline.inference, native.Bench_actions_universal
77
+ captured = {}
78
+ def capture(**kwargs):
79
+ condition = kwargs['conditional_dict']
80
+ np.savez_compressed(case_dir / 'inputs.npz', initial_noise=kwargs['noise'].float().cpu().numpy(),
81
+ keyboard=condition['keyboard_cond'][0].float().cpu().numpy(), mouse=condition['mouse_cond'][0].float().cpu().numpy())
82
+ videos = original_inference(**kwargs)
83
+ captured['prediction'] = torch.cat(videos, dim=1)[0, 1:25].detach().float().cpu().add(1).div(2)
84
+ return videos
85
+ engine.pipeline.inference = capture
86
+ for row in rows:
87
+ case_dir = args.output / f"case{row['global_test_index']}"
88
+ case_dir.mkdir(exist_ok=True)
89
+ path = args.data_root / row['relative_path']
90
+ rgb = read_frames(path, torch.arange(699, 724))
91
+ images = [Image.fromarray(frame.mul(255).round().byte().permute(1, 2, 0).numpy()) for frame in rgb]
92
+ images[0].save(case_dir / 'input.png')
93
+ reference = torch.stack([engine.frame_process(engine._resizecrop(im, 352, 640)).add(1).div(2) for im in images[1:]])
94
+ with np.load(path.with_suffix('.npz')) as annotation:
95
+ controls = replay_controls(annotation['actions'][700:724], args.mode, 33)
96
+ native.Bench_actions_universal = native_controls if args.mode == 'demo_actions' else lambda length: controls
97
+ model_args.img_path, model_args.output_folder = str(case_dir / 'input.png'), str(case_dir)
98
+ engine.config['mode'] = 'universal'
99
+ native.set_seed(42000000 + int(row['global_test_index']))
100
+ engine.generate_videos()
101
+ save_result(case_dir, 'comparison', captured.pop('prediction'), reference)
102
+ (args.output / 'complete.json').write_text(json.dumps({'mode': args.mode, 'complete': True}))
103
+ print('NATIVE_CONTROL_COMPLETE', flush=True)
104
+
105
+ if __name__ == '__main__':
106
+ main()
results/worldmem-baseline-evals/matrix-game2/diagnostic_native_neutral_job85112_task2/case0/comparison.json ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "case": "comparison",
3
+ "raw_rgb_psnr": [
4
+ 29.00463104248047,
5
+ 25.083839416503906,
6
+ 5.1293206214904785,
7
+ 7.163086891174316,
8
+ 7.246057510375977,
9
+ 7.313009262084961,
10
+ 7.356295585632324,
11
+ 7.3129777908325195,
12
+ 7.402219772338867,
13
+ 7.4208784103393555,
14
+ 7.457307815551758,
15
+ 7.469139099121094,
16
+ 7.432450771331787,
17
+ 7.4313764572143555,
18
+ 7.441709518432617,
19
+ 7.446588516235352,
20
+ 7.415165901184082,
21
+ 7.416438579559326,
22
+ 7.437826156616211,
23
+ 7.455380439758301,
24
+ 7.600482940673828,
25
+ 7.668927192687988,
26
+ 7.7082390785217285,
27
+ 7.726196765899658
28
+ ],
29
+ "raw_rgb_mse": [
30
+ 0.0012575836153700948,
31
+ 0.0031018152367323637,
32
+ 0.3069502115249634,
33
+ 0.19217252731323242,
34
+ 0.18853598833084106,
35
+ 0.1856517493724823,
36
+ 0.1838105469942093,
37
+ 0.18565309047698975,
38
+ 0.18187710642814636,
39
+ 0.1810973733663559,
40
+ 0.17958466708660126,
41
+ 0.1790960729122162,
42
+ 0.18061546981334686,
43
+ 0.18066012859344482,
44
+ 0.18023081123828888,
45
+ 0.18002846837043762,
46
+ 0.18133574724197388,
47
+ 0.1812826246023178,
48
+ 0.1803920418024063,
49
+ 0.17966437339782715,
50
+ 0.1737607717514038,
51
+ 0.1710437834262848,
52
+ 0.16950249671936035,
53
+ 0.16880306601524353
54
+ ],
55
+ "mean_rgb": [
56
+ 0.71062171459198,
57
+ 0.712151288986206,
58
+ 0.20236869156360626,
59
+ 0.3093110918998718,
60
+ 0.31275486946105957,
61
+ 0.316022664308548,
62
+ 0.31764835119247437,
63
+ 0.31517931818962097,
64
+ 0.31939250230789185,
65
+ 0.32033178210258484,
66
+ 0.32227084040641785,
67
+ 0.3230479955673218,
68
+ 0.32040339708328247,
69
+ 0.31977322697639465,
70
+ 0.3199549615383148,
71
+ 0.32007846236228943,
72
+ 0.31954720616340637,
73
+ 0.32010453939437866,
74
+ 0.3214494287967682,
75
+ 0.3225550353527069,
76
+ 0.3296678364276886,
77
+ 0.33288630843162537,
78
+ 0.33478885889053345,
79
+ 0.3357396125793457
80
+ ]
81
+ }
results/worldmem-baseline-evals/matrix-game2/diagnostic_native_neutral_job85112_task2/case0/inputs.npz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1fe3a1516baaadafaf55d193a12a989c649b2c01bf0cfe6a68446be845073ec3
3
+ size 952253
results/worldmem-baseline-evals/matrix-game2/diagnostic_native_neutral_job85112_task2/case1/comparison.json ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "case": "comparison",
3
+ "raw_rgb_psnr": [
4
+ 20.059900283813477,
5
+ 18.597415924072266,
6
+ 18.113113403320312,
7
+ 17.338909149169922,
8
+ 18.3916072845459,
9
+ 18.688901901245117,
10
+ 18.53306007385254,
11
+ 18.357519149780273,
12
+ 18.232343673706055,
13
+ 18.186416625976562,
14
+ 18.135757446289062,
15
+ 18.113117218017578,
16
+ 18.16193389892578,
17
+ 18.166234970092773,
18
+ 18.167783737182617,
19
+ 18.165790557861328,
20
+ 18.197973251342773,
21
+ 18.205169677734375,
22
+ 18.255691528320312,
23
+ 18.27703285217285,
24
+ 18.182619094848633,
25
+ 18.162242889404297,
26
+ 18.10346794128418,
27
+ 18.056255340576172
28
+ ],
29
+ "raw_rgb_mse": [
30
+ 0.009863022714853287,
31
+ 0.013812059536576271,
32
+ 0.015441467985510826,
33
+ 0.018454786390066147,
34
+ 0.01448235847055912,
35
+ 0.013524146750569344,
36
+ 0.014018258079886436,
37
+ 0.014596477150917053,
38
+ 0.015023309737443924,
39
+ 0.015183024108409882,
40
+ 0.015361170284450054,
41
+ 0.01544145680963993,
42
+ 0.015268862247467041,
43
+ 0.015253743156790733,
44
+ 0.015248307026922703,
45
+ 0.015255306847393513,
46
+ 0.015142681077122688,
47
+ 0.015117603354156017,
48
+ 0.01494276151061058,
49
+ 0.014869509264826775,
50
+ 0.015196304768323898,
51
+ 0.015267775394022465,
52
+ 0.0154758021235466,
53
+ 0.01564495824277401
54
+ ],
55
+ "mean_rgb": [
56
+ 0.7140963077545166,
57
+ 0.7141072154045105,
58
+ 0.7137575149536133,
59
+ 0.7141113877296448,
60
+ 0.7121320366859436,
61
+ 0.7116583585739136,
62
+ 0.7107756733894348,
63
+ 0.7105647325515747,
64
+ 0.7109081149101257,
65
+ 0.711028516292572,
66
+ 0.7102257609367371,
67
+ 0.7101965546607971,
68
+ 0.7101762294769287,
69
+ 0.7103557586669922,
70
+ 0.7101123332977295,
71
+ 0.7103460431098938,
72
+ 0.7076926827430725,
73
+ 0.7064762115478516,
74
+ 0.7051817178726196,
75
+ 0.7046799063682556,
76
+ 0.7081876993179321,
77
+ 0.7094244956970215,
78
+ 0.7100866436958313,
79
+ 0.7104617953300476
80
+ ]
81
+ }
results/worldmem-baseline-evals/matrix-game2/diagnostic_native_neutral_job85112_task2/case1/inputs.npz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:95cf1a93c298840e6226640ffa742607ab41f4aee3b1b5ae60a50691a67e83bd
3
+ size 951965
results/worldmem-baseline-evals/matrix-game2/diagnostic_native_neutral_job85112_task2/complete.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"mode": "neutral", "complete": true}
results/worldmem-baseline-evals/matrix-game2/diagnostic_native_neutral_job85112_task2/inference.py ADDED
@@ -0,0 +1,169 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import argparse
3
+ import torch
4
+ import numpy as np
5
+
6
+ from omegaconf import OmegaConf
7
+ from torchvision.transforms import v2
8
+ from diffusers.utils import load_image
9
+ from einops import rearrange
10
+ from pipeline import CausalInferencePipeline
11
+ from wan.vae.wanx_vae import get_wanx_vae_wrapper
12
+ from demo_utils.vae_block3 import VAEDecoderWrapper
13
+ from utils.visualize import process_video
14
+ from utils.misc import set_seed
15
+ from utils.conditions import *
16
+ from utils.wan_wrapper import WanDiffusionWrapper
17
+ from safetensors.torch import load_file
18
+
19
+ def parse_args():
20
+ parser = argparse.ArgumentParser()
21
+ parser.add_argument("--config_path", type=str, default="configs/inference_yaml/inference_universal.yaml", help="Path to the config file")
22
+ parser.add_argument("--checkpoint_path", type=str, default="", help="Path to the checkpoint")
23
+ parser.add_argument("--img_path", type=str, default="demo_images/universal/0000.png", help="Path to the image")
24
+ parser.add_argument("--output_folder", type=str, default="outputs/", help="Output folder")
25
+ parser.add_argument("--num_output_frames", type=int, default=150,
26
+ help="Number of output latent frames")
27
+ parser.add_argument("--seed", type=int, default=0, help="Random seed")
28
+ parser.add_argument("--pretrained_model_path", type=str, default="Matrix-Game-2.0", help="Path to the VAE model folder")
29
+ args = parser.parse_args()
30
+ return args
31
+
32
+ class InteractiveGameInference:
33
+ def __init__(self, args):
34
+ self.args = args
35
+ self.device = torch.device("cuda")
36
+ self.weight_dtype = torch.bfloat16
37
+
38
+ self._init_config()
39
+ self._init_models()
40
+
41
+ self.frame_process = v2.Compose([
42
+ v2.Resize(size=(352, 640), antialias=True),
43
+ v2.ToTensor(),
44
+ v2.Normalize(mean=[0.5, 0.5, 0.5], std=[0.5, 0.5, 0.5]),
45
+ ])
46
+
47
+ def _init_config(self):
48
+ self.config = OmegaConf.load(self.args.config_path)
49
+
50
+ def _init_models(self):
51
+ # Initialize pipeline
52
+ generator = WanDiffusionWrapper(
53
+ **getattr(self.config, "model_kwargs", {}), is_causal=True)
54
+ current_vae_decoder = VAEDecoderWrapper()
55
+ vae_state_dict = torch.load(os.path.join(self.args.pretrained_model_path, "Wan2.1_VAE.pth"), map_location="cpu")
56
+ decoder_state_dict = {}
57
+ for key, value in vae_state_dict.items():
58
+ if 'decoder.' in key or 'conv2' in key:
59
+ decoder_state_dict[key] = value
60
+ current_vae_decoder.load_state_dict(decoder_state_dict)
61
+ current_vae_decoder.to(self.device, torch.float16)
62
+ current_vae_decoder.requires_grad_(False)
63
+ current_vae_decoder.eval()
64
+ current_vae_decoder.compile(mode="max-autotune-no-cudagraphs")
65
+ pipeline = CausalInferencePipeline(self.config, generator=generator, vae_decoder=current_vae_decoder)
66
+ if self.args.checkpoint_path:
67
+ print("Loading Pretrained Model...")
68
+ state_dict = load_file(self.args.checkpoint_path)
69
+ pipeline.generator.load_state_dict(state_dict)
70
+
71
+ self.pipeline = pipeline.to(device=self.device, dtype=self.weight_dtype)
72
+ self.pipeline.vae_decoder.to(torch.float16)
73
+
74
+ vae = get_wanx_vae_wrapper(self.args.pretrained_model_path, torch.float16)
75
+ vae.requires_grad_(False)
76
+ vae.eval()
77
+ self.vae = vae.to(self.device, self.weight_dtype)
78
+
79
+ def _resizecrop(self, image, th, tw):
80
+ w, h = image.size
81
+ if h / w > th / tw:
82
+ new_w = int(w)
83
+ new_h = int(new_w * th / tw)
84
+ else:
85
+ new_h = int(h)
86
+ new_w = int(new_h * tw / th)
87
+ left = (w - new_w) / 2
88
+ top = (h - new_h) / 2
89
+ right = (w + new_w) / 2
90
+ bottom = (h + new_h) / 2
91
+ image = image.crop((left, top, right, bottom))
92
+ return image
93
+
94
+ def generate_videos(self):
95
+ mode = self.config.pop('mode')
96
+ assert mode in ['universal', 'gta_drive', 'templerun']
97
+
98
+ image = load_image(self.args.img_path)
99
+ image = self._resizecrop(image, 352, 640)
100
+ image = self.frame_process(image)[None, :, None, :, :].to(dtype=self.weight_dtype, device=self.device)
101
+ # Encode the input image as the first latent
102
+ padding_video = torch.zeros_like(image).repeat(1, 1, 4 * (self.args.num_output_frames - 1), 1, 1)
103
+ img_cond = torch.concat([image, padding_video], dim=2)
104
+ tiler_kwargs={"tiled": True, "tile_size": [44, 80], "tile_stride": [23, 38]}
105
+ img_cond = self.vae.encode(img_cond, device=self.device, **tiler_kwargs).to(self.device)
106
+ mask_cond = torch.ones_like(img_cond)
107
+ mask_cond[:, :, 1:] = 0
108
+ cond_concat = torch.cat([mask_cond[:, :4], img_cond], dim=1)
109
+ visual_context = self.vae.clip.encode_video(image)
110
+ sampled_noise = torch.randn(
111
+ [1, 16,self.args.num_output_frames, 44, 80], device=self.device, dtype=self.weight_dtype
112
+ )
113
+ num_frames = (self.args.num_output_frames - 1) * 4 + 1
114
+
115
+ conditional_dict = {
116
+ "cond_concat": cond_concat.to(device=self.device, dtype=self.weight_dtype),
117
+ "visual_context": visual_context.to(device=self.device, dtype=self.weight_dtype)
118
+ }
119
+
120
+ if mode == 'universal':
121
+ cond_data = Bench_actions_universal(num_frames)
122
+ mouse_condition = cond_data['mouse_condition'].unsqueeze(0).to(device=self.device, dtype=self.weight_dtype)
123
+ conditional_dict['mouse_cond'] = mouse_condition
124
+ elif mode == 'gta_drive':
125
+ cond_data = Bench_actions_gta_drive(num_frames)
126
+ mouse_condition = cond_data['mouse_condition'].unsqueeze(0).to(device=self.device, dtype=self.weight_dtype)
127
+ conditional_dict['mouse_cond'] = mouse_condition
128
+ else:
129
+ cond_data = Bench_actions_templerun(num_frames)
130
+ keyboard_condition = cond_data['keyboard_condition'].unsqueeze(0).to(device=self.device, dtype=self.weight_dtype)
131
+ conditional_dict['keyboard_cond'] = keyboard_condition
132
+
133
+ with torch.no_grad():
134
+ videos = self.pipeline.inference(
135
+ noise=sampled_noise,
136
+ conditional_dict=conditional_dict,
137
+ return_latents=False,
138
+ mode=mode,
139
+ profile=False
140
+ )
141
+
142
+ videos_tensor = torch.cat(videos, dim=1)
143
+ videos = rearrange(videos_tensor, "B T C H W -> B T H W C")
144
+ videos = ((videos.float() + 1) * 127.5).clip(0, 255).cpu().numpy().astype(np.uint8)[0]
145
+ video = np.ascontiguousarray(videos)
146
+ mouse_icon = 'assets/images/mouse.png'
147
+ if mode != 'templerun':
148
+ config = (
149
+ keyboard_condition[0].float().cpu().numpy(),
150
+ mouse_condition[0].float().cpu().numpy()
151
+ )
152
+ else:
153
+ config = (
154
+ keyboard_condition[0].float().cpu().numpy()
155
+ )
156
+ process_video(video.astype(np.uint8), self.args.output_folder+f'/demo.mp4', config, mouse_icon, mouse_scale=0.1, process_icon=False, mode=mode)
157
+ process_video(video.astype(np.uint8), self.args.output_folder+f'/demo_icon.mp4', config, mouse_icon, mouse_scale=0.1, process_icon=True, mode=mode)
158
+ print("Done")
159
+
160
+ def main():
161
+ """Main entry point for video generation."""
162
+ args = parse_args()
163
+ set_seed(args.seed)
164
+ os.makedirs(args.output_folder, exist_ok=True)
165
+ pipeline = InteractiveGameInference(args)
166
+ pipeline.generate_videos()
167
+
168
+ if __name__ == "__main__":
169
+ main()
results/worldmem-baseline-evals/matrix-game2/diagnostic_native_neutral_job85112_task2/inference_universal.yaml ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ denoising_step_list:
2
+ - 1000
3
+ - 666
4
+ - 333
5
+ warp_denoising_step: true
6
+ ts_schedule: false
7
+ mixed_precision: true
8
+ seed: 42
9
+ image_or_video_shape:
10
+ - 1
11
+ - 16
12
+ - 15
13
+ - 44
14
+ - 80
15
+ num_frame_per_block: 3
16
+ context_noise: 0
17
+ mode: universal
18
+ causal: true
19
+ model_kwargs:
20
+ timestep_shift: 5.0
21
+ model_config: configs/distilled_model/universal
results/worldmem-baseline-evals/matrix-game2/diagnostic_native_neutral_job85112_task2/launcher.sh ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ #SBATCH --job-name=matrix-game2-native-control
3
+ #SBATCH --array=0-4
4
+ #SBATCH --nodes=1
5
+ #SBATCH --ntasks=1
6
+ #SBATCH --cpus-per-task=14
7
+ #SBATCH --gres=gpu:1
8
+ #SBATCH --time=02:00:00
9
+ #SBATCH --account=berzelius-2026-196
10
+ #SBATCH --chdir=/proj/cvl/users/x_fahkh2/worldmem-baseline-evals
11
+ #SBATCH --output=slurm_logs/%x-%A_%a.out
12
+ #SBATCH --error=slurm_logs/%x-%A_%a.out
13
+ set -euo pipefail
14
+ module load buildenv-gcccuda/12.9.1-gcc11
15
+ ROOT=/proj/cvl/users/x_fahkh2/worldmem-baseline-evals
16
+ PYTHON=/proj/cvl/users/x_fahkh2/envs/matrix-game2-eval/bin/python
17
+ DATA_ROOT=/proj/cvl/users/x_fahkh2/WorldMem_Repro/datasets/minecraft
18
+ MODES=(official_demo demo_actions neutral recorded small_mouse)
19
+ MODE=${MODES[$SLURM_ARRAY_TASK_ID]}
20
+ OUTPUT=$ROOT/Matrix-Game/Matrix-Game-2/outputs/diagnostic_native_${MODE}_job${SLURM_ARRAY_JOB_ID}_task${SLURM_ARRAY_TASK_ID}
21
+ export TMPDIR=$ROOT/cache
22
+ export TRITON_CACHE_DIR=$ROOT/cache
23
+ export TORCHINDUCTOR_CACHE_DIR=$ROOT/cache/torchinductor
24
+ export HF_HOME=$ROOT/cache/huggingface
25
+ export TORCH_HOME=$ROOT/cache/torch
26
+ export XDG_CACHE_HOME=$ROOT/cache
27
+ export MPLCONFIGDIR=$ROOT/cache/matplotlib
28
+ export PYTHONPATH=$ROOT/Matrix-Game/Matrix-Game-2
29
+ export PYTHONNOUSERSITE=1 PYTHONUNBUFFERED=1 OMP_NUM_THREADS=4 MKL_NUM_THREADS=4
30
+ export WANDB_MODE=disabled HF_HUB_OFFLINE=1 TRANSFORMERS_OFFLINE=1
31
+ mkdir -p "$TMPDIR" "$TORCHINDUCTOR_CACHE_DIR" "$OUTPUT"
32
+ "$PYTHON" "$ROOT/deployment/verify_node.py" --expected-gpus 1 --output "$OUTPUT"
33
+ cp "$0" "$OUTPUT/launcher.sh"
34
+ cp "$ROOT/deployment/matrix_native_controls.py" "$OUTPUT/probe.py"
35
+ cp "$ROOT/Matrix-Game/Matrix-Game-2/inference.py" "$ROOT/Matrix-Game/Matrix-Game-2/configs/inference_yaml/inference_universal.yaml" "$OUTPUT/"
36
+ srun --ntasks=1 --gpus-per-task=1 --cpus-per-task=14 --cpu-bind=cores \
37
+ "$PYTHON" "$ROOT/deployment/matrix_native_controls.py" \
38
+ --mode "$MODE" --data-root "$DATA_ROOT" --output "$OUTPUT"
results/worldmem-baseline-evals/matrix-game2/diagnostic_native_neutral_job85112_task2/manifest.json ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "mode": "neutral",
3
+ "diagnostic_only": true,
4
+ "checkpoint": "/proj/cvl/users/x_fahkh2/worldmem-baseline-evals/checkpoints/matrix-game2",
5
+ "upstream_revision": "71c3cd7f741311f8100f6cf9cde942b6c1378d11",
6
+ "weight_policy": "released raw distilled; original normalization; no optimizer or updates",
7
+ "expected_generator_parameters": 1619242304,
8
+ "expected_vae_parameters": 126892531,
9
+ "expected_clip_parameters": 1193014785,
10
+ "batch_size": 1,
11
+ "lora": null,
12
+ "lr": null,
13
+ "activation_checkpointing": false,
14
+ "steps": 3,
15
+ "shift": 5,
16
+ "cache_latents": 6,
17
+ "decoder": "official compiled max-autotune-no-cudagraphs",
18
+ "official_demo": "unchanged inference.py; supplied painting0000.png; seed0;150latents=597RGB",
19
+ "minecraft": {
20
+ "anchor": 699,
21
+ "native_latents": 9,
22
+ "native_rgb": 33,
23
+ "scored_slice": [
24
+ 1,
25
+ 25
26
+ ],
27
+ "targets": [
28
+ 700,
29
+ 724
30
+ ],
31
+ "recorded_control_alignment": "incoming700:724 plus9noops; small_mouse scales camera only",
32
+ "reference": "rawRGB with official center crop and frame_process"
33
+ },
34
+ "score_caveat": "Only recorded controls replay GT actions; other modes test stability, not benchmark accuracy",
35
+ "cases": [
36
+ {
37
+ "index": "0",
38
+ "path": "test/val_plains/2/000034.mp4",
39
+ "seed": 42000000
40
+ },
41
+ {
42
+ "index": "1",
43
+ "path": "test/val_desert/1/000029.mp4",
44
+ "seed": 42000001
45
+ }
46
+ ],
47
+ "output_frames_per_case": 33,
48
+ "generator_requires_grad_parameters": 1619242304,
49
+ "inference_grad_policy": "unchanged native no_grad; parameter flags unmodified"
50
+ }
results/worldmem-baseline-evals/matrix-game2/diagnostic_native_neutral_job85112_task2/node.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "devices": [
3
+ "NVIDIA H200"
4
+ ],
5
+ "torch": "2.7.0+cu126",
6
+ "slurm_job_id": "85115"
7
+ }
results/worldmem-baseline-evals/matrix-game2/diagnostic_native_neutral_job85112_task2/probe.py ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Official Matrix demo and native-image controls; all scores are diagnostic."""
2
+ import argparse
3
+ import json
4
+ import os
5
+ import subprocess
6
+ import sys
7
+ from pathlib import Path
8
+ import numpy as np
9
+ import torch
10
+ from PIL import Image
11
+ from diagnose_matrix_game2 import save_result
12
+ from protocol import minecraft_actions, read_frames, select_cases
13
+ from worldmem_adapter import map_actions
14
+
15
+ ROOT = Path(__file__).resolve().parents[1]
16
+ REPO = ROOT / 'Matrix-Game/Matrix-Game-2'
17
+ MODES = ['official_demo', 'demo_actions', 'neutral', 'recorded', 'small_mouse']
18
+
19
+ def replay_controls(raw, mode, length):
20
+ keyboard, mouse = map_actions(minecraft_actions(raw), 1.0)
21
+ keys, turns = torch.zeros(length, 4), torch.zeros(length, 2)
22
+ if mode != 'neutral':
23
+ keys[:24], turns[:24] = keyboard, mouse * (0.1 if mode == 'small_mouse' else 1.0)
24
+ return {'keyboard_condition': keys, 'mouse_condition': turns}
25
+
26
+ def main():
27
+ parser = argparse.ArgumentParser(description=__doc__)
28
+ parser.add_argument('--mode', choices=MODES, required=True)
29
+ parser.add_argument('--data-root', type=Path, required=True)
30
+ parser.add_argument('--output', type=Path, required=True)
31
+ parser.add_argument('--dry-run', action='store_true')
32
+ args = parser.parse_args()
33
+ checkpoint = ROOT / 'checkpoints/matrix-game2'
34
+ rows = select_cases(ROOT / 'deployment/manifests/minecraft_test_300.csv', limit=2)
35
+ manifest = {'mode': args.mode, 'diagnostic_only': True, 'checkpoint': str(checkpoint),
36
+ 'upstream_revision': '71c3cd7f741311f8100f6cf9cde942b6c1378d11',
37
+ 'weight_policy': 'released raw distilled; original normalization; no optimizer or updates',
38
+ 'expected_generator_parameters': 1619242304, 'expected_vae_parameters': 126892531,
39
+ 'expected_clip_parameters': 1193014785, 'batch_size': 1, 'lora': None, 'lr': None,
40
+ 'activation_checkpointing': False, 'steps': 3, 'shift': 5, 'cache_latents': 6,
41
+ 'decoder': 'official compiled max-autotune-no-cudagraphs',
42
+ 'official_demo': 'unchanged inference.py; supplied painting0000.png; seed0;150latents=597RGB',
43
+ 'minecraft': {'anchor': 699, 'native_latents': 9, 'native_rgb': 33, 'scored_slice': [1, 25],
44
+ 'targets': [700, 724], 'recorded_control_alignment': 'incoming700:724 plus9noops; small_mouse scales camera only',
45
+ 'reference': 'rawRGB with official center crop and frame_process'},
46
+ 'score_caveat': 'Only recorded controls replay GT actions; other modes test stability, not benchmark accuracy',
47
+ 'cases': ([{'image': 'demo_images/universal/0000.png', 'seed': 0}] if args.mode == 'official_demo'
48
+ else [{'index': r['global_test_index'], 'path': r['relative_path'],
49
+ 'seed': 42000000 + int(r['global_test_index'])} for r in rows]),
50
+ 'output_frames_per_case': 597 if args.mode == 'official_demo' else 33}
51
+ if args.dry_run:
52
+ print(json.dumps(manifest, indent=2))
53
+ return
54
+ args.output.mkdir(parents=True, exist_ok=True)
55
+ (args.output / 'manifest.json').write_text(json.dumps(manifest, indent=2))
56
+ os.chdir(REPO)
57
+ if args.mode == 'official_demo':
58
+ subprocess.run([sys.executable, 'inference.py', '--checkpoint_path', str(checkpoint / 'base_distilled_model/base_distill.safetensors'),
59
+ '--pretrained_model_path', str(checkpoint), '--img_path', 'demo_images/universal/0000.png',
60
+ '--config_path', 'configs/inference_yaml/inference_universal.yaml', '--seed', '0',
61
+ '--num_output_frames', '150', '--output_folder', str(args.output)], check=True)
62
+ from torchvision.io import read_video
63
+ video, _, _ = read_video(str(args.output / 'demo.mp4'), pts_unit='sec')
64
+ assert len(video) == 597
65
+ Image.fromarray(torch.cat([video[t] for t in [0, 1, 2, 24, 100, 596]], dim=1).numpy()).save(args.output / 'samples.jpg')
66
+ else:
67
+ import inference as native
68
+ native.set_seed(0)
69
+ model_args = argparse.Namespace(config_path='configs/inference_yaml/inference_universal.yaml',
70
+ checkpoint_path=str(checkpoint / 'base_distilled_model/base_distill.safetensors'),
71
+ pretrained_model_path=str(checkpoint), num_output_frames=9, seed=0, img_path='', output_folder='')
72
+ engine = native.InteractiveGameInference(model_args)
73
+ manifest['generator_requires_grad_parameters'] = sum(p.numel() for p in engine.pipeline.generator.parameters() if p.requires_grad)
74
+ manifest['inference_grad_policy'] = 'unchanged native no_grad; parameter flags unmodified'
75
+ (args.output / 'manifest.json').write_text(json.dumps(manifest, indent=2))
76
+ original_inference, native_controls = engine.pipeline.inference, native.Bench_actions_universal
77
+ captured = {}
78
+ def capture(**kwargs):
79
+ condition = kwargs['conditional_dict']
80
+ np.savez_compressed(case_dir / 'inputs.npz', initial_noise=kwargs['noise'].float().cpu().numpy(),
81
+ keyboard=condition['keyboard_cond'][0].float().cpu().numpy(), mouse=condition['mouse_cond'][0].float().cpu().numpy())
82
+ videos = original_inference(**kwargs)
83
+ captured['prediction'] = torch.cat(videos, dim=1)[0, 1:25].detach().float().cpu().add(1).div(2)
84
+ return videos
85
+ engine.pipeline.inference = capture
86
+ for row in rows:
87
+ case_dir = args.output / f"case{row['global_test_index']}"
88
+ case_dir.mkdir(exist_ok=True)
89
+ path = args.data_root / row['relative_path']
90
+ rgb = read_frames(path, torch.arange(699, 724))
91
+ images = [Image.fromarray(frame.mul(255).round().byte().permute(1, 2, 0).numpy()) for frame in rgb]
92
+ images[0].save(case_dir / 'input.png')
93
+ reference = torch.stack([engine.frame_process(engine._resizecrop(im, 352, 640)).add(1).div(2) for im in images[1:]])
94
+ with np.load(path.with_suffix('.npz')) as annotation:
95
+ controls = replay_controls(annotation['actions'][700:724], args.mode, 33)
96
+ native.Bench_actions_universal = native_controls if args.mode == 'demo_actions' else lambda length: controls
97
+ model_args.img_path, model_args.output_folder = str(case_dir / 'input.png'), str(case_dir)
98
+ engine.config['mode'] = 'universal'
99
+ native.set_seed(42000000 + int(row['global_test_index']))
100
+ engine.generate_videos()
101
+ save_result(case_dir, 'comparison', captured.pop('prediction'), reference)
102
+ (args.output / 'complete.json').write_text(json.dumps({'mode': args.mode, 'complete': True}))
103
+ print('NATIVE_CONTROL_COMPLETE', flush=True)
104
+
105
+ if __name__ == '__main__':
106
+ main()