Files
project_6/cccl_upstream/docs/cub/determinism.rst
muh-bot 2a7ca101d7 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
2026-08-07 02:34:33 +00:00

77 lines
2.8 KiB
ReStructuredText

.. _cub-determinism:
Determinism
===============
Several ``cub`` device algorithms let you request a reproducibility guarantee for a call. The concepts
behind the three guarantees — ``not_guaranteed``, ``run_to_run``, and ``gpu_to_gpu`` — and the meaning
of *reproducibility* are described in the :ref:`CCCL determinism overview <cccl-determinism>`. This
page documents how to request a guarantee for a CUB algorithm and which algorithms support which
guarantees.
Requesting a guarantee
----------------------
A determinism guarantee is passed to a device algorithm through its execution environment using
``cuda::execution::require``. The example below requests run-to-run reproducibility for
``cub::DeviceReduce::Sum``:
.. literalinclude:: ../../cub/test/catch2_test_device_reduce_env_api.cu
:language: c++
:dedent:
:start-after: example-begin sum-env-determinism
:end-before: example-end sum-env-determinism
The general rules for requesting a guarantee are described in the
:ref:`CCCL determinism overview <cccl-determinism>`.
Each CUB algorithm has its own default guarantee, applied when none is requested, and its own type and
operator constraints for each guarantee, summarized below. Requesting a guarantee that an algorithm
does not support is rejected at compile time.
Support matrix
--------------
.. list-table::
:header-rows: 1
:widths: 30 18 18 18 16
* - Algorithm
- ``not_guaranteed``
- ``run_to_run``
- ``gpu_to_gpu``
- Default
* - ``cub::DeviceReduce`` (``Reduce``, ``Sum``, ``Min``, ``Max``, ``TransformReduce``, ...)
- Yes
- Yes
- Yes (partial)
- ``run_to_run``
* - ``cub::DeviceScan`` (``ExclusiveSum``, ``ExclusiveScan``, ``InclusiveSum``, ``InclusiveScan``, ...)
- Yes
- Yes (partial)
- Yes (partial)
- ``not_guaranteed``
* - ``cub::DeviceSegmentedReduce``
- Yes
- Yes
- No
- ``run_to_run``
.. note::
The set of algorithms that accept determinism requirements, and the type/operator constraints for
each guarantee, are expanding over time. The matrix above reflects the current implementation.
Algorithm-specific determinism models
--------------------------------------
The three guarantees describe the *scope* of reproducibility and fit most algorithms, where a
reproducible result means a *bitwise-identical* output. A few algorithms still use the same three
levels but extend the model with additional, algorithm-specific controls, documented on their own
pages:
- :ref:`cub::DeviceTopK <cub-topk-requirements>` — determinism applies to *set membership* (which
*K* items are selected) rather than a bitwise-identical buffer, and it adds tie-breaking
(``cuda::execution::tie_break``) and output-ordering (``cuda::execution::output_ordering``)
controls.