Repository navigation
feat(inspect): read an Inspect AI eval and list its samples as task rows - #6929
Draft
cwing-nvidia wants to merge 1 commit into
Draft
cwing-nvidia wants to merge 1 commit into
cwing-nvidia wants to merge 1 commit into
Conversation
Contributor
Author
|
/ok to test cb7b842 |
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>
Contributor
Author
|
/ok to test 10076ea |
cwing-nvidia
force-pushed
the
cwing/inspect/task-prepare
branch
from
November 30, 2026 17:22
cb7b842 to
10076ea
Compare
|
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 aninspect:<package>/<task>reference, builds a Python environment for Inspect, and writes one row per sample.environment_servers/inspect/inspect_worker/: the worker process that importsinspect_aiand the eval's code.Design points for review
openai. Gym never importsinspect_ai.inspect_evalsruns only withtrust_unreviewed_packages.Validation
pytest tests/unit_tests/data/tasks/inspect: 71 passed, several against a real worker.pre-commit run --all-filespasses.Rollout evidence: N/A, nothing here runs an episode. See PR 5.
Compatibility: additive.