Repository navigation
Count infinite histogram samples once in edge buckets - #5361
sylvesterkaczmarek wants to merge 1 commit into
Conversation
Signed-off-by: Sylvester Kaczmarek <16242628+sylvesterkaczmarek@users.noreply.github.com>
|
@yhwen @IsaacYangSLA The histogram regression tests and common-statistics suite pass locally (83 passed, 12 skipped), along with scoped style checks. Could you review this and trigger |
|
| bucket_low_value = float("-inf") | ||
| bucket_sample_count += num_neginf | ||
| elif bucket_count == len(counts) - 1 and num_posinf > 0: | ||
| if bucket_count == len(counts) - 1 and num_posinf > 0: |
There was a problem hiding this comment.
Mixed clients lose histogram counts
When one client has infinite values and another does not, their outer bins have different boundaries. For example, with three bins over (-1, 1), [-inf, 0, inf] produces infinite outer edges, while [-1, 0, 1] produces finite ones. accumulate_hists matches bins by exact boundaries and keeps only the first client's bins, so the combined histogram counts four of the six samples. The new two-client test gives both clients the same infinity pattern and does not catch this case.
Knowledge Base Used: Built-in application components
Fixes #5360.
Description
Remove the extra degenerate infinity bucket from
get_std_histogram_buckets: those samples have already been included in the first or last bucket. Make the positive-infinity check independent of the negative-infinity check so a one-bin histogram can include both endpoints.The result retains the requested number of bins and counts each infinite sample once. Finite input handling, explicit-range behavior and NaN exclusion remain unchanged. Automatic range inference with infinite inputs is not changed.
Validation
Ten new cases cover negative/positive infinities separately and together, one-bin and all-infinite inputs, finite controls, NaNs, out-of-range finite values, empty inputs, read-only strided views and nonmutation. A dataframe-to-global-histogram check verifies two client datasets produce counts
[3, 1, 3], totaling their seven nonmissing samples../runtest.sh -spassed on both changed files: Black, isort and flake8.git diff --checkpassed.Tested on macOS with Python 3.12.11 and NumPy 2.5.3. The full
runtest.shsuite and a deployed federated job were not run. No dependency, workflow or configuration changes.Types of changes