Skip to content

[rl] Generator metrics are always generator/*; validation renames its own - #5969

Merged
felipemello1 merged 2 commits into
mainfrom
felipemello1/overlap-validation/1-generator-metrics-label
Nov 9, 2026
Merged

felipemello1 merged 2 commits into
mainfrom
felipemello1/overlap-validation/1-generator-metrics-label

Conversation

@felipemello1

@felipemello1 felipemello1 commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary (human-written)

  1. we would like to visualize generatioin metrics for training and validation separately
  2. currently we pass a "metric prefix" and have the generator add the suffix
  3. this doesnt compose well with verifiers
  4. we remove this, and let the evaluator add the suffix when they come back

Agent details

Stack: main <- #5944 <- this PR <- #5228. Supersedes #5948 (one generate_fn per group, kept in a dict).

TLDR: The generate path no longer carries a metrics label. Generators always name their metrics generator/*, and validation renames its own to validation_generator/* after results return, so the W&B keys stay as on main. #5228 (validation beside training) needs this first: Verifiers' HTTP server holds one generate_fn, so once groups of both kinds overlap, a request can log under the other kind's label.

main:     validation generate_fn(metrics_prefix="validation_generator") -> router -> generator -> "validation_generator/queue_time_ms"
this PR:  every generate_fn, no label                                    -> router -> generator -> "generator/queue_time_ms"
          validation, after the group returns:  "generator/queue_time_ms" -> "validation_generator/queue_time_ms"

Problem

  1. The controller builds two kinds of generate_fn: training's sends metrics_prefix="generator", validation's "validation_generator".
  2. The label travels through 7 layers to name each request's metrics: controller, InterGeneratorRouter, the Monarch router and generator, Generator, engine loop, dispatcher.
  3. Verifiers runs its agents against an HTTP server that holds one generate_fn (GenerationServer.set_generate_fn). Each group that starts replaces it.
  4. So while a training group and a validation group run at once, a request uses the function of the group that started last, and logs under that kind's label. Once validation runs beside training ([rl] Periodic validation beside training #5228), that is most turns of a multi-turn env.
  5. On main no logged metric is wrong: validation never overlaps a running training rollout. A late call from a cancelled rollout lands in metadata nobody reads. So on main this PR is a cleanup that prevents the bug.

Solution

  1. Drop metrics_prefix from the generate path. The dispatcher spells each key: generator/queue_time_ms, generator/num_cached_tokens, ...
  2. _collect_validation_rollouts renames its turns' generator/* metrics to validation_generator/* after results return.
  3. The Verifiers server keeps its one slot. Every group now passes a function with no label, so replacing it is safe (a comment at the call).
  4. Unchanged: the W&B keys (generator/* for training, validation_generator/* for validation), the GenerateFn contract, routing and request ids.
  5. The logic is in two places: the rename in _collect_validation_rollouts and the spelled keys in _prepare_generation_request_metrics. The other files only delete the parameter, plus one comment in the Verifiers rollouter and the new test.

You may ask:

NOTE:

  • A metric about the whole engine shouldn't ride on one request's metrics: validation renames every generator/* key on its turns, and a failed group drops its turns' metrics.
  • Open PRs that pass metrics_prefix need a rebase that drops it.
  • The rollout recorder writes no metrics, so rollout_samples.jsonl is unchanged.

Test plan

pytest tests/rl/unit_tests/cpu -q --ignore=tests/rl/unit_tests/cpu/test_vllm_wrapper.py
    # 551 passed, 7 skipped (base: 550 passed, 7 skipped)
pytest tests/rl/unit_tests/cpu/test_verifiers*.py tests/rl/unit_tests/cpu/test_model_defaults.py   # in a venv with verifiers
    # 61 passed
pre-commit run --files <changed files>
    # all hooks pass
pyrefly check
    # 1 error, the same on the base: FSDPModule.set_unshard_in_current_stream (torchtitan/distributed/fsdp.py:593)
  • New: test_async_controller.py::test_validation_renames_generator_metrics. It fails when the rename is removed.
  • test_generator.py, test_engine_loop.py, test_async_controller.py: the calls drop metrics_prefix. test_metric_timing_math now checks generator/* keys.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 9, 2026
@felipemello1
felipemello1 added this pull request to stack #5970 November 9, 2026 03:18
@felipemello1

Copy link
Copy Markdown
Contributor Author

Reply from claude: @claude please review this PR (head 3f215a5). It is the middle of a stack: main <- #5944 <- this <- #5228. Review only this PR's diff against its base.

@claude

claude Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @felipemello1's task in 1m 10s —— View job


Approve (please fill in the empty "Summary (human-written)" section before merging) -- review

@claude claude Bot 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.

Verdict: Approve -- please address the item below before merging -- the diff removes metrics_prefix from the whole generate path, every in-repo caller is updated, and the W&B keys stay what they were. One description item is still open.

What this PR does. It deletes the metrics_prefix argument that went from the controller through InterGeneratorRouter, the Monarch router and generator actors, Generator, EngineLoop and RequestDispatcher. The dispatcher now writes literal generator/* keys. _collect_validation_rollouts renames generator/* to validation_generator/* after compute_rollout_metrics. Because no generate_fn carries a per-kind label anymore, the Verifiers GenerationServer keeps one generate_fn slot, and replacing it is now harmless.

Example.

Verifiers env, a training group and a validation group overlap (possible once #5228 lands):
  base:    validation sets the server's generate_fn last -> a training turn logs validation_generator/queue_time_ms
  this PR: both fns are identical -> every turn logs generator/queue_time_ms;
           only validation's own turns are renamed -> validation_generator/queue_time_ms
Training keys (generator/*) and validation keys (validation_generator/*) on W&B: unchanged.

Must fix

  1. PR description -- the "Summary (human-written)" section is empty. The author needs to fill it in. Per CONTRIBUTING.md, agents don't write this section.

Details

Details
  • Gate: on main the problem is latent, since validation never overlaps a running training rollout. The description says so, and the change is a net simplification (+96/-82, nearly all of the growth is the new test and the import block). It's a prerequisite for #5228. Moving the label out of the request path is the right layer: one function with no label is correct no matter which group calls it, and a keyed-per-group server (#5948) would add lifetime state that only fixes Verifiers.
  • Callsite audit: metrics_prefix has no remaining references in the repo. I found no other producer of generator/* turn metrics (the only ones are dispatcher.py:271 and dispatcher.py:391-413), so the rename in controller.py:780-783 touches only generator metrics. The rollout/- and validation/-prefixed keys from compute_rollout_metrics don't start with generator/.
  • The console allowlist in observability/metrics/processor.py:62-66 still matches the training keys.
  • The Verifiers comment at rollouter.py:254-255 is accurate: generation_server.py:199 reads group_id from each request's sampling params, not from the closure.
  • New test test_validation_renames_generator_metrics: it guards a metric-key invariant that would otherwise break silently, and it's the only test that runs _collect_validation_rollouts. Placement is fine.

A maintainer still needs to review (this touches RL generator core).

@felipemello1
felipemello1 marked this pull request as ready for review November 9, 2026 03:22
@pytorch-bot pytorch-bot Bot added the ciflow/fake-pg Run 1-GPU Fake PG integration tests label Nov 9, 2026
@github-actions
github-actions Bot requested a review from pzhan9 November 9, 2026 03:22
@felipemello1
felipemello1 force-pushed the felipemello1/overlap-validation/1-generator-metrics-label branch from 3f215a5 to 9f009d7 Compare November 9, 2026 03:26

@tianyu-l tianyu-l 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.

much nicer!
Actually, when I reviewed the previous PR that added "metrics_prefix" to functions, I didn't feel right but let go. I feel in the future we could be more sensitive to such fragile code, even without concrete counter-examples. But changing code is easy nowadays, so not a big deal.

Base automatically changed from felipemello1/max-num-seqs-config to main November 9, 2026 15:44
Felipe Mello added 2 commits November 9, 2026 10:44
… own

The generate path no longer takes metrics_prefix (controller, InterGeneratorRouter, Monarch
router and generator, Generator, engine loop, dispatcher). Every request's metrics are named
generator/*, and the controller builds one kind of generate_fn for training and validation.

_collect_validation_rollouts renames its turns' generator/* metrics to validation_generator/*
after results return, so the W&B keys stay as before.

This removes a Verifiers bug: its HTTP server holds one generate_fn, replaced by each group that
starts, so a request could log under the label of another group's kind.
@felipemello1
felipemello1 force-pushed the felipemello1/overlap-validation/1-generator-metrics-label branch from 9f009d7 to 5eb96a2 Compare November 9, 2026 15:44
@felipemello1
felipemello1 merged commit 4f655bf into main Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/fake-pg Run 1-GPU Fake PG integration tests ciflow/rl CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants