Add timeout and memory limits to CodeEnvironment execution#2208
Draft
taivu1998 wants to merge 1 commit intoNVIDIA-NeMo:mainfrom
Draft
Add timeout and memory limits to CodeEnvironment execution#2208taivu1998 wants to merge 1 commit intoNVIDIA-NeMo:mainfrom
taivu1998 wants to merge 1 commit intoNVIDIA-NeMo:mainfrom
Conversation
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
This PR adds execution limits to
CodeEnvironmentso coding rollouts can constrain untrusted code without taking down the Ray worker.Closes #816.
What Changed
default_timeout_secondsanddefault_memory_limit_bytestimeout_secondsandmemory_limit_bytessupport inCodeEnvMetadataresource.RLIMIT_ASon Linux and return a clear error observation on unsupported platformsWhy
Issue #816 asks for timeout and RAM limits when training or evaluating coding tasks. Without those constraints, generated programs can rely on brute-force behavior, infinite loops, or pathological memory use that distorts the training signal and can destabilize the execution environment.
Design Notes
extra_env_infometadata path.RLIMIT_ASis not reliable across platforms.Validation
git diff --checkpython3 -m py_compile nemo_rl/environments/code_environment.py tests/unit/environments/test_code_environment.pyRAY_ENABLE_UV_RUN_RUNTIME_ENV=0 PYTHONPATH=/tmp/codex-verification-stubs:/tmp/rl-issue-816-code-env /tmp/rl-issue-816-code-env/.venv-test/bin/python - <<'PY' ... pytest.main([... 'tests/unit/environments/test_code_environment.py', '-k', 'not vllm_execute_code']) ... PYResult:
7 passed, 1 skipped, 1 deselected in 44.17sNotes