Repository navigation
[Data] Reject non-finite weights in Dataset.mix - #67506
hello-peter-tang wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a centralized validate_mix_weights function to ensure that mix weights are positive and finite, preventing issues with NaN or infinite values. It updates the dataset documentation and adds unit tests to verify this validation. A review comment identifies a missing import of MixOperator in the new test cases, which would lead to a NameError during execution.
Jadiouo
left a comment
There was a problem hiding this comment.
Verified against base 8bfa990 and head 702036c (Python 3.13, CPU only, Ray nightly with ray/data swapped).
Through the public API (ds1.mix(ds2, weights=...), then take_all()): on base, weights=[nan, 1] and [inf, 1] are accepted by mix() and execution then hangs (I stopped it after 30s). With the PR, NaN, +inf and -inf raise ValueError: Weights must be finite. Got weights: [...] at the mix() call. Zero, negative and all-zero weights still raise the "positive" error, and finite weights produce the same block order as base. test_mix.py: 30 passed; the nan/inf/-inf cases fail on base.
Two small things: the gemini comment about a missing MixOperator import doesn't apply, since it's imported at the top of the file. The two parametrize lists are identical and could share one constant.
One question: richardliaw suggested on #67387 holding off until more people report this. Has that been cleared?
|
@richardliaw — there's now an independent reproduction on the linked issue: @Jadiouo verified against base |
Dataset.mix only checked `weight <= 0`, which lets NaN and +inf through; they then flow into the normalized weights and corrupt the deficit-based selection. Validate that weights are finite in both the logical and physical Mix operators, and document it on the public API. Signed-off-by: hello-peter-tang <[email protected]>
702036c to
e5a24a9
Compare
|
I merged I could not read the failure — the Buildkite build page requires a login and the API returns 401 unauthenticated. What I could check: of the 8 most recently updated open PRs, 4 fail Could a maintainer re-run |
|
This pull request has been automatically marked as stale because it has not had You can always ask for help on our discussion forum or Ray's public slack channel. If you'd like to keep this open, just leave any comment, and the stale label will be removed. |
Why are these changes needed?
Dataset.mixonly rejected weights withweight <= 0. That letsNaNand+infthrough, and they are then divided by the total weight, producing non-finite normalized weights that corrupt the deficit-based block selection.-infwas rejected, but with the misleading "Weights must be positive" message.What is the change?
validate_mix_weights(), shared by the logicalMixoperator and the physicalMixOperator.ValueError: Weights must be finite. Got weights: [...]; zero and negative weights keep the existing positive-weights error.Dataset.mix.Related issue number
Fixes #67387
Tests
nan,inf,-inf,0.0, and-1.0at both theDataset.mixlevel and theMixOperatorlevel.python/ray/data/tests/test_mix.py: 30 passed (20 existing + 10 new).blackandruffclean on the touched files.AI assistance: developed with an AI coding agent; the human submitter reviewed the diff and ran the tests above.