Repository navigation
feat(browsecomp,opencode_multimodal_benchmarks): add a search cache pack and failure kinds for budget-stop masks - #6676
Conversation
The search cache keeps one flat file per entry. A long-lived cache of millions of entries is then millions of small files, which a shared filesystem handles badly (metadata load, file-count quota, slow copies). This adds a read-only pack of the same entries in 512 shard file pairs, behind the flat cache. - search_cache_pack.py: the pack format and its reader. One shard holds the flat files of one <kind>/<ab>/ directory. Reads use pread on long-lived file descriptors. Any read or corruption error is a counted miss, never an error in a rollout. - search_cache.py: a read tries the flat file first and goes to the pack only when the flat file does not exist. A corrupt flat file stays a miss, and a pack entry passes the same shape check. Writes always go to flat files. The pack is on only when pack/MANIFEST.json exists. New stats: search_pack_hits, browse_pack_hits and pack_errors. - build_cache_pack.py: an offline tool that builds, verifies and finalizes the pack, reports its status, unpacks it again (rollback), and lists the flat files that are byte-identical to their packed copy. - app.py: the startup log names the pack generation. A cache root without a pack behaves as before. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Jiaqi Zeng <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
…timed-out rollouts This lets a training config mask budget stops and agent errors in the agent itself, on the legacy /run path: - mask_stop_reasons (default empty): a row whose response ends with one of these stop_reason values comes back with mask_sample true and its judged reward kept. A training framework reads mask_sample from the row. - mask_agent_errors (default false): a row that ended in an agent error (scored 0 with agent_error, for example a /verify 500 after a judge that never answered) comes back masked instead of as an unmasked 0. - A timed-out rollout now goes to /verify like any other. The resources server already scores it 0 without the judge. On this path no close is sent, so the verify is what releases the session's tool sandbox and workspace. The old timeout branch skipped that. The defaults keep the previous scoring. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Jiaqi Zeng <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
…en-capture prefix) A training config can run the host loop with max_reset_count 0 and with the progress board and step nudges on. Token capture links each model call to the one before it by prefix. This test checks call by call that every input extends the previous input and output under those settings (prompts over the reset threshold on every call, nudges at the quarter, half and near-end steps). It also checks that the same run with resets uncapped does rewrite the history. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Jiaqi Zeng <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
…heir timeout Before, trajectory_tool_reward raised ToolEvidenceError for any tool record left "incomplete", so a rollout that hit its wall-clock timeout while a tool was running was masked (verifier_error) and never trained. A rollout timeout is the model's budget, so when the tool's root invocation records the harness deadline (status "incomplete", error_type "timeout", set by the OpenCode agent when its process timed out) the cut tool now scores as a failed call, like a tool's own timeout, and the row is graded normally (usually 0) and trained. Still masked: missing records, "unknown" outcomes, and unfinished tools under a root that did not record a timeout (cancelled, server error, or no evidence). Shared by math/mcqa/string_match/llm_judge_tool_rewards and Agent-X. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Jiaqi Zeng <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
…able math-judge reply math_tool_rewards inherits math_with_judge's judge parsing, which now raises JudgeError for a judge reply that is cut off or names no verdict (#6673). Route the test through judge_failsafe, as the /verify route does, and assert that those cases come back masked (judge_failed / judge_unparseable). Usable verdicts are still graded and shaped as before. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Jiaqi Zeng <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
…del-stop failure kind A trainer can keep a masked row in the group baseline only when the mask comes from the rollout's own budget. It needs a failure kind to tell that mask from an infrastructure failure. - browsecomp_agent: a row masked by mask_stop_reasons carries failure_kind agent_limit (max_steps), agent_timeout (timeout), model_context_limit (context_full), or browsecomp_agent:<stop_reason>, unless the resources server already set a kind. - opencode_multimodal_benchmarks: a rollout cut mid-tool by its wall-clock deadline is masked again (reward 0, as before the earlier fix in this series), now with failure_kind agent_timeout. Any other unfinished or unknown tool evidence stays a verifier_error mask and takes precedence. Signed-off-by: Jiaqi Zeng <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
- browsecomp_agent README: give the legacy /run mask options their own paragraph and list each stop's failure kind. - browsecomp_advanced_harness: a comment said that the agent's /run scores a timed-out rollout without a verify. The /run now sends it to /verify too. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
|
/ok to test b9ea7d7 |
…owsecomp-cache-pack-stop-masks Signed-off-by: Yi-Fu Wu <[email protected]>
|
/ok to test ad19089 |
… for
nemo_gym/rollouts/health/timeouts.py lists browsecomp_agent's timed_out field
as a legacy timeout signal. A core test checks that its producer still holds
the text update={"timed_out": int(bool(. The stop-reason mask had moved the
value into a local dict, so the check failed although the field is still
written. Build the stop-reason mask first and pass the timed_out update
inline again.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>
|
/ok to test f854249 |
- A timed-out rollout whose /verify fails keeps timed_out: 1 on its agent-error row, so run health counts it as a timeout. - The mask_stop_reasons type comes from STOP_REASON_FAILURE_KINDS, so a value without a kind fails when the config loads instead of turning a masked row into an agent error. - mask_stop_reasons and mask_agent_errors are refused when the config cannot serve /run (no allow_host_execution or no resources_server). - The mask_agent_errors example is a /verify 5xx. A failed judge call already comes back from /verify as a judge_failed mask. - The agent README says that these masks also leave rows out of gym eval scores. Comments and docs no longer say that nothing reads stop_reason, or that /run skips /verify after a timeout. - The token-capture prefix test also runs with the /tokenize pre-call path on. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
- candidates lists a flat file only when MANIFEST.json serves its shard and the shard files still have their recorded sizes. Before, it also listed files of verified shards that the server could not yet serve. - build_cache_index.py also indexes the norms of packed search entries, so a rebuild after flat files are deleted keeps those queries visible to fuzzy matching. - The startup error says to run unpack before moving MANIFEST.json aside. - The README gets a Cache pack section: how to build, verify and finalize, when it is safe to delete flat files, and how to roll back. - The build_cache_pack usage line names this server's venv, and the pack hit counters are described as they behave. - The pack tests build one template pack per module and copy it per test. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
…r a tool cut by the deadline A row with a tool cut by the rollout timeout and then a tool with an unknown outcome is masked as verifier_error, not agent_timeout. This pins the order that trajectory_tool_reward documents. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
|
/ok to test 32b2054 |
…owsecomp-cache-pack-stop-masks Signed-off-by: Yi-Fu Wu <[email protected]>
|
/ok to test 199d45d |
…owsecomp-cache-pack-stop-masks Signed-off-by: Yi-Fu Wu <[email protected]>
…s in the baseline browsecomp_agent:max_output_tokens is not one of NeMo RL's default policy failure kinds. Under exclude_infra, a recipe that masks max_output_tokens must add that kind to grpo.policy_failure_kinds, and that list replaces the default list. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
yaoyu-33
left a comment
There was a problem hiding this comment.
Re-reviewed the published-cache preservation and agent stop-reason changes at 0bfa914. Failed or incomplete rebuilds preserve the published shard. A normal answered response keeps its verifier reward with all four budget masks enabled. The 53 cache tests, 187 agent tests, and full pre-commit checks passed. The stack order is #6675, #6673, then this PR.
|
/ok to test 0bfa914 |
…top-masks Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
|
/ok to test 470acde |
…ache-pack-stop-masks Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
|
/ok to test 06727ab |
…-masks Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
|
/ok to test 256f809 |
yaoyu-33
left a comment
There was a problem hiding this comment.
The earlier shard rebuild and stop-reason cases are covered. I found one runtime limit that affects whether the same packed queries are served from cache.
A pack reader keeps both files of every shard it has read open until close(). A full pack lists 512 shards, so it needs 2 x 512 files. With a soft RLIMIT_NOFILE below that, a shard past the limit cannot open, and its entries become misses that can go to a paid live search. A run's search source then changes without notice. open_pack now checks the limit before it returns a reader. It needs 2 per listed shard plus FD_HEADROOM (256) for the server's sockets, logs and flat-cache files. A lower soft limit is raised up to the hard limit, and the server logs one line. If even the hard limit is too low, open_pack raises PackManifestError with the count needed, the limits found and `ulimit -n`, so the server refuses to start, as it does for a missing shard file. An unlimited limit is enough. The pack tests fake RLIMIT_NOFILE, so they do not change the test process's real limit. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
…-masks Signed-off-by: Yi-Fu Wu <[email protected]>
|
/ok to test f2a0a61 |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/46938603295 |
What does this PR do?
This PR has three parts. All of them are off by default or keep the current score on shipped configurations.
These changes were written by Jiaqi Zeng (@HeyyyyyyG). The commits after his (
docs(browsecomp): ..., thetimed_outtext fix and the three review-fix commits) are new in this PR.Issue: none. This is a focused upstream of tested changes, and this body states the reasons.
1. A read-only pack behind the BrowseComp search cache
browsecomp_advanced_harnesskeeps its search cache as one flat JSON file per entry. A long-lived cache of millions of entries is then millions of small files. A shared filesystem handles that badly: metadata load, file-count quota and slow copies.search_cache_pack.py(new): a read-only pack of the same entries in 512 shard file pairs (an.idxand a.datper<kind>/<ab>shard). Reads usepreadon long-lived file descriptors. Any read or corruption error is a counted miss (pack_errors), never an error in a rollout.search_cache.py: a read tries the flat file first and goes to the pack only when the flat file does not exist. A corrupt flat file stays a miss. A pack entry passes the same shape check as a flat entry. Writes always go to flat files. New stats:search_pack_hits,browse_pack_hitsandpack_errors.SearchCache.close()(also a context manager) closes the pack's file descriptors, and the harness calls it at shutdown.build_cache_pack.py(new): an offline tool withbuild,verify,finalize,status,unpack(rollback) andcandidates.candidateslists the flat files that are byte-identical to their packed copy, and only for shards thatMANIFEST.jsonserves at their recorded sizes.buildrefuses a shard whose pack holds entries with no flat file (rununpackfirst), so a rebuild cannot drop the only copy of a deleted entry.verifyexpects a pack hit only for an entry SearchCache accepts.unpackstages each file under its own exclusively created name.build_cache_index.py: the fuzzy index rebuild also indexes the norms of packed search entries whose flat file was deleted, so their queries stay visible to fuzzy matching. It skips packed entries that still have a flat file, and reads only a prefix of the others (about 4 KB of compressed bytes, the same head read as a flat file). An entry whose norm lies past that prefix is read in full.<cache_root>/pack/MANIFEST.jsonexists.finalizewrites that file last. If the manifest names a shard file that is missing or has the wrong size, the server refuses to start. Each silent miss is a paid provider call, so a loud start failure is the safer choice.2. Config-gated masks on the BrowseComp agent's legacy
/runbrowsecomp_agentgets two config fields. Both apply only to the legacy/runpath, so a config that sets either one withoutallow_host_execution: trueand aresources_serverfails to load.mask_stop_reasons(default[]): a row whose response ends with one of thesestop_reasonvalues comes back withmask_sample: trueand its judged reward kept. The allowed values are the keys ofSTOP_REASON_FAILURE_KINDS, so an unknown value fails config validation.mask_agent_errors(defaultfalse): a row that ended in an agent error (scored 0 withagent_error, for example after/verifyanswered 5xx) comes back masked instead of as an unmasked 0. A failed judge call does not need this option:/verifyalready returns that row masked asjudge_failed.A timed-out rollout on
/runnow goes to/verifylike any other row. The resources server already scores it 0 without the judge. On this path no close is sent, so the verify is what releases the session's tool sandbox and workspace. The old timeout branch skipped the verify, so it did not release them. If that/verifycall fails, the agent-error row keepstimed_out: 1, so run health still counts it as a timeout.A test also pins the token-capture prefix: with
max_reset_count: 0, the progress board and step nudges on, every model call's input extends the previous call's input and output. It runs with the/tokenizepre-call path off and on.Possible follow-up, not in this PR: move
mask_stop_reasonsand its kinds into the_verifyofbrowsecomp_advanced_harness, so agent sessions and other harnesses get the same masks.3. A failure kind on budget-stop masks
A trainer can keep a masked row in its group baseline only when the rollout's own budget caused the mask. It needs a failure kind to tell that row from an infrastructure failure.
browsecomp_agent: a row masked bymask_stop_reasonscarriesfailure_kindagent_limit(max_steps),agent_timeout(timeout),model_context_limit(context_full), orbrowsecomp_agent:<stop_reason>for the other values. A kind that the resources server already set (for exampleprovider_unavailable) wins.opencode_multimodal_benchmarks(shared bymath_tool_rewards,mcqa_tool_rewards,string_match_tool_rewards,llm_judge_tool_rewardsand Agent-X): a tool left unfinished under a root invocation that the OpenCode agent stopped at its wall-clock deadline (status: incomplete,error_type: timeout) raises the newRolloutTimeoutToolEvidence. The row is masked withfailure_kind: agent_timeout. Any other unfinished or unknown tool record, a call with no record or with a record under another tool name, and a repeated call ID still mask the row asverifier_error, and that error wins when both occur. Tests pin that order. Two commits in the series first trained such a row and then masked it again. The net change against the base is the failure kind only.agent_limit,agent_timeoutandmodel_context_limitalready exist innemo_gym/core/failure_kinds.pyand are in its default model class. The namespacedbrowsecomp_agent:*kinds have no default class.Why
A row that stops at its step, time or context budget often scores 0. That 0 says little about the answer. Before this PR, a training config had no way to mask these rows in the BrowseComp agent itself. A masked row also needs a kind, so a trainer can tell "the model ran out of budget" from "our servers failed".
Stack
This PR stacks on #6673 (
yifuw/mask-judge-replies-without-verdict), which stacks on #6675. The branch has signed merges of the #6673 branch, the latest ata5b89da7d5, so the diff here shows only this layer. The opencode test change that expects a masked row for an unusable math-judge reply now lives in #6673, so it no longer shows in this diff. After #6675 and #6673 merge, this PR retargets tomain.Related PRs (pointers only)
browsecomp_agent/app.py.browsecomp_advanced_harness/app.py. This PR changes one log line and two comments there.trajectory_tool_rewardloop that this PR changes. A rebase of fix(eval): preserve planned repeats through aggregation and reverification #6017 needs to keepRolloutTimeoutToolEvidence.Validation
Local, CPU only, at the head
fa4028852a(after the merge of #6673 ata5b89da7d5), with uv 0.13.9 (uv venv && uv sync --extra dev) andRAY_TMPDIR=/tmp:pre-commit run --all-filesgym env test +entrypoint=responses_api_agents/browsecomp_agent +should_validate_data=truegym env test +entrypoint=resources_servers/browsecomp_advanced_harness +should_validate_data=truegym env test +entrypoint=resources_servers/opencode_multimodal_benchmarks +should_validate_data=truecv2, 1 test needs Node.js or Bun), data validatedgym env test +entrypoint=resources_servers/llm_judge_tool_rewards +should_validate_data=truerewards.py)gym env test +entrypoint=resources_servers/math_tool_rewards +should_validate_data=truerewards.py)pytest tests/unit_tests/verification tests/unit_tests/eval/recoverypytest tests/unit_tests/rollouts(atc15e959a23, and the later commits change no core code)test_tool_telemetry.pyfail locally withKeyError: 'nemo.gym.tool.span_id'. This branch changes nothing innemo_gym/ortests/, and CI does not report them.The new tests for the review fixes fail without their fix: the
timed_outrow after a failed/verify, the mask refusal without/run,candidatesbeforefinalizeand with a wrong-size shard file, and the index rebuild after flat files are deleted. The same holds for the tests added for the review bot's findings: the refused rebuild, the rejected-shape entries inverify, the shared staging file inunpack, the descriptors afterclose(), the misplaced flat copy in the index rebuild, and the inconsistent tool evidence beside a deadline-cut tool.CI classification: server-only (
resources_servers/**andresponses_api_agents/**).Rollouts
The main run below was at
72584a6858. The later commits change only the index-rebuild tool (now about 40 times faster on the sample), merge #6673's inverse_if fixes and fix one word in thecandidatessummary. The earlier 34-row run and the OpenCode rollout were at199d45d2ff, before the #6675 and #6673 review fixes, which touch no BrowseComp or OpenCode code.Rollouts: CPU only, a hosted model as agent and judge. Search was served from a cache pack built with this PR's tooling from a sample of an existing search cache, and cache misses went to live Exa.
/run, withmask_stop_reasons: [max_steps, context_full, timeout]andmask_agent_errors: true:answeredrows came back unmasked with no failure kind (5 scored 1.0).max_stepsrows came back masked withagent_limit.timeoutrows came back masked withagent_timeout./verify500 from a judge reply that held only reasoning, a bug on main, outside this PR./verify:timed_out: 1, reward 0, no judge call.answeredunmasked, 5max_stepsmasked withagent_limitand their judged reward kept, and 18timeoutmasked withagent_timeout.candidateslisted 0 files beforefinalizeand 20,241 after.build_cache_index.pykept all 12,173 norms.math_tool_rewardswith tool rewards on) was cut by its 240 s deadline during asleep 600bash call. It came back masked withfailure_kind: agent_timeout.context_fullandmax_output_tokens. Unit tests cover them.Compatibility and benchmark impact
mask_stop_reasonsis empty andmask_agent_errorsis false. The cache pack is off until aMANIFEST.jsonexists.mask_stop_reasonsormask_agent_errorswithoutallow_host_execution: trueand aresources_servernow fails to load. Both options are new, so no existing config sets them./runwithrollout_timeout_s, timed-out rollouts. The reward stays 0, and the row now carries the resources server's verify fields (metrics,reasoning). The session's tool sandbox and workspace are released at the end of the rollout. Two rows change:provider_unavailable. Before, it was an unmasked 0./verifyanswers 5xx or cannot connect is nowkill_shapedwith_ng_no_persist, so a resume runs it again. It keepstimed_out: 1. Before, it was a settled 0.opencode_multimodal_benchmarkstraining servers: a rollout cut mid-tool by its deadline was masked asverifier_errorand is now masked asagent_timeout. It stays masked with reward 0. A trainer that groups or excludes masked rows by kind sees the new kind.gym evalrecovery treats averifier_errorrow as evaluation-side, so it can offer the row for--rerun-masked-without-artifact. Anagent_timeoutrow that kept its answer is the model's final result, so recovery no longer offers these rows.grpo.masked_reward_policy: exclude_infra, a masked row stays in its group baseline only when its kind is ingrpo.policy_failure_kinds. A recipe that masksmax_output_tokensmust addbrowsecomp_agent:max_output_tokensto that list. The list replaces the default list, so the recipe must also list the default kinds.gym evalalso leaves masked rows out of the score, which can raise the mean, so these masks are for training.Checklist
pre-commit run --all-files) (so CI lint/format checks pass).git commit -s) (so the DCO check passes).🤖 Generated with Claude Code