You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement. We’ll occasionally send you account related emails.<
8000
/p>
When I run the GRPO, I met the problem about the gradient.:
Traceback (most recent call last):
File "/mnt/workspace/haoyu/music_codebase/Video-R1/src/r1-v/src/open_r1/grpo_hy.py", line 372, in
main(script_args, training_args, model_args)
File "/mnt/workspace/haoyu/music_codebase/Video-R1/src/r1-v/src/open_r1/grpo_hy.py", line 358, in main
trainer.train()
File "/root/anaconda3/envs/video-r1/lib/python3.11/site-packages/transformers/trainer.py", line 2241, in train
return inner_training_loop(
^^^^^^^^^^^^^^^^^^^^
File "/root/anaconda3/envs/video-r1/lib/python3.11/site-packages/transformers/trainer.py", line 2548, in _inner_training_loop
tr_loss_step = self.training_step(model, inputs, num_items_in_batch)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/anaconda3/envs/video-r1/lib/python3.11/site-packages/transformers/trainer.py", line 3740, in training_step
self.accelerator.backward(loss, **kwargs)
File "/root/anaconda3/envs/video-r1/lib/python3.11/site-packages/accelerate/accelerator.py", line 2329, in backward
loss.backward(**kwargs)
File "/root/anaconda3/envs/video-r1/lib/python3.11/site-packages/torch/_tensor.py", line 581, in backward
torch.autograd.backward(
File "/root/anaconda3/envs/video-r1/lib/python3.11/site-packages/torch/autograd/init.py", line 347, in backward
_engine_run_backward(
File "/root/anaconda3/envs/video-r1/lib/python3.11/site-packages/torch/autograd/graph.py", line 825, in _engine_run_backward
return Variable._execution_engine.run_backward( # Calls into the C++ engine to run the backward pass
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: element 0 of tensors does not require grad and does not have a grad_fn
After I revise code in the compute_loss() before return:
if not loss.requires_grad:
loss.requires_grad = True
return loss
The Error is temporarily resolved. But the loss is always 0 (the reward is not Zero/None), and I check the components of the loss,
loss = ((per_token_loss * completion_mask).sum(dim=1) / completion_mask.sum(dim=1)).mean()
{all components of the loss}.requires_grad is False. The requires_grad of model parameters are True.
a
Why it happens?
The text was updated successfully, but these errors were encountered:
Uh oh!
There was an error while loading. Please reload this page.
Thanks for your amazing work!
When I run the GRPO, I met the problem about the gradient.:
Traceback (most recent call last):
File "/mnt/workspace/haoyu/music_codebase/Video-R1/src/r1-v/src/open_r1/grpo_hy.py", line 372, in
main(script_args, training_args, model_args)
File "/mnt/workspace/haoyu/music_codebase/Video-R1/src/r1-v/src/open_r1/grpo_hy.py", line 358, in main
trainer.train()
File "/root/anaconda3/envs/video-r1/lib/python3.11/site-packages/transformers/trainer.py", line 2241, in train
return inner_training_loop(
^^^^^^^^^^^^^^^^^^^^
File "/root/anaconda3/envs/video-r1/lib/python3.11/site-packages/transformers/trainer.py", line 2548, in _inner_training_loop
tr_loss_step = self.training_step(model, inputs, num_items_in_batch)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/anaconda3/envs/video-r1/lib/python3.11/site-packages/transformers/trainer.py", line 3740, in training_step
self.accelerator.backward(loss, **kwargs)
File "/root/anaconda3/envs/video-r1/lib/python3.11/site-packages/accelerate/accelerator.py", line 2329, in backward
loss.backward(**kwargs)
File "/root/anaconda3/envs/video-r1/lib/python3.11/site-packages/torch/_tensor.py", line 581, in backward
torch.autograd.backward(
File "/root/anaconda3/envs/video-r1/lib/python3.11/site-packages/torch/autograd/init.py", line 347, in backward
_engine_run_backward(
File "/root/anaconda3/envs/video-r1/lib/python3.11/site-packages/torch/autograd/graph.py", line 825, in _engine_run_backward
return Variable._execution_engine.run_backward( # Calls into the C++ engine to run the backward pass
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: element 0 of tensors does not require grad and does not have a grad_fn
After I revise code in the compute_loss() before return:
if not loss.requires_grad:
loss.requires_grad = True
return loss
The Error is temporarily resolved. But the loss is always 0 (the reward is not Zero/None), and I check the components of the loss,
loss = ((per_token_loss * completion_mask).sum(dim=1) / completion_mask.sum(dim=1)).mean()
{all components of the loss}.requires_grad is False. The requires_grad of model parameters are True.
a
Why it happens?
The text was updated successfully, but these errors were encountered: