verl icon indicating copy to clipboard operation
verl copied to clipboard

如何设置全局种子以确保所有训练均可控?How to set seed to ensure controlable training.

Open lihaoyuan81 opened this issue 1 year ago • 11 comments

对于GRPO训练,其中dataloader的种子可在参数表里配置,但generate,optimizer的种子如何设置,或者说有没有ray训练进程全局种子的设置方法?我在说明文档中没有找到这一点。 For GRPO training, the seed for the dataloader can be configured in the parameter list, but how can the seeds for generate and the optimizer be set? Or rather, is there a way to set a global seed for the Ray training process? I couldn’t find this in the documentation.

lihaoyuan81 avatar May 25 '25 14:05 lihaoyuan81

There is no way to reproduce exactly experiments due to rollout. Rollout uses a non-deterministic torch operator torch.cumsum.

vermouth1992 avatar May 26 '25 11:05 vermouth1992

Setting seed is useless if the operator is non-deterministic as the divergence will become larger and larger as training progresses.

vermouth1992 avatar May 26 '25 11:05 vermouth1992

I agree with with @vermouth1992. At this point providing deterministic RLVR training is pointless due to extremely non-deterministic behavior in vLLM. Setting the the dataloader seed to ensure the ordering of the training samples is the best we can do.

YunfanZhang42 avatar May 28 '25 03:05 YunfanZhang42

@youkaichao @WoosukKwon any plan to make vllm deterministic? Verifying the correctness of RL algorithms are typically resource consuming. For regression test, if the training can be deterministic, it would be much easier to draw conclusions without running experiments for hundreds of steps

eric-haibin-lin avatar Jun 01 '25 05:06 eric-haibin-lin

theoretically it is possible to make vllm fully deterministic, and i know there are some private deployments of vllm with this feature.

in the open-source world, it might be complicated. basically we need to control any single kernel we use, and swap it with a deterministic version. notably, cublas matmul can be non-deterministic itself.

youkaichao avatar Jun 02 '25 08:06 youkaichao

@youkaichao @WoosukKwon any plan to make vllm deterministic? Verifying the correctness of RL algorithms are typically resource consuming. For regression test, if the training can be deterministic, it would be much easier to draw conclusions without running experiments for hundreds of steps

I completely agree this point. Even though it’s impossible to make every aspect of RL training deterministic, verl as a framework should at least—like PyTorch or Transformers—provide a way to set most of the random seeds.

butterluo avatar Jun 13 '25 01:06 butterluo

theoretically it is possible to make vllm fully deterministic, and i know there are some private deployments of vllm with this feature.

in the open-source world, it might be complicated. basically we need to control any single kernel we use, and swap it with a deterministic version. notably, cublas matmul can be non-deterministic itself.

Cublas can be made deterministic via a single env var and I'm not worried. @youkaichao could you share more experience on what other kernels have non-determinism found in private deployment?

eric-haibin-lin avatar Jun 13 '25 14:06 eric-haibin-lin

Hi @butterluo Have you find any way for deterministic training for vllm? I am encoutering non-deterministic evaluation with vllm==0.10.1 Do you have any clue for solving this?

JamesSand avatar Jan 09 '26 20:01 JamesSand

请问将 data.seed 固定,是否就可以让每次训练的样本顺序完全一致呢?

If I fix the data.seed, will the order of the samples used in each training session be exactly the same?

zhangxixi551 avatar Mar 21 '26 03:03 zhangxixi551

请问将 data.seed 固定,是否就可以让每次训练的样本顺序完全一致呢?

If I fix the data.seed, will the order of the samples used in each training session be exactly the same?

@zhangxixi551 From my experience. The answer is yes.

JamesSand avatar Mar 21 '26 14:03 JamesSand

请问将 data.seed 固定,是否就可以让每次训练的样本顺序完全一致呢? If I fix the data.seed, will the order of the samples used in each training session be exactly the same?

@zhangxixi551 From my experience. The answer is yes.

Thank you very much!

zhangxixi551 avatar Mar 21 '26 14:03 zhangxixi551