Skip to content

feat(inspect): read an Inspect AI eval and list its samples as task rows - #6929

Draft
cwing-nvidia wants to merge 1 commit into
cwing/inspect/cli-serving-bodyfrom
cwing/inspect/task-prepare
Draft

cwing-nvidia wants to merge 1 commit into
cwing/inspect/cli-serving-bodyfrom
cwing/inspect/task-prepare

Conversation

@cwing-nvidia

@cwing-nvidia cwing-nvidia commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Goal of the stack (#6683): run an eval written for Inspect AI in Gym without porting it. The eval's dataset, solver and scorer run as written; Gym serves the model and records every model call.

PR 2 of 5. This PR reads the eval and lists its samples; nothing runs yet.

What

  • nemo_gym/data/tasks/inspect/: reads an inspect:<package>/<task> reference, builds a Python environment for Inspect, and writes one row per sample.
  • environment_servers/inspect/inspect_worker/: the worker process that imports inspect_ai and the eval's code.
  • A pre-run check that stops before any model call, with the fix, for an eval that cannot run (needs a sandbox, a model Gym cannot route, a gated dataset, a missing package).

Design points for review

  • The worker has its own environment because Inspect and Gym need different major versions of openai. Gym never imports inspect_ai.
  • Eval code from outside inspect_evals runs only with trust_unreviewed_packages.
  • The dataset loads under a fixed seed, so sample ids are the same on every run.
  • The worker gets no model API key from Gym's environment.

Validation

  • pytest tests/unit_tests/data/tasks/inspect: 71 passed, several against a real worker.
  • pre-commit run --all-files passes.

Rollout evidence: N/A, nothing here runs an episode. See PR 5.

Compatibility: additive.

@copy-pr-bot

copy-pr-bot Bot commented Nov 30, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@cwing-nvidia
cwing-nvidia added this pull request to stack #6933 November 30, 2026 04:50
@cwing-nvidia cwing-nvidia added area:data Datasets, preparation, task formats, and materialization feature New capabilities, enhancements, or enablement work labels Nov 30, 2026
@cwing-nvidia

Copy link
Copy Markdown
Contributor Author

/ok to test cb7b842

@svcnvidia-nemo-ci svcnvidia-nemo-ci added the risk:high Autobot PR risk: high label Nov 30, 2026
Adds nemo_gym.data.tasks.inspect and the Inspect worker's check and prepare commands.

An inspect:<package>/<task> or inspect:<file.py>@<task> reference is parsed, the task is loaded in a worker process with its own Python environment, a pre-run check stops a task that cannot run, and each sample becomes one row with the task, its arguments, the sample id and a hash of the sample.

The worker has its own environment because Inspect's model client and Gym need different major versions of the openai package. It is built on first use in the user's cache folder. A worker starts with an explicit set of environment variables, in an empty private folder, and imports nothing from the folder gym is run from. A package outside the curated suite (inspect_evals) runs, and is installed, only with trust_unreviewed_packages.

Before a task is loaded, in prepare and in every worker, the random number generators are seeded with a fixed seed that is recorded in every row and in the run configuration. An eval that shuffles without a seed when it loads then builds the same samples, prompts and ids each time, which an `inspect eval` run does not do.

Samples can be selected by id with shell-style patterns, and a worker that only loads a task gets a placeholder model key and an address that answers nothing, so an eval that builds a model client while it loads can be prepared without any real key.

The pre-run check also reads the eval's own source files that the loaded task uses, imports inside functions
included, and stops when a top-level module cannot be found, so a package only a metric or a scorer needs is
found before any model call is made. Nothing is imported to find out. allow_missing_modules names modules a run
can do without.

At prepare, when the task's distribution declares an extra named after the task's eval folder, the worker
environment is built with that extra, and the run uses that environment. install_eval_extra turns it off.

Before a task is loaded, the worker sets the defaults every model client is built with (the OpenAI SDK sends
each request once; tools are not marked strict unless the run asks) and checks the Inspect internals Gym calls,
because an eval may build a judge while it loads and a client keeps the defaults it was built with. A set-up
that cannot be applied stops the run under its own code.

An extra that cannot be installed is noted and the run goes on with the package alone. A build error never
shows the credential of a package address. The import check leaves out imports under an if on the operating
system or on __name__, keeps an import whose handler re-raises, and, for a task defined in a file, counts
a module beside the importing file as present.

A credential in a package address is never shown: not in a build error, where it is redacted before the output
is cut, not in the stop for an unreviewed package, and not in the stop for an isolated eval.

An eval its package marks as isolated ships without its dependencies, which a package of the eval's own in the
source repository declares. When that package is not in the worker environment, prepare stops before any model
call with the worker_packages line that installs it, built from the installed distribution's source repository
and the release tag looked up there. The line is printed as one shell word in double quotes, so it can be
pasted after the command. With worker_python set, the stop gives the command that installs the package into
that environment. A development or local build has no release tag, and the stop says so. A worker that cannot
read the package is reported in a notice. Nothing is installed automatically. check_isolated_package turns it
off.

Signed-off-by: Chris Wing <cwing@nvidia.com>
@cwing-nvidia

Copy link
Copy Markdown
Contributor Author

/ok to test 10076ea

@cwing-nvidia
cwing-nvidia force-pushed the cwing/inspect/task-prepare branch from cb7b842 to 10076ea Compare November 30, 2026 17:22
@copy-pr-bot

copy-pr-bot Bot commented Nov 30, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:data Datasets, preparation, task formats, and materialization feature New capabilities, enhancements, or enablement work risk:high Autobot PR risk: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants