README: decisions are every 5 ticks (250 ms), not 10
Browse files
README.md
CHANGED
|
@@ -1,214 +1,214 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: other
|
| 3 |
-
pretty_name: alpha-CR IL_Replay v2 (engine-replayed human battles)
|
| 4 |
-
task_categories:
|
| 5 |
-
- reinforcement-learning
|
| 6 |
-
tags:
|
| 7 |
-
- clash-royale
|
| 8 |
-
- imitation-learning
|
| 9 |
-
size_categories:
|
| 10 |
-
- 100K<n<1M
|
| 11 |
-
---
|
| 12 |
-
|
| 13 |
-
# alpha-CR IL_Replay v2
|
| 14 |
-
|
| 15 |
-
224,689 human Clash Royale battles as imitation-learning (IL) games for the alpha-CR policy. Both seats are labelled
|
| 16 |
-
on every decision. Every battle comes from the public
|
| 17 |
-
[VanguardX101/IL_Replay](https://huggingface.co/datasets/VanguardX101/IL_Replay) dataset. Each one was replayed
|
| 18 |
-
command by command in the extracted global game engine and recorded with full engine state, then exported in the
|
| 19 |
-
same NPZ format as the rest of the alpha-CR IL data. The data is ready to train on and needs no recording or engine.
|
| 20 |
-
|
| 21 |
-
| | games | decisions (both seats) | card plays | hero abilities |
|
| 22 |
-
| --- | ---: | ---: | ---: | ---: |
|
| 23 |
-
| strict (`ilr-v2-NN`) | 198,074 | 328,878,822 | 10,808,144 | 485,226 |
|
| 24 |
-
| relaxed (`ilr-v2-NN-relaxed`) | 26,615 | 47,902,448 | 1,775,954 | 107,584 |
|
| 25 |
-
| **total** | **224,689** | **376,781,270** | **12,584,098** | **592,810** |
|
| 26 |
-
|
| 27 |
-
A game has a median of 773 snapshots (one decision every
|
| 28 |
-
190,719 games include at least one hero ability.
|
| 29 |
-
|
| 30 |
-
Every game has a unit-state sidecar (`unit-state-v1`, 36 features per unit token). Collected 2026-11-12 to
|
| 31 |
-
2026-11-15 as batch 2 (13 chunks, `ilr-v2-00` … `ilr-v2-12`). Every game uses `tensor_version` 5 and 62 token slots.
|
| 32 |
-
The unit vocabulary has 377 entries. Chunks 08 and 10 append one more, `global-unit:Ghost_EV1_Clone` (378 entries,
|
| 33 |
-
earlier ids unchanged), and `merge_archives` takes the union automatically.
|
| 34 |
-
|
| 35 |
-
## Layout
|
| 36 |
-
|
| 37 |
-
All shards are uncompressed TAR files; the NPZ members inside are already compressed. Member paths are relative to
|
| 38 |
-
the alpha-CR project root, so extracting a shard at the root puts every file where training looks for it.
|
| 39 |
-
|
| 40 |
-
| path | contents | size |
|
| 41 |
-
| --- | --- | --- |
|
| 42 |
-
| `games/ilr-v2-NN.tar` | `data/archives/ilr-v2-NN/{manifest.json, games/<tag>.npz}` (strict) | 47.2 GB for both game kinds |
|
| 43 |
-
| `games/ilr-v2-NN-relaxed.tar` | `data/archives/ilr-v2-NN-relaxed/…` (relaxed) | |
|
| 44 |
-
| `unit-state/ilr-v2-NN.tar` | `data/archives/unit-state-v1/<tag>.npz`, sidecars for both archives of chunk NN | 41.3 GB in all |
|
| 45 |
-
| `inventory.json` | bytes, sha256 and member count of every shard; game count of every archive | |
|
| 46 |
-
| `quality.json` | the full quality report (below) | |
|
| 47 |
-
|
| 48 |
-
Each archive's `manifest.json` has these fields:
|
| 49 |
-
|
| 50 |
-
| field | meaning |
|
| 51 |
-
| --- | --- |
|
| 52 |
-
| `games` | game paths relative to the archive |
|
| 53 |
-
| `vocab` | unit vocabulary; ids are list index + 2 |
|
| 54 |
-
| `decision_weights` | per-game `[first, last]` weights (see below) |
|
| 55 |
-
| `decision_weight_rule` | parameters used to compute those weights |
|
| 56 |
-
| `rejected` | `{tag: reason}` for recordings that were not exported |
|
| 57 |
-
|
| 58 |
-
A game NPZ (`s0/…` and `s1/…`, one block per seat, `T` snapshots, one
|
| 59 |
-
|
| 60 |
-
| key | shape | meaning |
|
| 61 |
-
| --- | --- | --- |
|
| 62 |
-
| `troop_tiles` | `[T, 72]` | |
|
| 63 |
-
| `scalars` | `[T, 12]` | elixir, time, towers, … |
|
| 64 |
-
| `hand_ids`, `hand_cost` | `[T, 5]` | the hand plus the next card |
|
| 65 |
-
| `hand_spell`, `hand_anywhere`, `hand_mask` | `[T, 4]` | |
|
| 66 |
-
| `tok_ids`, `tok_type`, `tok_side`, `tok_mask` | `[T, 62]` | unit tokens |
|
| 67 |
-
| `tok_feat` | `[T, 62, 6]` | unit token features |
|
| 68 |
-
| `ability_ready` | `[T]` | |
|
| 69 |
-
| `opp_hand_ids` | `[T, 5]` | |
|
| 70 |
-
| `tower_troop` | `[T, 2]` | |
|
| 71 |
-
| `opp_elixir`, `opp_elixir_est` | `[T, 1]` | |
|
| 72 |
-
| `gate` | `[T]` | label: 0 = wait, 1 = play |
|
| 73 |
-
| `slot` | `[T]` | label: hand slot |
|
| 74 |
-
| `tile` | `[T]` | label: placement tile |
|
| 75 |
-
|
| 76 |
-
`meta` is a JSON string: replay tag, `snapshots`, `decisions`, `plays`, `abilities`, `states_sha256`,
|
| 77 |
-
`tensor_version`. A sidecar holds `s0/tok_unit` and `s1/tok_unit`, each `[T, 62, 36]` float32: per-token motion,
|
| 78 |
-
combat and status state, aligned to `tok_ids`.
|
| 79 |
-
|
| 80 |
-
## How the games were made
|
| 81 |
-
|
| 82 |
-
1. Each IL_Replay battle was rendered to a replay page (`tools/il_replay_pages.py`).
|
| 83 |
-
2. The battle was validated on the extracted global engine (`tools/independent_validation_queue.py --max-candidates
|
| 84 |
-
4 --seeds 1`), which picks the best starting candidate. 239,646 battles passed and 908 failed.
|
| 85 |
-
3. The battle was recorded with combat-v1 probes (`tools/il_replay_record.py`).
|
| 86 |
-
4. The recording was exported to NPZ (`tools/export_extra_global.py --allow-unsettled`), giving the strict archive.
|
| 87 |
-
Recordings that the strict rules rejected for a single label they cannot represent were exported again under
|
| 88 |
-
relaxed rules (`--relaxed`). The relaxed rules drop a second action within one decision window and accept
|
| 89 |
-
abilities when two are ready.
|
| 90 |
-
5. Decision weights were computed (`tools/il_replay_weights.py`), and unit-state sidecars were exported
|
| 91 |
-
(`tools/export_unit_state.py --no-npy`).
|
| 92 |
-
|
| 93 |
-
The engine runs a different game balance from the one these battles were played on. It reproduces each opening as
|
| 94 |
-
the human saw it but drifts later in the game, so the per-game **decision weight** falls linearly over the game's
|
| 95 |
-
decisions, from `first` to `last`:
|
| 96 |
-
|
| 97 |
-
| replay outcome | games (strict / relaxed) | weight |
|
| 98 |
-
| --- | ---: | --- |
|
| 99 |
-
| exact (same result as the real battle) | 5,295 / 482 | 1 → 1 |
|
| 100 |
-
| different, but every play ran | 86,944 / 12,869 | 0.5 → 0.5·exp(−ΔtowerHP/2000)·exp(−\|Δend tick\|/100) |
|
| 101 |
-
| cut (the engine refused a later play) or undecided | 105,835 / 13,264 | 0.5 → 0.05 |
|
| 102 |
-
|
| 103 |
-
A cut game keeps only the commands before the first refused play. The ending weight averages 0.147 for strict games
|
| 104 |
-
and 0.142 for relaxed games, with a median of 0.05 for both. Training multiplies each decision's loss terms by its
|
| 105 |
-
weight and does not renormalise. Treat this as a large, noisy, human-prior corpus: weight it below exactly
|
| 106 |
-
reproduced data, or mix it with such data.
|
| 107 |
-
|
| 108 |
-
## Quality check
|
| 109 |
-
|
| 110 |
-
`tools/ilr_quality.py` checks every game:
|
| 111 |
-
|
| 112 |
-
- zip CRC of the game and its sidecar;
|
| 113 |
-
- all 40 seat keys are present, with the same `T` across keys and seats;
|
| 114 |
-
- float arrays are finite;
|
| 115 |
-
- `meta.snapshots == T`, with data finalization verified;
|
| 116 |
-
- sidecar shape `[T, 62, 36]` and finite;
|
| 117 |
-
- no duplicate tags across chunks, one vocabulary, and decision weights for every game.
|
| 118 |
-
|
| 119 |
-
Result: **all 224,689 games passed (0 failures)**. The per-chunk counts and reject reasons are in `quality.json`.
|
| 120 |
-
|
| 121 |
-
| stage | battles |
|
| 122 |
-
| --- | ---: |
|
| 123 |
-
| IL_Replay battles validated on the engine | 239,646 (908 failed validation) |
|
| 124 |
-
| exported under the strict rules | 198,074 (40,613 rejected) |
|
| 125 |
-
| recovered under the relaxed rules | 26,615 |
|
| 126 |
-
| still rejected | 13,998 |
|
| 127 |
-
|
| 128 |
-
The 13,998 still rejected break down as:
|
| 129 |
-
|
| 130 |
-
- play violates the training placement mask: 12,298
|
| 131 |
-
- play unaffordable at the decision tick: 1,621
|
| 132 |
-
- ability unavailable or ambiguous: 79
|
| 133 |
-
|
| 134 |
-
In 10,433 relaxed games, the number of `gate == 1` labels is lower than `meta.plays`. The difference always equals
|
| 135 |
-
`meta.dropped_second_actions`, the second actions that the relaxed rules drop by design.
|
| 136 |
-
|
| 137 |
-
## Training (alpha-CR)
|
| 138 |
-
|
| 139 |
-
You need the alpha-CR code (`python -m alpha_cr.train.il`).
|
| 140 |
-
|
| 141 |
-
```bash
|
| 142 |
-
# 1. download (88.5 GB; about 89 GB more once extracted) and extract at the project root
|
| 143 |
-
cd ~/alpha-cr
|
| 144 |
-
huggingface-cli download will8821/alpha-cr-ilr-v2 --repo-type dataset --local-dir /tmp/ilr-v2
|
| 145 |
-
for f in /tmp/ilr-v2/games/*.tar /tmp/ilr-v2/unit-state/*.tar; do tar -xf "$f" -C .; done
|
| 146 |
-
python - <<'EOF' # optional: verify the shards against inventory.json
|
| 147 |
-
import hashlib, json, pathlib
|
| 148 |
-
inv = json.load(open('/tmp/ilr-v2/inventory.json'))
|
| 149 |
-
for name, s in inv['shards'].items():
|
| 150 |
-
h = hashlib.sha256(); f = open(f'/tmp/ilr-v2/{name}', 'rb')
|
| 151 |
-
for b in iter(lambda: f.read(1 << 24), b''): h.update(b)
|
| 152 |
-
assert h.hexdigest() == s['sha256'], name
|
| 153 |
-
print('ok', len(inv['shards']))
|
| 154 |
-
EOF
|
| 155 |
-
|
| 156 |
-
# 2. only for models with unit state (model.unit_state): build the memory-mapped fp16 stores that training reads
|
| 157 |
-
# (<tag>.s0.npy / .s1.npy beside each .npz). About 7.6 MB per game, so roughly 1.7 TB for all 224,689 games.
|
| 158 |
-
python tools/export_unit_state.py --convert --workers 64
|
| 159 |
-
```
|
| 160 |
-
|
| 161 |
-
Every archive goes in `data:`. They share one vocabulary, so `merge_archives` concatenates them, and the per-game
|
| 162 |
-
decision weights are read from the manifests automatically. Here is an example config on the v6c recipe:
|
| 163 |
-
|
| 164 |
-
```yaml
|
| 165 |
-
# configs/il-ilr-v2.yaml
|
| 166 |
-
data: [data/archives/ilr-v2-00, data/archives/ilr-v2-00-relaxed, data/archives/ilr-v2-01, data/archives/ilr-v2-01-relaxed,
|
| 167 |
-
data/archives/ilr-v2-02, data/archives/ilr-v2-02-relaxed, data/archives/ilr-v2-03, data/archives/ilr-v2-03-relaxed,
|
| 168 |
-
data/archives/ilr-v2-04, data/archives/ilr-v2-04-relaxed, data/archives/ilr-v2-05, data/archives/ilr-v2-05-relaxed,
|
| 169 |
-
data/archives/ilr-v2-06, data/archives/ilr-v2-06-relaxed, data/archives/ilr-v2-07, data/archives/ilr-v2-07-relaxed,
|
| 170 |
-
data/archives/ilr-v2-08, data/archives/ilr-v2-08-relaxed, data/archives/ilr-v2-09, data/archives/ilr-v2-09-relaxed,
|
| 171 |
-
data/archives/ilr-v2-10, data/archives/ilr-v2-10-relaxed, data/archives/ilr-v2-11, data/archives/ilr-v2-11-relaxed,
|
| 172 |
-
data/archives/ilr-v2-12, data/archives/ilr-v2-12-relaxed]
|
| 173 |
-
unit_state_dir: data/archives/unit-state-v1
|
| 174 |
-
epochs: 3
|
| 175 |
-
batch: 32
|
| 176 |
-
lr: 6.0e-4
|
| 177 |
-
warmup: 300
|
| 178 |
-
final_lr: 0.1
|
| 179 |
-
weight_decay: 0.1
|
| 180 |
-
val_fraction: 0.02
|
| 181 |
-
mirror: 0.5
|
| 182 |
-
amp: true
|
| 183 |
-
aux_next_play: 0.5
|
| 184 |
-
aux_next_ability: 0.5
|
| 185 |
-
model:
|
| 186 |
-
dim: 384
|
| 187 |
-
layers: 6
|
| 188 |
-
heads: 8
|
| 189 |
-
ff: 768
|
| 190 |
-
dropout: 0.2
|
| 191 |
-
tower_context: true
|
| 192 |
-
unit_state: [motion, combat, status] # drop this line to train without sidecars (then skip step 2)
|
| 193 |
-
next_play_head: 13
|
| 194 |
-
next_ability_head: 13
|
| 195 |
-
packed_cache: data/il-packed
|
| 196 |
-
trim_board_padding: true
|
| 197 |
-
ema: 0.999
|
| 198 |
-
token_drop: 0.1
|
| 199 |
-
compile: true # needs triton; set false on Windows
|
| 200 |
-
```
|
| 201 |
-
|
| 202 |
-
```bash
|
| 203 |
-
python -m alpha_cr.train.il --config configs/il-ilr-v2.yaml
|
| 204 |
-
```
|
| 205 |
-
|
| 206 |
-
Things to know before training:
|
| 207 |
-
|
| 208 |
-
- **Tile smoothing:** `tile_smooth` cannot be combined with decision weights; training raises a `ValueError`.
|
| 209 |
-
- **Validation:** the validation split (`val_fraction`) is drawn from these weighted games, so its loss is weighted
|
| 210 |
-
too. For a clean comparison with earlier models, evaluate on an exact-replay or Tencent split as well.
|
| 211 |
-
- **Mixing with other data:** add the other archives (for example the `us*` archives) to `data:`. Archives without
|
| 212 |
-
`decision_weights` weigh 1.
|
| 213 |
-
- **Subsets:** each chunk is a random slice of IL_Replay, so a subset of chunks is a uniform subsample. Use, for
|
| 214 |
-
example, `ilr-v2-00` … `ilr-v2-03` for a quick screening run.
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: other
|
| 3 |
+
pretty_name: alpha-CR IL_Replay v2 (engine-replayed human battles)
|
| 4 |
+
task_categories:
|
| 5 |
+
- reinforcement-learning
|
| 6 |
+
tags:
|
| 7 |
+
- clash-royale
|
| 8 |
+
- imitation-learning
|
| 9 |
+
size_categories:
|
| 10 |
+
- 100K<n<1M
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
# alpha-CR IL_Replay v2
|
| 14 |
+
|
| 15 |
+
224,689 human Clash Royale battles as imitation-learning (IL) games for the alpha-CR policy. Both seats are labelled
|
| 16 |
+
on every decision. Every battle comes from the public
|
| 17 |
+
[VanguardX101/IL_Replay](https://huggingface.co/datasets/VanguardX101/IL_Replay) dataset. Each one was replayed
|
| 18 |
+
command by command in the extracted global game engine and recorded with full engine state, then exported in the
|
| 19 |
+
same NPZ format as the rest of the alpha-CR IL data. The data is ready to train on and needs no recording or engine.
|
| 20 |
+
|
| 21 |
+
| | games | decisions (both seats) | card plays | hero abilities |
|
| 22 |
+
| --- | ---: | ---: | ---: | ---: |
|
| 23 |
+
| strict (`ilr-v2-NN`) | 198,074 | 328,878,822 | 10,808,144 | 485,226 |
|
| 24 |
+
| relaxed (`ilr-v2-NN-relaxed`) | 26,615 | 47,902,448 | 1,775,954 | 107,584 |
|
| 25 |
+
| **total** | **224,689** | **376,781,270** | **12,584,098** | **592,810** |
|
| 26 |
+
|
| 27 |
+
A game has a median of 773 snapshots (one decision every 5 engine ticks = 250 ms at 20 ticks/s; 5th–95th percentile 492–1,241) and 50 plays.
|
| 28 |
+
190,719 games include at least one hero ability.
|
| 29 |
+
|
| 30 |
+
Every game has a unit-state sidecar (`unit-state-v1`, 36 features per unit token). Collected 2026-11-12 to
|
| 31 |
+
2026-11-15 as batch 2 (13 chunks, `ilr-v2-00` … `ilr-v2-12`). Every game uses `tensor_version` 5 and 62 token slots.
|
| 32 |
+
The unit vocabulary has 377 entries. Chunks 08 and 10 append one more, `global-unit:Ghost_EV1_Clone` (378 entries,
|
| 33 |
+
earlier ids unchanged), and `merge_archives` takes the union automatically.
|
| 34 |
+
|
| 35 |
+
## Layout
|
| 36 |
+
|
| 37 |
+
All shards are uncompressed TAR files; the NPZ members inside are already compressed. Member paths are relative to
|
| 38 |
+
the alpha-CR project root, so extracting a shard at the root puts every file where training looks for it.
|
| 39 |
+
|
| 40 |
+
| path | contents | size |
|
| 41 |
+
| --- | --- | --- |
|
| 42 |
+
| `games/ilr-v2-NN.tar` | `data/archives/ilr-v2-NN/{manifest.json, games/<tag>.npz}` (strict) | 47.2 GB for both game kinds |
|
| 43 |
+
| `games/ilr-v2-NN-relaxed.tar` | `data/archives/ilr-v2-NN-relaxed/…` (relaxed) | |
|
| 44 |
+
| `unit-state/ilr-v2-NN.tar` | `data/archives/unit-state-v1/<tag>.npz`, sidecars for both archives of chunk NN | 41.3 GB in all |
|
| 45 |
+
| `inventory.json` | bytes, sha256 and member count of every shard; game count of every archive | |
|
| 46 |
+
| `quality.json` | the full quality report (below) | |
|
| 47 |
+
|
| 48 |
+
Each archive's `manifest.json` has these fields:
|
| 49 |
+
|
| 50 |
+
| field | meaning |
|
| 51 |
+
| --- | --- |
|
| 52 |
+
| `games` | game paths relative to the archive |
|
| 53 |
+
| `vocab` | unit vocabulary; ids are list index + 2 |
|
| 54 |
+
| `decision_weights` | per-game `[first, last]` weights (see below) |
|
| 55 |
+
| `decision_weight_rule` | parameters used to compute those weights |
|
| 56 |
+
| `rejected` | `{tag: reason}` for recordings that were not exported |
|
| 57 |
+
|
| 58 |
+
A game NPZ (`s0/…` and `s1/…`, one block per seat, `T` snapshots, one every 5 ticks = 250 ms) holds:
|
| 59 |
+
|
| 60 |
+
| key | shape | meaning |
|
| 61 |
+
| --- | --- | --- |
|
| 62 |
+
| `troop_tiles` | `[T, 72]` | |
|
| 63 |
+
| `scalars` | `[T, 12]` | elixir, time, towers, … |
|
| 64 |
+
| `hand_ids`, `hand_cost` | `[T, 5]` | the hand plus the next card |
|
| 65 |
+
| `hand_spell`, `hand_anywhere`, `hand_mask` | `[T, 4]` | |
|
| 66 |
+
| `tok_ids`, `tok_type`, `tok_side`, `tok_mask` | `[T, 62]` | unit tokens |
|
| 67 |
+
| `tok_feat` | `[T, 62, 6]` | unit token features |
|
| 68 |
+
| `ability_ready` | `[T]` | |
|
| 69 |
+
| `opp_hand_ids` | `[T, 5]` | |
|
| 70 |
+
| `tower_troop` | `[T, 2]` | |
|
| 71 |
+
| `opp_elixir`, `opp_elixir_est` | `[T, 1]` | |
|
| 72 |
+
| `gate` | `[T]` | label: 0 = wait, 1 = play |
|
| 73 |
+
| `slot` | `[T]` | label: hand slot |
|
| 74 |
+
| `tile` | `[T]` | label: placement tile |
|
| 75 |
+
|
| 76 |
+
`meta` is a JSON string: replay tag, `snapshots`, `decisions`, `plays`, `abilities`, `states_sha256`,
|
| 77 |
+
`tensor_version`. A sidecar holds `s0/tok_unit` and `s1/tok_unit`, each `[T, 62, 36]` float32: per-token motion,
|
| 78 |
+
combat and status state, aligned to `tok_ids`.
|
| 79 |
+
|
| 80 |
+
## How the games were made
|
| 81 |
+
|
| 82 |
+
1. Each IL_Replay battle was rendered to a replay page (`tools/il_replay_pages.py`).
|
| 83 |
+
2. The battle was validated on the extracted global engine (`tools/independent_validation_queue.py --max-candidates
|
| 84 |
+
4 --seeds 1`), which picks the best starting candidate. 239,646 battles passed and 908 failed.
|
| 85 |
+
3. The battle was recorded with combat-v1 probes (`tools/il_replay_record.py`).
|
| 86 |
+
4. The recording was exported to NPZ (`tools/export_extra_global.py --allow-unsettled`), giving the strict archive.
|
| 87 |
+
Recordings that the strict rules rejected for a single label they cannot represent were exported again under
|
| 88 |
+
relaxed rules (`--relaxed`). The relaxed rules drop a second action within one decision window and accept
|
| 89 |
+
abilities when two are ready.
|
| 90 |
+
5. Decision weights were computed (`tools/il_replay_weights.py`), and unit-state sidecars were exported
|
| 91 |
+
(`tools/export_unit_state.py --no-npy`).
|
| 92 |
+
|
| 93 |
+
The engine runs a different game balance from the one these battles were played on. It reproduces each opening as
|
| 94 |
+
the human saw it but drifts later in the game, so the per-game **decision weight** falls linearly over the game's
|
| 95 |
+
decisions, from `first` to `last`:
|
| 96 |
+
|
| 97 |
+
| replay outcome | games (strict / relaxed) | weight |
|
| 98 |
+
| --- | ---: | --- |
|
| 99 |
+
| exact (same result as the real battle) | 5,295 / 482 | 1 → 1 |
|
| 100 |
+
| different, but every play ran | 86,944 / 12,869 | 0.5 → 0.5·exp(−ΔtowerHP/2000)·exp(−\|Δend tick\|/100) |
|
| 101 |
+
| cut (the engine refused a later play) or undecided | 105,835 / 13,264 | 0.5 → 0.05 |
|
| 102 |
+
|
| 103 |
+
A cut game keeps only the commands before the first refused play. The ending weight averages 0.147 for strict games
|
| 104 |
+
and 0.142 for relaxed games, with a median of 0.05 for both. Training multiplies each decision's loss terms by its
|
| 105 |
+
weight and does not renormalise. Treat this as a large, noisy, human-prior corpus: weight it below exactly
|
| 106 |
+
reproduced data, or mix it with such data.
|
| 107 |
+
|
| 108 |
+
## Quality check
|
| 109 |
+
|
| 110 |
+
`tools/ilr_quality.py` checks every game:
|
| 111 |
+
|
| 112 |
+
- zip CRC of the game and its sidecar;
|
| 113 |
+
- all 40 seat keys are present, with the same `T` across keys and seats;
|
| 114 |
+
- float arrays are finite;
|
| 115 |
+
- `meta.snapshots == T`, with data finalization verified;
|
| 116 |
+
- sidecar shape `[T, 62, 36]` and finite;
|
| 117 |
+
- no duplicate tags across chunks, one vocabulary, and decision weights for every game.
|
| 118 |
+
|
| 119 |
+
Result: **all 224,689 games passed (0 failures)**. The per-chunk counts and reject reasons are in `quality.json`.
|
| 120 |
+
|
| 121 |
+
| stage | battles |
|
| 122 |
+
| --- | ---: |
|
| 123 |
+
| IL_Replay battles validated on the engine | 239,646 (908 failed validation) |
|
| 124 |
+
| exported under the strict rules | 198,074 (40,613 rejected) |
|
| 125 |
+
| recovered under the relaxed rules | 26,615 |
|
| 126 |
+
| still rejected | 13,998 |
|
| 127 |
+
|
| 128 |
+
The 13,998 still rejected break down as:
|
| 129 |
+
|
| 130 |
+
- play violates the training placement mask: 12,298
|
| 131 |
+
- play unaffordable at the decision tick: 1,621
|
| 132 |
+
- ability unavailable or ambiguous: 79
|
| 133 |
+
|
| 134 |
+
In 10,433 relaxed games, the number of `gate == 1` labels is lower than `meta.plays`. The difference always equals
|
| 135 |
+
`meta.dropped_second_actions`, the second actions that the relaxed rules drop by design.
|
| 136 |
+
|
| 137 |
+
## Training (alpha-CR)
|
| 138 |
+
|
| 139 |
+
You need the alpha-CR code (`python -m alpha_cr.train.il`).
|
| 140 |
+
|
| 141 |
+
```bash
|
| 142 |
+
# 1. download (88.5 GB; about 89 GB more once extracted) and extract at the project root
|
| 143 |
+
cd ~/alpha-cr
|
| 144 |
+
huggingface-cli download will8821/alpha-cr-ilr-v2 --repo-type dataset --local-dir /tmp/ilr-v2
|
| 145 |
+
for f in /tmp/ilr-v2/games/*.tar /tmp/ilr-v2/unit-state/*.tar; do tar -xf "$f" -C .; done
|
| 146 |
+
python - <<'EOF' # optional: verify the shards against inventory.json
|
| 147 |
+
import hashlib, json, pathlib
|
| 148 |
+
inv = json.load(open('/tmp/ilr-v2/inventory.json'))
|
| 149 |
+
for name, s in inv['shards'].items():
|
| 150 |
+
h = hashlib.sha256(); f = open(f'/tmp/ilr-v2/{name}', 'rb')
|
| 151 |
+
for b in iter(lambda: f.read(1 << 24), b''): h.update(b)
|
| 152 |
+
assert h.hexdigest() == s['sha256'], name
|
| 153 |
+
print('ok', len(inv['shards']))
|
| 154 |
+
EOF
|
| 155 |
+
|
| 156 |
+
# 2. only for models with unit state (model.unit_state): build the memory-mapped fp16 stores that training reads
|
| 157 |
+
# (<tag>.s0.npy / .s1.npy beside each .npz). About 7.6 MB per game, so roughly 1.7 TB for all 224,689 games.
|
| 158 |
+
python tools/export_unit_state.py --convert --workers 64
|
| 159 |
+
```
|
| 160 |
+
|
| 161 |
+
Every archive goes in `data:`. They share one vocabulary, so `merge_archives` concatenates them, and the per-game
|
| 162 |
+
decision weights are read from the manifests automatically. Here is an example config on the v6c recipe:
|
| 163 |
+
|
| 164 |
+
```yaml
|
| 165 |
+
# configs/il-ilr-v2.yaml
|
| 166 |
+
data: [data/archives/ilr-v2-00, data/archives/ilr-v2-00-relaxed, data/archives/ilr-v2-01, data/archives/ilr-v2-01-relaxed,
|
| 167 |
+
data/archives/ilr-v2-02, data/archives/ilr-v2-02-relaxed, data/archives/ilr-v2-03, data/archives/ilr-v2-03-relaxed,
|
| 168 |
+
data/archives/ilr-v2-04, data/archives/ilr-v2-04-relaxed, data/archives/ilr-v2-05, data/archives/ilr-v2-05-relaxed,
|
| 169 |
+
data/archives/ilr-v2-06, data/archives/ilr-v2-06-relaxed, data/archives/ilr-v2-07, data/archives/ilr-v2-07-relaxed,
|
| 170 |
+
data/archives/ilr-v2-08, data/archives/ilr-v2-08-relaxed, data/archives/ilr-v2-09, data/archives/ilr-v2-09-relaxed,
|
| 171 |
+
data/archives/ilr-v2-10, data/archives/ilr-v2-10-relaxed, data/archives/ilr-v2-11, data/archives/ilr-v2-11-relaxed,
|
| 172 |
+
data/archives/ilr-v2-12, data/archives/ilr-v2-12-relaxed]
|
| 173 |
+
unit_state_dir: data/archives/unit-state-v1
|
| 174 |
+
epochs: 3
|
| 175 |
+
batch: 32
|
| 176 |
+
lr: 6.0e-4
|
| 177 |
+
warmup: 300
|
| 178 |
+
final_lr: 0.1
|
| 179 |
+
weight_decay: 0.1
|
| 180 |
+
val_fraction: 0.02
|
| 181 |
+
mirror: 0.5
|
| 182 |
+
amp: true
|
| 183 |
+
aux_next_play: 0.5
|
| 184 |
+
aux_next_ability: 0.5
|
| 185 |
+
model:
|
| 186 |
+
dim: 384
|
| 187 |
+
layers: 6
|
| 188 |
+
heads: 8
|
| 189 |
+
ff: 768
|
| 190 |
+
dropout: 0.2
|
| 191 |
+
tower_context: true
|
| 192 |
+
unit_state: [motion, combat, status] # drop this line to train without sidecars (then skip step 2)
|
| 193 |
+
next_play_head: 13
|
| 194 |
+
next_ability_head: 13
|
| 195 |
+
packed_cache: data/il-packed
|
| 196 |
+
trim_board_padding: true
|
| 197 |
+
ema: 0.999
|
| 198 |
+
token_drop: 0.1
|
| 199 |
+
compile: true # needs triton; set false on Windows
|
| 200 |
+
```
|
| 201 |
+
|
| 202 |
+
```bash
|
| 203 |
+
python -m alpha_cr.train.il --config configs/il-ilr-v2.yaml
|
| 204 |
+
```
|
| 205 |
+
|
| 206 |
+
Things to know before training:
|
| 207 |
+
|
| 208 |
+
- **Tile smoothing:** `tile_smooth` cannot be combined with decision weights; training raises a `ValueError`.
|
| 209 |
+
- **Validation:** the validation split (`val_fraction`) is drawn from these weighted games, so its loss is weighted
|
| 210 |
+
too. For a clean comparison with earlier models, evaluate on an exact-replay or Tencent split as well.
|
| 211 |
+
- **Mixing with other data:** add the other archives (for example the `us*` archives) to `data:`. Archives without
|
| 212 |
+
`decision_weights` weigh 1.
|
| 213 |
+
- **Subsets:** each chunk is a random slice of IL_Replay, so a subset of chunks is a uniform subsample. Use, for
|
| 214 |
+
example, `ilr-v2-00` … `ilr-v2-03` for a quick screening run.
|