Repository navigation
[rl] refactor alphabet-sort configs into examples/alphabet_sort - #3684
Conversation
73d7006 to
521f299
Compare
521f299 to
99e8f4b
Compare
felipemello1
left a comment
There was a problem hiding this comment.
looks good, lets just figure out where to put BatchInvariantFlexConverter
| _BATCH_INVARIANT_DEBUG = DebugConfig(batch_invariant=True, deterministic=True) | ||
|
|
||
|
|
||
| class BatchInvariantFlexConverter(ModelConfigConverter): |
There was a problem hiding this comment.
shouldnt this be shared by all configs?
| from torchtitan.experiments.rl.generator_router import ( | ||
| GeneratorRouter, | ||
| RoundRobinRoutingStrategy, | ||
| # Alphabet-sort example configs (the default GRPO smoke/debug recipe). |
There was a problem hiding this comment.
| # Alphabet-sort example configs (the default GRPO smoke/debug recipe). | |
| # Alphabet-sort example configs |
| # This source code is licensed under the BSD-style license found in the | ||
| # LICENSE file in the root directory of this source tree. | ||
|
|
||
| """Config entry points for the alphabet-sort example (the default GRPO recipe). |
There was a problem hiding this comment.
| """Config entry points for the alphabet-sort example (the default GRPO recipe). | |
| """Config entry points for the alphabet-sort example |
99e8f4b to
af6da39
Compare
There was a problem hiding this comment.
let's put it under rl/batch_invariance.py, and put these two method there too
https://github.com/pytorch/torchtitan/blob/main/torchtitan/experiments/rl/actors/generator.py#L442-L448
af6da39 to
8273ea8
Compare
| [ | ||
| [ | ||
| "--module rl", | ||
| "--module torchtitan.experiments.rl.examples.alphabet_sort", |
There was a problem hiding this comment.
Thanks, LGTM now. I'll make a PR to improve our life on this later.
There was a problem hiding this comment.
actually I saw the CI error.
The plan I had:
- Modify config/manager.py to search
--module alphabet_sortin torchtitan/experiments/rl/examples as well.
Maybe you can do it in this PR if it's blocking. Ping me for another look.
There was a problem hiding this comment.
yeah, lets leave that for next PR and I will fix the CI failure now first
Each example now owns its config_registry.py (matching search_r1), discovered via --module torchtitan.experiments.rl.examples.<name>. Move the nine alphabet-sort GRPO configs there and drop the central rl/config_registry.py aggregator; integration tests, README and generate.py use the full --module path now. Pull the batch-invariance helpers into rl/batch_invariance.py: the BatchInvariantFlexConverter (was inline in config_registry) plus patch_bmm_for_batch_invariance / force_logprobs_fn_for_batch_invariance (were in actors/generator.py), so any config — not just alphabet-sort — can reuse them.
8273ea8 to
e3d5a49
Compare
Follow-up to #3684. Now that each RL example owns its `config_registry` under `rl/examples/<name>`, running one meant typing the full `--module torchtitan.experiments.rl.examples.alphabet_sort`. This lets `ConfigManager` resolve the short name like it does for models/experiments. What changed: - `config/manager.py`: when resolving a short `--module` name, also search `torchtitan.experiments.rl.examples.<name>.config_registry` (after `torchtitan.models` and `torchtitan.experiments`). - `experiments/__init__.py`: register `alphabet_sort` and `search_r1` as supported shorthands. - Switch the integration tests, READMEs, `train`/example docs and `loss_compare.py` back to the short names (e.g. `--module alphabet_sort`). So `--module alphabet_sort --config rl_grpo_qwen3_0_6b_varlen` now works like `--module llama3`. Verified locally: - `--module llama3 --config llama3_debugmodel` still builds (no regression). - `--module alphabet_sort --config rl_grpo_qwen3_0_6b_varlen` and `--module search_r1 --config rl_grpo_qwen3_1_7b_search_r1` resolve and build. - unknown short name still errors, now listing the rl-examples search path. - added a CPU unit test for the shorthand registration (full resolution is exercised by the RL integration tests, which run `--module alphabet_sort` and pull in vLLM). cc @tianyu-l — this is the manager.py change you sketched.
Follow-up to Tianyu's note in #3602 (comment).
config_registry.pyhad collected all the alphabet-sort smoke/debug configs — the 0.6b/1.7b/14b GRPO recipes, the two batch-invariant variants, and theBatchInvariantFlexConverterthey share. That's example-specific code living in what's supposed to be a generic registry. search_r1 already keeps its configs underexamples/search_r1/config.pyand only re-imports them intoconfig_registrysoConfigManagercan find them via--config; this makes alphabet-sort do the same.What changed:
examples/alphabet_sort/config.pyholds the six config functions plus the converter/debug helpersconfig_registry.pyis now just two re-import blocks (alphabet-sort + search_r1)generate.py,test_generator.py,test_bitwise_parity.py) pull the functions from the example module instead ofconfig_registry--configon the CLI is unchanged:config_registrystill re-exports the names, sogetattr(config_registry, "rl_grpo_qwen3_0_6b_varlen")keeps working and the integration tests (tests/integration_tests.py) that pass--configstrings don't need touching.Pure move, no behavior change. Confirmed all six configs are still discoverable through
config_registryandpre-commitis clean.