Repository navigation
Description
Parent workstream: #3001
Slowdown path
flowchart LR
A[Reasoning Gym rollout] --> B[Join and extract answer]
B --> C[Resolve dataset scorer]
C --> D[Run dataset-specific score_fn inline]
D --> E[Event loop resumes peer verifies]
Current behavior
Verified on upstream main at 9287fb7797907ff17884963730d79f428a225639. verify() awaits nothing while it extracts and scores an answer (source). Exact synchronous operations include:
- walk every response message/content item, append all output text, and join it (source);
- call external
reasoning_gym.utils.extract_answerover the full text, then run are.searchboxed-answer fallback and strip the complete text if neither format matches (source); - construct an entry dict containing question, answer, and metadata (source);
- resolve a dataset-specific callable with
reasoning_gym.get_score_answer_fn(task_name)and invokescore_fn(answer=model_answer, entry=entry)directly on the event-loop thread (source); and - dump the full body into the response echo (source).
Scorer internals vary by source_dataset and live in the external reasoning-gym>=0.1.19 dependency, which is lower-bounded rather than pinned (source). Their cost and semantics can therefore vary across installations.
Impact and provenance
Measured
The 2026-08-31 report at investigations/gym-and-performance.md was measured against 6992a96de. It established that inline CPU blocks a Gym worker's single event-loop thread and that the default asyncio.to_thread pool on its 96-core rig had 32 slots shared with capture fsyncs. It grouped reasoning_gym in the audited synchronous tier but did not publish timings by dataset, a server-specific concurrency baseline, or a candidate speedup.
Expected
Expected, not measured: reusing scorer lookup safely and routing expensive GIL-bound dataset scorers through bounded processes should reduce loop occupancy and may increase multicore throughput. Actual impact depends on dataset mix, dependency version, scorer complexity/state, payload size, and serialization overhead.
Implementation constraints
- Preserve exact extracted answers, float scores/rewards, dataset-specific scoring semantics, exception-to-zero behavior, and response fields for every supported
source_dataset. - Pin or record the exact
reasoning-gymversion/commit for parity and performance runs. Do not compare runs across drifting scorer implementations. - Profile and classify scorers per dataset; do not apply one executor policy to all datasets.
- Threads can restore loop responsiveness but do not scale GIL-bound Python scoring. Use bounded Provide a shared warm process pool for CPU-heavy verification #3038 processes for trusted GIL-bound scorers; use threads only for blocking or demonstrated GIL-releasing scorers.
- Resolve the scorer inside a worker when the callable is not safely picklable. Pass only explicit serializable entry data and the task name, and test scorer initialization/global-state behavior under the chosen process start method.
- Bound executor submissions and worker/cache lifetime. Do not fork per verify.
- Keep cheap extraction/scorers inline when offload overhead is larger; define measured thresholds.
Acceptance criteria
- The supported dataset/scorer inventory is captured for an immutable reasoning-gym version.
- A representative corpus covers every supported scorer family, extraction formats/fallbacks, missing task names, scorer exceptions, empty outputs, and long responses.
- Before/after extracted answer, score, reward, task name, and exception behavior match exactly.
- Scorer lookup reuse is tested for mutable/process-global state and version-sensitive invalidation.
- Per-dataset profiling justifies inline, thread, or process placement and records serialization cost.
- Concurrent stress keeps queue depth, tasks, workers, cache, and RSS bounded and leaves no child processes behind.
- Performance claims cite only measured benchmark data.
Benchmark plan
- Freeze a reasoning-gym version and select deterministic examples across the supported scorer families, answer formats, and payload sizes 1 KB, 32 KB, 300 KB, and 2 MB.
- Measure response joining/extraction, scorer lookup/initialization, scorer execution, and serialization separately by dataset.
- Compare current inline execution, safe scorer lookup reuse, bounded threads for proven GIL-releasing/blocking scorers, and bounded Provide a shared warm process pool for CPU-heavy verification #3038 processes for trusted GIL-bound scorers.
- Run concurrency 1, 32, 256, and 8,192 with worker counts 1, 4, 16, and 32; record queue/execution p50/p95/p99, event-loop lag, completions/s, CPU, RSS, initialization, serialization, failures, and timeouts by dataset.
- Require exact score/extraction parity before publishing any measured gains or regressions.
Related work
- Parent resources-server workstream: Performance workstream: resources servers #3001
- Shared bounded warm process execution: Provide a shared warm process pool for CPU-heavy verification #3038
- Easier state-safe multi-worker serving: Make resources-server multi-worker serving easier and state-safe #3039
- Umbrella performance issue: Performance opportunities across the NeMo Gym server stack #2998
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDev Todo
Activity