Skip to content

fix(orchestrator): gate group-relative algorithms to a single trainable agent#3108

Open
hallerite wants to merge 1 commit into
mainfrom
fix/gate-group-algos-to-one-trainable-seat
Open

fix(orchestrator): gate group-relative algorithms to a single trainable agent#3108
hallerite wants to merge 1 commit into
mainfrom
fix/gate-group-algos-to-one-trainable-seat

Conversation

@hallerite

@hallerite hallerite commented Jul 22, 2026

Copy link
Copy Markdown
Member

What

GRPOAlgorithm.score_group / MaxRLAlgorithm.score_group now refuse a group whose trainable traces span more than one agent_name (new assert_single_trainable_agent helper in algo/base.py). Echo inherits the gate through GRPO's score_group; per-rollout algorithms (opd/opsd/sft) are untouched.

Why

Group-relative advantages assume the group is exchangeable attempts by one agent. After the multi-agent episode wire (#3104), a group's trainable survivors can span several agents, and mean-centering them together mixes different agents' reward scales into one baseline: silently wrong credit, no error.

The gate is deliberately the condition that matters, not "single-agent envs only": multi-agent envs with exactly one trainable agent keep working unchanged — e.g. a trainable solver rewarded by a frozen agentic judge. A group mixing trainable agent names is refused with an actionable message: mark the other agents untrainable in the env's setup() (agents.<name>.trainable = False), or implement your own algorithm that assigns credit across agents.

Cross-agent credit assignment is an open question prime-rl shouldn't answer silently in a base class — this refuses instead of guessing. If a well-founded scheme lands later, it arrives as a named Algorithm, and this gate is exactly the code it replaces.

Companion verifiers PR: PrimeIntellect-ai/verifiers#2101 (enforces standing at the source: an agent off the trainable model context refuses on training runs and is demoted on eval runs).

Test plan

  • uv run pytest tests/unit/orchestrator/test_advantage.py tests/unit/orchestrator/test_algorithms.py — green, including the new test_group_algos_refuse_multiple_trainable_agents (mixed-agent group raises for both algos; same-agent multi-trace group still centers to zero).
  • uv run ruff check / ruff format --check clean on the touched files.

🤖 Generated with Claude Code

@hallerite
hallerite force-pushed the fix/gate-group-algos-to-one-trainable-seat branch from 5a66ae9 to b68d05b Compare July 22, 2026 11:30
…le agent

GRPO/MaxRL mean-center over the whole trainable cohort of a group. A
multi-agent episode with several trainable agents would mix different
agents' reward scales into one baseline — silently wrong credit. Refuse
loudly instead: score_group now asserts the group's trainable traces
share one agent name (assert_single_trainable_agent in algo/base.py).

Single-trainable-agent multi-agent envs keep working unchanged — e.g. a
trainable solver rewarded by a frozen agentic judge is exchangeable
attempts by one agent, which is exactly what the baseline assumes. Echo
inherits the gate via GRPO's score_group; per-rollout algorithms
(opd/opsd/sft) are untouched. Cross-agent credit assignment stays open:
implement your own algorithm for it.

Verified: tests/unit/orchestrator/test_advantage.py + test_algorithms.py
green, ruff clean.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@hallerite
hallerite force-pushed the fix/gate-group-algos-to-one-trainable-seat branch from b68d05b to 388ac04 Compare July 22, 2026 11:30
@hallerite hallerite changed the title fix(orchestrator): gate group-relative algorithms to one trainable seat fix(orchestrator): gate group-relative algorithms to a single trainable agent Jul 22, 2026
@hallerite
hallerite marked this pull request as ready for review July 22, 2026 13:22
assert _max_rl(_make_group(rewards=[1.0, 1.0])) == pytest.approx([0.0, 0.0])


def test_group_algos_refuse_multiple_trainable_agents():

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

remove

Comment thread docs/algorithms.md

The default advantage is per-group reward minus per-group baseline (DR-GRPO without std normalization). For each prompt's group of `group_size` rollouts, every token in rollout $i$ receives advantage $s_i - \bar{s}$ where $\bar{s}$ is the group mean.

The group-relative algorithms (`grpo`, `max_rl`, `echo`) require the group's trainable traces to come from **one** agent — the baseline assumes exchangeable attempts by a single agent. Multi-agent envs work as long as exactly one agent is trainable (e.g. a trainable solver rewarded by a frozen agentic judge); a group spanning several trainable agent names is refused at scoring time. Credit assignment across multiple trainable agents is not something prime-rl prescribes — implement your own algorithm for it (see [Authoring an Algorithm](#authoring-an-algorithm)).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

do we have no such constraint for say opd?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

no, because for OPD, we just do a teacher prefill for each trainable trace

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants