Repository navigation
feat(rung4): the boost target — extra samples of a high-noise row's regret, every source below it sampled k of n or enumerated, each unbiased against the exact sum kept as EXACT, the arrival always exact - #89
Conversation
…every opponent hand and every physical entry of its key, and the walk's arrival rate, from the rules alone PR 1 of the targeted-sampling plan. `minidrawmaha/solver/exact_target.py` computes, for any table row, the regret the walk's samples there estimate (the mean over the opponent's hands of u − ⟨σ, u⟩, weighted by the deck and the opponent's own play, normalised by the arrival) and the probability one walk visits the row. It re-derives the public tree, key maps, draw maps and showdown from rules/ and never imports the grader, which grades what this will feed. Measured: a round-2 row costs 0.8 ms, the arrival alone 0.3 ms; a draw row 45–85 ms and a round-1 row 0.2–0.6 s, because the value below expands over the traverser's own replacements and the second board card. Tests: the back-solved reach equals the grader's carried vector on every board of every point (1e-10, full and restricted deals); arrival at a seat's first decision is the grader's frequency and sums to one; regret and arrival equal a world-by-world walk through MiniState on a small restricted game (1e-9) and the mean and visit count of 6,000 Collector walks row by row within 4 s.e. and pooled; the module's import block holds no grader.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Claude finished @AlecROndo's task in 1m 15s —— View job Review of PR #89: exact target (
|
| # | Sev | Conf | Where | Issue |
|---|---|---|---|---|
| 1 | Low | Medium | module docstring, "Cost" section | The memo bound "29 × 15 + 20 × 210 = 4,635 vectors, ~270 MB" is stated as a hard cap. _reach memoises on node.level <= 1 or (parent is CHANCE and deals_board). That covers every level-0/1 node: the chance nodes after throws and the board-deal chance node as well as the 29 decision points. The count is therefore an under-count. The measured 260 MB peak is real, but the "at most" claim is not derived from the code. Either count nodes or say "about". Per AGENTS.md ("a wrong claim in a docstring is a bug"), this should be fixed in this PR. The 260 MB figure is also untested, unlike the timing. |
| 2 | Low | High | _reach (root), reach() |
_reach returns self.weight[carried] and the memoised arrays themselves, with no copy. reach() is public, and the memo is per call, so mutation can't leak across calls. A caller who does r *= … on a result from a shallow point would still corrupt shared state for that call. This is cheap to guard with setflags(write=False). |
| 3 | Low | Medium | test_exact_target.py (sampled test) |
The pooled mean of z² is accepted in (0.4, 2.0). If the exact target is right, the mean sits near 1. A window this wide would pass an s.e. that is off by ~1.4× either way, but the means are what matter. Please justify the window (for example, a rough sd of the pooled statistic over the number of rows) or tighten it. The 4 s.e. per-row check with only 40+ visits uses a plug-in s.e. from a heavy-tailed sample, so a rare per-row flake is possible. I can't see a seed-stability argument from the PR text. |
| 4 | Low | Medium | module docstring, "regret is the conditional mean of the banked sample given a visit" | This is exact only for rows visited at most once per walk. AGENTS.md notes that about 1 in 1000 traversals banks a row twice. The targets() docstring mentions this for arrival but the module-level statement does not. A short caveat would keep the claim strictly true. |
| 5 | Low | High | docstring ("the plan rules out", "the plan's §3") | The plan is not in the repo, and the docstring gives no path. AGENTS.md says the design record should be in docstrings, so a reader of exact_target.py can't follow this pointer. Please name the spec file under docs/superpowers/ or inline the one-line reason. |
| 6 | Info | Medium | _weights |
Duplicate holes in holes= are silently de-duplicated by the set. That is harmless, but a restricted-deal set that is not size-checked (for example a hole of the wrong length) is caught only via unknown. This looks fine as-is. |
| 7 | Info | Low | scope | arrivals(), reach() and entries_of() are public API with no consumer in this PR (PR 3 is named in the description). They are tested, so I'm not flagging them, but remove anything unused if PR 3 changes shape. |
Tests
Coverage is strong for a first PR: (a) the reach against the grader to 1e-10, an exact world-by-world oracle on a restricted deal with two non-closed suit relabellings, a sampled test, and refusals. The default suite stays free of torch, Modal and network, as AGENTS.md requires. I'd still ask that the author paste the uv run pytest tests/minidrawmaha/test_exact_target.py output after any fix for #1 and #3.
…, 5,190 vectors, re-derived by a test; the sampled tests select rows by expected count, so a row cannot enter because it fluctuated high Review follow-ups on #89. The docstring counted the memo's level-1 points alone (29) where the chance nodes on the paths are memoised too (66 in all); the test now walks the ancestor closure and pins 66, 20 and 5,190. `reach()` hands out a copy. The pooled z² windows are a 4-sd band on the chi-square mean, √(2/n), instead of fixed numbers. The gated 200,000-walk test kept rows by observed count ≥ 100, which let seat 1's draw rows in only when they had fluctuated high (mean z +1.8 on two seeds); rows are now kept by expected count ≥ 80 against an observed cutoff of 40, and both seats read mean z within 0.01 of zero over thousands of rows. The module docstring names the double-visit caveat and no longer points at a plan outside the repo without saying where it is.
|
Claude finished @AlecROndo's task in 28s —— View job Re-review of PR #89 after 8ed5c32I read the new commit's diff to Earlier findings, status
Remaining nits (Low)
I found no new correctness problems in the changes since the last review. |
… the mean of z², and cap a single row at six standard errors — the deal alone dealt one picture 292 times against 220 at seed 12 The pooled mean is the sharp bias test (a tenth of a standard error in every row is caught at 1,600 rows); the per-row cap is loose because of about 3,000 rows one passes 5 in a run out of a thousand, and the deal itself did it at seed 12 in a count that involves nothing of this module. Run with MINIDRAWMAHA_FULL_TARGET=1: both seats pass.
|
Disposition of the review's findings, after 8ed5c32 and the commit above.
Re-review nits: the long docstring line and the "path to a decision" wording describe the same closure the test pins; left as is. One finding of my own while running the gated test. At seed 12, seat 1's picture 3c 3d 4h with 2c on the board (six relabellings) was dealt 292 times in 200,000 walks against an expected 220, 4.9 standard errors, in a count that involves no σ and nothing of this module (221, 219, 222 on three other seeds). The exact arrival for that row equals a direct enumeration of every deal and board through Test output after the fixes: |
|
Claude finished @AlecROndo's task in 38s —— View job Re-review of PR #89 after 0712aa1I read the diff of the latest commit, which only touches What changed: the sampled tests and the 200k-walk test now also pin Checked and correct
Remaining nits (all Low)
Overall: I found no correctness problems in |
…e band's assumptions written beside it — the "caught at 1,600 rows" line was a half-truth; the band is reached there and reliable at about 3,000
|
Claude finished @AlecROndo's task in 19s —— View job Re-review of PR #89 after 918a76cI read the diff of this commit, which touches only Earlier nits, status
Remaining nits (all Low)
Overall: I found no correctness problems in |
…9 at n = 10, biting from n ≈ 45 — and the arrival seeds checked named
|
Claude finished @AlecROndo's task in 11s —— View job Re-review of PR #89 after 30b7951I read the diff of this commit, which touches only a docstring and one comment in Earlier nits, status
Remaining nit (Low, confidence High)
Overall: I found no correctness problems in |
…width drops under 1, not from 45
|
Claude finished @AlecROndo's task in 9s —— View job Re-review of PR #89 after 23cd464I read the diff of this commit. It changes one docstring in Previous nit, status
Remaining findings: none. The docstring is the only change, and it is now arithmetically correct. Overall: I found no correctness, test or pedagogy problems in the latest commit. All findings from the earlier reviews are resolved. |
…high-noise row — board card, both seats' replacements, the opponent's actions and range — each unbiased against the exact sum, which stays as EXACT, with the arrival always exact and one stream per (seed, t, seat, row) exact_target.py becomes boost_target.py (ExactTargets → BoostTargets). targets() takes a required Sampling; EXACT reproduces the previous output bit for bit.
… one branch at a time, averaged, is the exact sum to 1e-10 — and the range draw is tested where a key's two entries face different ranges; the stream's tail is two words, not one, and seed and t take any integer
|
Claude finished @AlecROndo's task in 1m 33s —— View job Review of PR #89 after b53f2a3 (exact target → boost target,
|
| # | Sev | Conf | Where | Issue |
|---|---|---|---|---|
| 1 | Medium | High | PR title and body | They still describe exact_target.py / ExactTargets, "Nothing else changes", and a cost table of 0.8 ms (round-2 row), 45–85 ms (draw row) and 0.2–0.6 s (round-1 row). The branch now renames to boost_target.py, adds Sampling, _Draws and per-row streams, and the module docstring gives 2 ms, 160–230 ms and 0.5–0.75 s. The plan's Task 4 step 3 already says to retitle and rewrite. Until then the PR text makes claims the code no longer matches (AGENTS.md: a wrong claim in README.md or a docstring is a bug; the PR body is the same kind of record). |
| 2 | Medium | High | test_boost_target.py, UNBIASED (~L725–755) |
For hero draws, opponent draws and board cards, the per-source unbiasedness test cannot detect a wrong scale factor, and the test file's own comment says so. It runs 60–200 seeds with a 4.5 s.e. gate, resolving a 13% to over-100% relative bias. The branch-by-branch oracle (test_a_chance_source_kept_one_branch_at_a_time…) pins those scale factors exactly, so coverage exists, but the plan's Task 3 step 1 asked for 400 seeds and assert_pooled_fair over the pooled z. The pooled check is not applied in this test, and it is the sharper bias test. Please apply it across the cases, or state in the test that these cases only check composition. |
| 3 | Low | High | Sampling.__post_init__ vs targets |
Sampling(board_cards=np.int64(1)) raises (isinstance(value, int)), while seed/t accept any numbers.Integral. Pick one rule. |
| 4 | Low | High | Sampling.__post_init__ / is_exact |
A call with every count at or above its fan, for example board_cards=14, opponent_draws=12, hero_draws=12 with opponent_actions=None, opponent_range=None, enumerates everything. It is not is_exact, so it demands seed/t and accepts playouts>1, which averages identical play-outs at M× the cost. The tests only pin it bit-for-bit at playouts=1. Either refuse it or document it. |
| 5 | Low | Medium | _STREAM_TAG comment (L192–196) |
"A row's stream has six words and can never equal a walk's four-word stream" holds only for seed, t, seat and row below 2³². The last commit says seed and t take any integer, and a larger one adds words. Say "for seed and t below 2³²", or drop "never". |
| 6 | Low | Medium | module docstring, Cost paragraph | "Round-2 about 2 ms, draw row 160–230 ms, round-1 0.5–0.75 s, sampled 25–32 ms and 100–130 ms, sampled round-2 3–4 ms" are session measurements, not recomputed values. The benchmark prints them, and the only assertions are exact < 50 ms and a 2× ratio, skipped for round 2. Per the plan ("every number in it must be recomputed by a test or printed") they are printed, so this is acceptable. Note that the "costs more sampled than exact at round 2" claim has no assertion, so it can drift. |
| 7 | Info | Medium | _Draws.opponents |
The per-entry Python loop calls rng.choice over 7,280 states for each of up to 6 entries per play-out, with the p normalised each time. This is fine at k=1 on a few rows. If PR 3 boosts many rows per iteration it may dominate. A vectorised inverse-CDF draw would also remove the p-sums-to-1 tolerance dependency. |
| 8 | Info | Medium | _Draws.subset |
np.argsort(rng.random((*shape, n))) costs O(nb × 455 × 12 log 12) per edge and column for opponent draws. At nb = 210 that is about 1.1M uniforms per call. This is correct, and cheaper alternatives exist (a partial argpartition) if the cost table shows it. |
| 9 | Info | Low | plan doc | The plan mixes design record (the Sampling fields, the review focus) with process steps (merging into the PR 2 branch, workspace bariloche's git pull). The latter will go stale at merge. Consider trimming them once #89 and #91 land. |
Tests, in short
- Strong:
- the bit-for-bit enumeration test;
- per-row stream independence (reversed order, split calls, duplicate row, t+1);
- the unreachable-row case under range sampling;
- the spread > 0 non-vacuity assertion;
- the variance ratio window (1/16, 1/4) around the expected 1/8. Its window is wide for 200 seeds, but that is fine.
- Weak: finding fix(deploy): add vercel python entrypoint serving a status page #2 above.
- The new gates are justified in comments. I saw no loosened thresholds.
Overall: no correctness problems found in the sampling math or the seams. The PR text (#1) and the pooled-bias coverage (#2) are what I'd fix before merge.
· branch AlecROndo/canary-handoff-pr-1-build
… — None, or a chance count at its fan — so it needs no seed and refuses extra play-outs; counts take any integer type, as seed and t do; the stream comment says when six words hold
|
Addressed at b4ee6e4:
|
|
Claude finished @AlecROndo's task in 17s —— View job Re-review of PR #89 after b4ee6e4 (
|
…that draws nothing
|
At e566120:
|
|
Claude finished @AlecROndo's task in 28s —— View job Re-review of PR #89 after e566120 (play-outs refusal message)I read the diff of this commit. It changes one error string in Previous nits, status
Still open from the earlier review
Overall: I found no correctness problems in this commit. The PR text was rewritten, and the earlier findings are addressed or deliberately deferred. |
|
Claude finished @AlecROndo's task in 10s —— View job Re-review of PR #89 after 47a7718 (play-outs refusal wording)I read the diff of this commit. It changes one error string in Previous nit, status
Remaining findings: none new. The commit touches one string. Confidence is High that it is correct. Still open from earlier rounds, all deliberate or deferred
Overall: I found no correctness, test or pedagogy problems in this commit. |
…cle weigh a row by t × weight, and weight one is today's run bit for bit (#91) * feat(rung4): the exact target — a row's sampled regret averaged over every opponent hand and every physical entry of its key, and the walk's arrival rate, from the rules alone PR 1 of the targeted-sampling plan. `minidrawmaha/solver/exact_target.py` computes, for any table row, the regret the walk's samples there estimate (the mean over the opponent's hands of u − ⟨σ, u⟩, weighted by the deck and the opponent's own play, normalised by the arrival) and the probability one walk visits the row. It re-derives the public tree, key maps, draw maps and showdown from rules/ and never imports the grader, which grades what this will feed. Measured: a round-2 row costs 0.8 ms, the arrival alone 0.3 ms; a draw row 45–85 ms and a round-1 row 0.2–0.6 s, because the value below expands over the traverser's own replacements and the second board card. Tests: the back-solved reach equals the grader's carried vector on every board of every point (1e-10, full and restricted deals); arrival at a seat's first decision is the grader's frequency and sums to one; regret and arrival equal a world-by-world walk through MiniState on a small restricted game (1e-9) and the mean and visit count of 6,000 Collector walks row by row within 4 s.e. and pooled; the module's import block holds no grader. * fix(rung4): the reach memo is 66 level-1 nodes and 20 round-2 openers, 5,190 vectors, re-derived by a test; the sampled tests select rows by expected count, so a row cannot enter because it fluctuated high Review follow-ups on #89. The docstring counted the memo's level-1 points alone (29) where the chance nodes on the paths are memoised too (66 in all); the test now walks the ancestor closure and pins 66, 20 and 5,190. `reach()` hands out a copy. The pooled z² windows are a 4-sd band on the chi-square mean, √(2/n), instead of fixed numbers. The gated 200,000-walk test kept rows by observed count ≥ 100, which let seat 1's draw rows in only when they had fluctuated high (mean z +1.8 on two seeds); rows are now kept by expected count ≥ 80 against an observed cutoff of 40, and both seats read mean z within 0.01 of zero over thousands of rows. The module docstring names the double-visit caveat and no longer points at a plan outside the repo without saying where it is. * fix(rung4): the sampled tests pin the pooled mean of z at 4/√n beside the mean of z², and cap a single row at six standard errors — the deal alone dealt one picture 292 times against 220 at seed 12 The pooled mean is the sharp bias test (a tenth of a standard error in every row is caught at 1,600 rows); the per-row cap is loose because of about 3,000 rows one passes 5 in a run out of a thousand, and the deal itself did it at seed 12 in a count that involves nothing of this module. Run with MINIDRAWMAHA_FULL_TARGET=1: both seats pass. * fix(rung4): one pooled-fairness helper for the sampled tests, with the band's assumptions written beside it — the "caught at 1,600 rows" line was a half-truth; the band is reached there and reliable at about 3,000 * fix(rung4): the pooled band's small-n width stated as it is — 1 ± 1.79 at n = 10, biting from n ≈ 45 — and the arrival seeds checked named * fix(rung4): the z² band's low side bites from n = 33, where its half-width drops under 1, not from 45 * feat(rung4): every memory row carries a float32 weight, one unless a caller says otherwise; a file without the column loads as ones PR 2 of the targeted-sampling plan, first of three commits. The reservoir's row grows from (row, t, target) to (row, t, target, weight): 24 to 28 bytes, a 50M-row memory 1.2 to 1.4 GB. The weight rides its row's slot through Algorithm R's eviction, save and load; merge without a weight stamps ones; a file with no weight key is from before the column and loads with ones. Refused by name: a negative, non-finite, mis-shaped weight on merge, and a weight array of the wrong length or dtype on load. The learner seam still takes three arrays, so tests/deepcfr/test_train.py is red until the next commit, which threads the column through it. * feat(rung4): the refit weighs a row by t × weight; weight one is today's loss bit for bit and a row of weight zero is inert Second of PR 2's three commits. _weighted_loss scales each row's squared error by (t · w) / mean(t · w): with w ≡ 1 that is t / mean(t) in the same bits, since t · 1.0 is t in float32. fit_from_scratch and batch_loss take the weight as a fourth positional array, None meaning ones, and refuse a weight that is not 1-D, not the memory's length, non-finite, negative, or all zero (nothing to fit, as an empty memory is). A batch whose every row weighs 0 divides by a clamped mean and has loss 0, not NaN. fit_policy takes the column positionally so the policy memory's contents() unpack straight in; its weights are all one. * feat(rung4): the learner seam and the oracle take the weight; the oracle banks Σ t′ · w · r in LCFR's order, so weight one keeps the pin bit for bit Last of PR 2's three commits. Learner.fit takes the memory's four arrays, the weight positional with no default so no learner can drop it by accident; step is unchanged, the four-tuple from contents() flowing through. NetLearner hands the weight to fit_from_scratch and the held batch's loss, after the pot scaling and the regret rules act on the target: the weight says how loudly a row counts, never what it says. The oracle multiplies each sample by its weight in float64 before the per-t′ np.add.at sum, where × 1.0 is exact, so the LCFR pin passes unchanged; a weight of 2 banks what the row offered twice would, a weight of 0 nothing. Oracle model files carry the weight and load as ones without it. * fix(rung4): a scalar rows or weight and a corrupt pre-column file are refused by name — the ones default ran ahead of the checks it relied on; and the weight-one pin is against the old loss formula, not the code itself From the fresh-context review before the push. Reservoir.load sized the default weight from a negative `offered` before refusing it; merge and fit_from_scratch sized it from a 0-d rows before the 1-D check; a 0-d weight on load indexed its own empty shape. Each now fails on the by-name ValueError the old code gave. test_weight_one_is_the_unweighted_fit_bit_for_bit compared the fit to itself (both paths built the same ones); it now restates the pre-column loss, t / mean(t) over the legal squared error, and pins batch_loss at weight one and by default against it to the bit, then the whole fit. * fix(rung4): a weight is checked after its cast to float32, and t × weight for overflow, on merge, on load and in the fit — a float64 weight past float32's range passed the finite check and was stored as inf; and the oracle's "offered twice" claim holds to the bit only when the two are alone at the column - `_validate_offer` casts to float32 first and checks finite, non-negative and t × weight finite after; a bool or non-numeric weight is refused by name. - `Reservoir.load` refuses a weight that is NaN, negative or overflows t × weight, naming the file, as `merge` never writes one. - `fit_from_scratch` refuses a t × weight that overflows float32, the loss's scale. - `OracleLearner` docstring: weight 2 equals the row offered twice exactly only when nothing else sits at the column in that t′; otherwise up to rounding, since `np.add.at` sums one at a time. A new test pins two rows of widths 2 and 3 with weights 3 and 2 against the rows offered three and two times, so a weight landing on a neighbour's columns would show. - `batch_loss` says why it defaults the weight while `Learner.fit` does not; `NetLearner.fit` notes the held loss is a log line nothing decides on. * feat(rung4): the boost target samples k of n of every source below a high-noise row — board card, both seats' replacements, the opponent's actions and range — each unbiased against the exact sum, which stays as EXACT, with the arrival always exact and one stream per (seed, t, seat, row) exact_target.py becomes boost_target.py (ExactTargets → BoostTargets). targets() takes a required Sampling; EXACT reproduces the previous output bit for bit. * fix(rung4): every chance source's n/k scale is pinned with no noise — one branch at a time, averaged, is the exact sum to 1e-10 — and the range draw is tested where a key's two entries face different ranges; the stream's tail is two words, not one, and seed and t take any integer * fix(rung4): a Sampling that draws nothing is exact whatever spells it — None, or a chance count at its fan — so it needs no seed and refuses extra play-outs; counts take any integer type, as seed and t do; the stream comment says when six words hold * fix(rung4): the play-outs refusal names both spellings of a Sampling that draws nothing * fix(rung4): the play-outs refusal says at or above its fan
…et and draws B rows without replacement ∝ arrival — on LCFR-2M the line arm's draws land mostly on round-1 and draw rows, ~100× dearer than round 2's (#93) * feat(rung4): the exact target — a row's sampled regret averaged over every opponent hand and every physical entry of its key, and the walk's arrival rate, from the rules alone PR 1 of the targeted-sampling plan. `minidrawmaha/solver/exact_target.py` computes, for any table row, the regret the walk's samples there estimate (the mean over the opponent's hands of u − ⟨σ, u⟩, weighted by the deck and the opponent's own play, normalised by the arrival) and the probability one walk visits the row. It re-derives the public tree, key maps, draw maps and showdown from rules/ and never imports the grader, which grades what this will feed. Measured: a round-2 row costs 0.8 ms, the arrival alone 0.3 ms; a draw row 45–85 ms and a round-1 row 0.2–0.6 s, because the value below expands over the traverser's own replacements and the second board card. Tests: the back-solved reach equals the grader's carried vector on every board of every point (1e-10, full and restricted deals); arrival at a seat's first decision is the grader's frequency and sums to one; regret and arrival equal a world-by-world walk through MiniState on a small restricted game (1e-9) and the mean and visit count of 6,000 Collector walks row by row within 4 s.e. and pooled; the module's import block holds no grader. * fix(rung4): the reach memo is 66 level-1 nodes and 20 round-2 openers, 5,190 vectors, re-derived by a test; the sampled tests select rows by expected count, so a row cannot enter because it fluctuated high Review follow-ups on #89. The docstring counted the memo's level-1 points alone (29) where the chance nodes on the paths are memoised too (66 in all); the test now walks the ancestor closure and pins 66, 20 and 5,190. `reach()` hands out a copy. The pooled z² windows are a 4-sd band on the chi-square mean, √(2/n), instead of fixed numbers. The gated 200,000-walk test kept rows by observed count ≥ 100, which let seat 1's draw rows in only when they had fluctuated high (mean z +1.8 on two seeds); rows are now kept by expected count ≥ 80 against an observed cutoff of 40, and both seats read mean z within 0.01 of zero over thousands of rows. The module docstring names the double-visit caveat and no longer points at a plan outside the repo without saying where it is. * fix(rung4): the sampled tests pin the pooled mean of z at 4/√n beside the mean of z², and cap a single row at six standard errors — the deal alone dealt one picture 292 times against 220 at seed 12 The pooled mean is the sharp bias test (a tenth of a standard error in every row is caught at 1,600 rows); the per-row cap is loose because of about 3,000 rows one passes 5 in a run out of a thousand, and the deal itself did it at seed 12 in a count that involves nothing of this module. Run with MINIDRAWMAHA_FULL_TARGET=1: both seats pass. * fix(rung4): one pooled-fairness helper for the sampled tests, with the band's assumptions written beside it — the "caught at 1,600 rows" line was a half-truth; the band is reached there and reliable at about 3,000 * fix(rung4): the pooled band's small-n width stated as it is — 1 ± 1.79 at n = 10, biting from n ≈ 45 — and the arrival seeds checked named * fix(rung4): the z² band's low side bites from n = 33, where its half-width drops under 1, not from 45 * feat(rung4): every memory row carries a float32 weight, one unless a caller says otherwise; a file without the column loads as ones PR 2 of the targeted-sampling plan, first of three commits. The reservoir's row grows from (row, t, target) to (row, t, target, weight): 24 to 28 bytes, a 50M-row memory 1.2 to 1.4 GB. The weight rides its row's slot through Algorithm R's eviction, save and load; merge without a weight stamps ones; a file with no weight key is from before the column and loads with ones. Refused by name: a negative, non-finite, mis-shaped weight on merge, and a weight array of the wrong length or dtype on load. The learner seam still takes three arrays, so tests/deepcfr/test_train.py is red until the next commit, which threads the column through it. * feat(rung4): the refit weighs a row by t × weight; weight one is today's loss bit for bit and a row of weight zero is inert Second of PR 2's three commits. _weighted_loss scales each row's squared error by (t · w) / mean(t · w): with w ≡ 1 that is t / mean(t) in the same bits, since t · 1.0 is t in float32. fit_from_scratch and batch_loss take the weight as a fourth positional array, None meaning ones, and refuse a weight that is not 1-D, not the memory's length, non-finite, negative, or all zero (nothing to fit, as an empty memory is). A batch whose every row weighs 0 divides by a clamped mean and has loss 0, not NaN. fit_policy takes the column positionally so the policy memory's contents() unpack straight in; its weights are all one. * feat(rung4): the learner seam and the oracle take the weight; the oracle banks Σ t′ · w · r in LCFR's order, so weight one keeps the pin bit for bit Last of PR 2's three commits. Learner.fit takes the memory's four arrays, the weight positional with no default so no learner can drop it by accident; step is unchanged, the four-tuple from contents() flowing through. NetLearner hands the weight to fit_from_scratch and the held batch's loss, after the pot scaling and the regret rules act on the target: the weight says how loudly a row counts, never what it says. The oracle multiplies each sample by its weight in float64 before the per-t′ np.add.at sum, where × 1.0 is exact, so the LCFR pin passes unchanged; a weight of 2 banks what the row offered twice would, a weight of 0 nothing. Oracle model files carry the weight and load as ones without it. * fix(rung4): a scalar rows or weight and a corrupt pre-column file are refused by name — the ones default ran ahead of the checks it relied on; and the weight-one pin is against the old loss formula, not the code itself From the fresh-context review before the push. Reservoir.load sized the default weight from a negative `offered` before refusing it; merge and fit_from_scratch sized it from a 0-d rows before the 1-D check; a 0-d weight on load indexed its own empty shape. Each now fails on the by-name ValueError the old code gave. test_weight_one_is_the_unweighted_fit_bit_for_bit compared the fit to itself (both paths built the same ones); it now restates the pre-column loss, t / mean(t) over the legal squared error, and pins batch_loss at weight one and by default against it to the bit, then the whole fit. * fix(rung4): a weight is checked after its cast to float32, and t × weight for overflow, on merge, on load and in the fit — a float64 weight past float32's range passed the finite check and was stored as inf; and the oracle's "offered twice" claim holds to the bit only when the two are alone at the column - `_validate_offer` casts to float32 first and checks finite, non-negative and t × weight finite after; a bool or non-numeric weight is refused by name. - `Reservoir.load` refuses a weight that is NaN, negative or overflows t × weight, naming the file, as `merge` never writes one. - `fit_from_scratch` refuses a t × weight that overflows float32, the loss's scale. - `OracleLearner` docstring: weight 2 equals the row offered twice exactly only when nothing else sits at the column in that t′; otherwise up to rounding, since `np.add.at` sums one at a time. A new test pins two rows of widths 2 and 3 with weights 3 and 2 against the rows offered three and two times, so a weight landing on a neighbour's columns would show. - `batch_loss` says why it defaults the weight while `Learner.fit` does not; `NetLearner.fit` notes the held loss is a log line nothing decides on. * feat(rung4): the boost target samples k of n of every source below a high-noise row — board card, both seats' replacements, the opponent's actions and range — each unbiased against the exact sum, which stays as EXACT, with the arrival always exact and one stream per (seed, t, seat, row) exact_target.py becomes boost_target.py (ExactTargets → BoostTargets). targets() takes a required Sampling; EXACT reproduces the previous output bit for bit. * fix(rung4): every chance source's n/k scale is pinned with no noise — one branch at a time, averaged, is the exact sum to 1e-10 — and the range draw is tested where a key's two entries face different ranges; the stream's tail is two words, not one, and seed and t take any integer * feat(rung4): targeting names four granularities of group over the table's rows — 141 lines and 3,870 line × hand classes, from the rules alone * feat(rung4): the noise score is one walk's relative error at a group, √(E[r²]/p)/|E[r]|, from the memory's own walk rows only — an exact row is a mean, not a sample * feat(rung4): the aimed arms rank groups by leak × noise per reached infoset and take them until the pool is 20 × B reached rows; infoset takes the B best outright * feat(rung4): a target set draws B rows a seat without replacement ∝ arrival by exponential keys, reproducible from (seed, t, seat, stream) and never the same row twice * feat(rung4): one call turns leak, frequency and the memories into a frozen target set, asking for arrivals at the pool alone; the Refresher protocol is the seam PR 4 calls * feat(rung4): no module of the trainer's package imports the grader, checked on every import statement * fix(rung4): a Sampling that draws nothing is exact whatever spells it — None, or a chance count at its fan — so it needs no seed and refuses extra play-outs; counts take any integer type, as seed and t do; the stream comment says when six words hold * feat(rung4): the leak by betting line — the four leakiest lines are round 1's and hold 19% of LCFR-2M's exploitability on 0.07% of its reached infosets; the 20 leakiest hold 57% on a quarter * fix(rung4): the play-outs refusal names both spellings of a Sampling that draws nothing * fix(rung4): a one-step gain a few ulps under zero is rounding and reads as zero; a real negative is still refused — the LCFR-2M release has gains at −7e-12 * feat(rung4): the grader-backed refresher grades the exact average (or, by choice, the current strategy), weighs the pool by the walk's arrival, and is the only importer of the meter on the trainer's side * feat(rung4): round_two_only, off by default, keeps every arm off the one-board-card rows, whose exact rows cost about a hundred times a round-2 row's * feat(rung4): the docs name targeting and its refresher — the eight round-1 lines hold 22% of LCFR-2M's leak on 0.13% of its reached infosets, read by a test from the committed file * feat(rung4): the PR 3 plan — targeting's contract, the two provisional decisions, and the row-cost finding behind round_two_only * fix(rung4): the play-outs refusal says at or above its fan * fix(rung4): the noise score reads one walk's total as one visit or none, √(E[r²]/p − μ²)/|μ|, so a line every walk reaches scores its scatter σ/|μ| rather than √(σ² + μ²)/|μ|; the tests now pin p's memory share and make only the noise break a tie * fix(rung4): the layout test reads every point's first and last row through the table's own index, and a pool landing exactly on pool × B is pinned to take no further group * fix(rung4): a fresh interpreter checks that targeting loads neither the meter nor the analysis; float rows, non-int draws and a bad K are refused by name before any walk; a saved set reads back every spec field; σ is read only when an arrival is asked for; the package docs count ten modules * fix(rung4): the plan states the noise score as built, √(E[r²]/p − μ²)/|μ|, and the random arm's measured refresh, eight minutes a seat * fix(rung4): p's estimator is unbiased with exact rows in a full memory, because size and offered both count them — said in the docstring and pinned over 400 eviction streams; an infoset set's unread weights must be ones * fix(rung4): noise's docstring says the exact rows cancel in n_g / size · offered
PR 1 of the targeted-sampling plan for rung 4. It began as the exact target and is now a sampling framework, with the exact sum kept as its oracle. At a chosen high-noise row it draws extra, lower-noise samples of the same regret the walk banks there, and each sample is unbiased. Nothing consumes it yet; the boost stage is PR 4.
What it is
minidrawmaha/solver/boost_target.py(renamed fromexact_target.py;ExactTargets→BoostTargets).A play-out starts at the row and faces the opponent's range, back-solved exactly from the rules. It then plays the hand out.
Samplingnames how much of each random source below the row it takes;Nonetakes all of it:playoutsopponent_rangeNone(whole range)board_cardsopponent_drawshero_drawsopponent_actionsEXACTenumerates everything.Samplingthat draws nothing, however it is spelled, counts as exact: it needs no seed and refusesplayouts > 1.default_rng([seed, t, seat, r, "BOOST"]). That stream is separate from the walk's and the reservoir's, and a row's target never depends on which rows share the call.The exact path (
EXACT) is the code that was here before, with one seam threaded through it. It reproduces the pre-change output bit for bit. I checked this against the previous module, run side by side and not committed: 50 draw and round-2 rows on one table, and 32 round-1 rows on two tables, both seats each time. One change touches the exact path: an opponent line that carries no weight is skipped. Its value is zero, so the output is unchanged.Measured (this Mac, a table with every action positive)
Sampling()The board card and the hero's replacements are what sampling cuts. Against a whole range, sampling the opponent's actions saves nothing: splitting by σ is one array operation. It only adds noise and a little time, so it pays only when
opponent_rangeis a few hands.Sampling(opponent_actions=None)is the cheaper and quieter choice with the whole range.Tests (
tests/minidrawmaha/test_boost_target.py)All of PR 1's exact tests are kept, now run with
sampling=EXACT:New tests:
playouts > 1under EXACT. So is a sampled call withoutseed/t, and asamplingthat is not aSampling.arrivals()exactly. A mutation check (not committed) confirmed the gates bite. Dropping any n/k scale, the playouts division or σ's 1/k fails them, as does a 10% bias in the range draw, an n−1 in place of any n, or one entry's total used for another's. The seed counts' resolving power (3–8% for actions, range and the opponent's draws) is stated beside them. The hero's draws, the board card and the mixed forms resolve only 13% and up statistically; that is why their scales are pinned by the exact branch check instead.playouts = 8shrinks the variance by a factor in (1/16, 1/4).uv run pytest: 1,705 passed, 22 skipped at b53f2a3. The test file and the instruction-file check were re-run at b4ee6e4: 74 passed, 2 skipped.Not in this PR
build,sigmaandarrivals.targets. It must read the same σ the walk played at iteration t; that is where a bias could enter. It must also turn the walk's rows down by α in the advantage memory only.The implementation plan is
docs/superpowers/plans/2026-11-06-boost-target-modular-sampling.md.