Skip to content

CI fails with dev dependencies: ValueError: zero-size array to reduction operation maximum which has no identity #4321

@albertvillanova

Description

@albertvillanova

CI fails with dev dependencies: https://github.com/huggingface/trl/actions/runs/18712033739/job/53362520844

ValueError: zero-size array to reduction operation maximum which has no identity

FAILED tests/test_online_dpo_trainer.py::TestOnlineDPOTrainer::test_training_with_transformers_paged[standard_prompt_only] - ValueError: zero-size array to reduction operation maximum which has no identity
FAILED tests/test_online_dpo_trainer.py::TestOnlineDPOTrainer::test_training_with_transformers_paged[conversational_prompt_only] - ValueError: zero-size array to reduction operation maximum which has no identity

Stacktrace:

   >       trainer.train()
  
  tests/test_online_dpo_trainer.py:452: 
  _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
  .venv/lib/python3.12/site-packages/transformers/trainer.py:2156: in train
      return inner_training_loop(
  .venv/lib/python3.12/site-packages/transformers/trainer.py:2487: in _inner_training_loop
      tr_loss_step = self.training_step(model, inputs, num_items_in_batch)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  trl/trainer/online_dpo_trainer.py:1230: in training_step
      prompt_ids, prompt_mask, completion_ids, completion_mask = self._generate(model, prompts, images)
                                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  trl/trainer/online_dpo_trainer.py:1078: in _generate
      completion_ids = pad(completion_ids, padding_value=self.pad_token_id, padding_side="right")
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  trl/trainer/utils.py:348: in pad
      output_shape = np.max([t.shape for t in tensors], 0).tolist()
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  .venv/lib/python3.12/site-packages/numpy/_core/fromnumeric.py:3164: in max
      return _wrapreduction(a, np.maximum, 'max', axis, None, out,
  _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
  
  obj = [], ufunc = <ufunc 'maximum'>, method = 'max', axis = 0, dtype = None
  out = None
  kwargs = {'initial': <no value>, 'keepdims': <no value>, 'where': <no value>}
  passkwargs = {}
  
      def _wrapreduction(obj, ufunc, method, axis, dtype, out, **kwargs):
          passkwargs = {k: v for k, v in kwargs.items()
                        if v is not np._NoValue}
      
          if type(obj) is not mu.ndarray:
              try:
                  reduction = getattr(obj, method)
              except AttributeError:
                  pass
              else:
                  # This branch is needed for reductions like any which don't
                  # support a dtype.
                  if dtype is not None:
                      return reduction(axis=axis, dtype=dtype, out=out, **passkwargs)
                  else:
                      return reduction(axis=axis, out=out, **passkwargs)
      
  >       return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  E       ValueError: zero-size array to reduction operation maximum which has no identity
  
  .venv/lib/python3.12/site-packages/numpy/_core/fromnumeric.py:86: ValueError

Context:

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions