Skip to content

fix(scicode): run sub-steps in the resources server process, not a Ray worker - #1937

Merged
laszkiewiczp merged 2 commits into
mainfrom
scicode-run-substep-in-resources-venv
Jul 8, 2026
Merged

laszkiewiczp merged 2 commits into
mainfrom
scicode-run-substep-in-resources-venv

Conversation

@laszkiewiczp

Copy link
Copy Markdown
Contributor

Problem

SciCode's verify() dispatches each sub-step to a ray.remote worker that runs subprocess.run([sys.executable, "-c", program]). The worker's sys.executable is whatever Python the Ray cluster runs — which is not guaranteed to be the SciCode resources server's venv, the only one with SciCode's scientific deps (h5py, scipy, numpy, sympy, matplotlib).

In a split deployment — vLLM + the Ray head in one container, the resources server joining that cluster via ray_head_node_address=auto — the sub-step lands on a worker whose interpreter lacks those deps, so every generated program dies at import h5py and mean/reward is stuck at 0 even though the model's answers are fine.

Fix

Execute the sub-step in the resources server's own process via the thread-pool executor instead of shipping it to a Ray worker:

result = await loop.run_in_executor(None, run_substep, program, self.config.timeout_secs)

The resources server process already runs the SciCode venv, so run_substep's subprocess.run([sys.executable, ...]) now uses the interpreter that has the deps. Concurrency is unchanged — still bounded by the existing num_processes semaphore, and subprocess.run releases the GIL. The now-unused run_substep_remote/import ray are removed and the verify() tests retarget run_substep.

Validation

Ran the full SciCode benchmark end-to-end on a split (vLLM + separate resources) deployment. Before this change every sub-step failed at import h5py and reward was 0; after, sub-steps execute in the resources-server venv and subtask_accuracy lands in line with the NeMo-Skills SciCode reference. Unit tests updated and passing.

Alternative considered

Keeping the Ray task but pinning its interpreter (or a runtime_env) to the resources-server venv also works, but relies on that venv path being valid on every Ray worker (fragile across nodes/containers). Running in-process removes the ambient-interpreter assumption entirely; SciCode sub-steps are short, timeout-bounded subprocesses, so single-node execution is sufficient.

…y worker

verify() dispatched each sub-step to a ray.remote worker running
subprocess.run([sys.executable, ...]). That worker's interpreter is whatever
Python the Ray cluster runs, which need not have SciCode's scientific deps
(h5py/scipy/numpy/sympy). In a split deployment (vLLM + Ray head in one
container, the resources server joining that cluster) every sub-step dies at
'import h5py' and reward is always 0.

Run the sub-step in the resources server's own process via the thread-pool
executor, so the subprocess uses this server's interpreter (its venv has the
deps). Drop the now-unused run_substep_remote wrapper and ray import; retarget
the verify() tests at run_substep.

Signed-off-by: laszkiewiczp <85294967+laszkiewiczp@users.noreply.github.com>
@copy-pr-bot

copy-pr-bot Bot commented Jul 6, 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.

@laszkiewiczp
laszkiewiczp enabled auto-merge (squash) July 8, 2026 07:25
@laszkiewiczp
laszkiewiczp merged commit 049b1fd into main Jul 8, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants