You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
GenRM Compare Resource Server (Phase 2 — future) resources_servers/genrm_compare/: orchestration only; calls GenRM model via /v1/responses. Co-located strategy and utils.
Type support (Phase 1 — implemented) openai_utils.py: NeMoGymChatCompletionCustomRoleMessageParam, extended role literals for response_1, response_2, principle.
VLLMModel unchanged — No GenRM-specific code in base VLLM or LocalVLLM.
What we're NOT doing
Modifying VLLMModel or LocalVLLMModel.
Top-level nemo_gym/comparison_strategies.py — strategy lives in genrm_compare package.
Complex protocol abstractions for strategy swapping.
Overview
GenRM (Generative Reward Model) needs custom chat roles (response_1, response_2, principle) for pairwise comparison. PR #523 added these inside the generic VLLM model, which mixed concerns and broke the OpenAI-style contract. This design keeps the base model generic and adds a dedicated GenRM Response API Model (remote and local) with a dedicated converter.
Decisions: GenRMModel (remote) and LocalGenRMModel (local) inherit from VLLMModel / LocalVLLMModel and use a shared GenRMModelMixin + GenRMConverter for custom role handling. Comparison strategy is implemented inside the genrm_compare Resource Server. Rollout collection calls genrm_compare; genrm_compare calls the GenRM model.
Local:LocalGenRMModel = GenRMModelMixin + LocalVLLMModel. Same converter; downloads model and starts vLLM (e.g. Ray).
GenRMConverter (in remote app): extends VLLMConverter, overrides _format_message() for response_1 / response_2 / principle; passes other roles to parent.
GenRM Compare (Phase 2): Resource Server only orchestrates: build pairs, format messages with GenRM roles, call GenRM model /v1/responses, aggregate. No inference inside the Resource Server.
Role literals extended to include "response_1" | "response_2" | "principle" where needed for GenRM input/message types.
Included in NeMoGymChatCompletionMessageParam union. Logic for custom roles lives only in GenRMConverter.
Implementation path
Phase 1 (done): GenRM model package (remote + local), GenRMConverter, configs, tests; type support in openai_utils.
Phase 2: GenRM Compare Resource Server (directory structure, comparison_strategies in-package, app.py calling genrm_model), /compare endpoint, config to use genrm_model.
Phase 3: Type support — already done in Phase 1.
Phase 4: Rollout collection and Nemo-RL integration with genrm_compare.
Summary
Do: GenRM as its own Response API Model (remote + local); GenRMModelMixin + GenRMConverter; comparison strategy inside genrm_compare package; keep types in openai_utils, logic in GenRMConverter only.
Don’t: Change VLLMModel/LocalVLLMModel; add GenRM roles to VLLMConverter; put comparison strategy in nemo_gym/comparison_strategies.py.
Result: GenRM inference is a proper model (remote or local); genrm_compare only orchestrates and calls that model; base VLLM stays generic.
NeMo-RL is agnostic to comparison strategies, GenRM, and reward-model details. It only requests rollouts; all GenRM behavior is configured and executed in NeMo Gym (agents and resource servers).
Old Approach (Removed)
The previous integration violated layering by putting GenRM concepts in NeMo-RL:
NeMo-RL defined GenRMCompareConfig and took genrm_config in run_rollouts().
NeMo-RL built a comparison_strategy (e.g. GenRMStrategy) and passed it into run_examples(..., comparison_strategy=...).
rollouts.py accepted use_genrm_compare, num_generations_per_prompt, genrm_compare_server_name, genrm_agent_names and built genrm_config for the remote call.
That tied NeMo-RL to GenRM and to NeMo Gym internals.
Current Approach
Responsibilities
Layer
Responsibility
NeMo-RL
Calls run_rollouts(examples, tokenizer, timer_prefix). No GenRM types, no GenRM config, no strategy object.
NeMo Gym rollout_collection
For each row, POST to the agent’s /run endpoint. No comparison strategy; single code path.
Agent (e.g. genrm_simple_agent)
Runs policy generation, then calls the configured resource server (e.g. genrm_compare) /verify with the response (and optional principle).
genrm_compare resource server
/verify: buffers by prompt (and optional principle); when a cohort of size num_rollouts_per_prompt is ready, runs comparison, assigns rewards, returns them. /compare: batch API for scripts/tests.
So: rewards that depend on other rollouts for the same task (RLHF-style) are handled inside the genrm_compare server via cohort buffering in /verify. Rollout collection and NeMo-RL stay generic.
NeMo-RL interface (current)
# nemo_rl/environments/nemo_gym.py@ray.remote(max_restarts=-1, max_task_retries=-1)classNemoGym(EnvironmentInterface):
asyncdefrun_rollouts(
self,
nemo_gym_examples: list[dict],
tokenizer: PreTrainedTokenizerBase,
timer_prefix: str,
) ->list[dict]:
# Single path: run_examples with no strategy or GenRM paramsnemo_gym_result_iterator=self.rch.run_examples(
examples=nemo_gym_examples,
head_server_config=self.head_server_config,
)
# ... collect results, postprocess, return
No GenRMCompareConfig, no genrm_config, no comparison_strategy, no GenRM-specific parameters in NeMo-RL or in run_examples.
Where GenRM is configured (NeMo Gym side)
Agent config: The agent used for GRPO (e.g. genrm_simple_agent) is configured in NeMo Gym’s global config to use the genrm_compare resource server (for /verify after generation).
genrm_compare server config: In the genrm_compare block (e.g. in resources_servers/genrm_compare/configs/genrm_compare.yaml):
num_rollouts_per_prompt: Cohort size per prompt (e.g. 16). When this many verify requests are buffered for the same prompt (and optional principle), the server runs comparison and returns rewards.
genrm_model_server, comparison_strategy (circular/all_pairs), num_judges_per_comparison, use_principle, aggregator, length bonuses, etc.
Data: Each row’s agent_ref.name must match the agent that is wired to genrm_compare (e.g. genrm_simple_agent). Repeats per prompt (e.g. via num_repeats in rollout collection or by repeating rows in the dataset) should match num_rollouts_per_prompt so cohorts complete.
No GenRM or comparison-strategy configuration is passed from NeMo-RL; it all lives in NeMo Gym’s config and in the genrm_compare server.
How the old env/grpo GenRM settings get into Gym (after refactor)
Previously these were passed as kwargs into run_async_nemo_gym_rollout from master_config["env"] and master_config["grpo"]. They are no longer function arguments. Here is where the equivalent behavior is configured:
Old (removed) source
Where it lives now
How it gets to Gym
use_genrm_compare
Not a flag anymore
You “enable” GenRM by using an agent that is configured in Gym to call the genrm_compare resource server. Your data’s agent_ref.name must match that agent. No value is passed from NeMo-RL.
num_generations_per_prompt (grpo)
num_rollouts_per_prompt in genrm_compare server config
Set env.nemo_gym.genrm_compare.resources_servers.genrm_compare.num_rollouts_per_prompt in your training YAML (same value as grpo.num_generations_per_prompt, e.g. 16). That entire env.nemo_gym dict is passed as initial_global_config_dict when the NemoGym Ray actor is created (grpo.py builds NemoGymConfig(..., initial_global_config_dict=env_configs["nemo_gym"])). Gym’s RunHelper loads that dict and merges it with config_paths, so the genrm_compare server sees num_rollouts_per_prompt. Keep grpo.num_generations_per_prompt for GRPO batch math (e.g. repeat_interleave); set num_rollouts_per_prompt in the same YAML under env.nemo_gym so the server’s cohort size matches.
genrm_compare_server_name (env)
Agent’s resource server in Gym
The agent definition (e.g. genrm_simple_agent) in env.nemo_gym or in a config file listed in config_paths specifies which resource server it uses (e.g. resources_server.name: genrm_compare). Not passed from NeMo-RL.
genrm_agent_names (env)
Which agents use genrm_compare
Determined by Gym config: any agent that has resources_server pointing to genrm_compare “uses GenRM.” Your data chooses the agent via agent_ref.name. Not passed from NeMo-RL.
So: env.use_genrm_compare, env.genrm_compare_server_name, and env.genrm_agent_names are no longer read by code; you can remove them from the YAML or keep them as comments. The only value that must be set in env.nemo_gym for GenRM cohort behavior is num_rollouts_per_prompt under the genrm_compare server block (and it should match grpo.num_generations_per_prompt).
Flow (high level)
NeMo-RL
└─► run_rollouts(examples, tokenizer, timer_prefix)
└─► run_examples(examples, head_server_config)
NeMo Gym rollout_collection
└─► For each row: POST to agent_ref["name"] /run (one path only)
Agent (e.g. genrm_simple_agent)
└─► Generate response → POST to genrm_compare /verify (response + optional principle)
genrm_compare resource server
└─► /verify: buffer by prompt (and principle); when cohort size = num_rollouts_per_prompt
→ run comparison → return per-rollout rewards
└─► /compare: batch comparison API (e.g. for scripts/tests)
Enabling / disabling GenRM-style rewards
Use GenRM (relative rewards per cohort): Use an agent that is configured to call the genrm_compare resource server’s /verify. Ensure genrm_compare is loaded with num_rollouts_per_prompt (and other options) set as desired. Data should have the right number of rollouts per prompt.
Standard rewards: Use an agent that does not call genrm_compare (or that uses a different reward path). No change in NeMo-RL code.
Migration summary (what was removed from NeMo-RL)
GenRMCompareConfig TypedDict and any genrm_config parameter.
run_rollouts(..., genrm_config=...) and all logic that built a comparison_strategy and passed it to run_examples(..., comparison_strategy=...).
From run_async_nemo_gym_rollout: parameters use_genrm_compare, num_generations_per_prompt, genrm_compare_server_name, genrm_agent_names and the block that built genrm_config and passed it to run_rollouts.remote(..., genrm_config).
From call sites (e.g. GRPO, async rollout): all GenRM-specific kwargs; validation that required num_val_generations_per_prompt > 1 when “GenRM compare” was enabled.
NeMo-RL now only calls run_rollouts(examples, tokenizer, timer_prefix) and run_examples(examples, head_server_config) with no GenRM or strategy parameters.
Troubleshooting
Rewards not relative / cohort behavior wrong: Check genrm_compare server config (num_rollouts_per_prompt, comparison_strategy, etc.) and that the agent used in data is the one wired to genrm_compare’s /verify.
Wrong or missing rewards: Confirm genrm_compare and the GenRM model server are running and that agent_ref.name in the data matches the agent that calls genrm_compare.
Activity
[-]Reward model support[/-][+]feat: Reward model support[/+]ffrujeri commentedon Feb 11, 2026
Design Note: GenRM Reward Model Refactoring
Date: 2026-02-11
Status: Draft
Related PR: #523
What we're implementing
GenRM Response API Model (Phase 1 — implemented)
Package with remote and local variants, same GenRM roles and formatting:
Config keys:
genrm_model.remote(entrypointremote/app.py),genrm_model.local(entrypointlocal/app.py).GenRM Compare Resource Server (Phase 2 — future)
resources_servers/genrm_compare/: orchestration only; calls GenRM model via/v1/responses. Co-located strategy and utils.Type support (Phase 1 — implemented)
openai_utils.py:NeMoGymChatCompletionCustomRoleMessageParam, extended role literals forresponse_1,response_2,principle.VLLMModel unchanged — No GenRM-specific code in base VLLM or LocalVLLM.
What we're NOT doing
VLLMModelorLocalVLLMModel.nemo_gym/comparison_strategies.py— strategy lives in genrm_compare package.Overview
GenRM (Generative Reward Model) needs custom chat roles (
response_1,response_2,principle) for pairwise comparison. PR #523 added these inside the generic VLLM model, which mixed concerns and broke the OpenAI-style contract. This design keeps the base model generic and adds a dedicated GenRM Response API Model (remote and local) with a dedicated converter.Decisions: GenRMModel (remote) and LocalGenRMModel (local) inherit from VLLMModel / LocalVLLMModel and use a shared GenRMModelMixin + GenRMConverter for custom role handling. Comparison strategy is implemented inside the genrm_compare Resource Server. Rollout collection calls genrm_compare; genrm_compare calls the GenRM model.
Problem (reference: PR #523)
vllm_model/app.py, coupling GenRM to the generic model.Architecture
GenRM model (Phase 1):
GenRMModel=GenRMModelMixin+VLLMModel. Config:base_url,api_key,model,supports_principle_role, etc.LocalGenRMModel=GenRMModelMixin+LocalVLLMModel. Same converter; downloads model and starts vLLM (e.g. Ray).VLLMConverter, overrides_format_message()forresponse_1/response_2/principle; passes other roles to parent.GenRM Compare (Phase 2): Resource Server only orchestrates: build pairs, format messages with GenRM roles, call GenRM model
/v1/responses, aggregate. No inference inside the Resource Server.Type system (openai_utils.py)
NeMoGymChatCompletionCustomRoleMessageParam(role, content)."response_1" | "response_2" | "principle"where needed for GenRM input/message types.NeMoGymChatCompletionMessageParamunion. Logic for custom roles lives only in GenRMConverter.Implementation path
/compareendpoint, config to use genrm_model.Summary
nemo_gym/comparison_strategies.py.Result: GenRM inference is a proper model (remote or local); genrm_compare only orchestrates and calls that model; base VLLM stays generic.
ffrujeri commentedon Feb 12, 2026
NeMo-RL Integration Design
Principle: Zero GenRM Code in NeMo-RL
NeMo-RL is agnostic to comparison strategies, GenRM, and reward-model details. It only requests rollouts; all GenRM behavior is configured and executed in NeMo Gym (agents and resource servers).
Old Approach (Removed)
The previous integration violated layering by putting GenRM concepts in NeMo-RL:
GenRMCompareConfigand tookgenrm_configinrun_rollouts().comparison_strategy(e.g.GenRMStrategy) and passed it intorun_examples(..., comparison_strategy=...).use_genrm_compare,num_generations_per_prompt,genrm_compare_server_name,genrm_agent_namesand builtgenrm_configfor the remote call.That tied NeMo-RL to GenRM and to NeMo Gym internals.
Current Approach
Responsibilities
run_rollouts(examples, tokenizer, timer_prefix). No GenRM types, no GenRM config, no strategy object./runendpoint. No comparison strategy; single code path.genrm_simple_agent)/verifywith the response (and optional principle)./verify: buffers by prompt (and optional principle); when a cohort of sizenum_rollouts_per_promptis ready, runs comparison, assigns rewards, returns them./compare: batch API for scripts/tests.So: rewards that depend on other rollouts for the same task (RLHF-style) are handled inside the genrm_compare server via cohort buffering in
/verify. Rollout collection and NeMo-RL stay generic.NeMo-RL interface (current)
GenRMCompareConfig, nogenrm_config, nocomparison_strategy, no GenRM-specific parameters in NeMo-RL or inrun_examples.Where GenRM is configured (NeMo Gym side)
genrm_simple_agent) is configured in NeMo Gym’s global config to use the genrm_compare resource server (for/verifyafter generation).resources_servers/genrm_compare/configs/genrm_compare.yaml):num_rollouts_per_prompt: Cohort size per prompt (e.g. 16). When this many verify requests are buffered for the same prompt (and optional principle), the server runs comparison and returns rewards.genrm_model_server,comparison_strategy(circular/all_pairs),num_judges_per_comparison,use_principle, aggregator, length bonuses, etc.agent_ref.namemust match the agent that is wired to genrm_compare (e.g.genrm_simple_agent). Repeats per prompt (e.g. vianum_repeatsin rollout collection or by repeating rows in the dataset) should matchnum_rollouts_per_promptso cohorts complete.No GenRM or comparison-strategy configuration is passed from NeMo-RL; it all lives in NeMo Gym’s config and in the genrm_compare server.
How the old env/grpo GenRM settings get into Gym (after refactor)
Previously these were passed as kwargs into
run_async_nemo_gym_rolloutfrommaster_config["env"]andmaster_config["grpo"]. They are no longer function arguments. Here is where the equivalent behavior is configured:agent_ref.namemust match that agent. No value is passed from NeMo-RL.So: env.use_genrm_compare, env.genrm_compare_server_name, and env.genrm_agent_names are no longer read by code; you can remove them from the YAML or keep them as comments. The only value that must be set in env.nemo_gym for GenRM cohort behavior is num_rollouts_per_prompt under the genrm_compare server block (and it should match grpo.num_generations_per_prompt).
Flow (high level)
Enabling / disabling GenRM-style rewards
/verify. Ensure genrm_compare is loaded withnum_rollouts_per_prompt(and other options) set as desired. Data should have the right number of rollouts per prompt.Migration summary (what was removed from NeMo-RL)
GenRMCompareConfigTypedDict and anygenrm_configparameter.run_rollouts(..., genrm_config=...)and all logic that built acomparison_strategyand passed it torun_examples(..., comparison_strategy=...).run_async_nemo_gym_rollout: parametersuse_genrm_compare,num_generations_per_prompt,genrm_compare_server_name,genrm_agent_namesand the block that builtgenrm_configand passed it torun_rollouts.remote(..., genrm_config).num_val_generations_per_prompt > 1when “GenRM compare” was enabled.NeMo-RL now only calls
run_rollouts(examples, tokenizer, timer_prefix)andrun_examples(examples, head_server_config)with no GenRM or strategy parameters.Troubleshooting
num_rollouts_per_prompt, comparison_strategy, etc.) and that the agent used in data is the one wired to genrm_compare’s/verify.agent_ref.namein the data matches the agent that calls genrm_compare.feat: Adds GenRM pairwise comparison resource server to support RLHF …
feat: Adds GenRM Response API Model with support for custom roles use…
feat: Adds GenRM Response API Model with support for custom roles use…
feat: Adds GenRM Response API Model with support for custom roles use…