Skip to content

feat(rung4): targeting ranks groups by leak × noise per reached infoset 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

Merged
AlecROndo merged 42 commits into
mainfrom
AlecROndo/pr-3-targeting
Nov 9, 2026

Conversation

@AlecROndo

Copy link
Copy Markdown
Owner

PR 3 of the targeted-sampling plan for rung 4: targeting, which decides which table rows the boost stage (PR 4) will compute exactly. Nothing is wired into train.step or DeepConfig; the oracle pin is unchanged.

Branched from #91's head (it carries #89), and #91's later heads are merged in, never rebased. While #89 and #91 are open, the diff shows their files too.

What it adds

  • src/drawmaha_solver/deepcfr/targeting.py (NumPy only, never imports the grader)
    • TargetSpec: granularity, alpha (required, no default), budget B, refresh R, noise_cap, pool, stream, and the opt-in round_two_only.
    • Groups at four granularities, read off the rules alone: infoset (a row), line (a public point, 141), line_class (point × inner × outer category, 3,870 non-empty groups), and random (the whole seat). These are pinned by tests.
    • Noise = √(E[r²]/p − μ²)/|μ| at the column of largest |mean|: one walk's relative error, reading a walk as one visit or none, so σ/|μ| at p = 1. It is read from the seat's advantage memory, counting only rows the walk itself offered (weight 1 or α), because an exact row is a mean, not a sample. p is visits per walk, (n_g/size)·offered/(K·t_last). A group with fewer than two such rows, or a mean of exactly zero, gets the cap.
    • Selection by score = leak · min(noise, cap) / reached:
      • infoset takes the B best rows.
      • line and line_class take groups best first until their reached rows reach pool × B; the group that crosses is in.
      • random pools the whole seat.
    • TargetSet, frozen for R iterations. rows_for(t, seat, seed) draws ≤ B distinct rows ∝ the pool's arrival weight using exponential keys (successive sampling). The draws are deterministic in (seed, t, seat, stream), on a stream whose fifth word is "TARG". A set used outside its window is refused. save/load round-trip it as an atomic .npz.
    • target_set(...), the orchestrator, and the Refresher protocol PR 4 calls.
  • scripts/deepcfr/targeting_refresh.py: GraderRefresher, the only importer of the meter on the trainer's side.
    • It grades the profile (leak="average", the default, or "current"), lays the gains and frequencies on table rows, and weighs the pool by BoostTargets.arrivals under BoostTargets.sigma(table).
    • The random arm never runs the grader.
    • Run directly, it does one refresh from a release and prints what the pool and one draw hold per stage.
  • analysis.py: gains_by_row, scatter_by_row, line_profile, and minidraw-exploit-by-reach --by-line, which writes figures/rung3/exploit_by_line.json / .png (LCFR-2M).
    • The file reports 0.061346 split over 141 lines and 3,870 classes.
    • The four leakiest lines are round 1's and hold 19% on 0.07% of the reached infosets; the eight round-1 lines hold 22%.
    • The 20 leakiest lines hold 57% on a quarter of the reached infosets.
    • A test holds the file to exploit_by_reach.json and the README's sentence to the file.
  • Docs: deepcfr/__init__.py, deepcfr/AGENTS.md (the no-grader rule and the no-repeat rule), scripts/AGENTS.md, figures/AGENTS.md, one README sentence, and the plan docs/superpowers/plans/2026-11-06-targeted-sampling-pr3-targeting.md.

Departures from the appendix sketch, each for a reason:

  • The set stores its pool's rows and weights rather than a 6.2M-entry group_of_row.
  • The spec rides inside the set, so rows_for can refuse a stale iteration.
  • "none" is not a granularity, because a run without targeting has no spec.
  • One-step gains a few ulps under zero (−7e-12 on LCFR-2M) read as zero; a real negative is still refused.

Decisions provisional — Alec to confirm

Alec was asleep when this was built, so the plan's proposals are the defaults. Every one is a parameter, never hard-wired.

  1. B = 2,000 rows per seat per iteration, R = 25 iterations between refreshes: TargetSpec.budget and TargetSpec.refresh, the plan's proposals as they stood. Item 4 shows the 2,000 is cheap only on round-2 rows.

  2. Leak of what: GraderRefresher(leak="average"), the frozen exact average, which is what the run is graded on. leak="current" grades the table's current strategy, which is what the regrets follow. They cost the same two grader walks.

  3. Reach for draws = the walk's arrival (BoostTargets.arrivals under the table's σ), not the grader's play frequency. The boost's row weight multiplies the arrival, so drawing ∝ arrival spends the budget where the most sampled weight is replaced. It also means the random arm needs no grader. Eligible rows for the aimed arms are rows with frequency > 0, so the pool-size rule counts exactly the rows that can be drawn.

  4. B counts rows, but rows differ in cost a hundredfold. Measured with the real refresher on LCFR-2M (the release as the table, empty memories, so every noise is at the cap), the line arm's pool is about 45k rows per seat:

    seat round 1: share of draw weight draw: share round 2: share rows one t = 1 draw takes (round 1 / draw / round 2)
    0 34% 41% 26% 633 / 800 / 567
    1 36% 53% 11% 684 / 1,059 / 257

    Cost per row of BoostTargets.targets under LCFR-2M's σ, measured on 12 rows per stage from the leakiest lines:

    seat, stage EXACT Sampling() (the walk's own sampling below the row, against the whole range; seed=0, t=0)
    0, round 1 270 ms 52 ms
    0, draw 140 ms 22 ms
    0, round 2 2.2 ms 5.0 ms
    1, round 1 249 ms 40 ms
    1, draw 70 ms 10 ms
    1, round 2 1.0 ms 1.7 ms

    A quieter first pass over 12 other seat-0 rows read 181 / 101 / 1.1 ms for EXACT. Per iteration, at those draw counts:

    • (plan rule, all EXACT): 284 s + 245 s ≈ 530 s.
    • (a) round_two_only=True, EXACT: 2,000 round-2 rows per seat ≈ 4.5 s + 2.0 s ≈ 6.5 s, assuming the round-2 rows it would draw cost what these do.
    • (d) the plan's rule, with one-board-card rows boosted by a Sampling() target and round-2 rows exact: 52 s + 38 s ≈ 89 s.

    For scale: a table (Tier-1) iteration is about 18 s by the plan's estimate, and a 4 × 256 network iteration about 190 s.

    The random control is not cheaper under the plan's rule. Its whole-seat pool puts 10–12% of the draw weight on round-1 rows and 13–17% on draw rows. At t = 1 it draws 196 / 231 / 1,573 rows (seat 0) and 219 / 372 / 1,409 (seat 1), about 89 s + 82 s ≈ 170 s per iteration with EXACT. Its refresh (arrivals over both whole seats, no grader) measured 16 min 52 s.

    The plan's rule stays the default. round_two_only (option a) is here, opt-in. The other options are not built: (b) budget in cost rather than rows; (c) a separate, smaller B for one-board-card rows; (d) above, which is PR 4's to wire.

  5. α is not settled. TargetSpec.alpha has no default. This PR reads it only to tell the walk's rows from exact rows in the noise score, which is why PR 4 must not inject an exact row whose weight equals 1 or α.

Tests

  • uv run pytest (whole default suite, no torch): 1,872 passed, 24 skipped in 9 min 54 s, on the head merged with feat(rung4): every memory row carries a weight; the refit and the oracle weigh a row by t × weight, and weight one is today's run bit for bit #91's cbb5308.
  • MINIDRAWMAHA_FULL_GRADE=1 uv run pytest tests/deepcfr/test_targeting_refresh.py -k real: 1 passed in 3 min 8 s. This is a real refresh on the whole game: the pools are reached rows and the draws are reproducible.
  • New: tests/deepcfr/test_targeting.py covers:
    • the spec's refusals; the groups (141 lines, 3,870 classes, decoded by hand from keys);
    • noise against hand-worked numbers, with exact rows excluded;
    • selection, including the pool-crossing rule, round_two_only, and round-off gains;
    • draws: reproducible, moving with every word of the stream, never repeating over 200 seeds, inclusion probabilities against an exact enumeration over 20,000 seeds within 4 s.e., the window, the field refusals, and save/load;
    • the orchestrator's calls; and an AST check that no module under deepcfr/ imports the grader.
  • tests/deepcfr/test_targeting_refresh.py: the wiring with stand-ins for the grader walk and the oracle. One real end-to-end refresh is behind MINIDRAWMAHA_FULL_GRADE.
  • tests/minidrawmaha/test_exploit_by_line.py: the scatter checked against PackedTable.row_of, the profile's partition, the committed file against exploit_by_reach.json, and the README numbers.
  • The oracle pin tests/deepcfr/test_train.py::test_the_oracle_loop_is_lcfr_bit_for_bit passes unchanged.

Pre-push review (fresh-context reviewer subagent), dispositioned

The reviewer found no correctness bug in the selection, the draws, the scatter or save/load, and checked every quoted number against the committed JSON. Its findings:

  1. Fixed. The noise-from-memory test passed with noise ignored: lines A and B tied, and the lower id won. The noisy line is now the higher id, so only the noise can put it first.
  2. Fixed. The layering test read names only.
    • It now also bans answer.analysis by name, and checks in a fresh interpreter that importing targeting loads neither the meter nor the analysis.
    • deepcfr/AGENTS.md now says the name check is not transitive. average, distill, policy and train already reach exploitability through answer.strategy's row-sum tolerance constant; that predates this PR.
  3. Fixed. The memory-share factor of p was never exercised (size equalled offered in every test). There is now a test of a full memory, 10 offers into 4 slots.
  4. Fixed. The noise used p·E[r²] for the per-walk variance, which is right only for small p and overstates noise at round-1 lines (p ≈ 1). It now uses p·E[r²] − p²μ², read as one visit or none, which is σ/|μ| at p = 1. p > 1 (two throws to one point) is called out as an approximation, and a negative variance there reads as zero.
  5. Carried to PR 4, as agreed with the main session. Walk rows are told from exact rows by weight alone, so PR 4 must not inject an exact row whose weight equals 1 or α (for example a zero-arrival row at α = 0).
  6. Fixed. deepcfr/__init__.py now says ten modules and lists distill.
  7. Fixed. The refresher's docstring is in the future tense for PR 4, and deepcfr/AGENTS.md's stale "the package itself is complete" is updated.
  8. Fixed. The layout test now checks every point's first and last row against PackedTable.row_of.
  9. Fixed. A pool landing exactly on pool × B is pinned to take no further group.
  10. Fixed.
    • Float rows or groups, a non-int t/seed, seat=True, and a bad walks or spec (checked before any grader walk) are refused by name.
    • load rebuilds the spec from dataclasses.fields(TargetSpec) and refuses a file missing a field.
  11. Fixed (σ). The refresher reads σ only when an arrival is asked for, so infoset never reads it. Noted, not changed: groups() caches about 50 MB per granularity and seat.

Regenerate

uv run minidraw-exploit-by-reach --release tabular --by-line     # figures/rung3/exploit_by_line.json, .png (~100 s)
uv run python scripts/deepcfr/targeting_refresh.py --granularity line   # the stage tables above

…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.
…, 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.
… 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.
…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
…9 at n = 10, biting from n ≈ 45 — and the arrival seeds checked named
…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.
…y'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.
…cle 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.
… 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.
…ight 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.
…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
…le's rows — 141 lines and 3,870 line × hand classes, from the rules alone
… √(E[r²]/p)/|E[r]|, from the memory's own walk rows only — an exact row is a mean, not a sample
…nfoset and take them until the pool is 20 × B reached rows; infoset takes the B best outright
…rrival by exponential keys, reproducible from (seed, t, seat, stream) and never the same row twice
…rozen target set, asking for arrivals at the pool alone; the Refresher protocol is the seam PR 4 calls
… — 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
…ound 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
…ds as zero; a real negative is still refused — the LCFR-2M release has gains at −7e-12
…, 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
…one-board-card rows, whose exact rows cost about a hundred times a round-2 row's
…und-1 lines hold 22% of LCFR-2M's leak on 0.13% of its reached infosets, read by a test from the committed file
…l decisions, and the row-cost finding behind round_two_only
…ne, √(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
…rough the table's own index, and a pool landing exactly on pool × B is pinned to take no further group
…he 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
…/|μ|, and the random arm's measured refresh, eight minutes a seat
@vercel

vercel Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
drawmaha-solver Ready Ready Preview Nov 6, 2026 10:45am UTC

Request Review

@claude

claude Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Claude finished @AlecROndo's task in 46s —— View job


Review of PR #93 (targeting)

I read src/drawmaha_solver/deepcfr/targeting.py in full and re-derived its math. I did not read the other 29 changed files, including the tests, boost_target.py, analysis.py and the refresher script. I did not run uv run pytest or the regeneration commands.

Summary: I found no correctness bug in the selection, the draws or save/load. I have one medium-severity concern about the visit rate p once exact rows are in the memory, plus a few minor notes.

Math I re-derived (all hold)

  • Noise: with E[r²] = σ² + μ², one visit or none gives per-walk variance pE[r²] − p²μ² = pσ² + p(1−p)μ². Dividing its square root by pμ gives √(E[r²]/p − μ²)/|μ|, which is σ/|μ| at p = 1. The docstring matches the code at targeting.py:309.
  • Draws: keys E/w with E ~ Exp(1), taking the B smallest, are Efraimidis–Spirakis successive sampling without replacement ∝ w. Zero weights give infinite keys and are never drawn. argpartition(keys, B-1)[:B] is correct, and the count_nonzero(positive) <= B shortcut guarantees B finite keys on the other branch.
  • Pool-crossing rule: searchsorted(filled, pool*B) + 1 includes the crossing group. It takes everything when the target exceeds the total, and an exact landing takes no further group. An empty order is handled.
  • Cost arithmetic: I recomputed the per-iteration figures in the PR body from the stated draw counts and per-row timings, and each matches. Plan rule: 284 s + 245 s. Option (a): 4.4 s + 2.0 s. Option (d): 53 s + 38 s. Random arm: 89 s + 82 s.

Findings

1. Medium (confidence ~60%): p is probably understated once exact rows share the memory — targeting.py:308

  • visits = count / memory.size * memory.offered / (walks * t_last). Here count is only the walk's own rows, but memory.size includes the exact rows PR 4 will inject.
  • offered counts walk offers only, per the docstring. The matching denominator is therefore the number of resident walk-own rows, not size.
  • Once the boost is on, p shrinks by roughly natural/size. That inflates noise by roughly 1/√(that ratio) in every group, and unevenly across groups. For example, a group the boost targets heavily keeps few walk rows, and exact rows displace walk rows in a full reservoir.
  • Today the memories hold only weight-1 rows, so every test and measurement passes. The bug would appear only in PR 4.
  • I couldn't tell from this file whether offered includes injected rows. If it does, the code is right and the docstring should say so. Please confirm either way, and add a test with exact rows resident.

2. Low–medium (confidence ~90%, already acknowledged in the PR): walk rows are identified by weight alone — targeting.py:293

  • An exact row whose weight equals 1 or α is silently read as a sample. That includes any zero-arrival row at α = 0, which gets weight (1−α)·K·0 = 0 = α.
  • The silent failure mode makes this fragile. When PR 4 lands, consider a hard assertion at injection time. A flag column would be better but needs a format change.

3. Low: noise is dominated by the cap on infoset. Per-row groups need at least 2 resident walk rows. That is fine by design, but most rows will read as cap, so infoset ranking collapses to leak/reached for them. The README or plan may want a sentence saying so, since it affects how the infoset arm's result should be interpreted.

4. Nit: docstring wording. targeting.py:57 is a long run-on line that ends mid-paragraph ("…which it is, as an estimate of the group's mean."). The "p > 1" caveat is stated well, but the module docstring says p is "g's share of the memory times the rows offered per walk", which is imprecise: it is divided by K·t_last. Related to finding 1.

5. Nit: unvalidated groups and weight. TargetSet.__post_init__ does not check that groups are valid ids for the granularity, or that weight is all ones for infoset. A hand-built set can pass any values. This is low risk because target_set builds them.

6. Note: caches. Two @cached groups() arrays per granularity and seat (about 50 MB each) are retained for the process lifetime. You already flagged this.

Scope

…y, 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
@AlecROndo

Copy link
Copy Markdown
Owner Author

Round 1 of the review, dispositioned in 2306ed8.

  1. p once exact rows share the memory: the code was right, and the docstring now says why.
    • Reservoir.offered counts every row merged, exact rows included (reservoir.py's merge does self._offered += count for every offer). Algorithm R keeps a uniform sample of all offers.
    • So n_g / size · offered is an unbiased estimate of the walk rows ever offered at g, whatever share the exact rows hold. Dividing by the resident walk rows instead would overstate p.
    • The module docstring now states this.
    • New test test_p_is_unbiased_when_exact_rows_share_a_full_memory: 30 walk rows at one line and 30 exact rows at another go into 20 slots, with K · t_last = 60, so the true p is 0.5. The mean estimate over 400 eviction streams is within 4 s.e. (0.0046) of 0.5. The resident-walk-row denominator would read p ≈ 1.
    • The earlier test_only_the_walks_own_rows_count already had an exact row resident below capacity.
  2. Walk rows told from exact rows by weight alone: agreed. This is PR 4's to enforce at injection (refuse an exact row whose weight equals 1 or α, including a zero-arrival row at α = 0), and it is in PR 4's plan. Nothing in PR 3 injects rows.
  3. infoset noise is mostly the cap where the memory is thin: said in the module docstring now. A group of one row reads as the cap until the memory holds two samples of it, so where the memory is thin the infoset arm ranks by leak per row alone.
  4. Docstring wording: fixed. The run-on line is split, and p is stated as the formula with its denominator, K · t_last.
  5. Unvalidated groups and weight:
    • An infoset set's weights must now be all 1, and others are refused by name. Its rows are served, never drawn, so a weight there would read as one that mattered.
    • groups stays a record, best first, and nothing reads it. Checking ids against the granularity would cost a 6.2M-row groups() lookup per seat at every construction and load, for a field that cannot change behaviour. Not changed.
  6. Caches: noted, as in the body. About 50 MB per (granularity, seat), built only for what a process asks for.

Tests: tests/deepcfr/test_targeting.py, test_targeting_refresh.py and tests/minidrawmaha/test_exploit_by_line.py give 107 passed, 1 gated.

@claude

claude Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Claude finished @AlecROndo's task in 25s —— View job


Review of PR #93 (targeting), re-check after the latest push

I read targeting.noise and Reservoir.merge/offered/size. I did not run the tests or the regeneration commands.

Retraction of the earlier finding 1 (p understated once exact rows are resident). That finding was wrong, and no change is needed.

  • Reservoir.merge adds every offered row to _offered (reservoir.py:171), walk rows and exact rows alike. size is min(offered, capacity), so it counts both too.
  • The resident rows are a uniform sample of all offers. So n_g/size estimates the walk-own share of group g among all offers, and multiplying by offered estimates g's total walk-own offers. The exact rows cancel in the ratio.
  • That is the case the latest commit (2306ed8) pins over 400 eviction streams.
  • The line in noise's docstring, "p = (n_g / size) · offered / (walks · t_last)", is correct. It would be clearer if it said that offered and size both include exact rows, and that this is why they cancel.

Still open (unchanged from the earlier review):

  • Low–medium, ~90% confidence. Walk rows are told from exact rows by weight alone (targeting.py:304). An exact row whose weight equals 1 or α is read as a sample. The PR already carries this to PR 4. I suggest a hard assertion at injection time, because the failure is silent.
  • Low. On infoset, most rows have fewer than two resident walk rows, so their noise reads as cap. The ranking then collapses to leak/reached. A sentence in the plan or README would help anyone interpreting that arm.
  • Nit. TargetSet.__post_init__ does not check that groups are valid ids for the granularity, or that weight is all ones for infoset. This is low risk because target_set builds them.
  • Note. The @cached groups() arrays hold about 50 MB per granularity and seat for the process lifetime. The PR already flags this.

The selection, draws and save/load logic looks correct. I found nothing new.

@AlecROndo

Copy link
Copy Markdown
Owner Author

Round 2, against 2306ed8, plus one docstring line in 6616976.

  • Retracted finding 1: agreed. As suggested, noise's own docstring now also says size and offered both count exact rows, which cancel in the ratio (6616976). The module docstring already said it.
  • Weight-only identification: carried to PR 4, with the injection-time refusal you suggest, and in that PR's plan. PR 3 injects nothing.
  • infoset mostly at the cap: already stated in the module docstring in 2306ed8 ("where the memory is thin, the infoset arm ranks by leak per row alone"). The PR body's decision section is where Alec reads the arms.
  • weight all ones for infoset: already enforced in 2306ed8, in TargetSet.__post_init__ ("an infoset set's weights are all 1"), tested by test_an_infoset_set_holds_at_most_b_rows_each_of_weight_one.
  • groups ids: not checked, on purpose. Nothing reads groups; it is the refresh's record. Validating ids would cost a 6.2M-row groups() lookup per seat at every construction and load, for a field that cannot change behaviour.
  • Caches: noted.

No code change beyond the docstring line.

@claude

claude Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Claude finished @AlecROndo's task in 11s —— View job


Re-check of PR #93 after 6616976

This push only changes a docstring in targeting.noise. It adds: "size and offered both count exact rows, which cancel in the ratio."

  • The sentence is correct. Reservoir.merge counts every offer in offered, and size = min(offered, capacity). The exact rows therefore appear in both counts and drop out of n_g/size · offered.
  • This is the clarification I suggested last round. I have no new findings on this commit.
  • I did not run the tests, and I did not re-read the rest of the diff this round.

Still open from the earlier review (unchanged):

  • Low–medium, ~90% confidence: walk rows are told from exact rows by weight alone. PR 4 should assert at injection time that no exact row has weight 1 or α, because the failure is silent.
  • Nit: TargetSet.groups ids are not validated against the granularity. This is acceptable, since nothing reads the field.

This branch was successfully deployed

1 active deployment
Preview — 6616976c Deployed Nov 6, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant