Prepare selective regeneration of teacher games with capped rollouts

This commit is contained in:
coyotte508 2026-10-01 00:01:59 +02:00
commit d0fa8f0181
4 changed files with 173 additions and 1 deletions

View file

@ -10997,5 +10997,21 @@
}
},
"decision": "Continue H200 training: update19 improves over update9 against economic opponents at 3-6 players and frozen A260 at 3 players with paired intervals above zero. A260 win credit 32.0833% remains below 33.3333% equal-share point reference and is not qualification. Two-player economic performance regresses versus geoleague update9 (paired -6.875pp, CI [-13.28125,-0.78125]); retain earlier candidates."
},
"strong_teacher_selective_repair": {
"status": "PREPARED_NOT_LAUNCHED",
"reason": "Six-player original teacher job reports two capped teacher rollouts at 110 games. Original job remains running; repair must wait for all five complete shards and pin their immutable input revision.",
"source": {
"archive": "strong-source-v33.tgz",
"revision": "be9262485a29f38dd5c7f0f8442909d70bb98b94",
"base_revision": "37465b08df007221665d796448aea57e6828257e",
"changed_files": [
"ai/strong/repair-teacher-dataset.py"
],
"archive_sha256": "c1d380544a9db2f15dece6d6d45c5233a5eaa39fd3243f1aef4326a3ca5cf556"
},
"launcher": "ai/strong/launch-teacher-repair.sh",
"output_version": "multiplayer-teacher-v2-strong-repaired",
"policy": "Preserve clean games; replay only affected full games at 2400-step search horizon using original IDs/seeds. Keep originals untouched and record original capped counts. Require full strict audit before GPU training."
}
}

View file

@ -8,7 +8,7 @@ hf jobs run --detach --flavor "${HF_FLAVOR:-a10g-large}" --timeout "${JOB_TIMEOU
--secrets HF_TOKEN \
--env HF_DATA_REPO=coyotte508/powergrid-ai-training-v1 \
--env HF_MODEL_REPO=coyotte508/powergrid-ai-germany-v1 \
--env RUN_NAME="${RUN_NAME:-multiplayer-distillation-strong-replay-v1-$mode}" --env TARGET_MODE="$mode" --env TRAIN_SEED=622 --env ARCHITECTURE=multiplayer_ordered --env DATA_REVISION="$revision" --env EPOCHS="${EPOCHS:-15}" --env LR="${LR:-0.00005}" --env DATA_VERSION=multiplayer-teacher-v2-strong --env SHARDS=5 --env DISAGREEMENT_WEIGHT=2 \
--env RUN_NAME="${RUN_NAME:-multiplayer-distillation-strong-replay-v1-$mode}" --env TARGET_MODE="$mode" --env TRAIN_SEED=622 --env ARCHITECTURE=multiplayer_ordered --env DATA_REVISION="$revision" --env EPOCHS="${EPOCHS:-15}" --env LR="${LR:-0.00005}" --env DATA_VERSION="${DATA_VERSION:-multiplayer-teacher-v2-strong-repaired}" --env SHARDS=5 --env DISAGREEMENT_WEIGHT=2 \
--env INIT_CHECKPOINT=runs/multiplayer-distillation-v2-hard/best.pt --env INIT_REVISION=ab34dd266010ded1c9a6c818c721e5505dd1ddeb \
--env REPLAY_DATA_VERSION=multiplayer-teacher-v1 --env REPLAY_DATA_REVISION=082ca1456736940ee32c96db3ad1bc4e4d0b206b \
--label project=powergrid-ai --label stage="multiplayer-distillation-strong-replay-$mode" \

View file

@ -0,0 +1,23 @@
#!/usr/bin/env bash
set -euo pipefail
revision=${1:?Pin completed original stronger-opponent dataset revision}
[[ "$revision" =~ ^[0-9a-f]{40}$ ]]
hf jobs run --detach --flavor cpu-performance --timeout 3h \
--secrets HF_TOKEN \
--env HF_DATA_REPO=coyotte508/powergrid-ai-training-v1 \
--env REPAIR_INPUT_REVISION="$revision" \
--env REPAIR_INPUT_VERSION=multiplayer-teacher-v2-strong \
--env REPAIR_OUTPUT_VERSION=multiplayer-teacher-v2-strong-repaired \
--env DATA_WORKERS=24 \
--label project=powergrid-ai --label stage=strong-teacher-horizon-repair \
-- pytorch/pytorch:2.6.0-cuda12.4-cudnn9-runtime bash -lc '
set -euo pipefail
python -m pip install --quiet --timeout 120 --retries 5 huggingface_hub==2.0.0
mkdir -p /workspace
python -c "import urllib.request,tarfile; urllib.request.urlretrieve(\"https://nodejs.org/dist/v24.14.0/node-v24.14.0-linux-x64.tar.xz\",\"/tmp/node.tar.xz\");tarfile.open(\"/tmp/node.tar.xz\").extractall(\"/opt\")"
export PATH=/opt/node-v24.14.0-linux-x64/bin:$PATH
python -c "from huggingface_hub import hf_hub_download;import tarfile;p=hf_hub_download(\"coyotte508/powergrid-ai-training-v1\",\"strong-source-v33.tgz\",repo_type=\"dataset\",revision=\"be9262485a29f38dd5c7f0f8442909d70bb98b94\");tarfile.open(p).extractall(\"/workspace\")"
cd /workspace
node --test ai/test.cjs ai/strong/test.cjs
python -u ai/strong/repair-teacher-dataset.py
'

View file

@ -0,0 +1,133 @@
"""HF CPU job: preserve clean teacher games and replay capped games at 2400 moves."""
from concurrent.futures import ThreadPoolExecutor
from collections import Counter
import gzip
import json
import os
from pathlib import Path
import subprocess
from huggingface_hub import HfApi, hf_hub_download
from teacher_contract import validate_game
repo = os.environ["HF_DATA_REPO"]
revision = os.environ["REPAIR_INPUT_REVISION"]
version = os.environ["REPAIR_INPUT_VERSION"]
target = os.environ["REPAIR_OUTPUT_VERSION"]
assert len(revision) == 40 and all(c in "0123456789abcdef" for c in revision)
assert version != target
assert all(c.isalnum() or c in "-_" for c in target)
limit = int(
subprocess.check_output(
[
"node",
"-e",
"console.log(require('./ai/strong/search.cjs').DEFAULT_MAX_STEPS)",
],
text=True,
)
)
assert limit == 2400
out = Path("ai/runs") / target
out.mkdir(parents=True, exist_ok=True)
manifest = dict(
input_revision=revision,
input_version=version,
output_version=target,
repaired_search_max_steps=limit,
shards=[],
)
seen = set()
def capped(g):
return bool(
g["truncated"]
or g["searchStats"]["truncated"]
or g.get("opponentSearchStats", {}).get("truncated", 0)
)
def regenerate(old):
env = {
**os.environ,
"DATA_VERSION": version,
"PLAYER_COUNT": str(old["playerCount"]),
"FEATURE_REVISION": "4.0-multiplayer",
"TEACHER_OPPONENTS": "search_geo",
"OPPONENT_SEARCH_SAMPLES": "16",
"SEARCH_SAMPLES": "48",
"GEOGRAPHY": "1",
"INCLUDE_ALL_PHASES": "1",
}
result = subprocess.run(
["node", "ai/strong/search-teacher.cjs", str(old["id"])],
env=env,
text=True,
capture_output=True,
check=True,
)
new = json.loads(result.stdout)
validate_game(new)
assert not capped(new), "Corrected game still truncated; keep it out of training"
for key in ["seed", "id", "playerCount", "variant", "sealed", "opponent"]:
assert old[key] == new[key], f"Replay identity changed: {key}"
new["searchMaxSteps"] = limit
print(
json.dumps(dict(stage="repaired_teacher_game", id=new["id"], seed=new["seed"])),
flush=True,
)
return new
for shard, n in enumerate(range(2, 7)):
path = hf_hub_download(
repo,
f"{version}/{version}-{shard}.jsonl.gz",
repo_type="dataset",
revision=revision,
)
with gzip.open(path, "rt") as f:
games = [json.loads(line) for line in f]
assert len(games) == 240 and len({g["id"] for g in games}) == 240
for g in games:
validate_game(g)
assert g["playerCount"] == n and g["opponent"] == "search_geo"
assert g["seed"] not in seen
seen.add(g["seed"])
bad = [g for g in games if capped(g)]
with ThreadPoolExecutor(int(os.getenv("DATA_WORKERS", "24"))) as pool:
replacements = {g["id"]: g for g in pool.map(regenerate, bad)}
repaired = [replacements.get(g["id"], g) for g in games]
cells = Counter((g["rows"][0]["seat"], g["variant"], g["sealed"]) for g in repaired)
assert len(cells) == 4 * n and set(cells.values()) == {240 // (4 * n)}
assert all(not capped(g) for g in repaired)
with gzip.open(out / f"{target}-{shard}.jsonl.gz", "wt") as f:
for g in repaired:
f.write(json.dumps(g, separators=(",", ":")) + "\n")
info = dict(
shard=shard,
player_count=n,
games=240,
preserved_games=240 - len(bad),
regenerated_games=len(bad),
positions=sum(len(g["rows"]) for g in repaired),
original_capped_games=[
dict(
id=g["id"],
seed=g["seed"],
truncated=g["truncated"],
searchStats=g["searchStats"],
opponentSearchStats=g.get("opponentSearchStats"),
)
for g in bad
],
)
manifest["shards"].append(info)
print(json.dumps(dict(stage="repaired_shard", **info)), flush=True)
assert len(seen) == 1200
(out / "repair-manifest.json").write_text(json.dumps(manifest, indent=2) + "\n")
HfApi().upload_folder(
repo_id=repo, repo_type="dataset", folder_path=str(out), path_in_repo=target
)