feat(cccl): integrate missing CCCL directories — python/, ci/, .agent/, docs/, test/

Sparse-checkout from NVIDIA/cccl main branch to complete cccl_upstream:

Added:
- python/cuda_cccl/ (226 files) — Python bindings for device-level algorithms
  Critical for muh toolchain: cuda.compute.reduce_into, scan, radix_sort, etc.
  Includes 204 .py files with full test coverage for all 27 algorithms
- ci/ (163 files) — Build/test infrastructure
  build_cub.sh, test_cub.sh, build_and_test_targets.sh, matrix.yaml
  Directly maps to our [INFRA-CI] and [INFRA-BUILD] items
- .agent/skills/ (7 files) — NVIDIA's own agent skills for CCCL
  cccl-style/SKILL.md, cccl-test/SKILL.md, sass-diff/SKILL.md
- docs/ (491 files) — Official CCCL documentation
  CI references, CMake guides, Python compute docs, libcudacxx PTX docs
- test/ (12 files) — Top-level integration tests (cuda_smoke, stdpar)
- Root configs: .clang-format, .clang-tidy, CONTRIBUTING.md, pyproject.toml
- CLAUDE.md symlink → AGENTS.md (NVIDIA's standard)

cccl_upstream now mirrors full NVIDIA/cccl structure:
  Before: 42M (cub + thrust + libcudacxx + cudax + c + examples + benchmarks)
  After:  53M (+python +ci +docs +.agent +test +configs)

This completes the CCCL base needed for:
- [muh-bench] items: ci/util/build_and_test_targets.sh for targeted builds
- [CCCL-verify] items: python/cuda_cccl/tests/ as reference implementations
- [CCCL-test] items: ci/test_cub.sh, ci/test_thrust.sh
- Agent workflow: .agent/skills/ for consistent style and test patterns
This commit is contained in:
muh-bot
2026-08-07 02:34:33 +00:00
parent 3f97dca7ad
commit 2a7ca101d7
908 changed files with 121615 additions and 0 deletions

View File

@@ -0,0 +1,82 @@
# Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED.
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
"""
Python benchmark for reduce custom operation using cuda.compute.reduce_into.
C++ equivalent: cub/benchmarks/bench/reduce/custom.cu
Notes:
- Uses a custom max operator (not OpKind) to exercise generic path
- int128 and complex32 are not supported by cupy
- Migration: Python limits to basic numeric types; C++ includes int128/complex.
"""
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent))
import cupy as cp
import numpy as np
from utils import SIGNED_TYPES as TYPE_MAP
from utils import as_cupy_stream, generate_data_with_entropy
import cuda.bench as bench
from cuda.compute import make_reduce_into
def max_op(a, b):
return a if a > b else b
def bench_reduce_custom(state: bench.State):
type_str = state.get_string("T{ct}")
dtype = TYPE_MAP[type_str]
num_items = int(state.get_int64("Elements{io}"))
alloc_stream = as_cupy_stream(state.get_stream())
with alloc_stream:
d_in = generate_data_with_entropy(num_items, dtype, "1.000", alloc_stream)
d_out = cp.empty(1, dtype=dtype)
h_init = np.zeros(1, dtype=dtype)
reducer = make_reduce_into(d_in=d_in, d_out=d_out, op=max_op, h_init=h_init)
temp_storage_bytes = reducer(
temp_storage=None,
d_in=d_in,
d_out=d_out,
num_items=num_items,
op=max_op,
h_init=h_init,
)
with alloc_stream:
temp_storage = cp.empty(temp_storage_bytes, dtype=np.uint8)
state.add_element_count(num_items)
state.add_global_memory_reads(num_items * d_in.dtype.itemsize, "Size")
state.add_global_memory_writes(d_out.dtype.itemsize)
def launcher(launch: bench.Launch):
reducer(
temp_storage=temp_storage,
d_in=d_in,
d_out=d_out,
num_items=num_items,
op=max_op,
h_init=h_init,
stream=launch.get_stream(),
)
state.exec(launcher, batched=False)
if __name__ == "__main__":
b = bench.register(bench_reduce_custom)
b.set_name("base")
b.add_string_axis("T{ct}", list(TYPE_MAP.keys()))
b.add_int64_power_of_two_axis("Elements{io}", range(16, 29, 4))
bench.run_all_benchmarks(sys.argv)

View File

@@ -0,0 +1,85 @@
# Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED.
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
"""
Python benchmark for reduce min operation using cuda.compute.reduce_into.
C++ equivalent: cub/benchmarks/bench/reduce/min.cu
Notes:
- Uses OpKind.MINIMUM for minimum reduction
- C++ uses cuda::minimum<> which CUB recognizes for optimized code paths (DPX on Hopper+)
- int128 and complex32 are not supported by cupy
"""
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent))
import cupy as cp
import numpy as np
from utils import FUNDAMENTAL_TYPES as TYPE_MAP
from utils import as_cupy_stream, generate_data_with_entropy
import cuda.bench as bench
from cuda.compute import OpKind, make_reduce_into
def bench_reduce_min(state: bench.State):
type_str = state.get_string("T{ct}")
dtype = TYPE_MAP[type_str]
num_items = int(state.get_int64("Elements{io}"))
alloc_stream = as_cupy_stream(state.get_stream())
with alloc_stream:
d_in = generate_data_with_entropy(num_items, dtype, "1.000", alloc_stream)
d_out = cp.empty(1, dtype=dtype)
# Initial value for min reduction (max value of type)
if np.issubdtype(dtype, np.integer):
init_val = np.iinfo(dtype).max
else:
init_val = np.finfo(dtype).max
h_init = np.array([init_val], dtype=dtype)
reducer = make_reduce_into(d_in=d_in, d_out=d_out, op=OpKind.MINIMUM, h_init=h_init)
temp_storage_bytes = reducer(
temp_storage=None,
d_in=d_in,
d_out=d_out,
num_items=num_items,
op=OpKind.MINIMUM,
h_init=h_init,
)
with alloc_stream:
temp_storage = cp.empty(temp_storage_bytes, dtype=np.uint8)
state.add_element_count(num_items)
state.add_global_memory_reads(num_items * d_in.dtype.itemsize, "Size")
state.add_global_memory_writes(d_out.dtype.itemsize)
def launcher(launch: bench.Launch):
reducer(
temp_storage=temp_storage,
d_in=d_in,
d_out=d_out,
num_items=num_items,
op=OpKind.MINIMUM,
h_init=h_init,
stream=launch.get_stream(),
)
state.exec(launcher, batched=False)
if __name__ == "__main__":
b = bench.register(bench_reduce_min)
b.set_name("base")
b.add_string_axis("T{ct}", list(TYPE_MAP.keys()))
b.add_int64_power_of_two_axis("Elements{io}", range(16, 29, 4))
bench.run_all_benchmarks(sys.argv)

View File

@@ -0,0 +1,87 @@
# Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED.
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
"""
Python benchmark for nondeterministic reduce sum using cuda.compute.reduce_into.
C++ equivalent: cub/benchmarks/bench/reduce/nondeterministic.cu
Notes:
- Uses Determinism.NOT_GUARANTEED
- C++ tests int32, int64, float, double
- Migration: Python fixes offsets; C++ exposes an OffsetT axis.
- OffsetT axis is omitted because the Python API does not expose offset type.
"""
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent))
import cupy as cp
import numpy as np
from utils import ALL_TYPES as _ALL_TYPES
from utils import as_cupy_stream, generate_data_with_entropy
import cuda.bench as bench
from cuda.compute import Determinism, OpKind, make_reduce_into
TYPE_MAP = {k: _ALL_TYPES[k] for k in ("I32", "I64", "F32", "F64")}
def bench_reduce_nondeterministic(state: bench.State):
type_str = state.get_string("T{ct}")
dtype = TYPE_MAP[type_str]
num_items = int(state.get_int64("Elements{io}"))
alloc_stream = as_cupy_stream(state.get_stream())
with alloc_stream:
d_in = generate_data_with_entropy(num_items, dtype, "1.000", alloc_stream)
d_out = cp.empty(1, dtype=dtype)
h_init = np.zeros(1, dtype=dtype)
reducer = make_reduce_into(
d_in=d_in,
d_out=d_out,
op=OpKind.PLUS,
h_init=h_init,
determinism=Determinism.NOT_GUARANTEED,
)
temp_storage_bytes = reducer(
temp_storage=None,
d_in=d_in,
d_out=d_out,
num_items=num_items,
op=OpKind.PLUS,
h_init=h_init,
)
with alloc_stream:
temp_storage = cp.empty(temp_storage_bytes, dtype=np.uint8)
state.add_element_count(num_items)
state.add_global_memory_reads(num_items * d_in.dtype.itemsize, "Size")
state.add_global_memory_writes(1 * d_out.dtype.itemsize)
def launcher(launch: bench.Launch):
reducer(
temp_storage=temp_storage,
d_in=d_in,
d_out=d_out,
num_items=num_items,
op=OpKind.PLUS,
h_init=h_init,
stream=launch.get_stream(),
)
state.exec(launcher, batched=False)
if __name__ == "__main__":
b = bench.register(bench_reduce_nondeterministic)
b.set_name("base")
b.add_string_axis("T{ct}", list(TYPE_MAP.keys()))
b.add_int64_power_of_two_axis("Elements{io}", range(16, 29, 4))
bench.run_all_benchmarks(sys.argv)

View File

@@ -0,0 +1,80 @@
# Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED.
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
"""
Python benchmark for reduce sum operation using cuda.compute.reduce_into.
C++ equivalent: cub/benchmarks/bench/reduce/sum.cu
Notes:
- int128 and complex32 are not supported by cupy
- Migration: Python excludes int128/complex; C++ supports more types/tuning.
"""
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent))
import cupy as cp
import numpy as np
from utils import SIGNED_TYPES as TYPE_MAP
from utils import as_cupy_stream, generate_data_with_entropy
import cuda.bench as bench
from cuda.compute import OpKind, make_reduce_into
def bench_reduce_sum(state: bench.State):
type_str = state.get_string("T{ct}")
dtype = TYPE_MAP[type_str]
num_items = int(state.get_int64("Elements{io}"))
alloc_stream = as_cupy_stream(state.get_stream())
with alloc_stream:
d_in = generate_data_with_entropy(num_items, dtype, "1.000", alloc_stream)
d_out = cp.empty(1, dtype=dtype)
# Initial value for reduction
h_init = np.zeros(1, dtype=dtype)
reducer = make_reduce_into(d_in=d_in, d_out=d_out, op=OpKind.PLUS, h_init=h_init)
temp_storage_bytes = reducer(
temp_storage=None,
d_in=d_in,
d_out=d_out,
num_items=num_items,
op=OpKind.PLUS,
h_init=h_init,
)
with alloc_stream:
temp_storage = cp.empty(temp_storage_bytes, dtype=np.uint8)
state.add_element_count(num_items)
state.add_global_memory_reads(num_items * d_in.dtype.itemsize, "Size")
state.add_global_memory_writes(d_out.dtype.itemsize)
def launcher(launch: bench.Launch):
reducer(
temp_storage=temp_storage,
d_in=d_in,
d_out=d_out,
num_items=num_items,
op=OpKind.PLUS,
h_init=h_init,
stream=launch.get_stream(),
)
state.exec(launcher, batched=False)
if __name__ == "__main__":
b = bench.register(bench_reduce_sum)
b.set_name("base")
b.add_string_axis("T{ct}", list(TYPE_MAP.keys()))
b.add_int64_power_of_two_axis("Elements{io}", range(16, 29, 4))
bench.run_all_benchmarks(sys.argv)