-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add remaining NDS-H queries to libcudf with CI validation #23624
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
Draft
bdice
wants to merge
18
commits into
main
Choose a base branch
from
ndsh
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+4,114
−106
Draft
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
c4c4405
Add relational helpers for NDS-H benchmarks
bdice 26f61ae
Add standard modes to NDS-H queries
bdice c351c0e
Add remaining NDS-H query benchmarks
bdice e6e50e4
Add smoke coverage for NDS-H benchmarks
bdice 93dedb3
Fix NDS-H benchmark iteration metrics
bdice 061caf4
Install NDS-H generator test
bdice 4990387
Document NDS-H benchmark queries
bdice dc8bbca
Fix NDS-H query result semantics
bdice cab2af8
Validate NDS-H benchmark results with DuckDB
bdice 31c04a1
Validate NDS-H queries 2, 5, and 6
bdice 0806f0b
Validate NDS-H queries 7, 8, and 10
bdice 7e7cd37
Validate NDS-H queries 11, 12, and 13
bdice 0f8d927
Validate NDS-H queries 14, 15, and 16
bdice 1ceb155
Validate NDS-H queries 19, 20, and 22
bdice a089808
Validate NDS-H smoke tests at scale factor 1
bdice e61f618
Update cpp/benchmarks/ndsh/README.md
bdice a06beff
Update ci/run_cudf_benchmark_smoketests.sh
bdice 9e4319b
Merge branch 'main' into ndsh
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
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 |
|---|---|---|
| @@ -0,0 +1,130 @@ | ||
| #!/usr/bin/env python3 | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import argparse | ||
| import math | ||
| import numbers | ||
| from pathlib import Path | ||
|
|
||
| import duckdb | ||
|
|
||
| QUERIES = ( | ||
| "q01", | ||
| "q02", | ||
| "q03", | ||
| "q04", | ||
| "q05", | ||
| "q06", | ||
| "q07", | ||
| "q08", | ||
| "q09", | ||
| "q10", | ||
| "q11", | ||
| "q12", | ||
| "q13", | ||
| "q14", | ||
| "q15", | ||
| "q16", | ||
| "q17", | ||
| "q18", | ||
| "q19", | ||
| "q20", | ||
| "q21", | ||
| "q22", | ||
| ) | ||
| EXPECTED_NAMES = { | ||
| "q18": [ | ||
| "c_name", | ||
| "c_custkey", | ||
| "o_orderkey", | ||
| "o_orderdate", | ||
| "o_totalprice", | ||
| "sum(l_quantity)", | ||
| ] | ||
| } | ||
|
|
||
|
|
||
| def values_equal(actual, expected): | ||
| if actual is None or expected is None: | ||
| return actual is expected | ||
| if isinstance(actual, numbers.Number) and isinstance( | ||
| expected, numbers.Number | ||
| ): | ||
| return math.isclose( | ||
| float(actual), float(expected), rel_tol=0.0, abs_tol=0.01 | ||
| ) | ||
| return actual == expected | ||
|
|
||
|
|
||
| def validate_query(query_name, sql_dir, output_dir, scale_factor=0.01): | ||
| connection = duckdb.connect() | ||
| for path in (output_dir / query_name / "input").glob("*.parquet"): | ||
| table_name = path.stem.replace('"', '""') | ||
| parquet_path = str(path).replace("'", "''") | ||
| connection.execute( | ||
| f'CREATE VIEW "{table_name}" AS ' | ||
| f"SELECT * FROM read_parquet('{parquet_path}')" | ||
| ) | ||
|
|
||
| parameters = ( | ||
| {"scale_factor": scale_factor} if query_name == "q11" else None | ||
| ) | ||
| expected = connection.execute( | ||
| (sql_dir / f"{query_name}.sql").read_text(), parameters | ||
| ) | ||
| expected_names = [column[0] for column in expected.description] | ||
| expected_rows = expected.fetchall() | ||
|
|
||
| result_path = output_dir / query_name / "results" / f"{query_name}.parquet" | ||
| actual = connection.execute( | ||
| "SELECT * FROM read_parquet(?)", [str(result_path)] | ||
| ) | ||
| actual_names = [column[0] for column in actual.description] | ||
| actual_rows = actual.fetchall() | ||
|
|
||
| expected_names = EXPECTED_NAMES.get(query_name, expected_names) | ||
| if actual_names != expected_names: | ||
| return f"column names differ: {actual_names} != {expected_names}" | ||
| if len(actual_rows) != len(expected_rows): | ||
| return f"row counts differ: {len(actual_rows)} != {len(expected_rows)}" | ||
|
|
||
| for row_index, (actual_row, expected_row) in enumerate( | ||
| zip(actual_rows, expected_rows, strict=True) | ||
| ): | ||
| for column_name, actual_value, expected_value in zip( | ||
| actual_names, actual_row, expected_row, strict=True | ||
| ): | ||
| if not values_equal(actual_value, expected_value): | ||
| return ( | ||
| f"row {row_index}, column {column_name} differs: " | ||
| f"{actual_value!r} != {expected_value!r}" | ||
| ) | ||
| return None | ||
|
|
||
|
|
||
| def main(): | ||
| parser = argparse.ArgumentParser( | ||
| description="Validate NDS-H benchmark Parquet results against DuckDB" | ||
| ) | ||
| parser.add_argument("--output-dir", type=Path, required=True) | ||
| parser.add_argument("--sql-dir", type=Path, required=True) | ||
| parser.add_argument("--scale-factor", type=float, default=0.01) | ||
| args = parser.parse_args() | ||
|
|
||
| failed = False | ||
| for query_name in QUERIES: | ||
| error = validate_query( | ||
| query_name, args.sql_dir, args.output_dir, args.scale_factor | ||
| ) | ||
| if error is None: | ||
| print(f"{query_name}: PASSED") | ||
| else: | ||
| failed = True | ||
| print(f"{query_name}: FAILED: {error}") | ||
|
|
||
| raise SystemExit(failed) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() |
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
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
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
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
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
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
57 changes: 57 additions & 0 deletions
57
cpp/benchmarks/common/ndsh_data_generator/ndsh_data_generator_test.cpp
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 |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| /* | ||
| * SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| #include "ndsh_data_generator.hpp" | ||
|
|
||
| #include <cudf_test/base_fixture.hpp> | ||
|
|
||
| #include <cudf/reduction.hpp> | ||
| #include <cudf/scalar/scalar.hpp> | ||
|
|
||
| #include <gtest/gtest.h> | ||
|
|
||
| struct NDSHDataGeneratorTest : public cudf::test::BaseFixture {}; | ||
|
|
||
| TEST_F(NDSHDataGeneratorTest, ScaleFactorPointZeroOne) | ||
| { | ||
| constexpr double scale_factor = 0.01; | ||
|
|
||
| auto [orders, lineitem, part] = cudf::datagen::generate_orders_lineitem_part(scale_factor); | ||
| auto partsupp = cudf::datagen::generate_partsupp(scale_factor); | ||
| auto supplier = cudf::datagen::generate_supplier(scale_factor); | ||
| auto customer = cudf::datagen::generate_customer(scale_factor); | ||
| auto nation = cudf::datagen::generate_nation(); | ||
| auto region = cudf::datagen::generate_region(); | ||
|
|
||
| auto const expect_cardinality = | ||
| [](cudf::table const& table, cudf::size_type rows, cudf::size_type columns) { | ||
| EXPECT_EQ(table.num_rows(), rows); | ||
| EXPECT_EQ(table.num_columns(), columns); | ||
| }; | ||
|
|
||
| expect_cardinality(*orders, 15'000, 9); | ||
| EXPECT_GE(lineitem->num_rows(), 15'000); | ||
| EXPECT_LE(lineitem->num_rows(), 105'000); | ||
| EXPECT_EQ(lineitem->num_columns(), 16); | ||
| expect_cardinality(*part, 2'000, 9); | ||
| expect_cardinality(*partsupp, 8'000, 5); | ||
| expect_cardinality(*supplier, 100, 7); | ||
| expect_cardinality(*customer, 1'500, 8); | ||
| expect_cardinality(*nation, 25, 4); | ||
| expect_cardinality(*region, 5, 3); | ||
|
|
||
| auto const expect_supplier_key_range = [](cudf::column_view const& keys, | ||
| cudf::size_type supplier_rows) { | ||
| EXPECT_EQ(keys.null_count(), 0); | ||
| auto const [minimum, maximum] = cudf::minmax(keys); | ||
| auto const min_key = static_cast<cudf::numeric_scalar<cudf::size_type> const*>(minimum.get()); | ||
| auto const max_key = static_cast<cudf::numeric_scalar<cudf::size_type> const*>(maximum.get()); | ||
| EXPECT_GE(min_key->value(), 1); | ||
| EXPECT_LE(max_key->value(), supplier_rows); | ||
| }; | ||
|
|
||
| expect_supplier_key_range(lineitem->view().column(2), supplier->num_rows()); | ||
| expect_supplier_key_range(partsupp->view().column(1), supplier->num_rows()); | ||
| } |
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
Oops, something went wrong.
Oops, something went wrong.
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.