Launch paired continuation-policy and larger-budget teacher audit
This commit is contained in:
parent
1835c4ccd3
commit
4bc256a8b1
6 changed files with 171 additions and 2 deletions
15
ai/strong/audit-search-budget.cjs
Normal file
15
ai/strong/audit-search-budget.cjs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
// Paired public scenarios across continuation policies and nested search budgets.
|
||||
const fs = require('node:fs');
|
||||
const search = require('./search.cjs');
|
||||
const rows = fs.readFileSync(process.argv[2], 'utf8').trim().split('\n');
|
||||
const row = JSON.parse(rows[Number(process.argv[3])]);
|
||||
const continuation = process.argv[4], batch = process.argv[5];
|
||||
if (!['a', 'b'].includes(batch)) throw Error('Invalid batch');
|
||||
const { state, player } = row.request;
|
||||
const result = search.choose(state, player, {
|
||||
samples: 384, candidates: 6, geography: true, maxSteps: 2400,
|
||||
seed: `teacher-reliability-v1-${row.fixtureIndex}-${batch}`,
|
||||
continuation, includeSamples: true,
|
||||
});
|
||||
console.log(JSON.stringify({ fixtureIndex: row.fixtureIndex, cell: row.cell,
|
||||
round: state.round, continuation, batch, samples: 384, result }));
|
||||
55
ai/strong/audit-search-budgets.py
Normal file
55
ai/strong/audit-search-budgets.py
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
"""HF diagnostic shard: repeat searches with shared scenarios across policies."""
|
||||
import concurrent.futures
|
||||
import hashlib
|
||||
import itertools
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
from huggingface_hub import HfApi
|
||||
|
||||
players = int(os.environ['PLAYER_COUNT'])
|
||||
assert 2 <= players <= 6
|
||||
fixtures = Path('ai/strong/fixtures/teacher-reliability-v1.jsonl')
|
||||
rows = [json.loads(line) for line in fixtures.read_text().splitlines()]
|
||||
indices = [i for i, r in enumerate(rows) if r['cell'][0] == players]
|
||||
assert len(indices) == 12
|
||||
tasks = list(itertools.product(indices, ['mixed', 'economic', 'heuristic'], ['a', 'b']))
|
||||
|
||||
|
||||
def audit(task):
|
||||
index, policy, batch = task
|
||||
process = subprocess.run(['node', 'ai/strong/audit-search-budget.cjs', str(fixtures),
|
||||
str(index), policy, batch], capture_output=True, text=True, check=True)
|
||||
row = json.loads(process.stdout)
|
||||
assert row['cell'][0] == players and row['continuation'] == policy and row['batch'] == batch
|
||||
result = row['result']
|
||||
assert len(result['sampleOutcomes']) * 384 == result['evaluations']
|
||||
assert sum(v.count(None) for v in result['sampleOutcomes'].values()) == result['truncated']
|
||||
for k, v in result['sampleOutcomes'].items():
|
||||
assert len(v) == 384 and sum(x for x in v if x is not None) == result['values'][k]
|
||||
return row
|
||||
|
||||
|
||||
completed = []
|
||||
with concurrent.futures.ThreadPoolExecutor(max_workers=24) as pool:
|
||||
futures = [pool.submit(audit, task) for task in tasks]
|
||||
for f in concurrent.futures.as_completed(futures):
|
||||
completed.append(f.result())
|
||||
print(json.dumps({'players': players, 'completed_searches': len(completed),
|
||||
'requested_searches': len(tasks)}), flush=True)
|
||||
completed.sort(key=lambda r: (r['fixtureIndex'], r['continuation'], r['batch']))
|
||||
output = Path(f'results-{players}p.jsonl')
|
||||
output.write_text(''.join(json.dumps(r) + '\n' for r in completed))
|
||||
manifest = {'players': players, 'positions': 12, 'searches': len(completed), 'samples': 384,
|
||||
'search_max_steps': 2400, 'fixture_sha256': hashlib.sha256(fixtures.read_bytes()).hexdigest(),
|
||||
'output_sha256': hashlib.sha256(output.read_bytes()).hexdigest(),
|
||||
'evaluations': sum(r['result']['evaluations'] for r in completed),
|
||||
'truncated': sum(r['result']['truncated'] for r in completed),
|
||||
'scope': 'Reused development positions; nested budgets and shared public scenarios; no strength claim.'}
|
||||
api = HfApi()
|
||||
api.upload_file(repo_id=os.environ['HF_MODEL_REPO'], path_or_fileobj=output,
|
||||
path_in_repo=f'runs/teacher-reliability-v2/{output.name}')
|
||||
api.upload_file(repo_id=os.environ['HF_MODEL_REPO'], path_or_fileobj=json.dumps(manifest, indent=2).encode(),
|
||||
path_in_repo=f'runs/teacher-reliability-v2/manifest-{players}p.json')
|
||||
print(json.dumps(manifest), flush=True)
|
||||
|
|
@ -218,7 +218,12 @@
|
|||
"league-admission-periodic-anchor-u19-economic-5p": "6abe1ad1404719ba37617103",
|
||||
"league-admission-periodic-anchor-u19-economic-6p": "6abe1ad2fbc85ba682360a72",
|
||||
"league-admission-periodic-anchor-u19-a260-3p": "6abe1ad2404719ba37617105",
|
||||
"teacher-reliability-v1": "6abe1cc8404719ba376171b1"
|
||||
"teacher-reliability-v1": "6abe1cc8404719ba376171b1",
|
||||
"teacher-reliability-v2-2p": "6abe1df0fbc85ba682360bd8",
|
||||
"teacher-reliability-v2-3p": "6abe1df1404719ba3761721e",
|
||||
"teacher-reliability-v2-4p": "6abe1df2fbc85ba682360bda",
|
||||
"teacher-reliability-v2-5p": "6abe1df2fbc85ba682360bdc",
|
||||
"teacher-reliability-v2-6p": "6abe1df3fbc85ba682360be0"
|
||||
},
|
||||
"cancelled_while_queued": [
|
||||
"6abd128efbc85ba68235b1a6",
|
||||
|
|
@ -34363,5 +34368,66 @@
|
|||
},
|
||||
"decision": "Target reproducibility is insufficient to assume that more hard-label distillation will improve the model: selected action agrees39/60 overall and8/20 bidding;16/60 discovery positions tie every candidate. This is a small reused-development diagnostic, not a game-strength estimate. Next compare larger sample budgets and fixed continuation policies on identical public scenarios before training more targets.",
|
||||
"caveat": "No positive distribution-free confirmation lower bound at48 samples does not prove no useful moves; the bound is conservative. Mixed-policy subset disagreement is confounded by distinct scenario samples, so it does not identify a causal policy effect."
|
||||
},
|
||||
"teacher_reliability_v2": {
|
||||
"status": "RUNNING",
|
||||
"source_revision": "d07e072058ee877112d609280980fc806ee8ce28",
|
||||
"source_archive": "strong-source-v36.tgz",
|
||||
"source_sha256": "6c4170317a74a5148c2a576ad93d1170441e0d8e791a7e6c23197c51dad69109",
|
||||
"base_revision": "aee5febe0ea0c60988f76a937521e87956544526",
|
||||
"changed_files": [
|
||||
"ai/strong/search.cjs",
|
||||
"ai/strong/test-search-samples.cjs",
|
||||
"ai/strong/audit-search-budget.cjs",
|
||||
"ai/strong/audit-search-budgets.py"
|
||||
],
|
||||
"fixture_sha256": "855b34ad7f07665dfcb012a673147f0780820a9e7560fda268a9a39478c60ff4",
|
||||
"positions": 60,
|
||||
"samples_per_batch": 384,
|
||||
"batches": [
|
||||
"a",
|
||||
"b"
|
||||
],
|
||||
"continuations": [
|
||||
"mixed",
|
||||
"economic",
|
||||
"heuristic"
|
||||
],
|
||||
"search_max_steps": 2400,
|
||||
"workers_per_job": 24,
|
||||
"jobs": [
|
||||
{
|
||||
"run": "teacher-reliability-v2-2p",
|
||||
"players": 2,
|
||||
"job_id": "6abe1df0fbc85ba682360bd8",
|
||||
"observed_stage": "RUNNING"
|
||||
},
|
||||
{
|
||||
"run": "teacher-reliability-v2-3p",
|
||||
"players": 3,
|
||||
"job_id": "6abe1df1404719ba3761721e",
|
||||
"observed_stage": "RUNNING"
|
||||
},
|
||||
{
|
||||
"run": "teacher-reliability-v2-4p",
|
||||
"players": 4,
|
||||
"job_id": "6abe1df2fbc85ba682360bda",
|
||||
"observed_stage": "RUNNING"
|
||||
},
|
||||
{
|
||||
"run": "teacher-reliability-v2-5p",
|
||||
"players": 5,
|
||||
"job_id": "6abe1df2fbc85ba682360bdc",
|
||||
"observed_stage": "RUNNING"
|
||||
},
|
||||
{
|
||||
"run": "teacher-reliability-v2-6p",
|
||||
"players": 6,
|
||||
"job_id": "6abe1df3fbc85ba682360be0",
|
||||
"observed_stage": "RUNNING"
|
||||
}
|
||||
],
|
||||
"purpose": "Separate finite-sample instability from dependence on continuation policy using nested budgets and shared public scenarios. Diagnostic only; no gradients and no strength claim.",
|
||||
"tests": "3 search regression tests pass, including preservation of defaults and identical fixed-policy samples."
|
||||
}
|
||||
}
|
||||
|
|
|
|||
18
ai/strong/launch-teacher-reliability-v2.sh
Normal file
18
ai/strong/launch-teacher-reliability-v2.sh
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
players=${1:?Specify player count 2–6}
|
||||
[[ "$players" =~ ^[2-6]$ ]]
|
||||
hf jobs run --detach --flavor cpu-performance --timeout 6h \
|
||||
--secrets HF_TOKEN --env PLAYER_COUNT="$players" --env HF_MODEL_REPO=coyotte508/powergrid-ai-germany-v1 \
|
||||
--label project=powergrid-ai --label stage="teacher-reliability-v2-${players}p" \
|
||||
-- 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-v36.tgz\",repo_type=\"dataset\",revision=\"d07e072058ee877112d609280980fc806ee8ce28\");tarfile.open(p).extractall(\"/workspace\")"
|
||||
cd /workspace
|
||||
node --test ai/strong/test-search-samples.cjs ai/strong/test-search-horizon.cjs
|
||||
python -u ai/strong/audit-search-budgets.py
|
||||
'
|
||||
|
|
@ -48,8 +48,10 @@ function choose(
|
|||
extraCandidates = [],
|
||||
geography = false,
|
||||
includeSamples = false,
|
||||
continuation = 'mixed',
|
||||
} = {}
|
||||
) {
|
||||
if (!['mixed', 'heuristic', 'economic'].includes(continuation)) throw Error('Invalid continuation policy');
|
||||
const actions = c.candidates(g, seat),
|
||||
options = [...new Set([...shortlist(g, seat, candidates, geography), ...extraCandidates])];
|
||||
if (options.some((i) => !Number.isInteger(i) || i < 0 || i >= actions.length))
|
||||
|
|
@ -68,7 +70,8 @@ function choose(
|
|||
let step = 0;
|
||||
while (!c.E.ended(sim) && step++ < maxSteps) {
|
||||
const p = sim.currentPlayers[0];
|
||||
const move = sample % 2 ? c.heuristic(sim, p, rng).action : eco.choose(sim, p, rng).action;
|
||||
const useHeuristic = continuation === 'heuristic' || (continuation === 'mixed' && sample % 2);
|
||||
const move = useHeuristic ? c.heuristic(sim, p, rng).action : eco.choose(sim, p, rng).action;
|
||||
c.E.move(sim, move, p);
|
||||
}
|
||||
if (c.E.ended(sim)) {
|
||||
|
|
|
|||
|
|
@ -24,3 +24,15 @@ test('optional paired outcomes preserve decisions and distinguish capped continu
|
|||
assert.equal(capped, maxSteps === 1200 ? 1 : 0);
|
||||
}
|
||||
});
|
||||
|
||||
test('fixed continuation policies share scenarios and reproduce mixed-policy samples', () => {
|
||||
const options = { ...fixture.options, samples: 2, maxSteps: 2400, includeSamples: true };
|
||||
const mixed = search.choose(fixture.state, fixture.seat, options);
|
||||
const economic = search.choose(fixture.state, fixture.seat, { ...options, continuation: 'economic' });
|
||||
const heuristic = search.choose(fixture.state, fixture.seat, { ...options, continuation: 'heuristic' });
|
||||
for (const k of Object.keys(mixed.sampleOutcomes)) {
|
||||
assert.equal(mixed.sampleOutcomes[k][0], economic.sampleOutcomes[k][0]);
|
||||
assert.equal(mixed.sampleOutcomes[k][1], heuristic.sampleOutcomes[k][1]);
|
||||
}
|
||||
assert.throws(() => search.choose(fixture.state, fixture.seat, { continuation: 'unknown' }), /Invalid continuation/);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue