Deduplicate merged GPU quantile sketch entries#12147
Merged
RAMitchell merged 2 commits intodmlc:masterfrom Apr 8, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a correctness bug in the GPU quantile sketch merge path where adjacent duplicate values could survive a merge (especially when prune returns early), by normalizing merged summaries via post-merge deduplication for both numerical and categorical features. It also strengthens GPU regression coverage to ensure merged outputs contain no repeated values and match CPU combine behavior on overlapping weighted examples.
Changes:
- Run post-merge
SegmentedUniquecompaction for all merged GPU sketch summaries (not only categorical), followed by existingFixErrornormalization. - Update existing merge tests to account for potential post-merge compaction (merged size can shrink).
- Add new GPU regression tests covering identical-value numerical merges and GPU-vs-CPU combine equivalence.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/common/quantile.cu |
Always compact duplicate sketch entries after merge (numerical + categorical) to prevent duplicates from surviving when prune returns early. |
tests/cpp/common/test_quantile.cu |
Adds focused merge regressions and extends merge validations to assert no adjacent duplicate values remain after merge. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
trivialfis
approved these changes
Apr 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes a GPU quantile sketch merge bug where duplicate numerical entries could survive a merge.
The GPU merge path materializes entries up front, so when both inputs contain the same value it can emit one combined entry and still leave a second copy of that value in the merged output. Numerical summaries were previously relying on a later prune step to remove duplicates, but can return early when the sketch already fits the target budget. In that case, repeated numerical values can remain in the merged summary.
This change normalizes merged GPU summaries by compacting duplicate entries for numerical features as well, not just categorical ones.
What Changed
Why
The weighted quantile summary support is supposed to behave like a set of retained values. Allowing duplicate numerical entries to survive merge violates that invariant and can leak repeated values into later stages.
Testing
Ran locally:
[==========] Running 5 tests from 1 test suite.
[----------] Global test environment set-up.
[----------] 5 tests from GPUQuantile
[ RUN ] GPUQuantile.MergeBasic
[ OK ] GPUQuantile.MergeBasic (641 ms)
[ RUN ] GPUQuantile.MergeDuplicated
[ OK ] GPUQuantile.MergeDuplicated (47 ms)
[ RUN ] GPUQuantile.MergeCategorical
[ OK ] GPUQuantile.MergeCategorical (0 ms)
[ RUN ] GPUQuantile.MergeSameValue
[ OK ] GPUQuantile.MergeSameValue (0 ms)
[ RUN ] GPUQuantile.MergeMatchesCpuCombine
[ OK ] GPUQuantile.MergeMatchesCpuCombine (0 ms)
[----------] 5 tests from GPUQuantile (690 ms total)
[----------] Global test environment tear-down
[==========] 5 tests from 1 test suite ran. (690 ms total)
[ PASSED ] 5 tests.
[==========] Running 13 tests from 1 test suite.
[----------] Global test environment set-up.
[----------] 13 tests from GPUQuantile
[ RUN ] GPUQuantile.Basic
[ OK ] GPUQuantile.Basic (524 ms)
[ RUN ] GPUQuantile.Prune
[ OK ] GPUQuantile.Prune (46 ms)
[ RUN ] GPUQuantile.PruneDuplicated
[ OK ] GPUQuantile.PruneDuplicated (6 ms)
[ RUN ] GPUQuantile.MergeEmpty
[ OK ] GPUQuantile.MergeEmpty (3 ms)
[ RUN ] GPUQuantile.MergeBasic
[ OK ] GPUQuantile.MergeBasic (66 ms)
[ RUN ] GPUQuantile.MergeDuplicated
[ OK ] GPUQuantile.MergeDuplicated (42 ms)
[ RUN ] GPUQuantile.MergeCategorical
[ OK ] GPUQuantile.MergeCategorical (0 ms)
[ RUN ] GPUQuantile.MergeSameValue
[ OK ] GPUQuantile.MergeSameValue (0 ms)
[ RUN ] GPUQuantile.MergeMatchesCpuCombine
[ OK ] GPUQuantile.MergeMatchesCpuCombine (0 ms)
[ RUN ] GPUQuantile.MultiMerge
[ OK ] GPUQuantile.MultiMerge (9 ms)
[ RUN ] GPUQuantile.MissingColumns
[ OK ] GPUQuantile.MissingColumns (4 ms)
[ RUN ] GPUQuantile.Push
[ OK ] GPUQuantile.Push (0 ms)
[ RUN ] GPUQuantile.MultiColPush
[ OK ] GPUQuantile.MultiColPush (0 ms)
[----------] 13 tests from GPUQuantile (707 ms total)
[----------] Global test environment tear-down
[==========] 13 tests from 1 test suite ran. (707 ms total)
[ PASSED ] 13 tests.