Skip to content

AsyncGRPO crashes with documented picklable reward callables #6133

Description

@siddiksawani

Reproduction

AsyncGRPOTrainer documentation says that reward functions passed to the spawned rollout worker can be module-level functions, functools.partial objects, or callable class instances.

However, _AsyncRolloutLoop currently creates reward metric names using:

self.reward_func_names = [f.__name__ for f in reward_funcs]

functools.partial objects and typical callable class instances do not define __name__. As a result, a valid picklable reward callable can fail during rollout-worker initialization with an AttributeError.

Minimal example:

from functools import partial

def correctness_reward(completions, **kwargs):
    return [1.0] * len(completions)

reward_func = partial(correctness_reward)
reward_func.__name__
# AttributeError: 'functools.partial' object has no attribute '__name__'

Proposed fix:

  • Preserve normal names for functions and methods.
  • Unwrap functools.partial and use the wrapped function name.
  • Use the class name for callable instances.
  • Add focused CPU-only regression coverage for partial and callable-instance reward functions.

System Info

Not applicable, this is a source-level issue identified by code inspection.

Checklist

  • I have checked that my issue isn't already filed (see open issues)
  • I have included my system information
  • Any code provided is minimal, complete, and reproducible (more on MREs)
  • Any code provided is properly formatted in code blocks, (no screenshot, more on code blocks)
  • Any traceback provided is complete

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions