Repository navigation
GPUs in the sandbox (environment.gpu); ASPIRE's simulator confined with them - #93
Merged
Merged
Conversation
…th them hermit's bubblewrap sandbox had no GPU: CUDA found no device and EGL rendered in software. environment.gpu (Sandbox(gpu=...)) shows the named NVIDIA GPUs, the N of /dev/nvidia<N>, and nothing of the others: their devices, the driver's nvidiactl and, when present, nvidia-uvm, nvidia-modeset and nvidia-caps, and read-only /sys/devices, /sys/bus/pci, /sys/module/nvidia(_uvm), which CUDA and EGL read to find them. Inside they count from 0. Off by default. ASPIRE's generated programs ran unconfined on the host in cap-harness, and ASPIRE's validator can be bypassed. Every cap-harness process (the simulator service's, the judge's, the direct actor's) now runs in a sandbox of its own (sim.confine): - it reads ASPIRE's checkout but not its worked solutions, agents' skills, tests, outputs/ or .git; - it writes only its run's output, and run storage inside the checkout is refused; - it reaches only the providers (8114/8115/8116/8118, CAP_HARNESS_*_URL ports; a remote one through an allowlist proxy); - it renders on the GPUs ASPIRE_SIM_GPU names. A venv interpreter keeps its venv. A hand-extracted EGL driver is shown file by file. The host reads a run's output only after removing links (modes repaired first), and only from run_dirs inside the run. A program's own directory is never a trusted grant. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…r ASPIRE's confined simulator - The host's CUDA_VISIBLE_DEVICES is not passed into the simulator's sandbox: its GPUs count from 0 there, so a host value (=8) left CUDA no device. - Each confined run gets a HOME of its own, removed after it: caches no longer land in the run's output, which is delivered into the session's workspace. - The service's and the judge's confined runs leave sandbox records ($ASPIRE_OUT/sim-service/sandbox/, $ASPIRE_OUT/sandbox/). - The simulator service refuses to start without bubblewrap or with an ASPIRE_SIM_GPU the machine lacks, instead of failing each session's runs after charging its budget. - The ASPIRE tests that run the simulator confined skip, with a reason, without a working bubblewrap. - Docs: other GPUs' /sys entries stay readable (no access to their devices), nvidia-uvm only when present, and environment.gpu has no effect where nothing is confined. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
8 of 11 tasks
10 of 12 tasks
iamziyuzhao
added a commit
that referenced
this pull request
Nov 10, 2026
…h branch Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Change
GPUs in the sandbox. hermit's bubblewrap sandbox mounts a minimal
/dev, so a sandboxed process had no GPU: CUDA found no device, and EGL fell back to Mesa's software renderer. Anything that needs a GPU therefore had to run outside the sandbox.environment.gpu: [N, ...](in code,Sandbox(gpu=[...])) shows the named NVIDIA GPUs and no other GPU's device:/dev/nvidia<N>, a GPU's Minor Number innvidia-smi -q./dev/nvidiaN, the driver'snvidiactl, and, when present,nvidia-uvm,nvidia-modesetandnvidia-caps(MIG)./sys:/sys/devices,/sys/bus/pci,/sys/module/nvidiaand/sys/module/nvidia_uvm. CUDA and EGL read these to find a GPU. I measured them on an L40 host: without/sys/devicesand/sys/module/nvidia, EGL falls back to llvmpipe; without/sys/bus/pci, CUDA finds no device. These entries describe every PCI device, the other GPUs included: that is information, not access to their devices.environment.imagetogether withenvironment.gpuis refused.sandbox.enabled: false,runner: host, orbest_effortwithout bubblewrap), every GPU is there, as everything else is.The setting reaches the task sandbox, its tool sandbox, and its judge's sandbox (by
dataclasses.replace). Documented indocs/guides/sandbox.md(item 9 under "How one sandbox is built"),docs/reference/config-fields.md,docs/developer/sandbox-design.mdandhermit/defaults.yaml.ASPIRE's simulator, confined (
examples/aspire_robosuite). This closes the open item from #74. The actor's programs run inside cap-harness on the host, and ASPIRE's_ProgramValidatorcan be bypassed: attribute traversal inside a format string reachesos. A program could therefore read and write host files (other sessions' workspaces, the judge's Stage 2 runs) and run held-out seeds itself. Now every cap-harness and validator process runs in a hermit Sandbox of its own (utils/agent/sim.py: confine). That covers the simulator service's runs, the judge'ssim.Engine, and the direct actor's.What that sandbox allows:
examples/(worked solutions),.claude/,.agents/,.codex/,tests/,outputs/(its CLI's runs) and.git(the history holds them all).confineand inlaunch.sh.CAP_HARNESS_*_URLport; a provider on another host is reached through anAllowlistProxyfor that host only.ASPIRE_SIM_GPUnames.launch.shpasses them to the service and exports them for the judge; with none, rendering falls back to Mesa's software renderer. The host'sCUDA_VISIBLE_DEVICESis not passed in, because inside the sandbox the GPUs count from 0.$ASPIRE_OUT/sim-service/sandbox/(the service's runs) or$ASPIRE_OUT/sandbox/(the judge's).Supporting details:
ASPIRE_SIM_READ.run_dirthat lies inside the run.pyvenv.cfg).The README's "actor's rules" section documents this, including the one thing it cannot do. A program that escapes the validator still runs in cap-harness's own process, so it could write its own run's outcome. Its score is not trustworthy, but it can affect nothing else.
Validation
a51bf6d(1327 passed, 69 skipped). This description is for the head with the audit fixes,528b024.python -m pytest tests/core/test_sandbox.py tests/core/test_isolate.py tests/core/test_session_sandbox.py tests/core/test_sandboxed_evolvers.py tests/methods/aspire: 183 passed, and 3 skipped (existing--integrationtests). Run as if bubblewrap were missing, the ASPIRE group gives 23 passed and 9 skipped, with a reason. This was on lovelace, which has 10× L40 and bubblewrap 0.x. The CI runner (Ubuntu 22.04) has a working bubblewrap: the last CI logs show no bubblewrap skips, so the ASPIRE tests run confined there. The real-GPU test skips without a GPU.Sandbox(gpu=[8]), CUDA reports 1 device, and its UUID is GPU 8's pernvidia-smi -q -x. A matmul runs, and MuJoCo's EGL renderer isNVIDIA L40.gpu, CUDA finds no device and EGL renders withllvmpipe.confinewith its default render environment (MUJOCO_EGL_DEVICE_ID=0), with a hostCUDA_VISIBLE_DEVICES=3(stripped), and with an inherited NVIDIA-only ICD selection:gpu=[8]renders on the L40, no GPU on llvmpipe.confinefrom real venvs (python -m venv) built on two different bases, hermit's Python 3.12 and a uv Python 3.13, and kept their venv packages.confine. It may read paths outside the checkout this setup does not show (its uv cache, model caches; HOME is now a fresh directory per run);ASPIRE_SIM_READgrants them. Not verified either: Robosuite's check ofMUJOCO_EGL_DEVICE_IDagainstCUDA_VISIBLE_DEVICES, and the RAM a run's temporary files take on the tmpfs/tmp./dev/nvidia-uvmdoes not exist yet, an AMD GPU (not supported: NVIDIA only), and a container.Review
tests/core/test_sandbox.pyandtests/methods/aspire/test_aspire.py.environment.gpu(default[]),Sandbox(gpu=), and ASPIRE'sASPIRE_SIM_GPU,ASPIRE_SIM_READ,sim_service.py --gpu.environment.gpuis set.CUDA_VISIBLE_DEVICESis not passed in;sim.Engine.run's log moved fromout/run-batch.logto<out>.run-batch.logbeside it;The README says so.
hermit/sandbox.py:gpu,gpu_list,gpu_args,GPU_SYS,GPU_DEVICES,DEV, and the record'sgpu.hermit/isolate.py:environment.gpuis validated and passed to the task and tool sandboxes.hermit/defaults.yaml.Popenand a service that is stopping.Sandbox.wrapand checks identity by UUID.bin/sim, throughsim.Engineand throughsim.confine, using a stand-incap-harness(FAKE_HARNESS) and a real venv.confineis unverified (see Validation).hermit.sandbox.Sandbox, viasim.confine. Its records (cap-harness-<n>.json) are written under$ASPIRE_OUT/sim-service/sandbox/and$ASPIRE_OUT/sandbox/; a test checks the service's. No record from a full ASPIRE run is linked, because none was made (see Validation).tests/core/for the sandbox,tests/methods/aspire/for ASPIRE./dev(viasandbox.DEV) lets the device-binding test run on machines without a GPU.needs_bwrap).gpt-6.1-solsession at high effort each round, every finding verified, 25 or so fixed. The last round found no blocker..gitandoutputs/; a program namedpyvenv.cfgwidening the grants; renderer grants too broad (whole directories); no Mesa fallback with an NVIDIA-only ICD; missing provider port 8115; a remote provider unreachable; a GPU test that could not detect an extra GPU.a51bf6d, checklists item by item, real-GPU probes on this host): no P1, and the GPU boundary held.CUDA_VISIBLE_DEVICEShid the GPU insideconfine.528b024: cap-harness's HOME was its output; the ASPIRE tests failed rather than skipped without bubblewrap; the cap-harness sandboxes wrote no record; the docs overstated the isolation (other GPUs'/sysentries are readable); a wrongASPIRE_SIM_GPUfailed each run after charging its budget (now refused at the service's start);nvidia-uvmwas not documented as optional;environment.gpuwas not documented as having no effect where nothing is confined.528b024, the fixes themselves.🤖 Generated with Claude Code