Repository navigation
[rl] PR 1/N - rollout logger - #3581
Conversation
There was a problem hiding this comment.
I wonder if there's anything shareable between this any observability work? It sounds similar in the sense of gathering some data and publish to JSONL for someone to consume.
It seems useful and arbitrary at the same time, in the sense that today I can have RolloutLogger, tomorrow someone else can do EpisodeLogger, etc.
There was a problem hiding this comment.
TBR doesn't mix the two. They also have a dedicated rollout logger. This is very simple:
- It is not intended to be a perfetto trace full of metadata
- It is not per-rank
- Not a decorator or context manager
Its just a dump of collected data. They don't even have a filter. They just dump everything. Search for 'ScubaLikeFuseRecorder'
If people go crazy and want to have an EpisodeLogger, we refactor. Wdyt?
There was a problem hiding this comment.
It seems they introduced a recorder list hosting all sorts of loggers, which makes it look less arbitrary. Maybe let's focus on other development and revisit this later, if it's not blocking?
There was a problem hiding this comment.
its very helpful to inspect the rollouts during the debugging (i used it many times). I would rather land it and revisit for a better abstraction later. Happy to add a #TODO.
It is much less harmful than the structured logger, since it runs only on the controller.
There was a problem hiding this comment.
OK, please leave a TODO to consider generalizing this to a list of recorders
tianyu-l
left a comment
There was a problem hiding this comment.
please address my nit comments.
| from torchtitan.experiments.rl.rollout import Rollout, RolloutGroup | ||
| from torchtitan.observability import structured_logger as sl | ||
|
|
||
| _FILENAME = "rollout_samples.jsonl" |
There was a problem hiding this comment.
maybe make configurable in rollout logger
| if not config.log_tensors: | ||
| self._fields_to_not_log |= {"prompt_token_ids", "completion_token_ids"} | ||
| if not config.log_logprobs: | ||
| self._fields_to_not_log |= {"completion_logprobs"} |
There was a problem hiding this comment.
this is anti-human, use _fields_to_log
|
|
||
| @dataclass(kw_only=True, slots=True) | ||
| class Config(Configurable.Config): | ||
| rollout_filter: FilterExtremeRewards.Config = field( |
There was a problem hiding this comment.
| rollout_filter: FilterExtremeRewards.Config = field( | |
| filter: FilterExtremeRewards.Config = field( |
| _FILENAME = "rollout_samples.jsonl" | ||
|
|
||
|
|
||
| class FilterExtremeRewards(Configurable): |
There was a problem hiding this comment.
FilterExtremeRewards sounds "filtering out" extreme rewards; consider renaming, maybe KeepExtremeRewardsFilter
There was a problem hiding this comment.
OK, please leave a TODO to consider generalizing this to a list of recorders
| return picked | ||
|
|
||
|
|
||
| class RolloutSampleLogger(Configurable): |
There was a problem hiding this comment.
maybe can use
| class RolloutSampleLogger(Configurable): | |
| class RolloutSampleRecorder(Configurable): |
to mentally separate from the already several loggers.
7cf31aa to
356e67b
Compare
6318a9d to
38df098
Compare
**Note**: Rebased on top of #3581. It also contains the `RolloutLogger` because of that. I added `AlphabetSort`, a task that works for single or multiturn, where the model is given names on each turn and is asked to sort a list by either first or last name. This is challenging because the model doesn't see characters. It sees tokens. The rewards start low and gradually grow, which is exactly what we need as a toy task. Our current 'SumDigits' gets 100% accuracy by qwen before any training. Since it is not helpful, i deleted it. ``` { "step": 0, "is_validation": true, "group_id": "step=0/group=3", "sample_id": "step=0/group=3/sample=0", "turns": [ { "policy_version": 0, "prompt_messages": [ { "role": "user", "content": "Sort these names in alphabetical order by FIRST name: PietroRigo, LaurentChapon, FedericoLevi, UriLerner\n\nUse exactly this format:\n<alphabetical_sorted>\nName1\nName2\n</alphabetical_sorted>" } ], "completion_message": { "role": "assistant", "content": "<alphabetical_sorted>\nFedericoLevi\nLaurentChapon\nPietroRigo\nUriLerner\n</alphabetical_sorted>" }, "env_messages": [], "env_rewards": {} } ], "status": "completed", "reward": 1.0, "reward_breakdown": { "RewardAlphabetSort": 1.0 }, "advantage": null } ``` <img width="898" height="559" alt="image" src="https://github.com/user-attachments/assets/089d3c09-d58e-4dd8-ae33-43a950a71e3c" /> Co-authored-by: Felipe Mello <[email protected]>
Adds a rollout logger. It takes a list[RolloutGroup], filter based on
some given callable, and logs them to json in outputdir.
It is helpful to inspect data and debug.
```
{"step": 0, "is_validation": true, "group_id": "step=0/group=18", "sample_id": "step=0/group=18/sample=0", "turns": [{"policy_version": 0, "prompt_messages": [{"role": "system", "content": "You are a helpful assistant. Solve the problem step by step.\nWhen you have your final answer, state it as [ANSWER] <number>.\n\nExample:\nUser: What is the total digit sum of [12, 345, 67]?\nAssistant: Break each number into digits:\n12 -> 1, 2\n345 -> 3, 4, 5\n67 -> 6, 7\nSum all digits: 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28\n[ANSWER] 28"}, {"role": "user", "content": "What is the total digit sum of [70, 97]?"}], "completion_message": {"role": "assistant", "content": "[ANSWER] 23", "reasoning_content": "Okay, let's see. The user is asking for the total digit sum of the numbers [70, 97]. Hmm, digit sum means adding all the individual digits together. Let me break it down step by step.\n\nFirst, take the first number, which is 70. The digits here are 7 and 0. So I need to add 7 and 0. That gives me 7.\n\nNext, the second number is 97. The digits are 9 and 7. Adding those together, 9 plus 7 equals 16. \n\nNow, I need to add the results from both numbers. So 7 plus 16. Let me do that calculation. 7 + 16 is 23. \n\nWait, let me double-check to make sure I didn't make a mistake. The first number is 70, digits 7 and 0. Sum is 7. Second number 97, digits 9 and 7. Sum is 16. Total is 7 + 16 = 23. Yeah, that seems right. So the answer should be 23."}, "env_messages": [], "env_rewards": {}}], "status": "completed", "reward": 0.9999999999999999, "reward_breakdown": {"RewardCorrect": 1.0, "RewardFormat": 1.0}, "advantage": null}
{"step": 0, "is_validation": true, "group_id": "step=0/group=19", "sample_id": "step=0/group=19/sample=0", "turns": [{"policy_version": 0, "prompt_messages": [{"role": "system", "content": "You are a helpful assistant. Solve the problem step by step.\nWhen you have your final answer, state it as [ANSWER] <number>.\n\nExample:\nUser: What is the total digit sum of [12, 345, 67]?\nAssistant: Break each number into digits:\n12 -> 1, 2\n345 -> 3, 4, 5\n67 -> 6, 7\nSum all digits: 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28\n[ANSWER] 28"}, {"role": "user", "content": "What is the total digit sum of [20, 64, 90]?"}], "completion_message": {"role": "assistant", "content": "[ANSWER] 21", "reasoning_content": "Okay, let's see. The user wants the total digit sum of the numbers [20, 64, 90]. Hmm, digit sum means adding all the individual digits together. Let me break it down step by step.\n\nFirst, take the first number, 20. The digits here are 2 and 0. Adding those gives 2 + 0 = 2.\n\nNext, the second number is 64. The digits are 6 and 4. Adding them gives 6 + 4 = 10.\n\nThen, the third number is 90. The digits are 9 and 0. Adding those gives 9 + 0 = 9.\n\nNow, I need to add all these results together: 2 + 10 + 9. Let me do that calculation. 2 plus 10 is 12, and 12 plus 9 is 21. So the total digit sum should be 21.\n\nWait, let me double-check to make sure I didn't make any mistakes. For 20, yes, 2 and 0. 64 is 6 and 4. 90 is 9 and 0. Adding them all: 2 + 10 + 9. Yep, that's 21. I think that's correct."}, "env_messages": [], "env_rewards": {}}], "status": "completed", "reward": 0.9999999999999999, "reward_breakdown": {"RewardCorrect": 1.0, "RewardFormat": 1.0}, "advantage": null}
{"step": 1, "is_validation": false, "group_id": "step=1/group=0", "sample_id": "step=1/group=0/sample=0", "turns": [{"policy_version": 0, "prompt_messages": [{"role": "system", "content": "You are a helpful assistant. Solve the problem step by step.\nWhen you have your final answer, state it as [ANSWER] <number>.\n\nExample:\nUser: What is the total digit sum of [12, 345, 67]?\nAssistant: Break each number into digits:\n12 -> 1, 2\n345 -> 3, 4, 5\n67 -> 6, 7\nSum all digits: 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28\n[ANSWER] 28"}, {"role": "user", "content": "What is the total digit sum of [24, 13, 45, 41]?"}], "completion_message": {"role": "assistant", "content": "[ANSWER] 24", "reasoning_content": "Okay, let's see. The user wants the total digit sum of the numbers [24, 13, 45, 41]. Hmm, I need to break each number into its individual digits and then add them up. Let me start with the first number, 24. The digits here are 2 and 4. So that's 2 + 4 = 6. \n\nNext is 13. The digits are 1 and 3. Adding those together gives 1 + 3 = 4. \n\nThen there's 45. The digits are 4 and 5. So 4 + 5 = 9. \n\nLastly, 41. The digits are 4 and 1. Adding them again, 4 + 1 = 5. \n\nNow I need to add all these results together: 6 (from 24) + 4 (from 13) + 9 (from 45) + 5 (from 41). Let me do that step by step. 6 + 4 is 10, plus 9 makes 19, and then adding 5 brings it to 24. Wait, but let me check again to make sure I didn't make a mistake. \n\nFirst number: 2 and 4 \u2192 6. Second: 1 and 3 \u2192 4. Third: 4 and 5 \u2192 9. Fourth: 4 and 1 \u2192 5. Adding them all: 6 + 4 = 10, 10 + 9 = 19, 19 + 5 = 24. So the total digit sum should be 24. \n\nI think that's right. Let me just confirm once more. Yeah, 2+4=6, 1+3=4, 4+5=9, 4+1=5. Sum is 6+4+9+5. Yep, 24. So the answer is 24."}, "env_messages": [], "env_rewards": {}}], "status": "completed", "reward": 0.9999999999999999, "reward_breakdown": {"RewardCorrect": 1.0, "RewardFormat": 1.0}, "advantage": 0.0}
{"step": 1, "is_validation": false, "group_id": "step=1/group=0", "sample_id": "step=1/group=0/sample=7", "turns": [{"policy_version": 0, "prompt_messages": [{"role": "system", "content": "You are a helpful assistant. Solve the problem step by step.\nWhen you have your final answer, state it as [ANSWER] <number>.\n\nExample:\nUser: What is the total digit sum of [12, 345, 67]?\nAssistant: Break each number into digits:\n12 -> 1, 2\n345 -> 3, 4, 5\n67 -> 6, 7\nSum all digits: 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28\n[ANSWER] 28"}, {"role": "user", "content": "What is the total digit sum of [24, 13, 45, 41]?"}], "completion_message": {"role": "assistant", "content": "[ANSWER] 24", "reasoning_content": "Okay, let's see. The user wants the total digit sum of the numbers [24, 13, 45, 41]. Hmm, digit sum means adding all the individual digits together. Let me break it down step by step.\n\nFirst, take each number and separate its digits. Starting with 24: 2 and 4. Then 13: 1 and 3. Next, 45: 4 and 5. Finally, 41: 4 and 1. \n\nNow I need to add all these digits together. Let me write them out:\n\n2 + 4 = 6\n\n1 + 3 = 4\n\n4 + 5 = 9\n\n4 + 1 = 5\n\nNow summing all those results: 6 + 4 is 10, plus 9 gives 19, and then adding 5 makes 24. So the total digit sum should be 24. Wait, let me check again to make sure I didn't mix any numbers. The numbers are 24, 13, 45, 41. Yes, each has two digits. So adding them all gives 2+4+1+3+4+5+4+1. Let me compute that again:\n\n2+4 is 6, 1+3 is 4, 4+5 is 9, 4+1 is 5. Total is 6+4=10, 10+9=19, 19+5=24. Yep, that seems right. I think the answer is 24."}, "env_messages": [], "env_rewards": {}}], "status": "completed", "reward": 0.9999999999999999, "reward_breakdown": {"RewardCorrect": 1.0, "RewardFormat": 1.0}, "advantage": 0.0}
{"step": 1, "is_validation": false, "group_id": "step=1/group=1", "sample_id": "step=1/group=1/sample=3", "turns": [{"policy_version": 0, "prompt_messages": [{"role": "system", "content": "You are a helpful assistant. Solve the problem step by step.\nWhen you have your final answer, state it as [ANSWER] <number>.\n\nExample:\nUser: What is the total digit sum of [12, 345, 67]?\nAssistant: Break each number into digits:\n12 -> 1, 2\n345 -> 3, 4, 5\n67 -> 6, 7\nSum all digits: 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28\n[ANSWER] 28"}, {"role": "user", "content": "What is the total digit sum of [27, 23]?"}], "completion_message": {"role": "assistant", "content": "<think>\nOkay, let's see. The user wants the total digit sum of the numbers [27, 23]. Hmm, first, I need to break down each number into their individual digits. \n\nStarting with 27. The digits here are 2 and 7. So I add 2 and 7. Then for the second number, 23, the digits are 2 and 3. Adding those together, 2 + 3. \n\nWait, let me check again. Is there any trick here? Like, maybe leading zeros? But the numbers given are 27 and 23, which don't have leading zeros. So no, I don't need to adjust anything. \n\nAdding 2 + 7 equals 9, and 2 + 3 equals 5. Then adding those two results: 9 + 5 equals 14. But wait, the question says \"total digit sum\". Does that mean the sum of all digits in both numbers? So yes, 2 + 7 + 2 + 3. Which is 12. Wait, but when I broke it down, I added each digit separately and then added the sums. So 2+7=9 and 2+3=5. So total is 14. \n\nWait, but the user wrote [27, 23]. Maybe they want the sum of each digit in each number? So 2 + 7 + 2 + 3. Which is 12. But why did I get 9+5 before? Because I thought each number's digits are added. Wait, maybe I confused the two ways. Let me confirm. \n\nIf the numbers are [27, 23], then each number has two digits. So adding each digit from each number. So 2 (from 27) + 7 (from 27) + 2 (from 23) + 3 (from 23). That's 12. So the total digit sum is 12. \n\nBut earlier, when I broke each number into digits and added them separately, I got 9 and 5. Then adding them would be 14. Wait, that's conflicting. What's the correct approach here? \n\nAh, no, the correct approach is to add all the individual digits. So for 27, the digits are 2 and 7, and for 23, digits are 2 and 3. So adding all digits together: 2 + 7 + 2 + 3. Which is 12. So that's the answer. But why did I get confused earlier? Because I thought each number's digits are added, but that's the same as adding all digits together. \n\nSo the answer should be 12. But let me check again. Let's add 2 + 7 first: 9. Then 2 + 3 is 5. 9 + 5 is 14. Wait, but that's adding each digit of 27 and each digit of 23. Wait, 2 and 7 from 27, and 2 and 3 from 23. So adding 2+7+2+3=12. So why did I think 9+5 before? Because I"}, "env_messages": [], "env_rewards": {}}], "status": "truncated_length", "reward": 0.0, "reward_breakdown": {"RewardCorrect": 0.0, "RewardFormat": 0.0}, "advantage": -0.8749999999999999}
{"step": 1, "is_validation": false, "group_id": "step=1/group=1", "sample_id": "step=1/group=1/sample=7", "turns": [{"policy_version": 0, "prompt_messages": [{"role": "system", "content": "You are a helpful assistant. Solve the problem step by step.\nWhen you have your final answer, state it as [ANSWER] <number>.\n\nExample:\nUser: What is the total digit sum of [12, 345, 67]?\nAssistant: Break each number into digits:\n12 -> 1, 2\n345 -> 3, 4, 5\n67 -> 6, 7\nSum all digits: 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28\n[ANSWER] 28"}, {"role": "user", "content": "What is the total digit sum of [27, 23]?"}], "completion_message": {"role": "assistant", "content": "[ANSWER] 14", "reasoning_content": "Okay, let's see. The user is asking for the total digit sum of the numbers [27, 23]. First, I need to break down each number into its individual digits. So, starting with 27. The digits here are 2 and 7. Then, the second number is 23, which has digits 2 and 3. \n\nNow, I should add all these individual digits together. Let me check again. For 27, the digits are 2 and 7. For 23, it's 2 and 3. Adding them all: 2 + 7 is 9, and 2 + 3 is 5. Adding those two results, 9 + 5 equals 14. \n\nWait, but I should make sure I'm not missing any digits. Let me confirm once more. 27 is two digits, so only the first and second digits. 23 is also two digits. So yes, 2 + 7 and 2 + 3. Adding them gives 14. Therefore, the total digit sum should be 14. \n\nHmm, I think that's correct. No other digits to consider here. The answer should be 14."}, "env_messages": [], "env_rewards": {}}], "status": "completed", "reward": 0.9999999999999999, "reward_breakdown": {"RewardCorrect": 1.0, "RewardFormat": 1.0}, "advantage": 0.125}
{"step": 1, "is_validation": false, "group_id": "step=1/group=2", "sample_id": "step=1/group=2/sample=0", "turns": [{"policy_version": 0, "prompt_messages": [{"role": "system", "content": "You are a helpful assistant. Solve the problem step by step.\nWhen you have your final answer, state it as [ANSWER] <number>.\n\nExample:\nUser: What is the total digit sum of [12, 345, 67]?\nAssistant: Break each number into digits:\n12 -> 1, 2\n345 -> 3, 4, 5\n67 -> 6, 7\nSum all digits: 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28\n[ANSWER] 28"}, {"role": "user", "content": "What is the total digit sum of [79, 21, 85, 64]?"}], "completion_message": {"role": "assistant", "content": "[ANSWER] 42", "reasoning_content": "Okay, let's see. I need to find the total digit sum of the numbers in the list [79, 21, 85, 64]. Hmm, digit sum means adding all the individual digits together. Let me take each number one by one.\n\nFirst number is 79. The digits here are 7 and 9. So 7 + 9 equals 16.\n\nNext number is 21. The digits are 2 and 1. Adding those gives 2 + 1 = 3.\n\nThird number is 85. The digits are 8 and 5. Summing them gives 8 + 5 = 13.\n\nFourth number is 64. The digits are 6 and 4. Adding those together is 6 + 4 = 10.\n\nNow, I need to add all these results together: 16 + 3 + 13 + 10. Let me do the math step by step. 16 plus 3 is 19, then 19 plus 13 is 32, and 32 plus 10 is 42. So the total digit sum should be 42.\n\nWait, let me double-check. 79 is 7+9=16, 21 is 3, 85 is 13, and 64 is 10. Yep, 16+3=19, 19+13=32, 32+10=42. That seems right. I don't think I made any mistakes here. The answer should be 42."}, "env_messages": [], "env_rewards": {}}], "status": "completed", "reward": 0.9999999999999999, "reward_breakdown": {"RewardCorrect": 1.0, "RewardFormat": 1.0}, "advantage": 0.0}
{"step": 1, "is_validation": false, "group_id": "step=1/group=2", "sample_id": "step=1/group=2/sample=7", "turns": [{"policy_version": 0, "prompt_messages": [{"role": "system", "content": "You are a helpful assistant. Solve the problem step by step.\nWhen you have your final answer, state it as [ANSWER] <number>.\n\nExample:\nUser: What is the total digit sum of [12, 345, 67]?\nAssistant: Break each number into digits:\n12 -> 1, 2\n345 -> 3, 4, 5\n67 -> 6, 7\nSum all digits: 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28\n[ANSWER] 28"}, {"role": "user", "content": "What is the total digit sum of [79, 21, 85, 64]?"}], "completion_message": {"role": "assistant", "content": "[ANSWER] 42", "reasoning_content": "Okay, let me try to figure out the total digit sum of the numbers [79, 21, 85, 64]. Hmm, digit sum means adding up each individual digit of each number. So I need to break down each number into its digits and then add them all together.\n\nFirst, let's take each number one by one. Starting with 79. The digits are 7 and 9. So adding those together gives 7 + 9 = 16. Then the next number is 21. The digits here are 2 and 1. Adding those gives 2 + 1 = 3. \n\nMoving on to 85. The digits are 8 and 5. Adding them gives 8 + 5 = 13. Finally, the last number is 64. The digits are 6 and 4. Adding those gives 6 + 4 = 10. \n\nNow, I need to add all these results together: 16 (from 79) + 3 (from 21) + 13 (from 85) + 10 (from 64). Let me do the math step by step. 16 + 3 is 19, then 19 + 13 is 32, and 32 + 10 is 42. \n\nWait, let me double-check to make sure I didn't make a mistake. For 79, 7 + 9 = 16. Correct. 21 is 2 + 1 = 3. 85 is 8 + 5 = 13. 64 is 6 + 4 = 10. Adding them all: 16 + 3 is 19, plus 13 makes 32, plus 10 is 42. That seems right. So the total digit sum should be 42. \n\nBut just to confirm, maybe I should write down each step again. Starting with 79: 7 + 9 = 16. 21: 2 + 1 = 3. 85: 8 + 5 = 13. 64: 6 + 4 = 10. Then 16 + 3 = 19, 19 + 13 = 32, 32 + 10 = 42. Yep, that's correct. So the answer should be 42."}, "env_messages": [], "env_rewards": {}}], "status": "completed", "reward": 0.9999999999999999, "reward_breakdown": {"RewardCorrect": 1.0, "RewardFormat": 1.0}, "advantage": 0.0}
{"step": 1, "is_validation": false, "group_id": "step=1/group=3", "sample_id": "step=1/group=3/sample=0", "turns": [{"policy_version": 0, "prompt_messages": [{"role": "system", "content": "You are a helpful assistant. Solve the problem step by step.\nWhen you have your final answer, state it as [ANSWER] <number>.\n\nExample:\nUser: What is the total digit sum of [12, 345, 67]?\nAssistant: Break each number into digits:\n12 -> 1, 2\n345 -> 3, 4, 5\n67 -> 6, 7\nSum all digits: 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28\n[ANSWER] 28"}, {"role": "user", "content": "What is the total digit sum of [13, 21]?"}], "completion_message": {"role": "assistant", "content": "[ANSWER] 7", "reasoning_content": "Okay, let's see. The user is asking for the total digit sum of the numbers [13, 21]. Hmm, digit sum means adding all the individual digits together. Let me break it down step by step.\n\nFirst, take each number in the list and split them into individual digits. The first number is 13. The digits here are 1 and 3. The second number is 21, so its digits are 2 and 1. \n\nNow, I need to add all these digits together. Let me write that out: 1 + 3 + 2 + 1. Let's do the math. Starting with 1 plus 3, that's 4. Then adding 2 gives 6, and then adding 1 more gives 7. So the total digit sum should be 7. \n\nWait, let me double-check to make sure I didn't mix any numbers. The original list is [13, 21], so yes, splitting into 1,3 and 2,1. Adding them all gives 7. I think that's correct. The answer should be 7."}, "env_messages": [], "env_rewards": {}}], "status": "completed", "reward": 0.9999999999999999, "reward_breakdown": {"RewardCorrect": 1.0, "RewardFormat": 1.0}, "advantage": 0.0}
{"step": 1, "is_validation": false, "group_id": "step=1/group=3", "sample_id": "step=1/group=3/sample=7", "turns": [{"policy_version": 0, "prompt_messages": [{"role": "system", "content": "You are a helpful assistant. Solve the problem step by step.\nWhen you have your final answer, state it as [ANSWER] <number>.\n\nExample:\nUser: What is the total digit sum of [12, 345, 67]?\nAssistant: Break each number into digits:\n12 -> 1, 2\n345 -> 3, 4, 5\n67 -> 6, 7\nSum all digits: 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28\n[ANSWER] 28"}, {"role": "user", "content": "What is the total digit sum of [13, 21]?"}], "completion_message": {"role": "assistant", "content": "[ANSWER] 7", "reasoning_content": "Okay, let's see. The user wants the total digit sum of the numbers [13, 21]. Hmm, digit sum means I need to add up all the individual digits of each number. Let me break it down.\n\nFirst number is 13. The digits here are 1 and 3. Adding those gives 1 + 3 = 4. \n\nThen the second number is 21. The digits are 2 and 1. Adding those together gives 2 + 1 = 3. \n\nNow I need to add those two results: 4 + 3 = 7. \n\nWait, let me double-check. 13 is 1+3=4, and 21 is 2+1=3. Yes, 4+3=7. So the total digit sum should be 7. I think that's right."}, "env_messages": [], "env_rewards": {}}], "status": "completed", "reward": 0.9999999999999999, "reward_breakdown": {"RewardCorrect": 1.0, "RewardFormat": 1.0}, "advantage": 0.0}
```
Co-authored-by: Felipe Mello <[email protected]>
Adds a rollout logger. It takes a list[RolloutGroup], filter based on
some given callable, and logs them to json in outputdir.
It is helpful to inspect data and debug.
```
{"step": 0, "is_validation": true, "group_id": "step=0/group=18", "sample_id": "step=0/group=18/sample=0", "turns": [{"policy_version": 0, "prompt_messages": [{"role": "system", "content": "You are a helpful assistant. Solve the problem step by step.\nWhen you have your final answer, state it as [ANSWER] <number>.\n\nExample:\nUser: What is the total digit sum of [12, 345, 67]?\nAssistant: Break each number into digits:\n12 -> 1, 2\n345 -> 3, 4, 5\n67 -> 6, 7\nSum all digits: 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28\n[ANSWER] 28"}, {"role": "user", "content": "What is the total digit sum of [70, 97]?"}], "completion_message": {"role": "assistant", "content": "[ANSWER] 23", "reasoning_content": "Okay, let's see. The user is asking for the total digit sum of the numbers [70, 97]. Hmm, digit sum means adding all the individual digits together. Let me break it down step by step.\n\nFirst, take the first number, which is 70. The digits here are 7 and 0. So I need to add 7 and 0. That gives me 7.\n\nNext, the second number is 97. The digits are 9 and 7. Adding those together, 9 plus 7 equals 16. \n\nNow, I need to add the results from both numbers. So 7 plus 16. Let me do that calculation. 7 + 16 is 23. \n\nWait, let me double-check to make sure I didn't make a mistake. The first number is 70, digits 7 and 0. Sum is 7. Second number 97, digits 9 and 7. Sum is 16. Total is 7 + 16 = 23. Yeah, that seems right. So the answer should be 23."}, "env_messages": [], "env_rewards": {}}], "status": "completed", "reward": 0.9999999999999999, "reward_breakdown": {"RewardCorrect": 1.0, "RewardFormat": 1.0}, "advantage": null}
{"step": 0, "is_validation": true, "group_id": "step=0/group=19", "sample_id": "step=0/group=19/sample=0", "turns": [{"policy_version": 0, "prompt_messages": [{"role": "system", "content": "You are a helpful assistant. Solve the problem step by step.\nWhen you have your final answer, state it as [ANSWER] <number>.\n\nExample:\nUser: What is the total digit sum of [12, 345, 67]?\nAssistant: Break each number into digits:\n12 -> 1, 2\n345 -> 3, 4, 5\n67 -> 6, 7\nSum all digits: 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28\n[ANSWER] 28"}, {"role": "user", "content": "What is the total digit sum of [20, 64, 90]?"}], "completion_message": {"role": "assistant", "content": "[ANSWER] 21", "reasoning_content": "Okay, let's see. The user wants the total digit sum of the numbers [20, 64, 90]. Hmm, digit sum means adding all the individual digits together. Let me break it down step by step.\n\nFirst, take the first number, 20. The digits here are 2 and 0. Adding those gives 2 + 0 = 2.\n\nNext, the second number is 64. The digits are 6 and 4. Adding them gives 6 + 4 = 10.\n\nThen, the third number is 90. The digits are 9 and 0. Adding those gives 9 + 0 = 9.\n\nNow, I need to add all these results together: 2 + 10 + 9. Let me do that calculation. 2 plus 10 is 12, and 12 plus 9 is 21. So the total digit sum should be 21.\n\nWait, let me double-check to make sure I didn't make any mistakes. For 20, yes, 2 and 0. 64 is 6 and 4. 90 is 9 and 0. Adding them all: 2 + 10 + 9. Yep, that's 21. I think that's correct."}, "env_messages": [], "env_rewards": {}}], "status": "completed", "reward": 0.9999999999999999, "reward_breakdown": {"RewardCorrect": 1.0, "RewardFormat": 1.0}, "advantage": null}
{"step": 1, "is_validation": false, "group_id": "step=1/group=0", "sample_id": "step=1/group=0/sample=0", "turns": [{"policy_version": 0, "prompt_messages": [{"role": "system", "content": "You are a helpful assistant. Solve the problem step by step.\nWhen you have your final answer, state it as [ANSWER] <number>.\n\nExample:\nUser: What is the total digit sum of [12, 345, 67]?\nAssistant: Break each number into digits:\n12 -> 1, 2\n345 -> 3, 4, 5\n67 -> 6, 7\nSum all digits: 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28\n[ANSWER] 28"}, {"role": "user", "content": "What is the total digit sum of [24, 13, 45, 41]?"}], "completion_message": {"role": "assistant", "content": "[ANSWER] 24", "reasoning_content": "Okay, let's see. The user wants the total digit sum of the numbers [24, 13, 45, 41]. Hmm, I need to break each number into its individual digits and then add them up. Let me start with the first number, 24. The digits here are 2 and 4. So that's 2 + 4 = 6. \n\nNext is 13. The digits are 1 and 3. Adding those together gives 1 + 3 = 4. \n\nThen there's 45. The digits are 4 and 5. So 4 + 5 = 9. \n\nLastly, 41. The digits are 4 and 1. Adding them again, 4 + 1 = 5. \n\nNow I need to add all these results together: 6 (from 24) + 4 (from 13) + 9 (from 45) + 5 (from 41). Let me do that step by step. 6 + 4 is 10, plus 9 makes 19, and then adding 5 brings it to 24. Wait, but let me check again to make sure I didn't make a mistake. \n\nFirst number: 2 and 4 \u2192 6. Second: 1 and 3 \u2192 4. Third: 4 and 5 \u2192 9. Fourth: 4 and 1 \u2192 5. Adding them all: 6 + 4 = 10, 10 + 9 = 19, 19 + 5 = 24. So the total digit sum should be 24. \n\nI think that's right. Let me just confirm once more. Yeah, 2+4=6, 1+3=4, 4+5=9, 4+1=5. Sum is 6+4+9+5. Yep, 24. So the answer is 24."}, "env_messages": [], "env_rewards": {}}], "status": "completed", "reward": 0.9999999999999999, "reward_breakdown": {"RewardCorrect": 1.0, "RewardFormat": 1.0}, "advantage": 0.0}
{"step": 1, "is_validation": false, "group_id": "step=1/group=0", "sample_id": "step=1/group=0/sample=7", "turns": [{"policy_version": 0, "prompt_messages": [{"role": "system", "content": "You are a helpful assistant. Solve the problem step by step.\nWhen you have your final answer, state it as [ANSWER] <number>.\n\nExample:\nUser: What is the total digit sum of [12, 345, 67]?\nAssistant: Break each number into digits:\n12 -> 1, 2\n345 -> 3, 4, 5\n67 -> 6, 7\nSum all digits: 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28\n[ANSWER] 28"}, {"role": "user", "content": "What is the total digit sum of [24, 13, 45, 41]?"}], "completion_message": {"role": "assistant", "content": "[ANSWER] 24", "reasoning_content": "Okay, let's see. The user wants the total digit sum of the numbers [24, 13, 45, 41]. Hmm, digit sum means adding all the individual digits together. Let me break it down step by step.\n\nFirst, take each number and separate its digits. Starting with 24: 2 and 4. Then 13: 1 and 3. Next, 45: 4 and 5. Finally, 41: 4 and 1. \n\nNow I need to add all these digits together. Let me write them out:\n\n2 + 4 = 6\n\n1 + 3 = 4\n\n4 + 5 = 9\n\n4 + 1 = 5\n\nNow summing all those results: 6 + 4 is 10, plus 9 gives 19, and then adding 5 makes 24. So the total digit sum should be 24. Wait, let me check again to make sure I didn't mix any numbers. The numbers are 24, 13, 45, 41. Yes, each has two digits. So adding them all gives 2+4+1+3+4+5+4+1. Let me compute that again:\n\n2+4 is 6, 1+3 is 4, 4+5 is 9, 4+1 is 5. Total is 6+4=10, 10+9=19, 19+5=24. Yep, that seems right. I think the answer is 24."}, "env_messages": [], "env_rewards": {}}], "status": "completed", "reward": 0.9999999999999999, "reward_breakdown": {"RewardCorrect": 1.0, "RewardFormat": 1.0}, "advantage": 0.0}
{"step": 1, "is_validation": false, "group_id": "step=1/group=1", "sample_id": "step=1/group=1/sample=3", "turns": [{"policy_version": 0, "prompt_messages": [{"role": "system", "content": "You are a helpful assistant. Solve the problem step by step.\nWhen you have your final answer, state it as [ANSWER] <number>.\n\nExample:\nUser: What is the total digit sum of [12, 345, 67]?\nAssistant: Break each number into digits:\n12 -> 1, 2\n345 -> 3, 4, 5\n67 -> 6, 7\nSum all digits: 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28\n[ANSWER] 28"}, {"role": "user", "content": "What is the total digit sum of [27, 23]?"}], "completion_message": {"role": "assistant", "content": "<think>\nOkay, let's see. The user wants the total digit sum of the numbers [27, 23]. Hmm, first, I need to break down each number into their individual digits. \n\nStarting with 27. The digits here are 2 and 7. So I add 2 and 7. Then for the second number, 23, the digits are 2 and 3. Adding those together, 2 + 3. \n\nWait, let me check again. Is there any trick here? Like, maybe leading zeros? But the numbers given are 27 and 23, which don't have leading zeros. So no, I don't need to adjust anything. \n\nAdding 2 + 7 equals 9, and 2 + 3 equals 5. Then adding those two results: 9 + 5 equals 14. But wait, the question says \"total digit sum\". Does that mean the sum of all digits in both numbers? So yes, 2 + 7 + 2 + 3. Which is 12. Wait, but when I broke it down, I added each digit separately and then added the sums. So 2+7=9 and 2+3=5. So total is 14. \n\nWait, but the user wrote [27, 23]. Maybe they want the sum of each digit in each number? So 2 + 7 + 2 + 3. Which is 12. But why did I get 9+5 before? Because I thought each number's digits are added. Wait, maybe I confused the two ways. Let me confirm. \n\nIf the numbers are [27, 23], then each number has two digits. So adding each digit from each number. So 2 (from 27) + 7 (from 27) + 2 (from 23) + 3 (from 23). That's 12. So the total digit sum is 12. \n\nBut earlier, when I broke each number into digits and added them separately, I got 9 and 5. Then adding them would be 14. Wait, that's conflicting. What's the correct approach here? \n\nAh, no, the correct approach is to add all the individual digits. So for 27, the digits are 2 and 7, and for 23, digits are 2 and 3. So adding all digits together: 2 + 7 + 2 + 3. Which is 12. So that's the answer. But why did I get confused earlier? Because I thought each number's digits are added, but that's the same as adding all digits together. \n\nSo the answer should be 12. But let me check again. Let's add 2 + 7 first: 9. Then 2 + 3 is 5. 9 + 5 is 14. Wait, but that's adding each digit of 27 and each digit of 23. Wait, 2 and 7 from 27, and 2 and 3 from 23. So adding 2+7+2+3=12. So why did I think 9+5 before? Because I"}, "env_messages": [], "env_rewards": {}}], "status": "truncated_length", "reward": 0.0, "reward_breakdown": {"RewardCorrect": 0.0, "RewardFormat": 0.0}, "advantage": -0.8749999999999999}
{"step": 1, "is_validation": false, "group_id": "step=1/group=1", "sample_id": "step=1/group=1/sample=7", "turns": [{"policy_version": 0, "prompt_messages": [{"role": "system", "content": "You are a helpful assistant. Solve the problem step by step.\nWhen you have your final answer, state it as [ANSWER] <number>.\n\nExample:\nUser: What is the total digit sum of [12, 345, 67]?\nAssistant: Break each number into digits:\n12 -> 1, 2\n345 -> 3, 4, 5\n67 -> 6, 7\nSum all digits: 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28\n[ANSWER] 28"}, {"role": "user", "content": "What is the total digit sum of [27, 23]?"}], "completion_message": {"role": "assistant", "content": "[ANSWER] 14", "reasoning_content": "Okay, let's see. The user is asking for the total digit sum of the numbers [27, 23]. First, I need to break down each number into its individual digits. So, starting with 27. The digits here are 2 and 7. Then, the second number is 23, which has digits 2 and 3. \n\nNow, I should add all these individual digits together. Let me check again. For 27, the digits are 2 and 7. For 23, it's 2 and 3. Adding them all: 2 + 7 is 9, and 2 + 3 is 5. Adding those two results, 9 + 5 equals 14. \n\nWait, but I should make sure I'm not missing any digits. Let me confirm once more. 27 is two digits, so only the first and second digits. 23 is also two digits. So yes, 2 + 7 and 2 + 3. Adding them gives 14. Therefore, the total digit sum should be 14. \n\nHmm, I think that's correct. No other digits to consider here. The answer should be 14."}, "env_messages": [], "env_rewards": {}}], "status": "completed", "reward": 0.9999999999999999, "reward_breakdown": {"RewardCorrect": 1.0, "RewardFormat": 1.0}, "advantage": 0.125}
{"step": 1, "is_validation": false, "group_id": "step=1/group=2", "sample_id": "step=1/group=2/sample=0", "turns": [{"policy_version": 0, "prompt_messages": [{"role": "system", "content": "You are a helpful assistant. Solve the problem step by step.\nWhen you have your final answer, state it as [ANSWER] <number>.\n\nExample:\nUser: What is the total digit sum of [12, 345, 67]?\nAssistant: Break each number into digits:\n12 -> 1, 2\n345 -> 3, 4, 5\n67 -> 6, 7\nSum all digits: 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28\n[ANSWER] 28"}, {"role": "user", "content": "What is the total digit sum of [79, 21, 85, 64]?"}], "completion_message": {"role": "assistant", "content": "[ANSWER] 42", "reasoning_content": "Okay, let's see. I need to find the total digit sum of the numbers in the list [79, 21, 85, 64]. Hmm, digit sum means adding all the individual digits together. Let me take each number one by one.\n\nFirst number is 79. The digits here are 7 and 9. So 7 + 9 equals 16.\n\nNext number is 21. The digits are 2 and 1. Adding those gives 2 + 1 = 3.\n\nThird number is 85. The digits are 8 and 5. Summing them gives 8 + 5 = 13.\n\nFourth number is 64. The digits are 6 and 4. Adding those together is 6 + 4 = 10.\n\nNow, I need to add all these results together: 16 + 3 + 13 + 10. Let me do the math step by step. 16 plus 3 is 19, then 19 plus 13 is 32, and 32 plus 10 is 42. So the total digit sum should be 42.\n\nWait, let me double-check. 79 is 7+9=16, 21 is 3, 85 is 13, and 64 is 10. Yep, 16+3=19, 19+13=32, 32+10=42. That seems right. I don't think I made any mistakes here. The answer should be 42."}, "env_messages": [], "env_rewards": {}}], "status": "completed", "reward": 0.9999999999999999, "reward_breakdown": {"RewardCorrect": 1.0, "RewardFormat": 1.0}, "advantage": 0.0}
{"step": 1, "is_validation": false, "group_id": "step=1/group=2", "sample_id": "step=1/group=2/sample=7", "turns": [{"policy_version": 0, "prompt_messages": [{"role": "system", "content": "You are a helpful assistant. Solve the problem step by step.\nWhen you have your final answer, state it as [ANSWER] <number>.\n\nExample:\nUser: What is the total digit sum of [12, 345, 67]?\nAssistant: Break each number into digits:\n12 -> 1, 2\n345 -> 3, 4, 5\n67 -> 6, 7\nSum all digits: 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28\n[ANSWER] 28"}, {"role": "user", "content": "What is the total digit sum of [79, 21, 85, 64]?"}], "completion_message": {"role": "assistant", "content": "[ANSWER] 42", "reasoning_content": "Okay, let me try to figure out the total digit sum of the numbers [79, 21, 85, 64]. Hmm, digit sum means adding up each individual digit of each number. So I need to break down each number into its digits and then add them all together.\n\nFirst, let's take each number one by one. Starting with 79. The digits are 7 and 9. So adding those together gives 7 + 9 = 16. Then the next number is 21. The digits here are 2 and 1. Adding those gives 2 + 1 = 3. \n\nMoving on to 85. The digits are 8 and 5. Adding them gives 8 + 5 = 13. Finally, the last number is 64. The digits are 6 and 4. Adding those gives 6 + 4 = 10. \n\nNow, I need to add all these results together: 16 (from 79) + 3 (from 21) + 13 (from 85) + 10 (from 64). Let me do the math step by step. 16 + 3 is 19, then 19 + 13 is 32, and 32 + 10 is 42. \n\nWait, let me double-check to make sure I didn't make a mistake. For 79, 7 + 9 = 16. Correct. 21 is 2 + 1 = 3. 85 is 8 + 5 = 13. 64 is 6 + 4 = 10. Adding them all: 16 + 3 is 19, plus 13 makes 32, plus 10 is 42. That seems right. So the total digit sum should be 42. \n\nBut just to confirm, maybe I should write down each step again. Starting with 79: 7 + 9 = 16. 21: 2 + 1 = 3. 85: 8 + 5 = 13. 64: 6 + 4 = 10. Then 16 + 3 = 19, 19 + 13 = 32, 32 + 10 = 42. Yep, that's correct. So the answer should be 42."}, "env_messages": [], "env_rewards": {}}], "status": "completed", "reward": 0.9999999999999999, "reward_breakdown": {"RewardCorrect": 1.0, "RewardFormat": 1.0}, "advantage": 0.0}
{"step": 1, "is_validation": false, "group_id": "step=1/group=3", "sample_id": "step=1/group=3/sample=0", "turns": [{"policy_version": 0, "prompt_messages": [{"role": "system", "content": "You are a helpful assistant. Solve the problem step by step.\nWhen you have your final answer, state it as [ANSWER] <number>.\n\nExample:\nUser: What is the total digit sum of [12, 345, 67]?\nAssistant: Break each number into digits:\n12 -> 1, 2\n345 -> 3, 4, 5\n67 -> 6, 7\nSum all digits: 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28\n[ANSWER] 28"}, {"role": "user", "content": "What is the total digit sum of [13, 21]?"}], "completion_message": {"role": "assistant", "content": "[ANSWER] 7", "reasoning_content": "Okay, let's see. The user is asking for the total digit sum of the numbers [13, 21]. Hmm, digit sum means adding all the individual digits together. Let me break it down step by step.\n\nFirst, take each number in the list and split them into individual digits. The first number is 13. The digits here are 1 and 3. The second number is 21, so its digits are 2 and 1. \n\nNow, I need to add all these digits together. Let me write that out: 1 + 3 + 2 + 1. Let's do the math. Starting with 1 plus 3, that's 4. Then adding 2 gives 6, and then adding 1 more gives 7. So the total digit sum should be 7. \n\nWait, let me double-check to make sure I didn't mix any numbers. The original list is [13, 21], so yes, splitting into 1,3 and 2,1. Adding them all gives 7. I think that's correct. The answer should be 7."}, "env_messages": [], "env_rewards": {}}], "status": "completed", "reward": 0.9999999999999999, "reward_breakdown": {"RewardCorrect": 1.0, "RewardFormat": 1.0}, "advantage": 0.0}
{"step": 1, "is_validation": false, "group_id": "step=1/group=3", "sample_id": "step=1/group=3/sample=7", "turns": [{"policy_version": 0, "prompt_messages": [{"role": "system", "content": "You are a helpful assistant. Solve the problem step by step.\nWhen you have your final answer, state it as [ANSWER] <number>.\n\nExample:\nUser: What is the total digit sum of [12, 345, 67]?\nAssistant: Break each number into digits:\n12 -> 1, 2\n345 -> 3, 4, 5\n67 -> 6, 7\nSum all digits: 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28\n[ANSWER] 28"}, {"role": "user", "content": "What is the total digit sum of [13, 21]?"}], "completion_message": {"role": "assistant", "content": "[ANSWER] 7", "reasoning_content": "Okay, let's see. The user wants the total digit sum of the numbers [13, 21]. Hmm, digit sum means I need to add up all the individual digits of each number. Let me break it down.\n\nFirst number is 13. The digits here are 1 and 3. Adding those gives 1 + 3 = 4. \n\nThen the second number is 21. The digits are 2 and 1. Adding those together gives 2 + 1 = 3. \n\nNow I need to add those two results: 4 + 3 = 7. \n\nWait, let me double-check. 13 is 1+3=4, and 21 is 2+1=3. Yes, 4+3=7. So the total digit sum should be 7. I think that's right."}, "env_messages": [], "env_rewards": {}}], "status": "completed", "reward": 0.9999999999999999, "reward_breakdown": {"RewardCorrect": 1.0, "RewardFormat": 1.0}, "advantage": 0.0}
```
Co-authored-by: Felipe Mello <[email protected]>
**Note**: Rebased on top of pytorch#3581. It also contains the `RolloutLogger` because of that. I added `AlphabetSort`, a task that works for single or multiturn, where the model is given names on each turn and is asked to sort a list by either first or last name. This is challenging because the model doesn't see characters. It sees tokens. The rewards start low and gradually grow, which is exactly what we need as a toy task. Our current 'SumDigits' gets 100% accuracy by qwen before any training. Since it is not helpful, i deleted it. ``` { "step": 0, "is_validation": true, "group_id": "step=0/group=3", "sample_id": "step=0/group=3/sample=0", "turns": [ { "policy_version": 0, "prompt_messages": [ { "role": "user", "content": "Sort these names in alphabetical order by FIRST name: PietroRigo, LaurentChapon, FedericoLevi, UriLerner\n\nUse exactly this format:\n<alphabetical_sorted>\nName1\nName2\n</alphabetical_sorted>" } ], "completion_message": { "role": "assistant", "content": "<alphabetical_sorted>\nFedericoLevi\nLaurentChapon\nPietroRigo\nUriLerner\n</alphabetical_sorted>" }, "env_messages": [], "env_rewards": {} } ], "status": "completed", "reward": 1.0, "reward_breakdown": { "RewardAlphabetSort": 1.0 }, "advantage": null } ``` <img width="898" height="559" alt="image" src="https://github.com/user-attachments/assets/089d3c09-d58e-4dd8-ae33-43a950a71e3c" /> Co-authored-by: Felipe Mello <[email protected]>
Adds a rollout logger. It takes a list[RolloutGroup], filter based on some given callable, and logs them to json in outputdir.
It is helpful to inspect data and debug.