Does the DAPO dynamic sample parameter data.gen_batch_size really work?
readme里面提到:训练器将使用 gen_batch_size 重复采样,直到有足够多的合格组达到 train_batch_size 或达到 max_num_gen_batches 指定的上限,但代码中并没有找到gen_batch_size的相关取值约束,代码看起来是充满train_batch_size 为止,并没有gen_batch_size 的约束 In the readme, it is mentioned that "The trainer will repeat sampling with gen_batch_size until there are enough qualified groups for train_batch_size or reaching the upper limit specified by max_num_gen_batches.". However, no relevant value constraints for gen_batch_size were found in the code, and the code appears to be filled with train_batch_size without any constraints
在https://github.com/volcengine/verl/blob/gm-tyx/puffin/main/recipe/dapo/src/dapo_ray_trainer.py205行这里
在https://github.com/volcengine/verl/blob/gm-tyx/puffin/main/recipe/dapo/src/dapo_ray_trainer.py205行这里
if max_num_gen_batches <= 0 or num_gen_batches < max_num_gen_batches这一行吗,max_num_gen_batches是另一个参数https://github.com/volcengine/verl/blob/gm-tyx/puffin/main/recipe/dapo/run_dapo_qwen2.5_32b.sh max_num_gen_batches=10是第27行而gen_prompt_bsz=$((train_prompt_bsz * 3))在29行
是的 我也感觉这个参数没用上
两个参数是配合使用的,gen_prompt_bsz是每次生成的batch大小,如果单次生成后过滤完了不够train_batch_size,则最多重复max_num_gen_batches次生成来尝试填满train_batch_size,如果达到了max_num_gen_batches次的gen_prompt_bsz生成还是不满足train_batch_size则报错。
两个参数是配合使用的,gen_prompt_bsz是每次生成的batch大小,如果单次生成后过滤完了不够train_batch_size,则最多重复max_num_gen_batches次生成来尝试填满train_batch_size,如果达到了max_num_gen_batches次的gen_prompt_bsz生成还是不满足train_batch_size则报错。
就这个我还有一个疑问:在计算total_training_steps的时候,我发现代码里面的逻辑就是若设定了gen_prompt_bsz,则total_training_steps = (dataset_len / gen_prompt_bsz) * epochs。但是我又觉得这个不太对啊,因为实际上最终实际参与训练的还是刚好填满的train_batch_size啊,而不是gen_prompt_bsz,所以应该total_training_steps = (dataset_len / train_batch_size) * epochs才对吧?
对于grpo,total_training_steps=num_epochs * 数据集的batch数量,这里的数据集batch数量=len(dataset)除以train_prompt_bsz
不过我不能理解的点在于total_training_steps为什么在dapo里面就变成了数据集batch数量=len(dataset)除以gen_prompt_bsz
你好,你的邮件已收到,谢谢!
你好,你的邮件已收到,谢谢!
我在训练中也遇到了这个问题,起初我发现同样的数据,无论我用8/16/32卡训练,dapo的step数量都是固定的,而且是grpo的1/3,这存在一定的合理性,因为肯定会过滤掉一些方差为0的例子,用不了全部的数据;但是这样做相当于非常自信的认为,只用1/3的数据就能训练完成,因为实际参与更新的数据量还是根据train_batch_size确定的;
并且我在训练中遇到一个问题,总step是23,我设定了save/val_freq=5,但是由于这个填补batch的机制,好像直接跨过了一些step,我最终只存下了step5/10,起初我以为是32卡训练的多机通讯问题,但是切到单机8卡,这个问题还出现,好像是由于num_gen_batches=1. Keep generating...这个机制导致的
想问下你们是如何处理这个问题的
两个参数是配合使用的,gen_prompt_bsz是每次生成的batch大小,如果单次生成后过滤完了不够train_batch_size,则最多重复max_num_gen_batches次生成来尝试填满train_batch_size,如果达到了max_num_gen_batches次的gen_prompt_bsz生成还是不满足train_batch_size则报错。
就这个我还有一个疑问:在计算total_training_steps的时候,我发现代码里面的逻辑就是若设定了gen_prompt_bsz,则
total_training_steps = (dataset_len / gen_prompt_bsz) * epochs。但是我又觉得这个不太对啊,因为实际上最终实际参与训练的还是刚好填满的train_batch_size啊,而不是gen_prompt_bsz,所以应该total_training_steps = (dataset_len / train_batch_size) * epochs才对吧?对于grpo,
total_training_steps=num_epochs * 数据集的batch数量,这里的数据集batch数量=len(dataset)除以train_prompt_bsz不过我不能理解的点在于total_training_steps为什么在dapo里面就变成了数据集batch数量=len(dataset)除以gen_prompt_bsz
我也有同样的问题,每次都rollout生成gen_prompt_bsz个样本,但是如果这个时候符合要求的采样样本数量大于需要的一个batch大小,也就是train_batch_size,这些采样样本会被全部用于训练吗?如果不是,则step步数计算是没有问题的,反之则出现了问题
你好,你的邮件已收到,谢谢!
我在训练中也遇到了这个问题,起初我发现同样的数据,无论我用8/16/32卡训练,dapo的step数量都是固定的,而且是grpo的1/3,这存在一定的合理性,因为肯定会过滤掉一些方差为0的例子,用不了全部的数据;但是这样做相当于非常自信的认为,只用1/3的数据就能训练完成,因为实际参与更新的数据量还是根据train_batch_size确定的;
并且我在训练中遇到一个问题,总step是23,我设定了save/val_freq=5,但是由于这个填补batch的机制,好像直接跨过了一些step,我最终只存下了step5/10,起初我以为是32卡训练的多机通讯问题,但是切到单机8卡,这个问题还出现,好像是由于num_gen_batches=1. Keep generating...这个机制导致的
想问下你们是如何处理这个问题的
我就是save_freq设置成1似乎是最简单的。以及想问问如果要和GRPO公平比较,dapo应该比grpo多训多少epoch才合适?
你好,你的邮件已收到,谢谢!
这个问题好离谱,dapo官方论文里是写的过滤奖励都为0和1的batch,但是verl里面实现的时候又是用std>0来过滤,用EasyR1训练里面是用batch的奖励均值来过滤0和1的情况,感觉和论文是一致的,提前结束的问题也会好很多🤣
你好,你的邮件已收到,谢谢!
我看了当前 main 分支的实现后,结论是:data.gen_batch_size 本身是生效的,但它目前主要体现在 dataloader/rollout 批大小以及由此推导出的 total_training_steps 上;DAPO 文档中描述的 filter_groups 过滤后继续用 gen_batch_size backfill 到 train_batch_size、并受 max_num_gen_batches 限制的逻辑,在当前主训练循环里还没有看到已合入的实现。
具体来说,RayPPOTrainer._create_dataloader() 使用 data.gen_batch_size 作为 StatefulDataLoader(batch_size=...),total_training_steps 又按 len(train_dataloader) * total_epochs 计算,所以大家观察到 step 数随 gen_batch_size 而不是 train_batch_size 变化,是符合当前代码的。另一方面,当前 fit() 里的生成路径是从这个 dataloader batch 取 gen_batch、repeat rollout.n、调用 generate_sequences(),然后直接和 batch 合并;我没有在该路径里看到文档片段所说的 num_prompt_in_batch < train_batch_size 时继续生成、按 max_num_gen_batches 限制 backfill 的逻辑。
因此这看起来更像是“文档/配置面已经存在,但动态采样 backfill 实现尚未进入当前 main”的状态,而不是单纯的使用问题。相关 upstream 工作目前在 #2988([trainer] feat: Upstream Dynamic Sampling),但该 PR 仍是 open 且还有 requested changes。建议在 #2988 合入前,不要把 algorithm.filter_groups.max_num_gen_batches 当作当前 main 中已经生效的训练循环控制参数;如果需要复现 DAPO 的动态采样行为,应使用包含该 DAPO trainer/backfill 逻辑的 recipe/分支或等待 upstream PR 合入。
I checked the current main implementation. My conclusion is: data.gen_batch_size itself does work, but in current main it mainly controls the dataloader/rollout batch size and therefore the derived total_training_steps. The DAPO doc describes an additional filter_groups behavior where the trainer filters prompt groups, keeps generating with gen_batch_size until enough qualified groups fill train_batch_size, and stops at max_num_gen_batches; I do not see that backfill loop implemented in the current main training loop.
Concretely, RayPPOTrainer._create_dataloader() uses data.gen_batch_size as the StatefulDataLoader(batch_size=...), and total_training_steps is computed from len(train_dataloader) * total_epochs. So the observed step count following gen_batch_size rather than train_batch_size matches the current code. In contrast, the current fit() generation path takes one dataloader batch, repeats it by rollout.n, calls generate_sequences(), and unions the generated output back into the batch; I do not see the documented num_prompt_in_batch < train_batch_size / max_num_gen_batches backfill loop there.
So this currently looks like a docs/config surface vs implementation gap in main, not just a usage misunderstanding. The related upstream work appears to be #2988 ([trainer] feat: Upstream Dynamic Sampling), which is still open and has requested changes. Until that lands, I would not treat algorithm.filter_groups.max_num_gen_batches as an effective control parameter in current main; for DAPO-style dynamic sampling/backfill, use a recipe/branch that contains that trainer logic or wait for the upstream dynamic sampling PR to be merged.
This response was generated by a scheduled Codex GPT5.5 issue processing task.
你好,你的邮件已收到,谢谢!