Skip to content

Fix error type for IterableDataset in GRPO and RLOO#6324

Merged
albertvillanova merged 6 commits into
mainfrom
fix-error-iterable-ds
Jul 11, 2026
Merged

Fix error type for IterableDataset in GRPO and RLOO#6324
albertvillanova merged 6 commits into
mainfrom
fix-error-iterable-ds

Conversation

@albertvillanova

@albertvillanova albertvillanova commented Jul 8, 2026

Copy link
Copy Markdown
Member

This PR fixes the error type raised when an IterableDataset is passed to GRPOTrainer or RLOOTrainer.

Motivation

NotImplementedError (a subclass of RuntimeError) is meant for abstract methods that subclasses must override, or as a development placeholder. Rejecting an invalid combination of constructor arguments is not that case: the user passed arguments of the right type whose combination is unsupported, which is idiomatically a ValueError.

This aligns with the fix already applied for a similar case in DPOTrainer in:

Related change: tests are implemented (and should be updated) in:

Solution

Replace NotImplementedError with ValueError for the iterable dataset check in both trainers.

Changes

  • GRPOTrainer: raise ValueError instead of NotImplementedError when train_dataset or eval_dataset is an IterableDataset
  • RLOOTrainer: same fix as above

Note

Low Risk
Constructor-only exception type change with no training logic or API surface changes beyond how callers catch the error.

Overview
GRPOTrainer and RLOOTrainer now raise ValueError (instead of NotImplementedError) when train_dataset or eval_dataset is an IterableDataset, including iterable splits nested in an eval dict. The error message is unchanged.

Matching tests in test_grpo_trainer.py and test_rloo_trainer.py expect ValueError, consistent with the same pattern already used for DPOTrainer.

Reviewed by Cursor Bugbot for commit 53ce2f2. Bugbot is set up for automated code reviews on this repo. Configure here.

@bot-ci-comment

bot-ci-comment Bot commented Jul 8, 2026

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

):
# See https://github.com/huggingface/trl/issues/3213
raise NotImplementedError(
raise ValueError(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't we use TypeError?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TypeError in this codebase is reserved for when an argument doesn't match the type signature at all.

Here that's not the case: both trainers' signatures explicitly declare train_dataset: Dataset | IterableDataset | None. Therefore, IterableDataset is a documented, accepted type. The rejection isn't "wrong type"; it's "this valid type isn't supported by this trainer's current implementation" (per the linked issue #3213). That's a value/capability constraint, not a type mismatch; the same reasoning #6225 used (use_liger_kernel=True is not supported with PEFT models → ValueError, even though PEFT-ness is itself a type-like property).

So ValueError is the correct match for the existing convention. No change needed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, interesting

@albertvillanova albertvillanova merged commit 8972510 into main Jul 11, 2026
13 checks passed
@albertvillanova albertvillanova deleted the fix-error-iterable-ds branch July 11, 2026 06:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants