Skip to content

Deprecate DispatchScan and AgentScanPolicy - #9234

Merged
bernhardmgruber merged 9 commits into
NVIDIA:mainfrom
bernhardmgruber:depr_dispatch_scan
Jun 9, 2026
Merged

bernhardmgruber merged 9 commits into
NVIDIA:mainfrom
bernhardmgruber:depr_dispatch_scan

Conversation

@bernhardmgruber

@bernhardmgruber bernhardmgruber commented Jun 3, 2026 •

Copy link
Copy Markdown
Contributor

This is a follow-up to #8853 to keep that PR a bit shorter.

@bernhardmgruber
bernhardmgruber requested review from a team as code owners June 3, 2026 09:37
@github-project-automation github-project-automation Bot moved this to Todo in CCCL Jun 3, 2026
@cccl-authenticator-app cccl-authenticator-app Bot moved this from Todo to In Review in CCCL Jun 3, 2026
@bernhardmgruber bernhardmgruber changed the title Deprecate DispatchScan Deprecate DispatchScan Jun 3, 2026
@coderabbitai

coderabbitai Bot commented Jun 3, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 609176d3-602c-4819-981e-502ac1eee1e5

📥 Commits

Reviewing files that changed from the base of the PR and between b61eed6 and 2551f31.

📒 Files selected for processing (10)
  • cub/cub/agent/agent_scan.cuh
  • cub/cub/device/dispatch/dispatch_scan.cuh
  • cub/cub/device/dispatch/dispatch_scan_by_key.cuh
  • cub/cub/device/dispatch/kernels/kernel_radix_sort.cuh
  • cub/cub/device/dispatch/kernels/kernel_scan.cuh
  • cub/cub/device/dispatch/tuning/tuning_radix_sort.cuh
  • cub/cub/device/dispatch/tuning/tuning_scan.cuh
  • cub/test/catch2_test_device_radix_sort_custom_policy_hub.cu
  • cub/test/catch2_test_device_scan_custom_policy_hub.cu
  • cub/test/catch2_test_device_segmented_radix_sort_custom_policy_hub.cu
✅ Files skipped from review due to trivial changes (2)
  • cub/cub/device/dispatch/dispatch_scan_by_key.cuh
  • cub/test/catch2_test_device_radix_sort_custom_policy_hub.cu
🚧 Files skipped from review as they are similar to previous changes (8)
  • cub/cub/device/dispatch/kernels/kernel_radix_sort.cuh
  • cub/cub/device/dispatch/kernels/kernel_scan.cuh
  • cub/test/catch2_test_device_segmented_radix_sort_custom_policy_hub.cu
  • cub/cub/device/dispatch/tuning/tuning_scan.cuh
  • cub/test/catch2_test_device_scan_custom_policy_hub.cu
  • cub/cub/device/dispatch/tuning/tuning_radix_sort.cuh
  • cub/cub/agent/agent_scan.cuh
  • cub/cub/device/dispatch/dispatch_scan.cuh

Note: CodeRabbit is enabled on this repository as a convenience for maintainers
and contributors. Use your best judgment when considering its review comments and
suggestions — a suggested change may be inadequate, unnecessary, or safe to ignore.
Contributors are not expected to address every comment. Human reviews are what
ultimately matter for merging.

Overview

This follow-up PR deprecates the DispatchScan dispatcher and reorganizes the scan launch path to use new internal detail::scan helpers and a new internal agent_scan_policy. It is intended to be merged after PR #8853 (merge-order note present and checklist item completed). Deprecated aliases preserve backward compatibility while steering users toward the DeviceScan/tuning API.

Key Changes

  • dispatch_scan.cuh — deprecation + refactor (+~430/-34)

    • Marked struct DispatchScan as CCCL_DEPRECATED_BECAUSE("Please use DeviceScan").
    • Removed the prior centralized __invoke helper and made DispatchScan::Invoke branch directly on policy_getter{}().algorithm == ScanAlgorithm::warpspeed where needed.
    • Refactored scan launch/SMEM sizing and policy selection into detail::scan helpers (check_warpspeed_smem, invoke_lookback, invoke_warpspeed, and detail::scan::invoke) and changed per-capability dispatch paths to call detail::scan::invoke(...) directly (no longer constructing and calling a DispatchScan object).
    • Updated related SMEM/stage sizing and warpspeed vs lookback launch logic into the new helpers.
  • agent_scan.cuh — new internal policy type + deprecated alias (+36/-12)

    • Added cub::detail::agent_scan_policy<...> templated policy exposing LOAD_ALGORITHM, LOAD_MODIFIER, STORE_ALGORITHM, SCAN_ALGORITHM, nested delay-constructor alias, and deriving from the scaling type.
    • Replaced the old concrete AgentScanPolicy struct with a deprecated using-alias AgentScanPolicy = detail::agent_scan_policy<...> to preserve compatibility while signaling migration to the tuning API.
  • Tuning wiring — policy_hub updates (tuning_scan.cuh, tuning_radix_sort.cuh; ~+79/-79)

    • Updated tuning/policy_hub type aliases and selection helpers to construct/return agent_scan_policy (lowercase) instead of the deprecated AgentScanPolicy, preserving template arguments and tuning semantics.
  • Kernel updates (kernel_scan.cuh, kernel_radix_sort.cuh; small edits)

    • Kernel ScanPolicy aliases updated to use agent_scan_policy<> (lowercase) where agent scan policies are instantiated; algorithm branching and kernel wiring remain functionally unchanged.
  • dispatch_scan_by_key.cuh — diagnostic message fixes

    • Adjusted static_assert failure messages to reference DispatchScanByKey / scan_by_key::dispatch (instead of DispatchScan) for unsupported OffsetT types.
  • Tests — temporary suppression of deprecation warnings

    • Several custom policy-hub Catch2 tests now define CCCL_IGNORE_DEPRECATED_API (with TODOs) to suppress deprecation diagnostics for DispatchScan while tests continue to validate legacy dispatch behavior.

Public/API impact

  • Backwards-compatible: public types and function signatures remain available via deprecated aliases; callers will see deprecation diagnostics and are directed to migrate to DeviceScan / the tuning API.
  • No breaking API signature changes detected in the diff; behavior-preserving rewiring and aliasing were used to minimize user impact.
  • Merge-order dependency: must be applied after PR #8853 as noted by the author.

Review notes and effort estimate

  • High review effort: dispatch_scan.cuh refactor and deprecation (~430 lines added, wider control-flow and launch logic movement).
  • Medium review effort: agent_scan_policy introduction (new internal policy type and deprecated alias), tuning hub updates, and kernel alias swaps.
  • Low review effort: small diagnostic message changes and test macro additions.
  • Verify that all call-sites now resolve to detail::scan::invoke or the new agent_scan_policy aliases and that the deprecated aliases produce the intended deprecation diagnostics only (suppressed in test builds where CCCL_IGNORE_DEPRECATED_API is defined).

Walkthrough

This PR adds cub::detail::agent_scan_policy, deprecates AgentScanPolicy and DispatchScan, refactors DispatchScan launch logic into detail::scan helpers (warpspeed/lookback paths and SMEM checks), updates kernels and tuning wiring to use agent_scan_policy, and suppresses DispatchScan deprecation in tests.

Changes

agent_scan_policy migration and DispatchScan refactoring

Layer / File(s) Summary
New agent_scan_policy type and AgentScanPolicy deprecation
cub/cub/agent/agent_scan.cuh
cub::detail::agent_scan_policy is introduced and AgentScanPolicy becomes a deprecated alias forwarding to it.
DispatchScan deprecation and dispatch helper refactoring
cub/cub/device/dispatch/dispatch_scan.cuh
DispatchScan is marked deprecated; internal __invoke removed; Invoke now branches inline on policy_getter().algorithm; new detail::scan helpers (check_warpspeed_smem, invoke_lookback, invoke_warpspeed, invoke) encapsulate SMEM checks and kernel launches; per-CC dispatch calls detail::scan::invoke(...).
Scan kernel policy type updates
cub/cub/device/dispatch/kernels/kernel_scan.cuh, cub/cub/device/dispatch/kernels/kernel_radix_sort.cuh
Kernel scan policy adapters switch from AgentScanPolicy to agent_scan_policy for lookback paths; warpspeed vs lookback branching unchanged.
Scan policy hub tuning updates
cub/cub/device/dispatch/tuning/tuning_scan.cuh
detail::scan::policy_hub aliases and selection helpers now construct agent_scan_policy<...> with the same tuning-derived template arguments (including load_modifier where used).
Radix-sort kernel and policy hub wiring updates
cub/cub/device/dispatch/tuning/tuning_radix_sort.cuh
detail::radix_sort::policy_hub nested policies (Policy500–Policy800) and OnesweepSmallKeyTunedPolicy replace AgentScanPolicy with agent_scan_policy in their ScanPolicy aliases.
Error message clarity and test deprecation handling
cub/cub/device/dispatch/dispatch_scan_by_key.cuh, cub/test/*custom_policy_hub.cu
Static assert messages corrected to reference the right dispatcher names; tests add CCCL_IGNORE_DEPRECATED_API macros and TODO comments to silence DispatchScan deprecation warnings.

Possibly related PRs

  • NVIDIA/cccl#9098: Modifies DeviceScan dispatch machinery; may intersect with algorithm/dispatch refactor.
  • NVIDIA/cccl#9154: Also touches dispatch_scan.cuh dependent_launch/compute-capability gating and may overlap with launch changes.

Suggested reviewers

  • shwina
  • srinivasyadav18
  • miscco

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
cub/cub/detail/delay_constructor.cuh (1)

22-34: ⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

important: LookbackDelayAlgorithm::__reduce_by_key is now a public enumerator, so downstream code can spell an implementation-only mode directly and you effectively commit it as part of the public API. The internal reduce-by-key path is already representable through detail::lookback_delay_policy_from_type and default_reduce_by_key_delay_constructor_policy, so this mode should stay internal instead of being publicly constructible via LookbackDelayPolicy.

Also applies to: 132-195, 206-217


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 0ea531cc-5946-4649-94c5-4da9e6d96d21

📥 Commits

Reviewing files that changed from the base of the PR and between fdf1c6d and 66baecd.

📒 Files selected for processing (32)
  • c/parallel/src/radix_sort.cu
  • c/parallel/src/scan.cu
  • c/parallel/src/unique_by_key.cu
  • cub/benchmarks/bench/copy/memcpy.cu
  • cub/benchmarks/bench/scan/policy_selector.h
  • cub/cub/detail/delay_constructor.cuh
  • cub/cub/device/device_scan.cuh
  • cub/cub/device/dispatch/dispatch_radix_sort.cuh
  • cub/cub/device/dispatch/dispatch_rle.cuh
  • cub/cub/device/dispatch/dispatch_scan.cuh
  • cub/cub/device/dispatch/dispatch_scan_by_key.cuh
  • cub/cub/device/dispatch/dispatch_select_if.cuh
  • cub/cub/device/dispatch/dispatch_three_way_partition.cuh
  • cub/cub/device/dispatch/kernels/kernel_radix_sort.cuh
  • cub/cub/device/dispatch/kernels/kernel_scan.cuh
  • cub/cub/device/dispatch/kernels/kernel_scan_warpspeed.cuh
  • cub/cub/device/dispatch/tuning/tuning_batch_memcpy.cuh
  • cub/cub/device/dispatch/tuning/tuning_radix_sort.cuh
  • cub/cub/device/dispatch/tuning/tuning_reduce_by_key.cuh
  • cub/cub/device/dispatch/tuning/tuning_rle_encode.cuh
  • cub/cub/device/dispatch/tuning/tuning_rle_non_trivial_runs.cuh
  • cub/cub/device/dispatch/tuning/tuning_scan.cuh
  • cub/cub/device/dispatch/tuning/tuning_scan_by_key.cuh
  • cub/cub/device/dispatch/tuning/tuning_select_if.cuh
  • cub/cub/device/dispatch/tuning/tuning_three_way_partition.cuh
  • cub/cub/device/dispatch/tuning/tuning_unique_by_key.cuh
  • cub/test/catch2_test_device_partition_env.cu
  • cub/test/catch2_test_device_scan_custom_policy_hub.cu
  • cub/test/catch2_test_device_scan_env.cu
  • cub/test/catch2_test_device_scan_env_api.cu
  • nvbench_helper/nvbench_helper/look_back_helper.cuh
  • thrust/testing/scan.cu

@github-actions

This comment has been minimized.

@bernhardmgruber bernhardmgruber changed the title Deprecate DispatchScan Deprecate DispatchScan and AgentScanPolicy Jun 3, 2026
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 1d3e04aa-bc29-4c53-ab3d-e7cbdad66a06

📥 Commits

Reviewing files that changed from the base of the PR and between aa56305 and b61eed6.

📒 Files selected for processing (10)
  • cub/cub/agent/agent_scan.cuh
  • cub/cub/device/dispatch/dispatch_scan.cuh
  • cub/cub/device/dispatch/dispatch_scan_by_key.cuh
  • cub/cub/device/dispatch/kernels/kernel_radix_sort.cuh
  • cub/cub/device/dispatch/kernels/kernel_scan.cuh
  • cub/cub/device/dispatch/tuning/tuning_radix_sort.cuh
  • cub/cub/device/dispatch/tuning/tuning_scan.cuh
  • cub/test/catch2_test_device_radix_sort_custom_policy_hub.cu
  • cub/test/catch2_test_device_scan_custom_policy_hub.cu
  • cub/test/catch2_test_device_segmented_radix_sort_custom_policy_hub.cu
✅ Files skipped from review due to trivial changes (2)
  • cub/cub/device/dispatch/dispatch_scan_by_key.cuh
  • cub/test/catch2_test_device_scan_custom_policy_hub.cu
🚧 Files skipped from review as they are similar to previous changes (5)
  • cub/cub/device/dispatch/kernels/kernel_radix_sort.cuh
  • cub/test/catch2_test_device_segmented_radix_sort_custom_policy_hub.cu
  • cub/cub/device/dispatch/tuning/tuning_scan.cuh
  • cub/cub/device/dispatch/tuning/tuning_radix_sort.cuh
  • cub/test/catch2_test_device_radix_sort_custom_policy_hub.cu

@github-actions

This comment has been minimized.

@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

🥳 CI Workflow Results

🟩 Finished in 2h 26m: Pass: 100%/287 | Total: 11d 18h | Max: 2h 23m | Hits: 18%/996799

See results here.

KernelSource kernel_source,
KernelLauncherFactory launcher_factory)
{
const bool dependent_launch = cc >= ::cuda::compute_capability{9, 0};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: the old dispatch scan path set ptx_version to -1 so that PDL was disabled. Is this change intentional?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I didn't notice. That was definitely a performance bug then, which is addresses by this PR as a drive-by.

@bernhardmgruber
bernhardmgruber merged commit 01499a8 into NVIDIA:main Jun 9, 2026
307 checks passed
@github-project-automation github-project-automation Bot moved this from In Review to Done in CCCL Jun 9, 2026
@bernhardmgruber
bernhardmgruber deleted the depr_dispatch_scan branch June 9, 2026 22:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants