fix: validate dataset mixture fractions - #6982
Conversation
|
Verdict: the fix is correct, with two small changes worth making before merge. What I checkedInterpreter New and neighbouring tests on the PR head: Same test on a copy of the head worktree with So the test is a real oracle: red before, green after. The minimal case from issue #6981, with the real The reported crash is gone, the silently accepted negative fraction is now rejected, and a single zero share alongside a positive one still works.
Findings
Not reproducedNothing. Every claim above was executed. UnevaluableNothing. All cases fit the tiny |
|
Thanks for the detailed review. I pushed |
|
The follow-up head |
Signed-off-by: pengmin <minpeng@semigraph.com>
7d7784c to
ecb3079
Compare
|
Updated the PR branch onto the latest huggingface/trl main (56f6675) as requested. The change itself is unchanged; the new head is ecb3079. Local ruff, Python compilation, and diff check pass. Cursor Bugbot has started running; the other workflows may still require maintainer approval. Please re-review when convenient. |
|
Closing: we don't review fully AI-generated PRs from first-time contributors, see the AI usage policy. |
|
@cananoo after talking with @qgallouedec I reopened this work as #7142 from my fork so it can be reviewed. Your commits are cherry-picked there with your authorship intact and the PR body credits you; if you would rather carry it yourself, say so there and I will close mine. |
Fractions are checked before any load_dataset call: all set or all unset, non-negative, and summing to a positive value, so an all-zero mixture no longer raises ZeroDivisionError after downloading every dataset and a negative fraction no longer becomes a negative weight. Based on the approach proposed in huggingface#6982. Fixes huggingface#6981.
What does this PR do?
Fixes #6981.
This change validates dataset mixture fractions before loading any datasets. It rejects negative fractions and zero-sum fractions with actionable
ValueErrormessages, while preserving mixtures that include individual zero fractions when the total is positive.The regression tests also verify that invalid configurations fail before
datasets.load_datasetis called.Before submitting
AI writing disclosure
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag members/contributors who may be interested in your PR.
Note
Low Risk
Input validation and ordering change in dataset loading; behavior for valid mixtures is unchanged aside from earlier errors for invalid configs.
Overview
get_datasetnow checks mixturefractionsettings before anydatasets.load_datasetcalls, so bad configs fail fast with clearValueErrormessages instead of after expensive I/O.New rules: each fraction must be non-negative, and the sum must be > 0 (all-zero sums are rejected; individual zeros remain OK when the total is positive). Existing checks—fraction on all-or-none datasets and no fractions with streaming—are part of the same upfront block.
DatasetConfigdocs note the non-negative / positive-sum requirement.Tests add a parametrized case that mocks
load_datasetand asserts it is never called when fractions are invalid (zero sum or negatives).Reviewed by Cursor Bugbot for commit ecb3079. Bugbot is set up for automated code reviews on this repo. Configure here.