Skip to content

refactor(algo): declare action_loss_type once on the config; drop finalize_group - #3845

Merged
samsja merged 1 commit into
mainfrom
refactor/algo-action-loss-type
Oct 4, 2026
Merged

samsja merged 1 commit into
mainfrom
refactor/algo-action-loss-type

Conversation

@faresobeid

@faresobeid faresobeid commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Two small cleanups in orchestrator/algo/. Item 4 of the orchestrator review.

  • action_loss_type is now declared once, on the algorithm config classes. Before, it was declared on the config classes and again on the runtime classes (algo/base.py, sft.py, opd.py, opsd.py), and build_algorithm asserted that the two agreed. Now Algorithm.__init__ copies it from the config, so train_sink's env.algorithm.action_loss_type is unchanged.
  • Algorithm.finalize_group is removed. It only called score_group, and train_sink now calls score_group directly. finalize_episode is kept: its "has sampled tokens" guard matters for echo, whose score_episode does not filter on the mask.
  • docs/algorithms.md is updated to match.

Behavior change: none. Every algorithm type gets the same loss routing as before, because the old assert guaranteed that the config and runtime values were equal.

Checks

  • pytest tests/unit/orchestrator tests/unit/test_configs* -m "not gpu": 291 passed (test_algorithms covers the per-type action_loss_type).
  • ruff check, ruff format --check: clean.

GPU checks: none needed.

Conflicts

algo/base.py and algo/__init__.py: #3802, #3803 (small). #3838 (fold GenerationSource) also edits algo/base.py and algo/__init__.py (connect_frozen_client), which needs a trivial rebase. train_sink.py:245: #3652 rewrites train_sink.py (a one-line change there).


Note

Low Risk
Refactor-only: loss routing and group scoring call paths are unchanged in effect; no auth, data, or trainer hot-path logic changes.

Overview
Single source of truth for loss routing: runtime Algorithm instances now take action_loss_type from the algorithm config in __init__ instead of duplicating it on each subclass and asserting agreement in build_algorithm. Per-algorithm class variables on OPD, OPSD, and SFT are removed; train_sink still reads env.algorithm.action_loss_type when stamping samples.

Thinner scoring API: Algorithm.finalize_group is dropped and the train sink calls score_group directly when a group has trainable survivors. finalize_episode remains as the guarded entry point for rollout-local score_episode (skips episodes with no trainable sampled tokens).

Docs: algorithms.md is updated to describe this pipeline wiring and config-owned action_loss_type.

No intended training behavior change—loss routing values are the same as before when config and runtime matched.

Reviewed by Cursor Bugbot for commit 1ebee7f. Bugbot is set up for automated code reviews on this repo. Configure here.

@faresobeid
faresobeid marked this pull request as ready for review October 4, 2026 12:30
@samsja samsja closed this Oct 4, 2026
@faresobeid faresobeid reopened this Oct 4, 2026
@samsja
samsja merged commit 407e8ba into main Oct 4, 2026
21 of 38 checks passed
@samsja
samsja deleted the refactor/algo-action-loss-type branch October 4, 2026 23:56
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