Repository navigation
[rl] Add optional Verifiers rollout integration - #4356
Conversation
|
|
||
| @dataclass(kw_only=True, slots=True) | ||
| class Config(VerifiersRollouter.Config): | ||
| train_dataset: VerifiersTaskDataset.Config = field( |
There was a problem hiding this comment.
Dataset is defined through verifiers
762930e to
36c417d
Compare
| include = ["torchtitan*", "torchtitan_recipes*"] | ||
|
|
||
| [tool.setuptools.package-data] | ||
| "torchtitan.experiments.rl.examples.verifiers" = ["verifiers_env.toml"] |
There was a problem hiding this comment.
This is because when release, python packaging includes .py files automatically, but not .toml files. This will not make verifiers a hard dependency
There was a problem hiding this comment.
Maybe i am wrong, but this doesn't smell right. I will take a look at the .toml, but i wonder if theres a more elegant solution. If this is the only way, we should add a comment here on why we need it.
There was a problem hiding this comment.
The toml is consumed by Verifiers. The alternative is to translated into torchtitan VerifiersRollouter.Configs but the Verifiers has so many config fields which I just leave verifiers' config system as is
There was a problem hiding this comment.
strongly against this thing here, commented at https://github.com/pytorch/torchtitan/pull/4356/changes#r3919769394
|
not a review, just a general comment: Its unclear to me what the But it seems that you also need a If this example is about Also, it might be worth checking how other libraries integrate with verifiers. Example: https://github.com/thinking-machines-lab/tinker-cookbook/tree/main/tinker_cookbook/recipes/verifiers_rl |
In terms of folder organization, we are very similar. In-terms of integration point, I will take more look into details! |
felipemello1
left a comment
There was a problem hiding this comment.
partial review. I will finish it later.
| Note: Unified-model performance varies by model, input shape, and parallelism: it can trail native vLLM in inference-only workloads but outperform it end to end in some RL configurations. Batch invariance trades throughput for exact numerics and can be used for debugging or controlled on-policy studies. | ||
|
|
||
| [Architecture](#architecture) · [Write an experiment](#write-an-experiment) · [DAPO Math](./examples/dapo_math) · [Observability](#observability) · [Quick Start](#quick-start) | ||
| [Architecture](#architecture) · [Write an experiment](#write-an-experiment) · [DAPO Math](./examples/dapo_math) · [Verifiers](./examples/verifiers) · [Observability](#observability) · [Quick Start](#quick-start) |
There was a problem hiding this comment.
are you proposing that we delete dapo_math based on our Rollouter and keep only the verifiers-based one? I am not sure i 100% agree with it. What were your thoughts when you decided that?
There was a problem hiding this comment.
No, I want to keep both. Verifiers examples is trying to not emphasis on DAPO math , but just as an example for verifiers. The DAPO-math is the official support we have, which is a stand-alone task we used for stress-testing our RL and verifiers-free.
| from transformers import AutoTokenizer | ||
|
|
||
| tokenizer = AutoTokenizer.from_pretrained(tokenizer_path) | ||
| return create_renderer(tokenizer, self.as_renderers_config()) |
There was a problem hiding this comment.
why did you have to change it? Also, apparently there are some issues renderers. I am working on it, then lets rebase #4365
There was a problem hiding this comment.
Sounds good, let me rebase later
| include = ["torchtitan*", "torchtitan_recipes*"] | ||
|
|
||
| [tool.setuptools.package-data] | ||
| "torchtitan.experiments.rl.examples.verifiers" = ["verifiers_env.toml"] |
There was a problem hiding this comment.
Maybe i am wrong, but this doesn't smell right. I will take a look at the .toml, but i wonder if theres a more elegant solution. If this is the only way, we should add a comment here on why we need it.
There was a problem hiding this comment.
the math-verify is specific to DAPO math. Lets make sure to distinguish it.
| # Unused because this class replaces the base rollout-worker execution path. | ||
| worker: RolloutWorker.Config | None = None |
There was a problem hiding this comment.
Lets make this clearer. Also, i think that in Torchtitan, the standard is to have:
arg1: Blablabla
"""description arg1"""
is this true?
| rubric: Rubric.Config | ||
| # Converts sibling rollout rewards into training advantages. | ||
| advantage: Configurable.Config = field( | ||
| default_factory=AdvantageEstimator.Config | ||
| ) |
There was a problem hiding this comment.
why would we need it if we are already inheriting it from Rollouter.Config?
| def pop_generation_metadata(self, session_id: str) -> list[GenerationMetadata]: | ||
| """Remove and return generation metadata recorded for one rollout.""" | ||
| self.turn_counts.pop(session_id, None) | ||
| return self.generation_metadata.pop(session_id, []) |
There was a problem hiding this comment.
it sounds like this should live in trace_to_rollout_turns
| os.environ["NO_PROXY"] = no_proxy | ||
|
|
||
| with open(config_path, "rb") as file: | ||
| data = tomllib.load(file) |
There was a problem hiding this comment.
I don't think verifiers is consuming toml, it's consuming this dictionary / dataclass.
There was a problem hiding this comment.
I see, I checked verifiers they used toml as their config examples, but consumes a dictionary and translate into a config dataclass. I'm originally lean toward toml to let user use the same toml config directly from verifiers.
The alternative is to import Verifiers 's config dataclass, and baked into our components class. This should also be easy to achieved by users if they need to depend on more config dataclass from verifiers. The PR is updated
| include = ["torchtitan*", "torchtitan_recipes*"] | ||
|
|
||
| [tool.setuptools.package-data] | ||
| "torchtitan.experiments.rl.examples.verifiers" = ["verifiers_env.toml"] |
There was a problem hiding this comment.
strongly against this thing here, commented at https://github.com/pytorch/torchtitan/pull/4356/changes#r3919769394
There was a problem hiding this comment.
maybe should be in its own folder
There was a problem hiding this comment.
Sg, I'm moving it to examples/verifiers/dapo_math
| dataset: Literal["dapo_math", "aime2025"] = "dapo_math" | ||
|
|
||
|
|
||
| class VerifiersMathTaskset(vf.Taskset[VerifiersMathTask, VerifiersMathTasksetConfig]): |
There was a problem hiding this comment.
Becuase Verifiers doesn't have an existing DAPO-math dataset, so this is needed to bridge our dataset to be verifier's taskset. I think this is also useful for other tasks and serves as an example for user who brings their own dataset
|
|
||
| """Register TorchTitan's DAPO-Math and AIME datasets with Verifiers. | ||
|
|
||
| Verifiers 0.3.0 does not provide a v1 taskset for these datasets. This module |
There was a problem hiding this comment.
what's the relationship of 0.3.0 vs. v1? Shouldn't we use the latest verifiers?
There was a problem hiding this comment.
0.3.0 is their release number, the latest is 0.3.1 which is just release.
v1 vs v0 is their versioning of the their core source code (like vllm V1 engine), v1 is a rewrite version and v0 is the legacy version
b315a41 to
07a24ec
Compare
tianyu-l
left a comment
There was a problem hiding this comment.
Great work!
Please address remaining comments, including the ones I left in last round of review, e.g. making naming consistent (like data.py)
There was a problem hiding this comment.
I couldn't see the size of the img, but please make sure it's not too big e.g. > 1MB
There was a problem hiding this comment.
hey, thank you so much for this PR! Its not easy to add integrations.
I am leaving a lot of comments, sorry. However, there are very few things i would consider a hard blocker. Please, use your own judgment to prioritize. Feel free to leave TODOs. You don't have to act on every comment.
If i had to summarize: I know TitanRL pretty well, and when reading this integration, i got a bit lost/overwhelmed, because now i need to know: TitanRL + verifiers + verifiers/components + verifiers/dapo_math.
This scares me a bit.
I think that can/should simplify some parts/knobs and make some parts more explicit/obvious. Using the skill I shared to add a few comments in long functions + examples in docstrings can go a long way.
Again: please don't treat every comment as a must-fix
| return RolloutStatus.TRUNCATED_LENGTH | ||
|
|
||
| @staticmethod | ||
| def trace_to_rollout_turns( |
There was a problem hiding this comment.
could you please ask Sol to compare the logged rollout of dapo_math of verifiers vs titanRL, just as a sanity check? i.e. inspect the rollout structure.
There was a problem hiding this comment.
in terms of statistics:
- Both 100-step H100 runs completed:
Rollout check:
- Same top-level and turn schemas.
- All 402 shared groups had identical prompt_token_ids.
- All rollouts were single-turn.
- Completion token/log-prob lengths matched.
- No rollout errors.
- Truncation status matched the 2,048-token limit.
- Verifiers rewards propagated correctly through env_rewards.verifiers_reward.
And I checked some generation examples, both seems coherent and reasonable
ecc037c to
3407a0c
Compare
Summary
verifiersexample that reuses the DAPO Math dataset and training setup while delegating episode execution and reward calculation to Verifiers.verifiers.nullharness with a local subprocess runtime. No Docker or remote sandbox is required, and no tools are exposed to the model.dapo_mathimplementation unchanged as the native comparison path.The example can be launched with:
100-step comparison
Both runs loaded Qwen3-4B-Base from the same HF checkpoint on four H100 GPUs and used identical overrides:
The table reports the mean across all 100 W&B training steps unless otherwise noted.
dapo_mathverifiersThe 2 DAPO math run shows similar reward and rollout:
