[Bug]: Compile is not feasible at full-corpus scale: numpy undeclared and Reduce evidence injection unbounded
Issue Origin
Observed or reproduced in a real environment
Bug Description
At full-corpus scale (871 papers → 9,570 source ranges → 10,417 Map records), two Compile assumptions break and make the pipeline practically infeasible:
-
Undeclared numpy dependency in Shuffle.
vikingbot/compile/ops/shuffle.pyuses numpy fortop_candidatesand falls back to a pure-Python implementation when numpy is missing. The uv tool installation of 0.5.1 does not include numpy:ModuleNotFoundError: No module named 'numpy'The fallback computes top-k candidates in O(n²·d): with ~8,900 records × 4,096 dims this is ~10^11 operations and does not complete in practice. A full-corpus Shuffle therefore cannot run in the shipped environment.
-
Reduce injects original evidence without a budget/disable switch. In
pipeline_io.py, theFileResponsepath adds each record'soriginal_evidenceto the prompt: it usesevidence_spansexcerpts when available, otherwise a full source shard, and checks the soft input budget only while adding. There is no configuration to disable or cap this injection. For 8,764 body records the source shards total ~67.1M characters (~42M tokens) plus ~24.3M characters of Map payloads; even a perfect batching strategy exceeds a normal per-task budget, and re-use of sources across topic groups multiplies the cost. In a pilot with only 38 records, Reduce consumed 1.76M input tokens; scaling to 8.8k records is not economically viable.
Steps to Reproduce
- Install 0.5.1 with
uv tool install "openviking[bot]"on a clean machine; confirmpython -c "import numpy"fails. - Create a Compile task with ~8k Map records and enter Shuffle;
top_candidatestakes the stdlib fallback and effectively never returns. - With numpy available, let Shuffle finish and enter Reduce; observe prompt sizes (all
original_evidenceshards) and token usage.
Expected Behavior
- numpy should be a declared Compile dependency, or
top_candidatesshould have a bounded approximate implementation that does not require numpy for 10k-scale collections. - Reduce should expose a documented budget / truncation policy for
original_evidence(e.g. excerpt-only mode, per-record char cap, or a switch) and should reuse validated Reduce results across compatible runs.
Actual Behavior
- Shipped environment lacks numpy → Shuffle top-k cannot scale.
- Reduce prompt cost is dominated by repeated original source text; there is no setting to cap or disable it.
- Large tasks fail or become too expensive rather than degrading gracefully.
Minimal Reproducible Example
# 1) numpy missing in the shipped uv environment
# $ python -c "import numpy"
# ModuleNotFoundError: No module named 'numpy'
# 2) stdlib fallback path in Shuffle.top_candidates
from vikingbot.compile.ops.shuffle import top_candidates
vectors = [[0.0] * 4096 for _ in range(8900)]
top_candidates(vectors, 5) # stdlib fallback: not practical at this size
# 3) Reduce evidence injection is unconditional for FileResponse
# vikingbot/compile/pipeline_io.py:
# candidate = {**data, "original_evidence": {..., reference: source}}
# if self.fits(system, candidate, schema): data = candidate
Error Logs
$ python -c "import numpy"
ModuleNotFoundError: No module named 'numpy'
Pilot Reduce (38 records): 1.76M input tokens, 0.10M output tokens, 87 model calls
Measured corpus: 8,764 body records, 67.1M source chars, 24.3M payload chars
Estimated Reduce input from evidence injection alone: ~42M tokens (before batching overhead)
OpenViking Version
0.5.1
Python Version
3.12 (uv tool environment)
Operating System
Windows
Model Backend
Other
Additional Context
bot/vikingbot/compile/ops/shuffle.py:try: import numpy/ stdlib comment "The stdlib path keeps only each row's top-k candidates."bot/vikingbot/compile/pipeline_io.py:original_evidenceinjection around theFileResponsebranch;fits()provides a soft budget only.- Workaround used here: compute top-k with an external numpy process (no production env change), and synthesize pages from Map evidence with a custom batched pipeline instead of the built-in Reduce. Both are workarounds, not fixes.
- Suggest either declaring
numpyfor Compile extras or providing an approximate candidate selection mode, and documenting a Reduce evidence-budget parameter.
Compile-related follow-ups: #6368 (Shuffle failure isolation/checkpoint), #6369 (resume/checkpoint import).
Thank you for sharing the measurements from your 871-paper corpus. The NumPy packaging issue is fixed on current main: installing openviking[bot] now includes NumPy. Dependency declaration
Compile now defaults to simple mode. It reads sources and writes output directly in one agent loop, which avoids the overhead of running Map, Shuffle, and Reduce for smaller jobs. For a large batch like yours, we recommend setting bot.compile.mode to "complex" in ov.conf. We've also optimized the data structures in that pipeline: Shuffle stores routing vectors as compact float32 arrays and computes similarity in blocks, keeping only the top candidates for each record. This reduces peak memory use on large inputs. Mode configuration · Shuffle implementation
I'm closing this issue with those updates. Please try the latest main with your corpus. If Reduce input cost is still a bottleneck, we'd welcome a follow-up with the input-token count from the same 38-record pilot. That would give us a direct comparison with your original measurements.