Repository navigation
grl_snam.learning: learning histories, held-out curve marks, arms and learn-report (Phase 1a, 1b) - #171
Merged
Conversation
…pare arms, report claims Phase 1a and 1b of the learning proof: is a learner learning, or fitting noise? Held-out data, against an untrained arm and a constant arm. - grl_snam/learning/history.py: load(paths, follow=False) reads any trainer's JSON-lines history by the shared conventions (kind, step/epoch, train/terms beside heldout, heads.<g>.*, grad_norm, best*, blob/checkpoint), no per-schema adapter: series <kind>.<path>, the header as meta, a checkpoint table with the pick, train/held-out term pairs, band() across seeds, and an mtime/size re-read that tolerates a half-written last line. - grl_snam/learning/curves.py: best, Kneedle elbow, plateau (windowed Theil-Sen change against the curve's IQR) and divergence after best, on a 5-point running median, each threshold with a noise floor (robust sd of the second differences) so a flat noisy curve gets no elbow and no divergence. - grl_snam/learning/stats.py: the downstream A/B harness's percentile bootstrap, draw for draw (5000 resamples, one seeded generator), and paired differences that keep pairs together. - grl_snam/learning/arms.py + tools/arms_eval.py: arms NAME=PATH|const:..., scored on paired held-out seeds through coef_eval and scorecard_eval, written as grl_snam.arms/v1 (the harness's JSON shape plus per-seed values, direction and primary metrics). - grl_snam/learning/report.py + `grl-snam learn-report`: loss, selection, task and planted claims, each pass or fail, plus the curves' marks and the checkpoint tables. - tools/coef_export.py: --constant (a CoefMLP with zero weights whose output bias is the inverse activation of each constant, to .cvcnav or .pt) and read_coef_mlp (.cvcnav back to torch). - tools/scorecard_eval.py: episodes(model, seeds) gives the per-scene stats evaluate() reduces. - tests/learning/*, tests/fixtures/learning_history/* (five writers' layouts, downstream ones with neutral names), tests/fixtures/learning_marks_golden.json (tools/learning_marks_golden.py regenerates and checks it).
…rms, metrics, init) Found running learn-report on the five real retrain histories of the base-measure work (its PR #172): - A held-out <prefix>_<term> (grl-snam train's obj_goal) with no exact twin pairs with the training <term>; without it no objective term had a twin. - A held-out value with a training twin is a loss term; the loss claims are made on those (and on fitness) only. Held-out metrics with no twin (reach, path_m, min_clear_m, ...) get marks and are listed under untested, instead of a claim with a guessed direction: reach and min_clear_m read as lower-is-better before. HIGHER_IS_BETTER and a header `maximize` list give a metric's direction for its marks. - An `init` record (train_coef_energy's untrained evaluation before epoch 0) joins the first evaluated kind's series one before its first x, so the untrained net is the first point. - `planted` values are not loss terms (the planted claims read them). - One run needs 5 evaluations for a loss claim to pass (the noise floor needs them); its margin is now max(delta * IQR, z * noise). Fixtures: sdf_train_history.jsonl (a subset of retrain seed 0) and coef_energy_history_planted.jsonl (the E1 pipeline history), both from #172.
transfix
added a commit
that referenced
this pull request
Nov 14, 2026
… (held-out objectives in arms-eval) (#174) #171's loss claims compared a trained run's held-out loss terms only with that run's own step 0, because a learning history holds the trained run alone. Every arm is now scored with the trainer's own objective on the same held-out units, and learn-report claims on those as loss terms, as it already did for the task metric. - grl_snam.learning.objective: per-unit held-out terms for grl-snam train (loss, goal, col, reg per held-out pair; the mean is the history's obj_<term>) and coef-train (loss, goal, coll per held-out start, surrogate or bicycle; the mean is the trainer's step record at a fixed net). No gradient, a forked torch RNG, the net's mode restored. - arms-eval: opt-in cases objective-sdf and objective-coef (direction down, family "loss", unit "pair"/"start"); --label names the run. The default cases are unchanged. - arms: per-case family/unit fields; runs_paired_diff, a runs x units two-level bootstrap for one table per training seed. - learn-report: claims on a loss case are family "loss" (loss:<case>:<term>:trained-vs-<arm>); --arms repeats (one table per run, pooled). The report JSON only gains fields (sources.arms_tables; unit, runs, per_run, labels in evidence). - experiments/learning_proof/objective_arms.py scores through the library; it rebuilds docs/learning-validation/objective.json byte for byte.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Is a learner learning, or fitting noise? This adds the public, generic core that answers it on held-out data, against an untrained arm (the policy at step 0) and a constant arm (fixed coefficients, no state dependence). It covers Phase 1a and 1b of the learning-proof plan. E1 (planted dissipation) and the retrain come later.
What's here
grl_snam/learning/history.py: one reader for every trainer's learning history.load(paths, follow=False)reads JSON-lines histories by the shared conventions, with no per-schema adapter:kind; x fromstep(elseepoch);train/termsbesideheldout/heldout_terms;heads.<g>.{mean,spread,dtheta_rel,…},grad_norm;best*and theendrecord's pick,blob/checkpoint.<kind>.<dotted.path>(the header becomes the meta), a checkpoint table with the pick, train/held-out term pairs, andband(runs, name)across seeds.follow=Truere-reads a file whose mtime or size changed. A missing file reads as empty, and a half-written last line is skipped.grl_snam.coef_train_history/v1andgrl_snam.coef_energy_history/v1(round-trip tests through the real writers), libcvc'scvc.nav.coef_train_history/v1, and two downstream layouts (fixtures with neutral names).grl_snam/learning/curves.py: marks on a held-out curve, after a 5-point running median.patiencewindows. The window ismax(5, n // 6).tests/fixtures/learning_marks_golden.jsonholds 8 synthetic curves with their marks, parameters and tolerance, for other implementations to check against.python -m grl_snam.tools.learning_marks_golden --out|--checkregenerates and verifies it.grl_snam/learning/stats.py. A seeded percentile bootstrap that follows the downstream A/B harness'sbootstrap_cidraw for draw: 5000 resamples,random.Random, the same percentile indices, one generator consumed in order. Plus paired differences (arm − reference) that pair by unit and keep pairs together.Arms:
grl_snam/learning/arms.py,grl_snam/tools/arms_eval.py,grl-snam arms-eval.--arm NAME=PATH|const:…:.cvcnav(a run's step-0 blob is the untrained arm) or a.pt;const:1.2,3,4,const:beta=2.5,const:bias, orconst:hist=H.jsonl(each head's mean at the run's held-out pick: the trained policy with its state dependence removed).coef_eval(the ice-band city: reach, pen, clear, gap) andscorecard_eval(one city scene per seed: arrival, success, penetration %, path ratio, time to goal, stalls).scorecard_eval.episodes(model, seeds)is split out ofevaluate()for the per-scene values.evaluate()is unchanged.grl_snam.arms/v1, has the harness's JSON shape:arms, thenresults[].metrics[m][arm] = {mean, ci95, n, paired_diff}. It adds per-seedseeds/values,directionandprimarymetrics, so one table reader reads both.coef_export --constant SPEC out.cvcnav|out.pt.log(expm1)fold for α/β/γ;logit(c/max)for a sigmoid lam head.--liketakes the input layout from another policy. It also accepts the plaina,b,gform.read_coef_mlp(path)loads any.cvcnavback into torch, with the same forward and byte-identical re-export. Every layout is tested: plain, μ, risk, lam v1, two-head v2.coef_mlpreturns the constant blob's coefficients exactly.The report:
grl_snam/learning/report.py,grl-snam learn-report HIST… [--arms A.json] --json R.json. Each claim is marked pass or fail:<prefix>_<name>as ingrl-snam train'sobj_goal), orfitness. The last, not the picked one: the pick is chosen on the same held-out data. With several seeds the bootstrap CI of the per-run gain must lie above 0. One run needs at least 5 evaluations and a gain above max(δ·IQR, z·σ̂), and the evidence says that basis. Held-out metrics with no twin (reach, path length, clearance) get marks, with reach and clearance read as higher-is-better, but no claim; they are listed underuntested.paired_diff.…planted.<region>.rel_erris within the bound at the pick, and the untrained net's is not. This is ready for E1.The report also carries each run's curve marks, each head's plateau and the checkpoint table, which the Ariadne Learning window will read. A claim the data cannot support fails and says why, and
--strictexits 1 on any failure.Checked
tests/learning/: 61 tests, covering the five history layouts (plus two real ones from Does base GRL-SNAM's policy learn? The coef_sdf learning check, and E1 (planted dissipation) #172: agrl-snam trainretrain seed and the E1 history with itsinitrecord), both writers' round trips,follow, the golden, bootstrap parity, the arms table,arms_evalend to end,--constant/read_coef_mlp, the report families and the CLI passthroughs.coef-train --history --checkpoint-every --keep-best→arms-eval→learn-reporton a 40-step toy run. Its held-out pick was step 0, and the report failsselection:not-untrainedand every trained-vs-untrained claim (difference exactly 0), which is the right verdict.Not in this PR
Checked on real histories
The five retrain histories in #172 (
grl-snam train, 4000 steps, 41 checkpoints each) give: fitness +0.007 [+0.002, +0.013] (n = 5, pass); none of the four objective terms improves on held-out data (obj_loss −0.60 [−1.23, +0.03], fail);selection:not-untrainedfails (a seed picked step 0). This agrees with #172's write-up.