Skip to content

Deduplicate merged GPU quantile sketch entries#12147

Merged
RAMitchell merged 2 commits intodmlc:masterfrom
RAMitchell:gpu-merge-dedup-fix
Apr 8, 2026
Merged

Deduplicate merged GPU quantile sketch entries#12147
RAMitchell merged 2 commits intodmlc:masterfrom
RAMitchell:gpu-merge-dedup-fix

Conversation

@RAMitchell
Copy link
Copy Markdown
Member

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

  • run post-merge deduplication for all merged GPU sketch summaries, including numerical features
  • keep the existing error-fixup path after compaction
  • add focused GPU regressions for:
    • merging two one-entry numerical summaries with the same value
    • matching CPU behavior on a small overlapping weighted example

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:

  • Note: Google Test filter = GPUQuantile.MergeSameValue:GPUQuantile.MergeMatchesCpuCombine:GPUQuantile.MergeBasic:GPUQuantile.MergeDuplicated:GPUQuantile.MergeCategorical
    [==========] 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.

  • Note: Google Test filter = GPUQuantile.*
    [==========] 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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 SegmentedUnique compaction for all merged GPU sketch summaries (not only categorical), followed by existing FixError normalization.
  • 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.

@RAMitchell RAMitchell requested a review from trivialfis April 8, 2026 13:28
@RAMitchell RAMitchell merged commit 3a809d8 into dmlc:master Apr 8, 2026
78 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants