-
Notifications
You must be signed in to change notification settings - Fork 363
feat: algorithm abstraction — named algorithm classes + inline frozen-model references (grpo, opd, sft_distill, self_distill, echo) #2746
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
7095694
feat(algo): rebase algorithm abstraction (#2746) onto verifiers-v1 (#…
hallerite d33b3f4
fix(algo): make sft teacher emit tokens + opd/opsd prefill use v1 client
hallerite 1f9e165
Merge origin/main into feat/algorithm-abstraction
hallerite 12e3f79
feat(echo): weight only message-body tokens via MessageNode.is_content
hallerite 740569b
refactor(orchestrator): dump rollouts via Trace.to_record(); bump ver…
hallerite 3cc1197
refactor(opd/opsd): prefill via a PrefillClient, drop the hand-rolled fn
hallerite 216fa7a
refactor(opd/opsd): build prefill clients once, tear down via Algorit…
hallerite 6330e9e
refactor(opd/opsd): unify prefill onto StaticInferencePool.score
hallerite 7a4a30d
fix(opd/opsd): prefill scoring works on any pool type; opsd reuses th…
hallerite 2cfca89
refactor(orchestrator): collapse RolloutView into Rollout
hallerite d75d274
Merge origin/main into feat/algorithm-abstraction
hallerite 1929312
Merge origin/main into feat/algorithm-abstraction
hallerite 81aa147
chore(algo): remove #2746-internal dead code + stale docs (#2879)
hallerite 5da0575
Merge origin/main into feat/algorithm-abstraction
hallerite a8dba67
chore(algo): remove unused reward algorithm (no-baseline REINFORCE)
hallerite 86dd8e9
chore(trainer): remove dead per-token reward stream from the training…
hallerite c804b54
chore(algo): final review pass — contract/doc alignment + latent fixes
hallerite 3cec13b
feat(algo): turn-agnostic opsd via prepended demo system block
hallerite 1ed9195
chore(algo): drop sft_distill_external debug config
hallerite 9df5977
docs(algo): fix configs skill for the no-advantage-layer API + output…
hallerite 55903ad
Merge branch 'main' into feat/algorithm-abstraction
hallerite c326868
refactor(orchestrator/algo): de-privilege references, inline advantag…
hallerite b392c78
refactor(orchestrator/algo): split host-owned policy pool from connec…
hallerite 13fe9ba
refactor(configs): rename *AlgorithmConfig -> *AlgoConfig
hallerite cf9a21a
refactor(orchestrator/algo): collapse to two scoring hooks; opsd toke…
hallerite f131199
refactor(orchestrator/algo): drop the opd/opsd scoring semaphore + ma…
hallerite 8a7af12
fix(ci): align reverse_text rl_opd/rl_sft smoke max_steps to 15
hallerite File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| # Algorithm — Debug Configs | ||
|
|
||
| Minimal end-to-end configs for the algorithms against bundled verifiers envs, using `PrimeIntellect/Qwen3-0.6B-Reverse-Text-SFT` as the policy. | ||
|
|
||
| | Config | Algorithm | Frozen model | Notes | | ||
| |---|---|---|---| | ||
| | `grpo.toml` | `grpo` | none | | | ||
| | `max_rl.toml` | `max_rl` | none | GRPO with mean-normalized advantages (maximum-likelihood RL) | | ||
| | `opd.toml` | `opd` | local vLLM (`Qwen3-0.6B-Reverse-Text-RL`) | | | ||
| | `opd_lora.toml` | `opd` | local vLLM (`Qwen3-0.6B-Reverse-Text-RL`) | trains a LoRA adapter (rank 8) | | ||
| | `sft_distill.toml` | `sft` | local vLLM (`Qwen3-0.6B-Reverse-Text-RL`) | | | ||
| | `sft_distill_lora.toml` | `sft` | local vLLM (`Qwen3-0.6B-Reverse-Text-RL`) | trains a LoRA adapter (rank 8) | | ||
| | `self_distill.toml` | `opsd` | none (self-distills against the live policy) | SDFT; demo from reverse-text's `answer` field | | ||
| | `echo.toml` | `echo` | none | multi-turn `alphabet-sort`; CE on observation tokens | | ||
| | `mixed_grpo_opd.toml` | `grpo` + `opd` (per env) | local vLLM (`Qwen3-0.6B-Reverse-Text-RL`) | two envs, one run; heterogeneous batches (with/without `ref_logprobs`) | | ||
|
|
||
| The policy inference server is auto-launched on GPU 0 at `http://localhost:8000/v1` with `gpu_memory_utilization=0.5`. The local frozen model (used by `opd*.toml`, `sft_distill.toml` / `sft_distill_lora.toml`, and `mixed_grpo_opd.toml`) is **not** auto-launched — start it manually on GPU 1. | ||
|
|
||
| Frozen models are declared inline on the algorithm, named where the model is used — `[orchestrator.algo.teacher]` for `opd`, `[orchestrator.algo.sampling.source]` for `sft` — with `name` + `base_url`. `opsd` declares none (it self-distills against the live policy). prime-rl never hosts them; only the trainable policy's server is managed by the `rl` entrypoint. | ||
|
|
||
| ## Start the local frozen model | ||
|
|
||
| Needed for `opd*.toml`, `sft_distill.toml` / `sft_distill_lora.toml`, and `mixed_grpo_opd.toml`: | ||
|
|
||
| ```bash | ||
| CUDA_VISIBLE_DEVICES=1 uv run inference \ | ||
| --model.name PrimeIntellect/Qwen3-0.6B-Reverse-Text-RL \ | ||
| --server.port 8001 \ | ||
| --gpu-memory-utilization 0.5 \ | ||
| --model.enforce-eager | ||
| ``` | ||
|
|
||
| ## Run the debug configs | ||
|
|
||
| Every config writes to the default `outputs/` directory, so running two back-to-back — or re-running one — fails with `FileExistsError`. Pass a distinct `--output-dir outputs/<algo>` per config (recommended for a sweep) or `--clean-output-dir` to wipe and restart. | ||
|
|
||
| ```bash | ||
| # GRPO (no frozen model) | ||
| uv run rl @ configs/debug/algorithms/grpo.toml --output-dir outputs/grpo | ||
|
|
||
| # MaxRL (no frozen model) | ||
| uv run rl @ configs/debug/algorithms/max_rl.toml --output-dir outputs/max_rl | ||
|
|
||
| # OPD (needs the frozen model on port 8001) | ||
| uv run rl @ configs/debug/algorithms/opd.toml --output-dir outputs/opd | ||
| uv run rl @ configs/debug/algorithms/opd_lora.toml --output-dir outputs/opd_lora | ||
|
|
||
| # SFT distillation (needs the frozen model on port 8001) | ||
| uv run rl @ configs/debug/algorithms/sft_distill.toml --output-dir outputs/sft_distill | ||
| uv run rl @ configs/debug/algorithms/sft_distill_lora.toml --output-dir outputs/sft_distill_lora | ||
|
|
||
| # Self-distillation against the live policy (no frozen model) | ||
| uv run rl @ configs/debug/algorithms/self_distill.toml --output-dir outputs/self_distill | ||
|
|
||
| # ECHO (no frozen model; multi-turn env) | ||
| uv run rl @ configs/debug/algorithms/echo.toml --output-dir outputs/echo | ||
|
|
||
| # Mixed per-env algorithms: GRPO + OPD in one run (needs the frozen model on port 8001) | ||
| uv run rl @ configs/debug/algorithms/mixed_grpo_opd.toml --output-dir outputs/mixed_grpo_opd | ||
| ``` | ||
|
|
||
| See [docs/algorithms.md](../../../docs/algorithms.md) for what each algorithm does and how to author your own. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| # ECHO on the multi-turn alphabet-sort env (bundled with verifiers): GRPO on | ||
| # action tokens + weighted CE on the env's observation tokens. | ||
| # uv run rl @ configs/debug/algorithms/echo.toml | ||
|
|
||
| max_steps = 20 | ||
| seq_len = 4096 | ||
|
|
||
| [model] | ||
| name = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-SFT" | ||
|
|
||
| [wandb] | ||
| project = "algorithms-debug" | ||
| name = "debug-echo" | ||
|
|
||
| [orchestrator] | ||
| batch_size = 32 | ||
| group_size = 4 | ||
|
|
||
| # alphabet-sort's feedback arrives as user messages, so train the user role | ||
| # instead of echo's tool default. | ||
| [orchestrator.algo] | ||
| type = "echo" | ||
|
|
||
| [orchestrator.algo.roles.user] | ||
| alpha = 0.1 | ||
|
|
||
| [[orchestrator.train.env]] | ||
| id = "alphabet-sort" | ||
| args = { min_turns = 3, max_turns = 5, power_per_turn = false } | ||
|
|
||
| [orchestrator.train.sampling] | ||
| max_completion_tokens = 512 | ||
|
|
||
| # ECHO learns from observation tokens even when the GRPO advantage collapses | ||
| # to zero — keep zero-advantage rollouts in the batch. | ||
| [[orchestrator.post_batch_filters]] | ||
| type = "zero_advantage" | ||
| enforce = false | ||
|
|
||
| # Qwen3 finetune with the standard PI template patch; always re-emits prior | ||
| # <think> blocks, matched by the qwen3 renderer's preserve_all_thinking. | ||
| [orchestrator.renderer] | ||
| name = "qwen3" | ||
| preserve_all_thinking = true | ||
|
|
||
| [trainer.optim] | ||
| lr = 1e-6 | ||
|
|
||
| [inference] | ||
| gpu_memory_utilization = 0.5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| max_steps = 20 | ||
| seq_len = 2048 | ||
|
|
||
| [model] | ||
| name = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-SFT" | ||
|
|
||
| [wandb] | ||
| project = "algorithms-debug" | ||
| name = "debug-max-rl" | ||
|
|
||
| [orchestrator] | ||
| batch_size = 128 | ||
| group_size = 16 | ||
|
|
||
| [orchestrator.algo] | ||
| type = "max_rl" | ||
|
|
||
| [orchestrator.renderer] | ||
| name = "qwen3" | ||
|
|
||
| [orchestrator.train.sampling] | ||
| max_completion_tokens = 128 | ||
|
|
||
| [[orchestrator.train.env]] | ||
| id = "reverse-text" | ||
|
|
||
| [orchestrator.eval] | ||
| interval = 1 | ||
| num_examples = 128 | ||
|
|
||
| [orchestrator.eval.sampling] | ||
| max_completion_tokens = 128 | ||
|
|
||
| [[orchestrator.eval.env]] | ||
| id = "reverse-text" | ||
|
|
||
| [trainer.optim] | ||
| lr = 3e-6 | ||
|
|
||
| [ckpt] | ||
|
|
||
| [inference] | ||
| gpu_memory_utilization = 0.5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.