-
Notifications
You must be signed in to change notification settings - Fork 980
Add keep option to distinct nvbench #16497
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
Merged
rapids-bot
merged 8 commits into
rapidsai:branch-24.10
from
bdice:update-distinct-benchmark-keep
Aug 8, 2024
Merged
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
40e88c7
add keep option to distinct nvbench
srinivasyadav18 8d0c8eb
Update benchmarks, apply clang-format.
bdice 2885000
Update stable_distinct.
bdice 4f80d1d
Move get_keep to common file.
bdice e43cd10
Shrink benchmark axes.
bdice 017f925
Shrink benchmark axes for stable_distinct.
bdice b998449
clang-format
bdice bfb924b
Merge remote-tracking branch 'upstream/branch-24.10' into update-dist…
bdice File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| /* | ||
| * Copyright (c) 2020-2023, NVIDIA CORPORATION. | ||
| * Copyright (c) 2020-2024, NVIDIA CORPORATION. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
|
|
@@ -23,15 +23,44 @@ | |
|
|
||
| #include <nvbench/nvbench.cuh> | ||
|
|
||
| #include <limits> | ||
|
|
||
| NVBENCH_DECLARE_TYPE_STRINGS(cudf::timestamp_ms, "cudf::timestamp_ms", "cudf::timestamp_ms"); | ||
|
|
||
| cudf::duplicate_keep_option get_keep(std::string const& keep_str) | ||
| { | ||
| if (keep_str == "any") { | ||
| return cudf::duplicate_keep_option::KEEP_ANY; | ||
| } else if (keep_str == "first") { | ||
| return cudf::duplicate_keep_option::KEEP_FIRST; | ||
| } else if (keep_str == "last") { | ||
| return cudf::duplicate_keep_option::KEEP_LAST; | ||
| } else if (keep_str == "none") { | ||
| return cudf::duplicate_keep_option::KEEP_NONE; | ||
| } else { | ||
| CUDF_FAIL("Unsupported keep option."); | ||
| } | ||
| } | ||
|
|
||
| template <typename Type> | ||
| void nvbench_distinct(nvbench::state& state, nvbench::type_list<Type>) | ||
| { | ||
| cudf::size_type const num_rows = state.get_int64("NumRows"); | ||
| cudf::size_type const num_rows = state.get_int64("NumRows"); | ||
| auto const keep = get_keep(state.get_string("keep")); | ||
| cudf::size_type const cardinality = state.get_int64("cardinality"); | ||
|
|
||
| if (cardinality > num_rows) { | ||
| state.skip("cardinality > num_rows"); | ||
| return; | ||
| } | ||
|
|
||
| data_profile profile = data_profile_builder().cardinality(0).null_probability(0.01).distribution( | ||
| cudf::type_to_id<Type>(), distribution_id::UNIFORM, 0, 100); | ||
| data_profile profile = data_profile_builder() | ||
| .cardinality(cardinality) | ||
| .null_probability(0.01) | ||
| .distribution(cudf::type_to_id<Type>(), | ||
| distribution_id::UNIFORM, | ||
| static_cast<Type>(0), | ||
| std::numeric_limits<Type>::max()); | ||
|
|
||
| auto source_column = create_random_column(cudf::type_to_id<Type>(), row_count{num_rows}, profile); | ||
|
|
||
|
|
@@ -40,27 +69,29 @@ void nvbench_distinct(nvbench::state& state, nvbench::type_list<Type>) | |
|
|
||
| state.set_cuda_stream(nvbench::make_cuda_stream_view(cudf::get_default_stream().value())); | ||
| state.exec(nvbench::exec_tag::sync, [&](nvbench::launch& launch) { | ||
| auto result = cudf::distinct(input_table, | ||
| {0}, | ||
| cudf::duplicate_keep_option::KEEP_ANY, | ||
| cudf::null_equality::EQUAL, | ||
| cudf::nan_equality::ALL_EQUAL); | ||
| auto result = cudf::distinct( | ||
| input_table, {0}, keep, cudf::null_equality::EQUAL, cudf::nan_equality::ALL_EQUAL); | ||
| }); | ||
| } | ||
|
|
||
| using data_type = nvbench::type_list<bool, int8_t, int32_t, int64_t, float, cudf::timestamp_ms>; | ||
| using data_type = nvbench::type_list<int32_t, int64_t>; | ||
|
|
||
| NVBENCH_BENCH_TYPES(nvbench_distinct, NVBENCH_TYPE_AXES(data_type)) | ||
| .set_name("distinct") | ||
| .set_type_axes_names({"Type"}) | ||
| .add_int64_axis("NumRows", {10'000, 100'000, 1'000'000, 10'000'000}); | ||
| .add_string_axis("keep", {"any", "first", "last", "none"}) | ||
| .add_int64_axis("cardinality", | ||
| {100, 1'000, 10'000, 100'000, 1'000'000, 10'000'000, 100'000'000, 1'000'000'000}) | ||
|
||
| .add_int64_axis("NumRows", | ||
| {100, 1'000, 10'000, 100'000, 1'000'000, 10'000'000, 100'000'000, 1'000'000'000}); | ||
bdice marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| template <typename Type> | ||
| void nvbench_distinct_list(nvbench::state& state, nvbench::type_list<Type>) | ||
| { | ||
| auto const size = state.get_int64("ColumnSize"); | ||
| auto const dtype = cudf::type_to_id<Type>(); | ||
| double const null_probability = state.get_float64("null_probability"); | ||
| auto const keep = get_keep(state.get_string("keep")); | ||
|
|
||
| auto builder = data_profile_builder().null_probability(null_probability); | ||
| if (dtype == cudf::type_id::LIST) { | ||
|
|
@@ -80,17 +111,15 @@ void nvbench_distinct_list(nvbench::state& state, nvbench::type_list<Type>) | |
|
|
||
| state.set_cuda_stream(nvbench::make_cuda_stream_view(cudf::get_default_stream().value())); | ||
| state.exec(nvbench::exec_tag::sync, [&](nvbench::launch& launch) { | ||
| auto result = cudf::distinct(*table, | ||
| {0}, | ||
| cudf::duplicate_keep_option::KEEP_ANY, | ||
| cudf::null_equality::EQUAL, | ||
| cudf::nan_equality::ALL_EQUAL); | ||
| auto result = | ||
| cudf::distinct(*table, {0}, keep, cudf::null_equality::EQUAL, cudf::nan_equality::ALL_EQUAL); | ||
| }); | ||
| } | ||
|
|
||
| NVBENCH_BENCH_TYPES(nvbench_distinct_list, | ||
| NVBENCH_TYPE_AXES(nvbench::type_list<int32_t, cudf::list_view>)) | ||
| .set_name("distinct_list") | ||
| .set_type_axes_names({"Type"}) | ||
| .add_string_axis("keep", {"any", "first", "last", "none"}) | ||
| .add_float64_axis("null_probability", {0.0, 0.1}) | ||
| .add_int64_axis("ColumnSize", {100'000'000}); | ||
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
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
I would prefer to omit this skipping condition. I recognize that we can't have 1M distinct elements in 1K rows, but this condition adds a lot of friction when sweeping NumRows for the high cardinality case. It forces me to run a full factorial of matching NumRows and Cardinality values and filter the outputs for the highest Cardinality unskipped for each NumRows.
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.
I'll rewrite this logic. Thanks for the feedback!
Uh oh!
There was an error while loading. Please reload this page.
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.
Hmm. @GregoryKimball I reviewed the NVBench docs and I don't see a way to filter out certain jobs except by skipping them. https://github.com/NVIDIA/nvbench/blob/main/docs/benchmarks.md#beware-combinatorial-explosion-is-lurking
We might be able to use a string axis like
{"100,100", "100,1000", ..., "1000000000,1000000000"}and parse it, but that's hard to maintain.Uh oh!
There was an error while loading. Please reload this page.
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.
NVIDIA/nvbench#80 can solve this issue but the PR has been stalled for a while.