Skip to content

fix: validate loo_eval control counts before loading models - #307

Merged
ryoari merged 1 commit into
AOSSIE-Org:mainfrom
panshularora:fix/loo-eval-control-count
Nov 14, 2026
Merged

ryoari merged 1 commit into
AOSSIE-Org:mainfrom
panshularora:fix/loo-eval-control-count

Conversation

@panshularora

@panshularora panshularora commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #303.

  • Reject nonpositive --controls through argparse before reading inputs.
  • Reject requests larger than the eligible document pool, giving requested/available counts before loading any model.
  • Preserve the requested sample size, seed 1234, pool eligibility and evaluation arithmetic; never silently shrink the experiment.
  • Document the argument contract in simple/README.md.

Verification

  • Test-first: six invalid-input cases failed on unchanged upstream; two valid-count evaluations already passed and remain unchanged.
  • Full Python 3.12 CPU suite: 78 passed.
  • ruff check simple tests and git diff --check: passed.
  • Tests cover zero/negative counts, empty/insufficient pool, and positive counts up to the pool size. Valid evaluations use actual synthetic memmaps, a tokenizer, and tiny saved CPU models, checking seeded document selection and output.

Limits / review focus

Synthetic CPU fixtures, not released models or training. No claim about the published experiment. No change to filtering, sampling, loss calculation, model loading policy, hashes or dependencies.

Summary by CodeRabbit

  • Bug Fixes

    • The evaluation command now rejects zero or negative control counts and reports an error when the requested count exceeds the available eligible documents.
    • Invalid counts are reported before model loading, and requested sample sizes are no longer silently reduced.
  • Documentation

    • Clarified the valid range for control counts and how the command handles invalid requests.

@coderabbitai

coderabbitai Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

loo_eval.py now rejects nonpositive control counts and counts larger than the eligible document pool before model loading. Tests cover these errors and valid seeded sampling. The README documents the constraints.

Changes

Control-count validation

Layer / File(s) Summary
Validate control counts and evaluate
simple/loo_eval.py, tests/simple/test_loo_eval.py, simple/README.md
The CLI rejects nonpositive counts and reports when the requested count exceeds the eligible pool. Tests cover both error cases and seeded sampling with counts of 1 and 2. The README documents the validation behavior.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Suggested reviewers: ryoari

Merge Risk: Minimal · up to e10e5

The change makes loo_eval reject invalid control counts early with clear errors and keeps valid evaluations unchanged. No merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "fix: validate loo_eval control counts before loading models" names the primary change. The PR makes loo_eval reject nonpositive --controls values and requests that exceed the eligible contr…
Linked Issues check Passed Issue #303 requires three coding behaviors: reject nonpositive --controls clearly, report requested and available counts when the eligible pool is too small, and do both before loading models, while k…
Out of Scope Changes check Passed The reported changes stay within issue #303. simple/loo_eval.py adds only the two argument checks described above. simple/README.md documents the same argument contract. The test file adds fixtures an…
Full details: Title check

Explanation

The title "fix: validate loo_eval control counts before loading models" names the primary change. The PR makes loo_eval reject nonpositive --controls values and requests that exceed the eligible control-document pool before any model loads. The changeset touches simple/loo_eval.py, simple/README.md, and tests/simple/test_loo_eval.py, all of which match this scope. The title is specific, uses a conventional fix: prefix, and is under 60 characters.

Full details: Linked Issues check

Explanation

Issue #303 requires three coding behaviors: reject nonpositive --controls clearly, report requested and available counts when the eligible pool is too small, and do both before loading models, while keeping the seed, eligibility rules, and requested sample size. At the reviewed head, simple/loo_eval.py meets each requirement. The check if a.controls <= 0: p.error(...) runs right after parse_args and before any input is read. The pool is built from documents.jsonl using the existing eligibility rules (removed-document exclusion, cursor range, 3000 to 15000 targets). The check if a.controls > len(pool): p.error(...) reports both requested and available counts. random.Random(1234).sample(pool, a.controls) is unchanged, and the model loads come after both checks. The PR summary reports tests for zero, negative, empty, and insufficient pools, plus valid counts up to pool size. I did not inspect the test file or the base-side diff. The test results are reported by the author and were not independently verified here.

Full details: Out of Scope Changes check

Explanation

The reported changes stay within issue #303. simple/loo_eval.py adds only the two argument checks described above. simple/README.md documents the same argument contract. The test file adds fixtures and tests for those checks and for valid-count evaluation. The PR summary reports no changes to filtering, sampling, loss calculation, model-loading policy, hashes, or dependencies. The inspected head file shows the sampling, loss, and loading code unchanged in form. The README and test changes support the implemented requirement and are not unrelated. The exact base-side diff could not be read because changed blobs were unavailable, so the absence of other changes rests on the PR summary and the head file.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 7de70bd and e10e509.

Files selected for processing: 3

  • simple/README.md
  • simple/loo_eval.py
  • tests/simple/test_loo_eval.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@panshularora
panshularora marked this pull request as ready for review November 11, 2026 15:20
@ryoari

ryoari commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Looks good: invalid counts fail before any model is loaded, and the tests use real (tiny) inputs.

#306 is merged now, and it adds its paragraph to simple/README.md in the same place as yours, so this conflicts. Please rebase on main and keep both paragraphs, then mark it ready for review and I'll merge it.

@panshularora
panshularora force-pushed the fix/loo-eval-control-count branch from 2d9d060 to e10e509 Compare November 14, 2026 10:13
@panshularora

Copy link
Copy Markdown
Contributor Author

Rebased on latest main and kept both paragraphs in simple/README.md. Ready for merge!

@ryoari ryoari left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the rebase; both paragraphs are kept. Merging.

@ryoari
ryoari merged commit 000ac6e into AOSSIE-Org:main Nov 14, 2026
6 checks passed
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.

[BUG]: loo_eval crashes when the requested control count is zero or exceeds the eligible pool

2 participants