Skip to content

[Data] Expand DistributionTracker: add merge() and p25/p75 - #64074

Merged
bveeramani merged 10 commits into
ray-project:masterfrom
ayushk7102:mergeable_distbn_tracker
Jun 17, 2026
Merged

bveeramani merged 10 commits into
ray-project:masterfrom
ayushk7102:mergeable_distbn_tracker

Conversation

@ayushk7102

Copy link
Copy Markdown
Contributor

Description

In order to enable richer metric reporting and collection, we expand the implementation of DistributionTracker to have the following:

  • merge(...): To combine two DistributionTracker's into one
  • p25
  • p75

merge helps us record statistics per-worker and then merge them for aggregate statistics, and the p25/p75 provide more information about the data distribution.

Additional information

Uses Chan's parallel variant of Welford's algorithm for moments.
See: https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Welford:~:text=Parallel%20algorithm%5Bedit%5D

@ayushk7102
ayushk7102 requested a review from a team as a code owner June 13, 2026 01:34

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request adds a merge method to DistributionTracker using Chan's parallel variant of Welford's algorithm and introduces new properties for the 25th (p25) and 75th (p75) percentiles. The feedback points out that these new percentile properties should be included in the as_dict() method of DistributionTracker to ensure they are properly serialized and reported in the metrics.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@ray-gardener ray-gardener Bot added the data Ray Data-related issues label Jun 13, 2026
if self._sketch is None or other._sketch is None:
# Moments above still merged; quantile detail is lost for the
# side(s) without a sketch.
self._sketch = None

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe only None when both _sketch are None

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Keeping the partial sketch produces incorrect percentiles, as they would fall out of sync with the moments that we are merging. An alternative would be to not merge either moments or sketches if either sketch is none.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think it makes more sense to report the moments/mean always and report the quantiles as best effort (returning None) if available

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

There are 3 total unresolved issues (including 1 from previous review).

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 716629c. Configure here.

@ayushk7102
ayushk7102 requested a review from xinyuangui2 June 16, 2026 04:55
@ayushk7102 ayushk7102 added regression go add ONLY when ready to merge, run all tests and removed regression labels Jun 17, 2026
@bveeramani
bveeramani merged commit 79c66b2 into ray-project:master Jun 17, 2026
3 checks passed
limarkdcunha pushed a commit to limarkdcunha/ray that referenced this pull request Jun 30, 2026
…ct#64074)

## Description
In order to enable richer metric reporting and collection, we expand the
implementation of DistributionTracker to have the following:
- `merge(...)`: To combine two `DistributionTracker`'s into one
- p25
- p75

`merge` helps us record statistics per-worker and then merge them for
aggregate statistics, and the p25/p75 provide more information about the
data distribution.

## Additional information
Uses Chan's parallel variant of Welford's algorithm for moments.
See:
https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Welford:~:text=Parallel%20algorithm%5Bedit%5D

---------

Signed-off-by: Ayush Kumar <[email protected]>
400Ping pushed a commit to 400Ping/ray that referenced this pull request Aug 18, 2026
…ct#64074)

## Description
In order to enable richer metric reporting and collection, we expand the
implementation of DistributionTracker to have the following:
- `merge(...)`: To combine two `DistributionTracker`'s into one
- p25
- p75

`merge` helps us record statistics per-worker and then merge them for
aggregate statistics, and the p25/p75 provide more information about the
data distribution.

## Additional information
Uses Chan's parallel variant of Welford's algorithm for moments.
See:
https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Welford:~:text=Parallel%20algorithm%5Bedit%5D

---------

Signed-off-by: Ayush Kumar <[email protected]>
Signed-off-by: 400Ping <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

data Ray Data-related issues go add ONLY when ready to merge, run all tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants