Reproduction
GRPOTrainer._prepare_inputs on the non-Module reward_func.__name__: https://github.com/huggingface/trl/blob/v0.15.2/trl/trainer/grpo_trainer.py#L658
The latent crash here is __name__ is not guaranteed to be present on a Callable, for example with unittest.mock.Mock:
>>> from unittest.mock import Mock
>>> Mock().__name__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/jamesbraza/.pyenv/versions/3.12.8/lib/python3.12/unittest/mock.py", line 662, in __getattr__
raise AttributeError(name)
AttributeError: __name__
A more robust implementation is:
reward_func_name = getattr(reward_func, '__name__', str(reward_func))
Happy to make a PR for this.
System Info
n/a
Checklist
Reproduction
GRPOTrainer._prepare_inputson the non-Modulereward_func.__name__: https://github.com/huggingface/trl/blob/v0.15.2/trl/trainer/grpo_trainer.py#L658The latent crash here is
__name__is not guaranteed to be present on aCallable, for example withunittest.mock.Mock:A more robust implementation is:
Happy to make a PR for this.
System Info
n/a
Checklist