nemo_gym.rollout_reverification

View as Markdown

Module Contents

Classes

Functions

NameDescription
_agent_to_rs_mapping_from_agent_blocks-
_agent_to_rs_mapping_from_resources_only_config-
_build_agent_to_resources_server_mapping-
_build_verify_payload-
_call_aggregate_metricsCall /aggregate_metrics on each resource server after rollouts complete.
_check_reverify_modeQuery GET /reverify_mode on each unique resource server referenced by agent_to_rs.
_drop_cache_from_payloads-
_get_rs_names-
_guard_atif_preflightValidate selected routes before ATIF reverification touches output paths.
_guard_reverify_modeCheck reverify_mode for every RS in the config before reverification starts.
_is_judge_failureWhether a failures-sidecar row is a judge failure (the only recoverable class).
_load_cache_keys_by_status-
_load_reverified_resultsLoad the full main jsonl (cached + newly re-verified successes), sorted by (task, rollout).
_parse_output_line-
_parse_output_line_key-
_prepare_atif_payloadsBuild verifier payloads from an explicit ATIF-to-materialized-task manifest.
_prepare_output_fpaths-
_prepare_payloads-
_recovery_rollout_predicateBuild the row filter for --judge-failed-only recovery.
_resources_server_exposes_tools_over_mcpRead the selected resources server’s MCP exposure flag from Gym config.
_response_has_function_calls-
_rollout_verify_debug_summary-
_rs_for_rowThe resources server that verifies this row.
_run_verification_payloads-
_seed_output_with_successesCopy the already-successful rollout rows into the output file so the final aggregate covers
_selected_atif_resources_server_routesResolve each ATIF row through the same routing policy used by /verify.
_yield_inputs_and_rollouts_paired-
summarize_cache_usage-

Data

ATIF_NO_PERSIST_FAILURE_CLASS

ATIF_PROVENANCE_KEY

JUDGE_FAILED_FAILURE_CLASS

_CONFIG_BOOL_ADAPTER

_RECOVERY_TWO_SOURCES_WARNING

API

class nemo_gym.rollout_reverification.CacheKeysByStatus(
successful_keys: set[tuple[int, int]],
terminal_keys: set[tuple[int, int]],
maxed_out_keys: set[tuple[int, int]]
)
Dataclass
maxed_out_keys
set[tuple[int, int]]
successful_keys
set[tuple[int, int]]
terminal_keys
set[tuple[int, int]]
class nemo_gym.rollout_reverification.InputRolloutPair(
input: typing.Dict[str, typing.Any],
rollout: typing.Dict[str, typing.Any]
)
Dataclass
input
Dict[str, Any]
rollout
Dict[str, Any]
class nemo_gym.rollout_reverification.OutputPaths(
output: pathlib.Path,
failures: pathlib.Path
)
Dataclass
failures
Path
output
Path
class nemo_gym.rollout_reverification.RolloutReverificationConfig()

Bases: UploadRolloutsConfigMixin, BaseNeMoGymCLIConfig

append
bool
atif_manifest_jsonl_fpath
Optional[str]
disable_aggregation
bool
force
bool
input_format
Literal['gym', 'atif']
judge_failed_only
bool
limit
Optional[int]
materialized_inputs_jsonl_fpath
str
num_samples_in_parallel
Optional[int]
output_jsonl_fpath
str
overwrite
bool
resume_from_cache
bool
rollouts_jsonl_fpath
Optional[str]
class nemo_gym.rollout_reverification.RolloutReverificationHelper()

Bases: BaseModel

nemo_gym.rollout_reverification.RolloutReverificationHelper.run_from_config(
) -> typing.List[typing.Dict]
async
nemo_gym.rollout_reverification._agent_to_rs_mapping_from_agent_blocks(
global_config_dict: typing.Union[typing.Dict[str, typing.Any], omegaconf.DictConfig]
) -> typing.Dict[str, str]
nemo_gym.rollout_reverification._agent_to_rs_mapping_from_resources_only_config(
global_config_dict: typing.Union[typing.Dict[str, typing.Any], omegaconf.DictConfig]
) -> typing.Dict[str, str]
nemo_gym.rollout_reverification._build_agent_to_resources_server_mapping(
global_config_dict: typing.Union[typing.Dict[str, typing.Any], omegaconf.DictConfig]
) -> typing.Dict[str, str]
nemo_gym.rollout_reverification._build_verify_payload(
) -> typing.Dict
nemo_gym.rollout_reverification._call_aggregate_metrics(
results: typing.List[typing.Dict],
rows: typing.List[typing.Dict],
output_fpath: pathlib.Path
) -> typing.Optional[pathlib.Path]
async

Call /aggregate_metrics on each resource server after rollouts complete.

Writes a single _aggregate_metrics.json with one entry per agent (same shape as the old _agent_metrics.json). Returns the file path.

nemo_gym.rollout_reverification._check_reverify_mode(
agent_to_rs: typing.Dict[str, str]
) -> typing.List[str]
async

Query GET /reverify_mode on each unique resource server referenced by agent_to_rs.

Returns a sorted list of RS names that reported ReverifyMode.UNSUPPORTED or ReverifyMode.UNKNOWN.

nemo_gym.rollout_reverification._drop_cache_from_payloads(
payloads: typing.List[typing.Dict],
) -> typing.Iterator[typing.Dict]
nemo_gym.rollout_reverification._get_rs_names(
agent_to_rs: typing.Dict[str, str]
) -> typing.List[str]
nemo_gym.rollout_reverification._guard_atif_preflight(
payloads: typing.List[typing.Dict[str, typing.Any]]
) -> None
async

Validate selected routes before ATIF reverification touches output paths.

nemo_gym.rollout_reverification._guard_reverify_mode(
) -> typing.Optional[str]
async

Check reverify_mode for every RS in the config before reverification starts.

Returns a warning string when the user runs full re-verification (not judge-failed-only) and force=True and at least one RS is UNSUPPORTED or UNKNOWN (caller must print it and apply the unsafe_ output prefix). Raises ConfigError when force=False and at least one RS is UNSUPPORTED or UNKNOWN. Returns None when all RS are STATELESS.

nemo_gym.rollout_reverification._is_judge_failure(
row: typing.Dict[str, typing.Any]
) -> bool

Whether a failures-sidecar row is a judge failure (the only recoverable class).

nemo_gym.rollout_reverification._load_cache_keys_by_status(
nemo_gym.rollout_reverification._load_reverified_results(
output_fpath: pathlib.Path
) -> typing.Tuple[typing.List[typing.Dict], typing.List[typing.Dict]]

Load the full main jsonl (cached + newly re-verified successes), sorted by (task, rollout).

Returns (results, rows): results are the parsed rows — the source of truth used for both the W&B rollouts export and the aggregate-metrics payload; rows is a minimal {agent_ref, task_source} projection used only to route each result to its resources server (with the same resolver as /verify). Read once and reused for both so the file is never read twice.

nemo_gym.rollout_reverification._parse_output_line(
line: bytes
) -> typing.Dict[str, typing.Any]
nemo_gym.rollout_reverification._parse_output_line_key(
line: bytes
) -> tuple[int, int] | None
nemo_gym.rollout_reverification._prepare_atif_payloads(
materialized_inputs_jsonl_fpath: pathlib.Path,
atif_manifest_jsonl_fpath: pathlib.Path,
limit: typing.Optional[int] = None
) -> typing.List[typing.Dict]

Build verifier payloads from an explicit ATIF-to-materialized-task manifest.

nemo_gym.rollout_reverification._prepare_output_fpaths(
output_name_prefix: str,
output_jsonl_fpath: str,
resume_from_cache: bool,
overwrite: bool,
append: bool
nemo_gym.rollout_reverification._prepare_payloads(
materialized_inputs_jsonl_fpath: pathlib.Path,
rollouts_jsonl_fpath: pathlib.Path,
resume_from_cache: bool,
limit: typing.Optional[int] = None,
rollout_predicate: typing.Optional[typing.Callable[[Dict[str, Any]], bool]] = None
) -> typing.List[typing.Dict]
nemo_gym.rollout_reverification._recovery_rollout_predicate(
skip_keys: typing.Optional[set[tuple[typing.Any, typing.Any]]] = None
) -> typing.Callable[[Dict[str, Any]], bool]

Build the row filter for --judge-failed-only recovery.

Keeps only judge-class failures, skips any whose (task, rollout) key is in skip_keys (the keys already present in the output: seeded successes + rows a prior recovery already appended) so a key-in-both is never re-verified/duplicated and re-runs are idempotent — this dedup is done here, independent of the resume/cache machinery — and dedups on the key so a sidecar with multiple failure attempts for one key re-verifies it exactly once.

nemo_gym.rollout_reverification._resources_server_exposes_tools_over_mcp(
global_config_dict: typing.Union[typing.Dict[str, typing.Any], omegaconf.DictConfig],
resources_server_name: str
) -> bool

Read the selected resources server’s MCP exposure flag from Gym config.

nemo_gym.rollout_reverification._response_has_function_calls(
row: typing.Dict[str, typing.Any]
) -> bool
nemo_gym.rollout_reverification._rollout_verify_debug_summary(
row: typing.Dict[str, typing.Any],
resources_server_name: str
) -> typing.Dict[str, typing.Any]
nemo_gym.rollout_reverification._rs_for_row(
row: typing.Dict[str, typing.Any],
agent_to_rs: typing.Dict[str, str],
global_config_dict: typing.Union[typing.Dict[str, typing.Any], omegaconf.DictConfig]
) -> str

The resources server that verifies this row.

A task_source naming a resources server is authoritative (it is the declaring instance the dataset was stamped with — no agent indirection needed). Otherwise fall back to the rollout’s agent_ref via the config’s agent->rs edges.

nemo_gym.rollout_reverification._run_verification_payloads(
payloads: typing.List[typing.Dict],
semaphore: asyncio.Semaphore | contextlib.nullcontext[None] | None = None
) -> typing.Iterator[asyncio.Future]
nemo_gym.rollout_reverification._seed_output_with_successes(
successes_fpath: pathlib.Path,
output_fpath: pathlib.Path
) -> set[tuple[int, int]]

Copy the already-successful rollout rows into the output file so the final aggregate covers successes + recovered rows, and return the set of (task, rollout) keys ALREADY PRESENT in the output afterward

nemo_gym.rollout_reverification._selected_atif_resources_server_routes(
global_config_dict: typing.Union[typing.Dict[str, typing.Any], omegaconf.DictConfig],
payloads: typing.List[typing.Dict[str, typing.Any]]
) -> typing.List[str]

Resolve each ATIF row through the same routing policy used by /verify.

nemo_gym.rollout_reverification._yield_inputs_and_rollouts_paired(
materialized_inputs_jsonl_fpath: pathlib.Path,
rollouts_jsonl_fpath: pathlib.Path,
limit: typing.Optional[int] = None,
rollout_predicate: typing.Optional[typing.Callable[[Dict[str, Any]], bool]] = None
nemo_gym.rollout_reverification.summarize_cache_usage(
all_payloads: typing.List[typing.Dict],
filtered_payloads: typing.List[typing.Dict]
) -> None
nemo_gym.rollout_reverification.ATIF_NO_PERSIST_FAILURE_CLASS = 'kill_shaped'
nemo_gym.rollout_reverification.ATIF_PROVENANCE_KEY = '_ng_atif_provenance'
nemo_gym.rollout_reverification.JUDGE_FAILED_FAILURE_CLASS = 'judge_failed'
nemo_gym.rollout_reverification._CONFIG_BOOL_ADAPTER = TypeAdapter(bool)
nemo_gym.rollout_reverification._RECOVERY_TWO_SOURCES_WARNING = "WARNING: judge-failed-only recovery merges rewards from TWO sources — the succe...