Launch multiplayer training validation and extend search teacher data
This commit is contained in:
parent
6967682bdd
commit
df6ae86a95
4 changed files with 107 additions and 15 deletions
|
|
@ -90,7 +90,8 @@
|
|||
"specialists-heuristic-screen": "6abd39e2fbc85ba68235be7a",
|
||||
"specialists-rush-screen": "6abd39e2404719ba37613c5c",
|
||||
"specialists-legacy-screen": "6abd39e3fbc85ba68235be7c",
|
||||
"specialists-frozen-a260-screen": "6abd39e4404719ba37613c5e"
|
||||
"specialists-frozen-a260-screen": "6abd39e4404719ba37613c5e",
|
||||
"multiplayer-pipeline-v1": "6abd41d2404719ba37613e0f"
|
||||
},
|
||||
"cancelled_while_queued": [
|
||||
"6abd128efbc85ba68235b1a6",
|
||||
|
|
@ -112,7 +113,10 @@
|
|||
"archive": "strong-source-v6.tgz",
|
||||
"commit": "cc79acffc12ad4cc1daffbad20b024d2e1f4fe98"
|
||||
},
|
||||
"stopped_for_sustained_regression": ["6abd15cafbc85ba68235b347", "6abd15ca404719ba376134e5"],
|
||||
"stopped_for_sustained_regression": [
|
||||
"6abd15cafbc85ba68235b347",
|
||||
"6abd15ca404719ba376134e5"
|
||||
],
|
||||
"all_phase_distillation_source": {
|
||||
"archive": "strong-source-v7.tgz",
|
||||
"commit": "0862207a0f62cb75edfd0e6ecbc472cdc190bcd0"
|
||||
|
|
@ -142,7 +146,10 @@
|
|||
"commit": "49c872954eaf7761a3ac3453acbf737f569849b2"
|
||||
},
|
||||
"new_candidate_revision": "b38515c29e57826de05b55b645c29591e4a886bf",
|
||||
"cancelled_wrong_screening_seed": ["6abd2b51404719ba37613954", "6abd2b51404719ba37613956"],
|
||||
"cancelled_wrong_screening_seed": [
|
||||
"6abd2b51404719ba37613954",
|
||||
"6abd2b51404719ba37613956"
|
||||
],
|
||||
"a260_refinement_source": {
|
||||
"archive": "strong-source-v12.tgz",
|
||||
"commit": "7cc340b37ee051af51346800a15d285cebfb1a39",
|
||||
|
|
@ -161,7 +168,10 @@
|
|||
"strong-refine-v1-search": {
|
||||
"job": "6abd2783404719ba37613860",
|
||||
"best_evaluation_update": 10,
|
||||
"later_evaluations": [20, 30],
|
||||
"later_evaluations": [
|
||||
20,
|
||||
30
|
||||
],
|
||||
"reason": "Mean economic/heuristic/rush win share declined from 0.5764 at update 10 to 0.5660 at 20 and 0.5347 at 30; every update-30 opponent result was below update 20. Best checkpoint retained; corrected A260 refinement is substantially stronger."
|
||||
}
|
||||
},
|
||||
|
|
@ -181,5 +191,23 @@
|
|||
"replacement_id": "6abd3b59fbc85ba68235beee",
|
||||
"reason": "Terminal ERROR during pip dependency download: files.pythonhosted.org read timeout; no games started. Identical checkpoint, source, scope and seed retried."
|
||||
}
|
||||
]
|
||||
],
|
||||
"multiplayer_pipeline": {
|
||||
"source_archive": "strong-source-v16.tgz",
|
||||
"source_revision": "6064b1683379153e0a5dbca24903d41a972cbe0a",
|
||||
"git_revision": "6967682",
|
||||
"architecture": "multiplayer",
|
||||
"feature_revision": "4.0-multiplayer",
|
||||
"players": [
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
6
|
||||
],
|
||||
"updates": 10,
|
||||
"envs": 120,
|
||||
"opponent_mode": "mixed_search",
|
||||
"status": "submitted; no strength claim"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,14 @@ shard = int(os.environ["SHARD"])
|
|||
games = int(os.getenv("GAMES", "128"))
|
||||
version = os.getenv("DATA_VERSION", "search-teacher-v1")
|
||||
output = Path(f"{version}-{shard}.jsonl.gz")
|
||||
counts = {"games": 0, "positions": 0, "teacher_disagreements": 0, "truncated": 0}
|
||||
counts = {
|
||||
"games": 0,
|
||||
"positions": 0,
|
||||
"teacher_disagreements": 0,
|
||||
"truncated": 0,
|
||||
"search_rollouts": 0,
|
||||
"search_rollouts_truncated": 0,
|
||||
}
|
||||
|
||||
|
||||
def generate(game):
|
||||
|
|
@ -34,6 +41,8 @@ with concurrent.futures.ThreadPoolExecutor(
|
|||
game = future.result()
|
||||
counts["games"] += 1
|
||||
counts["truncated"] += game["truncated"]
|
||||
counts["search_rollouts"] += game["searchStats"]["evaluations"]
|
||||
counts["search_rollouts_truncated"] += game["searchStats"]["truncated"]
|
||||
# Keep truncated metadata, but never turn incomplete outcomes into targets.
|
||||
if game["truncated"]:
|
||||
game["rows"] = []
|
||||
|
|
@ -54,6 +63,14 @@ api.upload_file(
|
|||
api.upload_file(
|
||||
repo_id=repo,
|
||||
repo_type="dataset",
|
||||
path_or_fileobj=json.dumps({"shard": shard, "schema": 3, **counts}).encode(),
|
||||
path_or_fileobj=json.dumps(
|
||||
{
|
||||
"shard": shard,
|
||||
"schema": 4 if os.getenv("FEATURE_REVISION") == "4.0-multiplayer" else 3,
|
||||
"feature_revision": os.getenv("FEATURE_REVISION", "3.1-uranium39"),
|
||||
"player_count": int(os.getenv("PLAYER_COUNT", "3")),
|
||||
**counts,
|
||||
}
|
||||
).encode(),
|
||||
path_in_repo=f"{version}/shard-{shard}-metrics.json",
|
||||
)
|
||||
|
|
|
|||
21
ai/strong/launch-multiplayer-pipeline.sh
Normal file
21
ai/strong/launch-multiplayer-pipeline.sh
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
hf jobs run --detach --flavor a10g-large --timeout 3h \
|
||||
--secrets HF_TOKEN \
|
||||
--env HF_MODEL_REPO=coyotte508/powergrid-ai-germany-v1 \
|
||||
--env RUN_NAME=multiplayer-pipeline-v1 --env TRAIN_SEED=621 --env LR=.00005 --env ENTROPY=.005 --env ANCHOR=.03 --env UPDATES=10 --env EVAL_EVERY=5 --env ARCHITECTURE=multiplayer --env OPPONENT_MODE=mixed_search \
|
||||
--env ENVS=120 --env WORKERS=10 --env BATCH_SIZE=512 \
|
||||
--label project=powergrid-ai --label stage=multiplayer-pipeline-v1 \
|
||||
-- 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 onnx==1.20.1
|
||||
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-v16.tgz\",repo_type=\"dataset\",revision=\"6064b1683379153e0a5dbca24903d41a972cbe0a\");tarfile.open(p).extractall(\"/workspace\")"
|
||||
cd /workspace
|
||||
node --test ai/test.cjs ai/strong/test.cjs ai/strong/test-v4.cjs
|
||||
python ai/strong/test_model_v4.py
|
||||
python ai/strong/test_multiplayer_bridge.py
|
||||
python -u ai/strong/train.py
|
||||
'
|
||||
|
|
@ -2,23 +2,43 @@
|
|||
const c = require('../core.cjs'),
|
||||
eco = require('./economics.cjs'),
|
||||
search = require('./search.cjs'),
|
||||
features = require('./features.cjs');
|
||||
features = require(process.env.FEATURE_REVISION === '4.0-multiplayer' ? './features-v4.cjs' : './features.cjs');
|
||||
const playerCount = Number(process.env.PLAYER_COUNT || 3);
|
||||
if (!Number.isInteger(playerCount) || playerCount < 2 || playerCount > 6) throw Error('Invalid teacher player count');
|
||||
if (playerCount !== 3 && features.SCHEMA !== 4) throw Error('Multiplayer games require schema 4');
|
||||
const id = Number(process.argv[2] || 0),
|
||||
seed = (process.env.DATA_VERSION || 'search-teacher-v1') + '-' + id,
|
||||
g = c.start(seed, id % 2 ? 'recharged' : 'original', id % 4 < 2),
|
||||
seat = Math.floor(id / 4) % 3,
|
||||
seed =
|
||||
(process.env.DATA_VERSION || 'search-teacher-v1') +
|
||||
(features.SCHEMA === 4 ? '-' + playerCount + 'p' : '') +
|
||||
'-' +
|
||||
id,
|
||||
g = c.E.setup(
|
||||
playerCount,
|
||||
{ map: 'Germany', variant: id % 2 ? 'recharged' : 'original', fastBid: id % 4 < 2, showMoney: true },
|
||||
seed
|
||||
),
|
||||
seat = Math.floor(id / 4) % playerCount,
|
||||
rng = c.seedrandom(seed + '-choices'),
|
||||
samples = Number(process.env.SEARCH_SAMPLES || 4),
|
||||
rows = [];
|
||||
let steps = 0;
|
||||
const searchStats = { decisions: 0, evaluations: 0, truncated: 0 };
|
||||
while (!c.E.ended(g) && steps < 1600) {
|
||||
const p = g.currentPlayers[0],
|
||||
legal = c.candidates(g, p),
|
||||
strategic = legal.length > 1 && legal.some((a) => ['ChoosePowerPlant', 'Bid', 'Build'].includes(a.name));
|
||||
let action;
|
||||
if (p === seat && strategic) {
|
||||
const result = search.choose(g, p, { samples, candidates: 5, seed: seed + '-decision-' + steps });
|
||||
const result = search.choose(g, p, {
|
||||
samples,
|
||||
candidates: process.env.GEOGRAPHY === '1' ? 6 : 5,
|
||||
geography: process.env.GEOGRAPHY === '1',
|
||||
seed: seed + '-decision-' + steps,
|
||||
});
|
||||
action = result.action;
|
||||
searchStats.decisions++;
|
||||
searchStats.evaluations += result.evaluations || 0;
|
||||
searchStats.truncated += result.truncated || 0;
|
||||
if (result.evaluations && !result.truncated) {
|
||||
const x = features.encode(g, p);
|
||||
rows.push({
|
||||
|
|
@ -33,7 +53,7 @@ while (!c.E.ended(g) && steps < 1600) {
|
|||
});
|
||||
}
|
||||
} else {
|
||||
const opponent = ['economic', 'heuristic', 'rush'][Math.floor(id / 12) % 3];
|
||||
const opponent = ['economic', 'heuristic', 'rush'][Math.floor(id / (4 * playerCount)) % 3];
|
||||
action =
|
||||
p !== seat && opponent === 'heuristic'
|
||||
? c.heuristic(g, p, rng).action
|
||||
|
|
@ -58,13 +78,19 @@ while (!c.E.ended(g) && steps < 1600) {
|
|||
steps++;
|
||||
}
|
||||
const truncated = !c.E.ended(g),
|
||||
value = truncated ? [0, 0, 0] : c.outcome(g),
|
||||
relativeValue = Array.from({ length: 3 }, (_, i) => value[(seat + i) % 3]);
|
||||
value = truncated ? Array(playerCount).fill(0) : c.outcome(g),
|
||||
relativeValue = Array.from({ length: features.SCHEMA === 4 ? 6 : 3 }, (_, i) =>
|
||||
i < playerCount ? value[(seat + i) % playerCount] : 0
|
||||
);
|
||||
console.log(
|
||||
JSON.stringify({
|
||||
id,
|
||||
seed,
|
||||
featureRevision: features.FEATURE_REVISION,
|
||||
playerCount,
|
||||
variant: g.options.variant,
|
||||
sealed: !!g.options.fastBid,
|
||||
searchStats,
|
||||
steps,
|
||||
truncated,
|
||||
value,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue