Skip to content

While training GRPO, I noticed that my model crashes. Its loss is 0, its grad_norm and kl are both Nan, and it completes as “!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!”” #3930

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
KevinClaint opened this issue Apr 18, 2025 · 12 comments

Comments

@KevinClaint
Copy link

KevinClaint commented Apr 18, 2025

我在用GRPO的时候出现了下图的情况,这个情况发生的很随机,会在training过程中的任何一个步骤中出现

@KevinClaint
Copy link
Author

Image

@effortprogrammer
Copy link

Did you solve the issue?

@KevinClaint
Copy link
Author

KevinClaint commented Apr 22, 2025

I turned down my learning rate and then changed the initial REWARD from 0 to 1e-4 (a very small value), after which it didn't happen. Tried and true from other issues as well.
volcengine/verl#747

In the meantime, I'm hoping that someone with more authority can help come up with a more generalized method and answer the question of why the error occurs

@effortprogrammer
Copy link

effortprogrammer commented Apr 23, 2025

I don't understand how did you change initial reward from 0 to 1e-4.. Can you give more context with this?

In addition, can you provide which versions of libraries you are currently using?

@effortprogrammer
Copy link

cc. @Jintao-Huang Can you tag some people that can help with this issue?

@KevinClaint
Copy link
Author

I don't understand how did you change initial reward from 0 to 1e-4.. Can you give more context with this?

In addition, can you provide which versions of libraries you are currently using?

For example, if the model doesn't output the answer that can get the reward, the reward will be computed as zero. I just change it into 1e-4

@hjh0119
Copy link
Collaborator

hjh0119 commented Apr 23, 2025

what's the version of swift? I believe the issue with NaN gradients has been fixed.

https://github.com/modelscope/ms-swift/blob/main/swift/trainers/mixin.py#L264-L281

@JingMog
Copy link

JingMog commented Apr 23, 2025

My swfit version is 3.3.0 dev0, same problem, the grad clip seems not work. I use deepspeed zero2.

Image

@KevinClaint
Copy link
Author

KevinClaint commented Apr 26, 2025

My swfit version is 3.3.0 dev0, same problem, the grad clip seems not work. I use deepspeed zero2.

Image

My swfit version is the same version as yours. I also use deepspeed zero2. And I find that my problem can't be solved by using the method mentioned above. It must be something wrong, but it comes casually. I can't be stable to re-produce this problem again.

@KevinClaint
Copy link
Author

I also find that it occurs in the first 2k steps (most of them are in 1k steps). And after 2k steps, I never meet it.

@zhangansen
Copy link

我把我的temperature设为0,一开始就出现!!!!!!

@zhangansen
Copy link

温度设为其他就没事了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants