Repository navigation
feat: add gym env prefetch for baking server venvs into the container - #2255
Merged
Merged
Conversation
Placeholder for 'gym env prefetch' implementation. Addresses review feedback from #2161. Co-Authored-By: Claude Sonnet 4.6 (1M context) <[email protected]> Signed-off-by: Kajal Jain <[email protected]>
Implements 'gym env prefetch' — accepts the same config format as
'gym env start', installs each server's venv serially via
setup_env_command(), and exits without starting any server process
or initialising Ray.
This mirrors RL's prefetch_venvs.py approach: accepts a list of
configs, does a dry install of deps for each configured server, and
bakes the venvs into the container image so no network access is
needed at runtime.
Dockerfile updated to use NEMO_GYM_PREFETCH_CONFIGS (comma-separated
config paths) instead of NEMO_GYM_PREFETCH_SERVERS (space-separated
directory paths), enabling config-driven prefetch consistent with the
rest of the Gym CLI.
Example:
docker buildx build \
--build-arg NEMO_GYM_PREFETCH_CONFIGS="responses_api_models/local_vllm_model/configs/local_vllm_model.yaml" \
-f docker/Dockerfile .
Co-Authored-By: Claude Sonnet 4.6 (1M context) <[email protected]>
Signed-off-by: Kajal Jain <[email protected]>
kajalj22
force-pushed
the
add-prefetch-venvs
branch
from
August 3, 2026 14:43
d6029b3 to
51cc88e
Compare
kajalj22
marked this pull request as ready for review
August 3, 2026 15:03
Two blockers from code review: 1. prefetch() was defined but never added to the COMMANDS dispatch table in main.py — 'gym env prefetch' raised unknown-command. Added entry mirroring 'env start' flags (CONFIG, BENCHMARK, ENVIRONMENT, RESOURCES_SERVER_CONFIG, MODEL_TYPE, SEARCH_DIR). 2. process.communicate() discarded the return code — a failed 'uv pip install' would print "Prefetch complete." with exit 0, silently baking a broken venv into the container image. Now uses process.wait() and raises SystemExit on non-zero, so the Docker build fails loudly if any install fails. Co-Authored-By: Claude Sonnet 4.6 (1M context) <[email protected]> Signed-off-by: Kajal Jain <[email protected]>
If the same server dir appears under multiple top-level config keys (e.g. two configs both referencing local_vllm_model), the previous implementation would run setup_env_command twice against the same .venv. Track seen dir_paths in a set and skip duplicates — mirrors RL's prefetch_venvs.py which groups by py_executable to avoid redundant installs. Co-Authored-By: Claude Sonnet 4.6 (1M context) <[email protected]> Signed-off-by: Kajal Jain <[email protected]>
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.
Summary
Follow-up to #2161 (standalone Gym container). Implements
gym env prefetch— a proper config-driven CLI command for pre-warming server venvs at container build time, similar to how RL'sprefetch_venvs.pyworks.What this replaces
PR #2161 has
NEMO_GYM_PREFETCH_SERVERSwhich takes space-separated directory paths. This PR replaces it withNEMO_GYM_PREFETCH_CONFIGSwhich takes Gym config files — the same format asgym env start. This is the approach Ananth described in the review.How it works
gym env startdoessetup_env_command()— creates the venv and installs deps seriallySerial installation reduces uv cache size (same reasoning as
dry_runmode inRunHelper.start).Dockerfile usage
Changes
nemo_gym/cli/env.py—gym env prefetchcommanddocker/Dockerfile—NEMO_GYM_PREFETCH_CONFIGSreplacesNEMO_GYM_PREFETCH_SERVERS🤖 Generated with Claude Code