ms-swift icon indicating copy to clipboard operation
ms-swift copied to clipboard

跑官方文档中多模态GRPO的demo,训练过程loss出现负数是正常吗

Open wlh1027 opened this issue 1 year ago • 1 comments

datasets:okwinds/clevr_cogen_a_train#500

{'loss': -0.01984474, 'grad_norm': 2.83724597, 'learning_rate': 9.6e-07, 'memory(GiB)': 87.34, 'train_speed(iter/s)': 0.01697, 'completion_length': 64.91666794, 'response_clip_ratio': 0.0, 'rewards/MultiModalAccuracyORM': 0.63541669, 'rewards/Format': 1.0, 'reward': 1.63541669, 'reward_std': 0.44870499, 'kl': 0.06542969, 'clip_ratio': 0.0, 'epoch': 0.14, 'global_step/max_steps': '17/124', 'percentage': '13.71%', 'elapsed_time': '15m 58s', 'remaining_time': '1h 40m 31s'}

wlh1027 avatar Mar 20 '25 03:03 wlh1027

It's normal.

The GRPO loss consists of two components: a policy gradient term and a KL regularization term.

The KL term employs a K3 approximation to ensure positivity. The policy gradient term combines the importance sampling ratio (which is strictly positive) with a normalized advantage function (potentially negative).

So when the negative magnitude of the policy gradient term exceeds the positive contribution from the KL regularization term, the total loss become negative.

hjh0119 avatar Mar 20 '25 09:03 hjh0119