alexwengg commited on
Commit
f0ec44f
·
verified ·
1 Parent(s): 46a1032

MarioStudent: 9M Core ML Mario policy (53/96; 78/96 with lookahead)

Browse files
MarioStudent.mlpackage/Data/com.apple.CoreML/model.mlmodel ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4a22158159e530052908185b361db50a417e68e8e4767e11a787700ba8d74b2b
3
+ size 118244
MarioStudent.mlpackage/Data/com.apple.CoreML/weights/weight.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:924f70024936e3789389561b13e0e6c837f6cdaf1fa515668892417feba934ae
3
+ size 17750358
MarioStudent.mlpackage/Manifest.json ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "fileFormatVersion": "1.0.0",
3
+ "itemInfoEntries": {
4
+ "28F6376E-BAFE-449B-8819-62D398130CDB": {
5
+ "author": "com.apple.CoreML",
6
+ "description": "CoreML Model Weights",
7
+ "name": "weights",
8
+ "path": "com.apple.CoreML/weights"
9
+ },
10
+ "A8D5A8BF-9CB6-4A44-89C2-7B460ED934CC": {
11
+ "author": "com.apple.CoreML",
12
+ "description": "CoreML Model Specification",
13
+ "name": "model.mlmodel",
14
+ "path": "com.apple.CoreML/model.mlmodel"
15
+ }
16
+ },
17
+ "rootModelIdentifier": "A8D5A8BF-9CB6-4A44-89C2-7B460ED934CC"
18
+ }
README.md ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ library_name: coreml
4
+ pipeline_tag: reinforcement-learning
5
+ tags:
6
+ - coreml
7
+ - apple-neural-engine
8
+ - super-mario-bros
9
+ - imitation-learning
10
+ - dagger
11
+ - game-playing
12
+ ---
13
+
14
+ # MarioStudent (Core ML)
15
+
16
+ A 9.0M-parameter pixel policy that plays Super Mario Bros. (NES) on the Apple Neural Engine.
17
+
18
+ It is a MobileNetV3-Large that looks at the screen around Mario (now and 4 frames earlier) and picks one of 11
19
+ eight-frame moves: run, walk, hold, jump, hop, up, left, leftjump, wait, swim, down. It was trained by imitation on
20
+ a save-state beam-search solver that clears all 32 levels, plus DAgger rounds, with auxiliary tile and enemy grid
21
+ targets. It was not distilled from JEV.
22
+
23
+ - `MarioStudent.mlpackage`: fp16, 17 MB, all 185 ops on the Neural Engine, about 0.5 ms per decision (M5 Pro). Its
24
+ move choice matches PyTorch on CPU, GPU and ANE.
25
+ - `mario-student.pt`: the PyTorch checkpoint.
26
+ - `config.json`: inputs, outputs and move order.
27
+
28
+ ## Results
29
+
30
+ 32 levels × 3 start offsets:
31
+
32
+ | | Flags | Levels cleared at least once | Cleared every time |
33
+ |---|---|---|---|
34
+ | Model alone | 53/96 | 23 | 12 |
35
+ | Model + lookahead | 78/96 | 30 | 21 |
36
+
37
+ Lookahead: before each move, candidate moves are simulated on an emulator save state, each followed by the model's
38
+ next 6 moves, and the first that survives and gains ground is played. With lookahead the result is the model plus
39
+ emulator simulation, not the network alone. The maze castles 4-4 and 8-4 are not cleared.
40
+
41
+ ## Input / output
42
+
43
+ - Input `crop`: [1, 6, 120, 96] fp16 in [0, 1]. RGB now, then RGB 4 frames earlier, covering 32 px behind Mario to
44
+ 160 px ahead, every 2nd pixel of the 256×240 NES frame.
45
+ - Output `logits`: 11 move logits (order in `config.json`), then 11 survival logits.
46
+ - Moves are 8-frame button macros. The last input is held while the game has control, e.g. during a pipe entry.
47
+ - Mario's on-screen x, which places the crop, is read from emulator RAM.
48
+
49
+ ## Demo
50
+
51
+ [FluidUse `Sources/JevMarioDemo`](https://github.com/FluidInference/FluidUse/tree/main/Sources/JevMarioDemo) is a
52
+ SwiftUI app that runs this model on the Neural Engine, with or without lookahead, next to
53
+ [JEV-9B on Core ML](https://huggingface.co/FluidInference/jev-9b-coreml).
54
+
55
+ You need your own copy of the game. No ROM, frames or gameplay video are included here.
config.json ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model": "MarioStudent",
3
+ "architecture": "MobileNetV3-Large (ImageNet init) + heads: move (11), survival (11), tile grid 13x12, enemy grid 13x12",
4
+ "parameters": 9035296,
5
+ "input": {
6
+ "name": "crop",
7
+ "shape": [
8
+ 1,
9
+ 6,
10
+ 120,
11
+ 96
12
+ ],
13
+ "dtype": "float16",
14
+ "range": [
15
+ 0,
16
+ 1
17
+ ],
18
+ "layout": "RGB now, then RGB 4 frames earlier; screen from 32 px behind Mario to 160 px ahead, every 2nd pixel"
19
+ },
20
+ "output": {
21
+ "name": "logits",
22
+ "meaning": "11 move logits (order in `moves`) then 11 survival logits"
23
+ },
24
+ "moves": [
25
+ "run",
26
+ "walk",
27
+ "hold",
28
+ "jump",
29
+ "hop",
30
+ "up",
31
+ "left",
32
+ "leftjump",
33
+ "wait",
34
+ "swim",
35
+ "down"
36
+ ],
37
+ "macro_frames": 8,
38
+ "coreml": "MarioStudent.mlpackage (fp16, 185/185 ops on the Neural Engine)",
39
+ "pytorch": "mario-student.pt (model-lab mario-tiny student_retro.py, arch retro-aux, view half2)"
40
+ }
mario-student.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:021def4eef37994701d23b93e9fcb4ded4b67da90d550e63493f8558f65369bb
3
+ size 36374091