Skip to content

refactor(metrics): move the metrics modules into nemo_gym/metrics - #5211

Merged
ananthsub merged 1 commit into
mainfrom
ananthsub/layout-metrics
Oct 30, 2026
Merged

ananthsub merged 1 commit into
mainfrom
ananthsub/layout-metrics

Conversation

@ananthsub

@ananthsub ananthsub commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

What and why

Moves the rollout metrics into a new nemo_gym/metrics/ package: reward profiles with pass@k and majority statistics, and the metric definitions they share.

Where this PR sits

The stack lands bottom-up; each PR's base is the branch of the PR before it, so each diff shows only that PR's change.

flowchart LR
  compat["#5167<br/>Old import paths<br/>keep working"]
  linter["#5168<br/>import-linter<br/>layer contract"]
  prep["#5169<br/>Remove path and<br/>name couplings"]
  config["#5189<br/>Move config/"]
  utils["#5195<br/>Move utils/"]
  core["#5203<br/>Move core/"]
  client["#5206<br/>Move client/,<br/>start telemetry/"]
  trajectory["#5209<br/>Move trajectory/"]
  verification["#5210<br/>Move verification/"]
  metrics["#5211<br/>Move metrics/"]
  artifacts["#5212<br/>Move artifacts/"]
  srmods["#5214<br/>Move server_runtime/<br/>modules"]
  su["#5215<br/>Split server_utils"]
  model["#5224<br/>Move models/<br/>modules"]
  modelbase["#5225<br/>Split model<br/>call capture"]
  agents["#5228<br/>Move agents/"]
  data["#5229<br/>Move data/"]
  harbor["#5230<br/>Split the<br/>Harbor task CLI"]
  rollouts["#5231<br/>Move rollouts/"]
  rsplit["#5232<br/>Split the<br/>rollout collector"]
  testing["#5233<br/>Dissolve testing/"]
  orch["#5234<br/>Move orchestration/<br/>modules"]
  sup["#5235<br/>Split the<br/>server supervisor"]
  eval["#5244<br/>Move eval/"]
  env["#5298<br/>Move environment/<br/>registries"]
  cli["#5300<br/>Retire the<br/>cli_setup_command shim"]
  docs["#5385<br/>Describe the<br/>package layout"]
  owners["next<br/>CODEOWNERS:<br/>per-package groups"]
  remove["0.10.0<br/>Remove the<br/>old paths"]
  compat --> linter
  linter --> prep
  prep --> config
  config --> utils
  utils --> core
  core --> client
  client --> trajectory
  trajectory --> verification
  verification --> metrics
  metrics --> artifacts
  artifacts --> srmods
  srmods --> su
  su --> model
  model --> modelbase
  modelbase --> agents
  agents --> data
  data --> harbor
  harbor --> rollouts
  rollouts --> rsplit
  rsplit --> testing
  testing --> orch
  orch --> sup
  sup --> eval
  eval --> env
  env --> cli
  cli --> docs
  docs --> owners
  owners --> remove
  classDef this fill:#fde68a,stroke:#b45309,stroke-width:2px,color:#1f2937
  classDef later fill:#f3f4f6,stroke:#9ca3af,color:#4b5563,stroke-dasharray: 4 3
  class metrics this
  class owners,remove later
Loading

Where the package sits

flowchart TD
  cli["cli/"]
  eval["eval/"]
  environment["environment/"]
  testing["testing/"]
  orchestration["orchestration/"]
  rollouts["rollouts/"]
  data["data/"]
  agents["agents/"]
  model["models/"]
  server_runtime["server_runtime/"]
  artifacts["artifacts/"]
  metrics["metrics/"]
  verification["verification/"]
  trajectory["trajectory/"]
  sandbox["sandbox/"]
  client["client/"]
  telemetry["telemetry/"]
  core["core/"]
  utils["utils/"]
  config["config/"]
  cli --> eval
  cli --> environment
  cli --> orchestration
  eval --> rollouts
  environment --> data
  testing --> rollouts
  orchestration --> data
  rollouts --> data
  rollouts --> agents
  rollouts --> model
  data --> server_runtime
  data --> artifacts
  agents --> server_runtime
  model --> server_runtime
  server_runtime --> metrics
  server_runtime --> verification
  server_runtime --> trajectory
  artifacts --> trajectory
  artifacts --> utils
  metrics --> utils
  verification --> sandbox
  trajectory --> core
  sandbox --> client
  client --> telemetry
  client --> utils
  telemetry --> core
  core --> config
  utils --> config
  classDef this fill:#fde68a,stroke:#b45309,stroke-width:2px,color:#1f2937
  classDef done fill:#d1fae5,stroke:#047857,color:#1f2937
  classDef todo fill:#f3f4f6,stroke:#9ca3af,color:#4b5563
  class metrics this
  class config,utils,core,telemetry,client,trajectory,verification done
  class cli,eval,environment,testing,orchestration,rollouts,data,agents,model,server_runtime,artifacts,sandbox todo
Loading

An arrow means "imports"; each package imports only packages below it. Yellow: created by this PR. Green: created by an earlier PR in the stack. Grey: still to come.

What moves

Whole modules, unchanged:

Old path New path
nemo_gym/reward_profile.py nemo_gym/metrics/reward_profile.py
nemo_gym/metrics_config.py nemo_gym/metrics/metrics_config.py

How to review

One commit. Its changes:

  1. Renames, with no content changes.
  2. Everything else:
    • The moves are recorded in MOVED_MODULES in nemo_gym/_moved_paths.py.
    • In-repo references are rewritten by scripts/migrate_imports.py.
    • The contract's metrics layer becomes the nemo_gym.metrics package.
    • fern/docs.yml redirects the old library reference pages to the new ones.
  3. Tests: the reward profile tests move into tests/unit_tests/metrics/. test_aggregate_metrics.py stays: it checks the metrics endpoints of a resources server and an agent end to end.

Public API

Every layout package that exists after this PR has a lazy public API in its __init__.py: the names non-test code outside nemo_gym/ imports from it (servers, benchmarks, scripts, and code samples in docs and skills), each served from the submodule that defines it on first use. Code outside nemo_gym/ and its tests (servers and their tests, benchmarks, scripts, and docs) imports those names from nemo_gym.<package>, so later moves inside a package leave it alone. Code inside nemo_gym/, and the library's tests under tests/, import from the module that defines each name, so the import-linter contract sees every dependency and a test reads what it patches. A patch target names the module the code under test looks the name up in. AGENTS.md states the rule.

Validation

  • pytest -n 16 tests/unit_tests, also with -W error for the moved paths. The only failures are environment-specific and unrelated to the move: this machine's hostname resolves to 127.0.1.1, which the sandbox host check refuses (the Harbor run summary tests and the benchmark listing test), and two Docker PTY tests.
  • lint-imports.
  • pre-commit run on the changed files.
  • Server and agent tests run in CI.

Rollout evidence: N/A. The modules move unchanged.

Compatibility

  • Old paths work until 0.10.0, with one warning each, and give the same module objects.
  • The modules' own UserWarnings, such as "Standard error is 0", are now attributed to nemo_gym.metrics.reward_profile, so a warnings filter keyed on module="nemo_gym.reward_profile" needs the new name.
  • Open branches: run python scripts/migrate_imports.py <paths>.

Issue

Part of #5166.

@ananthsub
ananthsub added this pull request to stack #5170 October 28, 2026 18:48
@copy-pr-bot

copy-pr-bot Bot commented Oct 28, 2026

Copy link
Copy Markdown

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.

@ananthsub ananthsub changed the title ananthsub/layout metrics refactor(metrics): move the metrics modules into nemo_gym/metrics Oct 28, 2026
@ananthsub ananthsub added the feature New capabilities, enhancements, or enablement work label Oct 28, 2026
@ananthsub
ananthsub requested a review from yaoyu-33 October 28, 2026 18:50
@ananthsub ananthsub added area:core Shared APIs, servers, telemetry, health, and registries needs-review PR is ready for code review and waiting on a reviewer labels Oct 28, 2026
@ananthsub
ananthsub marked this pull request as ready for review October 28, 2026 18:50
@ananthsub
ananthsub requested review from a team as code owners October 28, 2026 18:50
@nemo-automation-bot
nemo-automation-bot Bot requested review from a team October 28, 2026 18:51
@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

@ananthsub
ananthsub force-pushed the ananthsub/layout-metrics branch from be2168f to b6a7cff Compare October 28, 2026 21:56
@ananthsub
ananthsub force-pushed the ananthsub/layout-metrics branch from b6a7cff to 2cd8756 Compare October 28, 2026 23:10
@ananthsub
ananthsub force-pushed the ananthsub/layout-metrics branch from 2cd8756 to 5dd83c4 Compare October 29, 2026 00:54

@yaoyu-33 yaoyu-33 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for another clean, mechanical step. We found no blockers or risks, only two small notes inline: one about old-path test coverage, one question about how the CLI reward_profile shim should travel with its module.

What this PR does. It moves reward_profile.py and metrics_config.py into a new nemo_gym/metrics package with a lazy public API. It records both moves in _moved_paths.py, swaps the import-linter layer to nemo_gym.metrics, rewrites the in-repo imports, and adds the docs redirects.

What we checked

  • Moves. metrics_config.py is byte-identical. reward_profile.py and test_reward_profile.py differ from the base only in their imports. Nothing in either module depends on its file location.
  • Imports. The other 64 changed Python files differ only in their imports. All 21 rewritten (module, name) pairs resolve to the identical objects. Both old module paths give the same module objects with one warning each, in either import order, and a pickle written at the base still loads.
  • Metrics. The aggregate-metric and reward-profile functions are unchanged. So are the /aggregate_metrics routes and the mixin MRO of every server, agent and environment server that uses them. _PUBLIC_API holds exactly the eight names that code outside the library imports, and test_public_api_facades.py picks the package up on its own.
  • Runtime lookups. No config, manifest or mock.patch string names these modules by dotted path. No script shipped into a sandbox imports them, and the harness tarballs include nemo_gym/metrics/. The fern/docs.yml redirects cover both URL forms. lint-imports passes in the Lint job.
  • Tests. The targeted unit tests pass locally, apart from three wandb tests that also fail at the base without the extra. With moved-path warnings turned into errors they still pass, which matches the PR's validation. Every touched server's tests pass in CI.

PR description

  • Neither moved module uses logging, so the logger-name bullet under Compatibility doesn't apply here. What does change is the module their UserWarnings are attributed to: a downstream warnings filter keyed on module="nemo_gym.reward_profile" (for example on "Standard error is 0") stops matching.
  • Validation could give the exact -W filter. A blanket -W error::DeprecationWarning also trips the unrelated agent_ref routing deprecation in rollout_collection.py.

CI (not from this PR)

  • Unit tests / Test: the Docker Hub 429 Harbor failures, plus telemetry/test_propagation.py::test_lazy_client_initialization_failure_is_inside_the_client_span[False/True].
  • Server suite (shard 3): four openai_model TestRefusedProviderConnection failures.
  • These six also fail on #5210's head and first appear at #5206, where the test fixtures patch names in server_utils that the moved client code no longer reads, so the fix belongs there. Harness conformance is non-blocking.

Comment thread nemo_gym/_moved_paths.py Resolved
yaoyu-33
yaoyu-33 previously approved these changes Oct 30, 2026

@yaoyu-33 yaoyu-33 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving. The two inline notes are non-blocking. The remaining CI failures also fail on #5210 and first appear at #5206, so the fix belongs there.

Record the two moves in MOVED_MODULES, rewrite in-repo references with
scripts/migrate_imports.py, make the contract's metrics layer the
nemo_gym.metrics package, and redirect the old library reference pages
in fern/docs.yml.

Regenerate the public API of each layout package that exists here from
what non-test code outside nemo_gym imports, and point code outside
nemo_gym, tests included, at nemo_gym.<package>.

Signed-off-by: Ananth Subramaniam <[email protected]>

This branch was previously deployed

1 inactive deployment
public — 66d6a4a6 Deployed Oct 30, 2026 by copy-pr-bot[bot] via release / finalize / notify #8774
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:core Shared APIs, servers, telemetry, health, and registries feature New capabilities, enhancements, or enablement work ready-to-merge PR is approved, current, and waiting for final CI or merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants