-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Migrate T-digest test helpers to memory_resources #23608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| /* | ||
| * SPDX-FileCopyrightText: Copyright (c) 2022-2025, NVIDIA CORPORATION. | ||
| * SPDX-FileCopyrightText: Copyright (c) 2022-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
|
|
@@ -10,6 +10,8 @@ | |
|
|
||
| #include <cudf/reduction.hpp> | ||
|
|
||
| #include <rmm/mr/statistics_resource_adaptor.hpp> | ||
|
|
||
| template <typename T> | ||
| struct ReductionTDigestAllTypes : public cudf::test::BaseFixture {}; | ||
| TYPED_TEST_SUITE(ReductionTDigestAllTypes, cudf::test::NumericTypes); | ||
|
|
@@ -77,6 +79,51 @@ TEST_F(ReductionTDigestMerge, Simple) | |
| cudf::test::tdigest_merge_simple(reduce_op{}, reduce_merge_op{}); | ||
| } | ||
|
|
||
| TEST_F(ReductionTDigestMerge, TestUtilityMemoryResourceControl) | ||
| { | ||
| auto upstream = cudf::get_current_device_resource_ref(); | ||
| auto output_mr = rmm::mr::statistics_resource_adaptor(upstream); | ||
| auto temporary_mr = rmm::mr::statistics_resource_adaptor(upstream); | ||
| auto resources = cudf::memory_resources{output_mr, temporary_mr}; | ||
|
|
||
| { | ||
| auto distribution = cudf::test::generate_typed_percentile_distribution( | ||
| {10.0}, {4}, cudf::data_type{cudf::type_id::FLOAT64}, false, resources); | ||
| cudf::test::get_default_stream().synchronize(); | ||
| EXPECT_GT(output_mr.get_bytes_counter().value, 0); | ||
| EXPECT_EQ(temporary_mr.get_bytes_counter().value, 0); | ||
| EXPECT_GT(temporary_mr.get_bytes_counter().total, 0); | ||
| } | ||
| cudf::test::get_default_stream().synchronize(); | ||
| EXPECT_EQ(output_mr.get_bytes_counter().value, 0); | ||
|
|
||
| cudf::test::fixed_width_column_wrapper<double> means{1.0, 2.0}; | ||
| cudf::test::fixed_width_column_wrapper<double> weights{1.0, 1.0}; | ||
| auto validation_output_mr = rmm::mr::statistics_resource_adaptor(upstream); | ||
| auto validation_temporary_mr = rmm::mr::statistics_resource_adaptor(upstream); | ||
| auto validation_resources = cudf::memory_resources{validation_output_mr, validation_temporary_mr}; | ||
| auto const temporary_bytes_before = temporary_mr.get_bytes_counter().total; | ||
|
|
||
| { | ||
| auto expected = | ||
| cudf::test::make_expected_tdigest_column({{means, weights, 1.0, 2.0}}, resources); | ||
| cudf::tdigest::tdigest_column_view tdv(*expected); | ||
| cudf::test::tdigest_sample_compare(tdv, {{0, 1.0, 1.0}, {1, 2.0, 1.0}}, validation_resources); | ||
| cudf::test::tdigest_minmax_compare<double>(tdv, means, validation_resources); | ||
|
|
||
| cudf::test::get_default_stream().synchronize(); | ||
| EXPECT_GT(output_mr.get_bytes_counter().value, 0); | ||
| EXPECT_EQ(temporary_mr.get_bytes_counter().value, 0); | ||
| EXPECT_GT(temporary_mr.get_bytes_counter().total, temporary_bytes_before); | ||
| EXPECT_EQ(validation_output_mr.get_bytes_counter().value, 0); | ||
| EXPECT_EQ(validation_output_mr.get_bytes_counter().total, 0); | ||
| EXPECT_EQ(validation_temporary_mr.get_bytes_counter().value, 0); | ||
| EXPECT_GT(validation_temporary_mr.get_bytes_counter().total, 0); | ||
| } | ||
| cudf::test::get_default_stream().synchronize(); | ||
| EXPECT_EQ(output_mr.get_bytes_counter().value, 0); | ||
| } | ||
|
Comment on lines
+82
to
+125
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟠 Major | 🏗️ Heavy lift Add a unit benchmark for resource-aware T-digest utilities. This test adds unit coverage, but this cohort adds no unit benchmark. Add a benchmark that exercises the resource-aware generation or aggregation path with distinct output and temporary resources. As per coding guidelines, 🤖 Prompt for AI AgentsSource: Coding guidelines |
||
|
|
||
| // tests an issue with the cluster generating code with a small number of centroids that have large | ||
| // weights | ||
| TEST_F(ReductionTDigestMerge, FewHeavyCentroids) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
🧩 Analysis chain
🏁 Script executed:
Repository: NVIDIA/cudf
Length of output: 7483
🏁 Script executed:
Repository: NVIDIA/cudf
Length of output: 35491
🏁 Script executed:
Repository: NVIDIA/cudf
Length of output: 36655
Propagate the output resource through all t-digest callbacks.
The callbacks use default resources for
cudf::reduce, copied child columns, andcudf::make_structs_column. Extend the callback contract and passcudf::get_default_stream()andmr.get_output_mr()through every aggregation and merge path. Add tracked-resource coverage.🤖 Prompt for AI Agents