Repository navigation
fix(spider2_lite): run SQL in a thread with a SQLite progress-handler timeout, not Ray - #6392
Conversation
… timeout, not Ray The server used Ray only to run one SQLite query as a remote task and cancel it after the timeout, but declaring ray_enabled made the supervisor require Ray in the environment where gym runs, and a query queued behind other Ray work could time out before it started. Same approach as bird_sql: run the query in a worker thread and abort it from inside SQLite once the deadline passes. The server no longer declares ray_enabled, and its dependency drops the ray extra. Signed-off-by: Ingo Guehring <[email protected]>
|
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. |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
SHIP WITH CARE
RISK: Supply the required validation for the execution change
The supplied validation has no representative real-model rollout or before/after reward profile for this commit. The description also says pre-commit run --all-files was not run. AGENTS.md requires real smoke rollouts for behavior-changing environment work and the repository checks. The review rubric additionally requires before/after reward evidence for fixed-benchmark verifier changes.
This is a fixed evaluation benchmark, and both verification branches turn execution outcomes into rewards. The tiny-database tests do not show that the changed backend and timeout behavior preserve scores on real databases. This is missing validation, not a demonstrated reward regression.
Could you add a representative model smoke run against the downloaded databases, record the command, model/configuration and inspected task outcomes, and provide before/after aggregate reward and timeout/error counts? Replay identical SQL responses on identical prepared tasks for the scoring comparison. Cover both gold_sql and gold_result: matching results should still score 1.0, mismatches and invalid SQL should score 0.0, and timeouts should remain controlled failures. Explain any changed scores. Also confirm startup without Ray installed and record the repository-pinned pre-commit results. These checks should validate the execution change without changing the existing result-comparison rules.
I reviewed all five changed files and their directly affected paths. I did not execute tests, hooks or rollouts in this read-only review.
Inline comments (escaped v1):
-
tests/unit_tests/server_runtime/test_ray_opt_out.pyline 33: RISK: Remove Spider2-Lite from the Ray test inventoryThis entry still declares Spider2-Lite Ray-backed after the PR removes its last production Ray import, class flag and dependency extra. By source inspection, it breaks four core tests: the import inventory assertion discovers no Spider2-Lite import, while the declaration, entrypoint and dependency tests still require Ray because they consume this set. The server-only test run reported in the PR does not cover this core suite.
Could you remove only this entry from
DIRECT_RAY_COMPONENTS["resources_servers"]?- "spider2_lite",Keep the production Ray removal and every other inventory entry. Restoring the flag or extra would undo the startup fix rather than repair the stale expectation.
Proposed acceptance checks, not executed here: run
pytest tests/unit_tests/server_runtime/test_ray_opt_out.py. The import inventory, class-declaration, entrypoint-detection and required-extra assertions should pass with Spider2-Lite excluded. Retaintest_joins_the_configured_clusterrequiring initialization for a Ray server andtest_non_ray_server_never_connectsrequiring no initialization for a non-Ray server. The invariant is that this inventory names exactly the components that still import Ray in production.
Review generated by codex. This was a full review. Request a full review with /review reset=true.
|
@ananthsub Thanks for keeping an eye on all the moving pieces! I really appreciate that! Re your suggestion: For me it is a human-bandwidth problem. I would like to get rid of ray here for MFN+Gym, but I don't have the capacity to deep dive into a more fundamental change. Selfishly asking: Do you think we can transfer it to #3669 lane, I cancel this one, and folks working on 3669 would pick it up? |
completely understood. i agree, unblocking the ray dependency can come first without the wholesale move to the sandbox API. |
…eout tests SQL queries ran in the event loop's shared default pool, which can be smaller than the semaphore: an admitted query could queue there behind slow ones and time out, and slow queries could hold up the server's own to_thread calls. The server now has a pool as large as its semaphore, passed to execute_sqlite_async and execute_and_compare. The timeout tests use a query that ends on its own after a few seconds, so a missing progress handler fails them instead of hanging the run, and one test checks that the worker thread has finished. The docs no longer say that the server uses Ray. Signed-off-by: Ingo Guehring <[email protected]>
The server no longer imports Ray, declares ray_enabled or requests the ray extra, so the inventory of direct Ray components must not list it. Signed-off-by: Ingo Guehring <[email protected]>
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/44557104089 |
What
spider2_literuns its SQLite queries in a worker thread with a SQLite progress-handler timeout, the waybird_sqldoes, instead of as Ray remote tasks:resources_servers/spider2_lite/eval_utils.py:execute_sqlitetakes an optionaltimeout_s; a progress handler aborts the query from inside SQLite once the call has run that long andTimeoutErroris raised.execute_sqlite_asyncruns it in a dedicatedThreadPoolExecutorunder the semaphore, with an outerwait_forbackstop, and still returnsNoneon timeout or query error.import ray, the@ray.remotewrapper andray.cancelare gone.resources_servers/spider2_lite/app.py: noray_enabled = True; the server owns a thread pool as large as its semaphore (max_concurrency), so an admitted query never waits in the pool shared with the rest of the server.resources_servers/spider2_lite/pyproject.tomlanduv.lock: the server no longer requests therayextra (nemo-gym[dev], notnemo-gym[dev,ray]; relocked with uv 0.13.5, Ray and its dependencies drop out).spider2_liteuses Ray.Part of #3669; meets the done criterion of #6430.
Why
Ray was used for one thing: running a single SQLite query in a separate process and cancelling it after 30 seconds.
ray_enabled = Truemakes the server supervisor require Ray in the environment wheregymruns, so a run in an environment installed without therayextra stops before the servers start with "These servers use Ray, but Ray isn't installed wheregymruns: spider2_lite_benchmark_resources_server".bird_sqlmade the same change for the same job; its docstring explains that Ray tasks can sit in the scheduler queue past the per-query timeout when the cluster is shared.Raised in review (not reproduced here): on
main,ray.canceldoes not stop a query that is already running. Its default cancel raisesKeyboardInterruptin the worker, whichsqlite3delivers only after the C call returns, so a runaway query held its Ray CPU slot until it finished.Each query still copies its whole database into memory, now in the server process instead of a Ray worker (the largest database is 313 MB). An out-of-memory kill now takes down the whole server. Opening the database read-only and querying it directly, as
bird_sqldoes, removes the copy; that is tracked in #6430.Validation
pytest resources_servers/spider2_lite/tests(withuv run --project resources_servers/spider2_lite): 51 passed. With the progress handler removed, the three timeout tests fail within 10 s instead of hanging.uv lock --checkin the server directory and the repo's pre-commit hooks on the changed files: passed.Real Spider2-Lite databases (31 SQLite files, 1.6 GB), the 24 tasks with public gold SQL. The same predictions through the old implementation (loaded from
mainwith a stubray) and through the server'sverify():gold_sqlgold_resultSELECT 1gold_sqlSELECT 1gold_resultgold_sqlgold_resultThe 8 of 24 gold SQLs that do not match their pre-computed CSV in
gold_resultmode are the same with both. Running the 24 gold queries 8 at a time takes 15 s with the new code against 27 s one after another. A never-ending prediction with a 2 s limit, 8 tasks at once, scores 0.0 withexecution_errorin 3.5 s.A rollout of the 24 tasks with a model (Nemotron-3-Nano served by vLLM,
vllm_model), one sample each, in an environment without Ray: all 24 scored, pass@1 0.25, no execution failures.Compatibility
execute_sqlite_asyncandexecute_and_comparetake the executor as an argument (after the semaphore); results are unchanged (rows, orNoneon query error or timeout).execute_sqlitegains an optional argument. The timeout still covers the in-memory copy of the database as well as the query, but its clock now starts when the query starts running in its thread; Ray's started when the task was submitted, so it also counted time spent waiting for a Ray worker. The copy cannot be interrupted, so a very slow copy is limited only by the outer wait (timeout_s+ 10 s).