Skip to content

fix(sourcehunt): make n-day filter and reveng reconstruction batch sizes configurable - #204

Open
tsunoda-kazuya wants to merge 1 commit into
Lazarus-AI:mainfrom
tsunoda-kazuya:fix/sourcehunt-batch-sizes
Open

fix(sourcehunt): make n-day filter and reveng reconstruction batch sizes configurable#204
tsunoda-kazuya wants to merge 1 commit into
Lazarus-AI:mainfrom
tsunoda-kazuya:fix/sourcehunt-batch-sizes

Conversation

@tsunoda-kazuya

Copy link
Copy Markdown
Contributor

Summary

  • Promote FILTER_BATCH_SIZE (10) and RECONSTRUCTION_BATCH_SIZE (8) from module constants to HuntTuning fields with matching CLI flags (--nday-filter-batch-size, --reveng-batch-size).
  • Defaults reproduce the current batching exactly.
  • Reject batch_size <= 0 with a clear ValueError instead of silently dropping input.

Problem

Both stages send fixed-size candidate batches to the model. On smaller local models with tight context, the batch can exceed the usable window and candidates at the tail are dropped without an error. Per-item scoring makes the batch size a pure context-fit knob, but it cannot be changed without editing source.

Fix

  • HuntTuning.nday_filter_batch_size: int = 10, HuntTuning.reveng_batch_size: int = 8.
  • NdayFilter.__init__(self, llm, batch_size=FILTER_BATCH_SIZE), RevengReconstructor.__init__(self, llm, batch_size=None) (falls back to self.BATCH_SIZE class attr for subclass compatibility).
  • NdayPipeline and RevengPipeline accept the batch size and pass it through to the wrapped classes.
  • CLI flags thread the value from argparse into SourceHuntConfig construction.
  • Both __init__s reject batch_size <= 0 with ValueError("batch_size must be >= 1, got {N}") — previously 0 raised an uncaught range(...) step must not be zero mid-iteration and negatives silently produced an empty loop that dropped all candidates.

Validation

  • uv run --frozen --extra dev pytest -q tests/test_nday.py tests/test_reveng.py tests/test_sourcehunt_config.py — 69 passed; new regressions: default batch preserved (10 items -> 1 call for filter, 8 for reveng), custom batch_size=3 splits into 4 calls, batch_size=0/-1 raise, config-driven threading verified from HuntTuning.
  • uv run --frozen --extra dev ruff check clearwing/sourcehunt/nday_filter.py clearwing/sourcehunt/reveng_reconstructor.py clearwing/sourcehunt/nday.py clearwing/sourcehunt/reveng.py clearwing/sourcehunt/config.py clearwing/ui/commands/sourcehunt.py
  • git diff --check

Backward compatibility

Defaults reproduce the previous constants exactly. RevengReconstructor.BATCH_SIZE class attribute is retained so subclasses that override it continue to work (resolved at __init__ time).

Independent of the other 4 PRs in this batch; trivial rebase if any lands first.

Fixed batch sizes (10 CVEs for n-day filter, 8 functions for reveng
reconstructor) overflow small local-model context windows and silently
drop trailing items past the model's output budget. Expose the batch
size on HuntTuning (nday_filter_batch_size=10, reveng_batch_size=8),
thread it through NdayPipeline and RevengPipeline, and add matching
--nday-filter-batch-size and --reveng-batch-size CLI flags so callers
running against smaller local models can shrink it; per-item evaluation
means quality is unchanged. Defaults are preserved.

Also reject batch_size <= 0 explicitly in NdayFilter and
RevengReconstructor: batch_size=0 previously raised an obscure
range() ValueError, and batch_size=-1 silently dropped every input.
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