Repository navigation
Description
Parent
#2999 — Performance workstream: core Gym infrastructure
Umbrella: #2998 — Performance opportunities across the NeMo Gym server stack
Related regression infrastructure: #860
Goal
Add a deterministic simulator that measures whether Gym remains a lightweight dispatch layer as RL rollout concurrency grows.
Large-model inference will dominate real training latency. The simulator should therefore make model work configurable or nearly free. This exposes Gym's own capacity ceiling and shows whether the driver, agent, HTTP stack, model adapter, or resources server becomes the bottleneck before the inference endpoint does.
This first version does not need to reproduce Nemotron model quality or match an empirical workload distribution.
System under test
flowchart LR
Load["Open-loop or closed-loop driver"] --> Agent["Synthetic agent"]
Agent --> Model["Configurable model stub"]
Agent --> Resources["Configurable resources server"]
Model --> Agent
Resources --> Agent
Agent --> Persist["Normal Gym persistence"]
The benchmark must use normal Gym HTTP boundaries, request models, response models, telemetry hooks, cancellation behavior, and output persistence. It must not replace the server stack with direct Python calls for the primary capacity result.
Provide a direct endpoint mode for isolating server capacity and a normal gym eval run --no-serve mode for measuring the complete driver path.
Self-contained components
Place all fixtures and scripts in a repository-owned benchmark directory, for example benchmarks/gym_capacity/. Do not depend on an external investigation directory or a separately modified worktree.
Include:
- a deterministic model server that can return a message-only terminal response without triggering an agent tool loop;
- a synthetic agent or pass-through route that can return large prebuilt output lists without interpreting them as tool requests;
- a resources server with selectable no-op, asynchronous-delay, CPU, executor, subprocess, and bounded-queue modes;
- deterministic dataset generation;
- a load driver;
- machine-readable result and comparison generation;
- CPU-only tests.
The model and resources fixtures must have normal Gym configs and isolated-server requirements. New source files require the standard NVIDIA header.
Payload profiles
Keep input-list length, output-list length, serialized bytes, and item-type diversity as independent dimensions.
Required profiles:
control: one input message and one output message.input-80andinput-320: 80 or 320 input items and one output item.output-80andoutput-320: one input item and 80 or 320 output items.duplex-80andduplex-320: large lists in both directions.mixed-items: a schema-valid bounded mixture of messages, reasoning, function calls, function results, and supported MCP items.payload-bytes: fixed item count with increasing content or token-metadata size.
The output-heavy profiles need a dedicated terminal synthetic agent or model route. Returning function calls through simple_agent would cause another tool turn and would not measure a terminal output list.
Each generated row must record:
- profile and deterministic row ID;
- input and output item counts;
- item-type counts;
- serialized request and expected response bytes;
- configured turns, model calls, and resources calls;
- configured model/resources delay;
- expected terminal status.
Do not call 80 or 320 items “distinct item types.”
Resources-server profiles
The resources fixture should make bottleneck classes explicit:
noop: immediate asynchronous completion.io-delay:asyncio.sleep()with fixed or seeded-distribution latency.cpu-inline: deterministic GIL-bound work on the event loop.cpu-thread: the same work through the supported thread path.cpu-process: the same work through a bounded process path when available.subprocess: bounded subprocess execution with timeout and cancellation.judge-delay: external-judge-shaped asynchronous latency without a real judge.bounded: selectable semaphore or queue limit to create observable queueing.
Every mode must return the same logical verification result where applicable. This allows throughput and scheduling behavior to change without changing correctness.
Load models
Closed-loop concurrency
Maintain a configured number of active requests. Sweep at least:
1, 8, 32, 128, 512, 1024, 4096, 8192
Run enough waves to reach steady state. Report the warm-up and measured windows separately.
RL burst
Submit 8,192 trajectories as one offered-work burst. This matches the order of magnitude of a 512-prompt by 16-generation RL step without simulating the model itself.
Record:
- time until the first request starts;
- time until 50%, 95%, and 100% complete;
- peak resident rollout tasks;
- peak active requests at each server;
- peak queue depth and memory.
Open-loop arrivals
Schedule requests against monotonic target times at fixed offered rates. Record scheduling lateness and achieved arrival rate.
Do not silently reduce the offered rate when the system slows. Closed-loop results are vulnerable to coordinated omission because slow responses reduce future request issuance; the open-loop mode must expose growing queues and latency.
Timing boundaries
Report these phases separately:
- server startup;
- dataset generation/materialization;
- warm-up;
- measured request window;
- output persistence and aggregation.
The primary request-capacity result must exclude startup, materialization, and final aggregation.
For every measured request, retain enough timing data to calculate p50, p95, p99, and maximum latency without storing request content.
Measurements
Each result cell should include:
- offered and achieved requests per second;
- completed, failed, cancelled, and timed-out requests;
- request latency percentiles;
- request and response bytes;
- input/output item counts and type counts;
- active and queued work at driver, agent, model, and resources boundaries;
- event-loop lag and resident task count per process;
- process CPU, RSS, threads, and file descriptors;
- GC pause count and duration;
- resources queue wait and execution duration;
- output write throughput and latency.
Run the raw capacity matrix with telemetry disabled. Run a separate diagnostic matrix with runtime telemetry enabled. Do not mix telemetry overhead into the headline capacity number.
Result format
Write one JSON record per variant/profile/concurrency/repeat. Include:
- exact Git commit and dirty state;
- Python and dependency versions;
- hardware and operating-system identity;
- complete simulator config;
- warm-up and measured durations;
- all correctness and performance measurements;
- paths to logs and rollout artifacts.
Generate a concise Markdown comparison that reports medians, ranges, confidence intervals where practical, and candidate-versus-baseline deltas. Mark a result invalid when rows are missing, failures are unexpected, output shapes differ, or configured work was not performed.
Correctness and reliability constraints
- Baseline and candidate must receive byte-identical input files and simulator configuration.
- Responses must revalidate through the public Gym Pydantic models.
- Output item types, counts, status, usage, reward, and failure routing must match expectations.
- Cancellation and timeout tests must leave no active tasks, child processes, temporary state, or open files.
- Offered work, active concurrency, connector limits, resources limits, and worker counts must be reported separately.
- The simulator must not use
httpx; use Gym's supportedaiohttppath. - A benchmark may expose a bottleneck but must not automatically prescribe more workers or a larger queue.
Implementation locations
Expected files include:
benchmarks/gym_capacity/config.yamlbenchmarks/gym_capacity/prepare.pybenchmarks/gym_capacity/run.pybenchmarks/gym_capacity/compare.pybenchmarks/gym_capacity/profiles/*.yamlbenchmarks/gym_capacity/tests/- one synthetic model component under
responses_api_models/ - one synthetic resources component under
resources_servers/ - a terminal synthetic agent only if output-heavy responses cannot be represented safely through an existing agent
Reuse the shared telemetry contract from the sibling telemetry issue. Keep benchmark-specific measurements in the harness.
Acceptance criteria
- A fresh checkout can run the benchmark without files from
investigations/or manually modified worktrees. - Control, input-heavy, output-heavy, duplex, mixed-item, and payload-byte profiles are deterministic and schema-valid.
- The resources fixture supports no-op, async-delay, inline CPU, bounded executor/process, subprocess, and bounded-queue cases.
- Closed-loop sweeps run through concurrency 8,192 when host limits permit.
- The 8,192-rollout burst reports completion milestones and peak residency.
- Open-loop runs report offered rate, achieved rate, scheduling lateness, queue growth, and request latency.
- Startup/materialization/aggregation time is separated from steady-state request time.
- The harness reports item counts, bytes, throughput, latency, failures, event-loop lag, CPU, RSS, GC, and queue measurements.
- All output rows and responses are validated for expected shape and semantics.
- Tests cover deterministic generation, schema validation, pacing, percentile calculation, missing rows, unexpected failures, timeout/cancellation cleanup, privacy, and comparison math.
- One baseline/candidate example demonstrates that the harness can identify whether the driver, agent, model adapter, or resources server saturated first.
- Documentation explains what the benchmark does and does not establish.
Out of scope
- Reproducing Nemotron answer quality, token distributions, or exact inference latency.
- Requiring a GPU or external model endpoint for the core capacity matrix.
- Replacing benchmark-specific end-to-end validation.
- Automatically enabling multiple server workers or changing resource limits.
- Making this a required CI performance gate in the first implementation.
Related work
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDev Todo
Activity
feat(telemetry): report event-loop, process, request, driver, and res…
perf(telemetry): drop instrumentation that exports nothing (#4481)