Metrics
NeMo Gym emits a small, deliberate set of metrics. This page lists them, and explains what is deliberately absent and why.
Application Telemetry, Not Experiment Telemetry
These metrics answer “how is this software behaving?” — where time goes, what failed, how a configuration performs on hardware you do not control.
Benchmark scores such as pass@k are experiment telemetry. They belong in Weights & Biases or
MLflow, which are built for comparing runs and keep data for the lifetime of a project. NeMo Gym
reports them through AggregateMetricsMixin, unchanged. What NeMo Gym does export is the reward
of each scored rollout as it arrives, so a broken run (all zeros, a sudden drop, many masked
samples) shows up while it is still running. See
What the Reward Metrics Show.
Metrics NeMo Gym Emits
Rollout duration is recorded even when a rollout fails. A crashed rollout still consumed wall-clock time, and dropping those samples would bias the histogram toward the fast path.
What gym.rollout.completed_total Counts
One increment per rollout attempt: one dispatch of one row in one gym eval run collection
run, recorded after the recovery store accepts the saved outcome. A retry on a later
resume run is another attempt; an HTTP-level re-send of /run inside one dispatch is not.
Reused cached results do not increment it. Coverage comes from the output files, not this counter.
TaskRunner.run_task (the in-process API) also records each returned rollout outcome, without a recovery-store
write. For this API, failed means the outcome has a failure, labeled with its kind and nothing else; scored means
a reward and no failure; unscored means neither a reward nor a failure. gym.rollout.rewarded_total counts only the
finite rewards of scored rollouts, masked ones included. A result is a failure when it carries failure_kind; a routing
class alone does not make it one. The collection driver described below folds completions without
a reward into scored and does not use unscored. A TaskRunner increment does not mean an outcome was saved. The
persistence and omitted rules below describe the collection driver.
nemo.gym.rollout.outcome is scored (written to the main output, masked and forced-zero
results and supported unscored completions included), failed (a saved failure), or omitted (a saved
intentional omission, including terminal skips and bare no-persist replies). A reported kill_shaped failure
(a Slurm SIGTERM, a dead Ray actor, or an out-of-memory kill) is saved as a failure so it remains eligible
for retry. The historical scored label does not guarantee a measured reward.
Rows drained by the dispatch budget never ran and are not counted. Every point carries
nemo.gym.rollout.dispatch.name, the environment server or, when rows name none, the agent.
Attempts with a failure class also carry nemo.gym.failure_class and, when supplied,
nemo.gym.failure_kind and nemo.gym.failure_type (the exception class name).
Older legacy producers retain their original routing class and exception type. Those two fields remain
producer-controlled, as on main; producers should supply stable category names, not free-text error details.
The kind label is included only when supplied: a registered or <server>:<kind> namespaced kind is retained,
otherwise it is unregistered. A saved record’s compatibility fallback does not add a kind label or replace
a distinct routing class.
Native episode failures and the legacy Environment Server adapter route by the shared kind. When that kind also
supplies the class, both labels use the same bounded-name rule. This changes the adapter’s dashboard labels:
previously it reported environment_server_failed without a kind label; it now reports the shared kind like a
native episode. Free-text kinds and reasons are never promoted to class labels. Existing legacy class/type fields
are retained, so arbitrary producer text in those fields is not automatically bounded.
Transport failures count as saved failures only when failure routing is enabled; otherwise the request error
aborts collection. An HTTP 500 uses agent_run_error; an unavailable server uses agent_request_failed.
Neither adds a kind label. The collector records the counter when telemetry is enabled; gym eval run --no-serve
does not initialize telemetry by default. Direct run_examples callers, GDPVal multistage and rollout
reverification do not record it.
What the Reward Metrics Show
Every scored attempt that carries a numeric reward is counted once in
gym.rollout.rewarded_total, at the same point as gym.rollout.completed_total. A result without a
numeric reward is unscored, not a zero, and is not counted. Failed and omitted attempts have no
reward.
Rewards are whatever the environment’s verifier returns: binary, partial credit, or a negative
penalty. nemo.gym.rollout.reward.range sorts each one into negative, zero, partial
(strictly between 0 and 1), full (exactly 1) or above_one.
The counter also carries nemo.gym.rollout.dispatch.name and nemo.gym.rollout.masked, the
result’s mask_sample. Filter on masked="false" to leave out samples whose reward is not a valid
measurement, as the aggregate metrics do.
The share of full rollouts is a live view, not the benchmark score. Scores like pass@k or
per-task averages are computed from all rollouts at the end by /aggregate_metrics and can differ
from it.
Startup Metrics
The stage histogram carries nemo.gym.server.name, nemo.gym.server.type, nemo.gym.startup.stage, and nemo.gym.server.worker. Stages are contiguous, so one process’s stages add up to the time from its start to the moment it accepts connections.
A server with num_workers above 1 runs run_webserver again in every Uvicorn worker. Each worker reports its own stages, starting at worker_start, with nemo.gym.server.worker set to true. The main process of that server reports the stages up to the hand-off to Uvicorn, with the attribute set to false. Filter or group by this attribute, so that a worker’s init_server is not averaged with the main process’s.
There is no supervisor-side total. The supervisor learns that a server is ready from a health poll every few seconds, so its total would be the stages above plus polling delay. The total for each server is the gym.startup.server span in the startup trace.
Event Loop and Process Metrics
These metrics are reported whenever metrics are exported. Every server process reports them, and the process.pid resource attribute tells apart the Uvicorn workers of one server.
A Gym server answers every request on one asyncio event loop. When synchronous work holds that loop, every other request waits, even though no single request looks slow. Requests that arrive in bursts make this worse, because each one waits for the synchronous work of the requests ahead of it.
gym.server.requests.cancelled_total uses registered route templates such as /work/{item_id}, never raw paths or rollout IDs. Rollout prefixes are removed before matching a template; requests without a matching route use <unmatched>. The phase is before_response_start until the ASGI http.response.start message has been sent, then response_started. A headers-only response and an SSE keepalive both count as response_started; this does not imply a model token was produced. Model-call capture’s ttft_ms supplies token timing when capture is enabled.
Sum the route and phase series to recover the server’s cancellation total; no separate aggregate series is exported. Each server counts its own HTTP disconnect, so one cancelled rollout can count at both the agent and its downstream model server. These are request counts, not unique rollout counts.
The stdout 499 line remains sampled once per 100 disconnects on every route. With ++global_aiohttp_client_request_debug=true, the existing debug override logs each disconnect and adds elapsed seconds and response-start phase. Without debug logging, the sampled line has no timing or phase fields.
The rollout driver, which is gym eval run, reports how much work it holds and where that work waits:
Resident minus active is the number of rollouts waiting for admission. A standalone gym eval run --no-serve driver sets up its own telemetry from the telemetry: block, so it reports these metrics and the gym.job span too.
gym.event_loop.lag_ms and gym.event_loop.tasks carry nemo.gym.event_loop, which is server for a server’s own loop, head_server for the head server’s loop inside the supervisor, and driver for the rollout driver’s loop.
The process.* metrics keep the OpenTelemetry process semantic-convention names, units, and cpu.mode attribute, so standard dashboards recognize them. The Gym metrics follow Gym’s own conventions: durations in milliseconds with a _ms suffix, counters with a _total suffix, and attributes under nemo.gym..
The work stays off the request path. The event loop runs one sampling coroutine per interval. Process, garbage-collection, and request totals are plain counters that the exporter’s background thread reads when it exports, so a request costs a few integer updates and no OpenTelemetry call.
Resources Operation Metrics
Many resources servers limit expensive work, such as a verifier subprocess or a judge call, with a semaphore. When the limit is too small, verification waits in a queue that no request metric shows. A resources server reports that queue by wrapping its limited work in nemo_gym.telemetry.resources_operations.resources_operation:
Every metric carries nemo.gym.resources.operation (verify, tool, judge, or other) and nemo.gym.resources.executor (inline, thread, process, subprocess, or other). They are recorded only while metrics are exported. math_with_judge uses this contract for its SymPy verifier subprocesses.
Concurrency Limit Metrics
A wait duration shows that work waited, not why. These metrics show the state of each configured concurrency limit, so a dashboard can show “limit 100, active 100, queued 75” and make clear that the limit is full and work is piling up behind it.
Every point carries nemo.gym.concurrency.component, nemo.gym.concurrency.limit_name, and, for a limit that belongs to a server, nemo.gym.server.name. Limits with the same attributes in one process are summed, and separate processes, such as the Uvicorn workers of one server, export their own points. These limits report today:
A component without a configured limit reports no series at all, not a limit of zero. Agent servers, the other model and resources servers, and sandbox providers keep their own limits, which these metrics do not report yet. No Gym limit rejects work when it is full, so there is no rejection count.
How to read them:
activeequal tolimitwith a growingqueue_depthmeans the limit is the bottleneck. Raising it helps only if the work behind it, such as the model endpoint, has capacity to spare.activebelowlimitwith slow requests means the time goes elsewhere. Comparegym.event_loop.lag_msand the HTTP connection-pool metrics.- A rising
admission_timeouts_totalmeans callers gave up waiting. For a model server, these are the requests that fail with “Timed out acquiring an upstream provider slot”; for an environment server, the episodes that fail at theadmissionstage. - For the rollout driver,
gym.driver.admission_duration_msgives the wait per rollout, andgym.concurrency.queue_depththe number waiting right now.
A slot costs a few integer updates and no OpenTelemetry call. The exporter’s background thread reads the totals, and they are reported whenever metrics are exported.
Sandbox Metrics
These are recorded whenever metrics are exported, whatever the span groups. AsyncSandbox records them for every sandbox provider, except gym.sandbox.create_retry_total, which a provider that retries creates records from its own loop (Daytona and OpenSandbox do). Every metric carries nemo.gym.sandbox.provider, such as docker or opensandbox.
Transfers include upload(), download(), and the seed files in SandboxSpec.files, which start() uploads after the provider returns the sandbox, so seed uploads are not part of gym.sandbox.startup_duration_ms. Sidecar downloads are not counted. Transfer spans record the file size but not the paths, because a path can name task content.
A transfer that raises is an error, including a download that probes for a file that may not exist yet. A transfer cut short by cancellation is cancelled, including one the caller abandons when its own deadline (for example asyncio.timeout) expires; a timeout inside the provider is an error.
Run Summary Metrics
When a collection or an aggregation of shards finishes, the run’s coverage and retry counts are recorded as gauges, the same numbers sent to MLflow or W&B. They are recorded whether or not an experiment tracker is configured, so a dashboard reading OpenTelemetry sees them too.
Each key becomes one gauge: coverage/scored is gym.run.coverage.scored, and retries/at_cap is gym.run.retries.at_cap. Failures by class, coverage/failed/<class>, become one gauge, gym.run.coverage.failed, with the class in nemo.gym.run.bucket. A class that is not a registered failure kind (or skipped, or unknown) is counted under unregistered, so the attribute stays bounded.
gym.run.coverage.failed holds two views of the same failures: the total, coverage/failed, as a point without nemo.gym.run.bucket, and one point per class with it. A run with one failure reports 1 for each, so summing every point counts it twice. Select one view:
- The total: keep the points where
nemo.gym.run.bucketis not set. - The breakdown: keep the points where it is set, and group by it.
gym.run.info is 1 for each finished run. Points carry nemo.gym.run.id, the run id from the run’s records. An aggregation has a run id only when it reads a single shard with attempt history; otherwise it leaves the attribute off, and the nemo.run.id resource attribute identifies the job.
A key is recorded only when the run reports it. An unknown count is left out rather than recorded as 0: an aggregation of shards without attempt history, for example, has no gym.run.coverage.expected.
Tool Metrics and Spans
When a rollout’s trajectory is a v2 record (see Rollout Evidence), the collection driver reads the tool executions the harness recorded; nothing is measured again.
gym.tool.calls_totalcounts executions bynemo.gym.tool.nameandnemo.gym.tool.status.gym.tool.duration_msrecords each measured duration, withnemo.gym.tool.timing_boundarysaying what it measures (executor,lifecycle,transcriptorevent_receipt). A boundary without a duration records nothing, so a missing measurement never reads as 0 ms.- With a trace exporter and the
rolloutspan group on, each execution with both recorded endpoints becomes agym.toolspan under the rollout’s dispatch span, or under its parent tool’s span (the nearest ancestor with a span, when its parent has no endpoints). The span takes the boundary closest to the execution itself and carries the full tool name, the boundary, the timing source andnemo.gym.tool.clock_domain. Anunknownclock domain means the endpoints come from the harness’s own clock, which may be skewed against Gym’s.
Tool names are free-form, so the metrics keep the first 64 names a process sees, up to 128 characters each, and count the rest as other; a missing name is unknown. Spans keep every name.
Memory Metrics
Memory metrics are emitted only when telemetry.memory_profiling.enabled is true. Server points carry nemo.gym.server.name, nemo.gym.server.type, and the root process.pid; server memory gauges also carry memory.type, which is rss or pss. Host points rely on the existing host.name resource attribute and carry no per-sample attributes.
RSS counts every resident page mapped by every process and can double-count pages shared by Uvicorn workers. PSS divides shared pages among the processes mapping them, so summing PSS across server trees is the better estimate of their combined host footprint. The sampled peak is not the kernel’s exact lifetime peak: an allocation that begins and ends between samples can be missed.
Host usage is total - available, matching the memory the operating system cannot make available without swapping. Host totals describe the whole node, not only Gym processes; compare them with summed server PSS to separate Gym footprint from training, inference, Ray, and system pressure.
Descendants remain attributed while they stay in the server’s Linux process tree. Detached or reparented processes and remote Ray actors are not included.
The same profiler reports CPU, with the same switch and the same process trees:
Each process’s CPU time includes the children it waited for (cutime and cstime in /proc/<pid>/stat), so a short command that starts and exits between two samples is counted once its parent waits for it. Processes are tracked by pid and start time, and time a child already reported, or a process that drops out of a single walk, is not counted again. The counter is a lower bound where an exited process’s time cannot reach a process still in the tree:
- A process whose parent does not wait for it, because the parent ignores
SIGCHLDor exits first, can be undercounted by up to its whole CPU time. Once reparented outside the tree, it is no longer counted. - The time the server’s root process uses after the last sample before it exits is lost.
The exception is a child subreaper inside the server’s tree (PR_SET_CHILD_SUBREAPER). The CritPt grader’s runner is one under the local sandbox provider, where it runs as a descendant of the resources server and adopts the orphans of the code it grades. An orphan that a sample sees after its adoption, or sees missing but still running, is counted once. When an orphan and its old parent both exit between the same two samples, the time the orphan had already reported moves onto the old parent’s nearest running ancestor rather than onto the subreaper that waited for it, so the subreaper counts it again. The counter then runs ahead by up to that time per such orphan until that ancestor exits: its held time passes up to the subreaper, which takes it back from its later CPU time.
The rollout driver of a --no-serve run is not a supervisor-managed server and is not included; its own process.cpu.time covers it.
Compare these series with http.server.active_requests, which requires traces, while increasing workload concurrency. Separate server processes export their HTTP metrics independently, so sum active requests by Gym server name when a server uses several Uvicorn workers.
Partial-Rollout Checkpoint Metrics
Servers that take part in partial-rollout checkpoints, and the controller that coordinates them, report
these metrics whenever metrics are exported, whether or not the checkpoint span group is enabled.
The operation is one of a participant’s control operations (prepare, commit, restore, resume,
retire, forget, or release), lease_reopen for one attempt to reopen a participant whose lease
expired, or coordinate.<operation> for one call the controller makes to every participant. The participant kind is
the server’s role in the checkpoint, such as model, agent, resources, or environment, and
controller for coordination.
A commit counts its records and bytes once, when its write finishes, and a restore counts them once it succeeds. A commit or restore that is retried therefore does not count the same records again. The bytes of a restore cover the whole records file it reads, while its records are only those it restores.
gym.checkpoint.control_errors_total counts each failed call to a participant’s checkpoint control routes
once. The error code is the code in the reply, such as checkpoint_deadline_exceeded, checkpoint_invalid_phase, or
checkpoint_conflict. A data request refused because of a checkpoint, such as a late request from a retired
attempt, is not counted.
gym.checkpoint.events_total has these events:
What gym.verify.success_rate Measures
It measures whether the verification call completed, not whether the task passed.
A verifier that correctly scores a wrong answer is a success. A verifier that raises an exception is a failure. Task correctness is experiment telemetry, and putting it here would turn this into a low-resolution accuracy metric living in the wrong system.
The value is cumulative over the reporting process’s lifetime, not a windowed rate. A gauge carries last-value semantics, so a rate cannot be expressed directly. A long-lived server therefore shows a figure that moves more slowly as it ages. Read it as “this process’s success fraction so far,” and use traces for anything finer.
Why Only the Supervisor Reports gym.servers.active
gym.servers.active is a gauge, so the exported value is whichever process wrote last.
If every server reported it, the result would be neither the fleet size nor any process’s
view of it. The supervisor is the only process that knows how many servers it started,
so it is the only writer. It sets the count after startup and zero on shutdown.
HTTP Metrics
FastAPI auto-instrumentation emits the standard HTTP server metrics on every NeMo Gym server while traces are exported. The pinned instrumentation package uses the older OpenTelemetry HTTP semantic conventions:
http.target carries the route template, such as /verify, not the raw path.
With traces_enabled: false, NeMo Gym does not install the instrumentor, because it costs
every request tens of microseconds even when no span is exported. A metrics-only run
therefore has no http.server.* metrics. Turn traces on to get them.
Use these for request latency. They are dimensioned, so you can compare /verify against
/v1/responses, or isolate 500s, which is what latency questions usually require.
The Gym-specific gym.http.connection_pool.queue_duration_ms histogram measures client-side
connection acquisition separately from request latency. Its bounded attributes identify the
destination server, queue outcome (ok or abandoned), and which pool constraint caused the
wait (total, per_host, or unknown). It records one sample for each queued connection
acquisition (connect()), combining repeated waiter wakeups within that acquisition.
Redirect hops, aiohttp’s internal reconnects, and Gym retries record separate samples when
their acquisitions queue. Connection attempts that acquire a slot immediately do not record
a queue-duration histogram sample.
abandoned means the wait ended before a slot became available, including timeout and cancellation.
Divide the number of gym.http.connection_pool.queue_duration_ms histogram samples by
gym.http.connection_pool.connect_total over the same interval and destination to calculate the
fraction of connection attempts that queued.
Both instruments use nemo.gym.http.destination.server.name for the request destination:
the configured server name for ServerClient calls, remote_agent_service for calls to the
remote agent’s external service, or external for unlabeled direct calls. This differs from
the resource attribute nemo.gym.server.name, which identifies the Gym process recording the metric.
These pool metrics require telemetry initialization before client construction. Standalone collection does not initialize telemetry automatically, so missing metrics do not mean no queueing. See HTTP Connection Pool for process coverage.
A Note on gym.server.request_duration_ms
nemo-lens declares a gym.server.request_duration_ms histogram. NeMo Gym does not use
it.
At the pinned nemo-lens version, that instrument records without attributes. Every
endpoint of every server type would land in one undimensioned histogram: a verification,
an inference call, and a liveness probe sharing one set of buckets. The result answers no
question anyone has. The dimensioned http.server.duration above supersedes it.
Enabling and Disabling
Metrics follow the master switch and can be turned off independently:
Metrics export on a timer. The default interval is 10 seconds and is configurable with the
standard OTEL_METRIC_EXPORT_INTERVAL environment variable, in milliseconds. A process
that lives for less than one interval may exit before exporting anything.
Rollout Health Metrics
The trajectory-level checks of the rollout health report also run as
each rollout finishes, so problems show up while a run is still in progress. Both counters use the
same check logic as the report. They depend only on telemetry being initialized with a metrics exporter, not on which span groups are
enabled:
disable_health_check turns off the post-run report, not these counters, and health_check_ignored_checks
applies to both.
gym.rollout.health_verdict_total counts each evaluated rollout once. The verdict is healthy,
unhealthy or unobserved, with the meaning it has in the report. A rollout is unobserved when no
check flagged it but at least one could not run, for example because observability_enabled is off
and no trajectory was captured. Rollouts that never ran are not evaluated. A rollout that failed in its
environment after the agent ran is evaluated when it returned agent evidence.
Both counters carry the outcome, scored or failed. The post-run report reads scored rollouts only,
so filter on scored to compare the two.
gym.rollout.health_flagged_total counts a rollout once per check that produced at least one finding,
however many findings that is. A check’s value is therefore the number of rollouts it flagged, which is
at most the number of unhealthy rollouts, while the sum over checks can be larger because one rollout
can be flagged by several checks. The report’s per-check issue counts are per finding. The check
ids are the fixed ids of the rollout-level checks in the health report, plus check_execution_error.
Neither counter has task or rollout identifiers as dimensions.