Skip to content

[cccl.c] Fix scan policy mismatch between host and NVRTC#9770

Open
NaderAlAwar wants to merge 1 commit into
NVIDIA:mainfrom
NaderAlAwar:fix-warpspeed-scan-mismatch-c-parallel
Open

[cccl.c] Fix scan policy mismatch between host and NVRTC#9770
NaderAlAwar wants to merge 1 commit into
NVIDIA:mainfrom
NaderAlAwar:fix-warpspeed-scan-mismatch-c-parallel

Conversation

@NaderAlAwar

Copy link
Copy Markdown
Contributor

The scan tuning policy is computed twice: once in the prebuilt cccl.c library and once by NVRTC while JIT-compiling the kernel, with a static_assert checking they agree. The decision depends on the CUDA compiler version (_CCCL_CUDACC_BELOW(13, 4) sm_120 guard, MSVC && nvcc < 13.1), so when the library's build CTK and the runtime NVRTC differ — e.g. a 13.1-built wheel meeting NVRTC 13.4, which enables warpspeed on sm_120 — the two sides pick different algorithms and every scan build fails with Error 999.

Fix: when the host picks lookback, pass -DCCCL_DISABLE_WARPSPEED_SCAN to NVRTC so the JIT makes the same choice. The other direction can't diverge as long as the library is built with CUDA < 13.4; a static_assert enforces that. This means cccl.c stays on lookback for sm_120 even with NVRTC 13.4 — acceptable since c.parallel v2 evaluates the policy only once and doesn't have this problem.

Verified on an sm_120 GPU with a 13.1-built library: baseline fails with the reported assert against NVRTC-as-13.4, fixed build compiles and produces correct scan results against both 13.3 and 13.4; sm_100 still selects warpspeed.

@NaderAlAwar NaderAlAwar requested a review from a team as a code owner July 9, 2026 17:31
@github-project-automation github-project-automation Bot moved this to Todo in CCCL Jul 9, 2026
@cccl-authenticator-app cccl-authenticator-app Bot moved this from Todo to In Review in CCCL Jul 9, 2026
@coderabbitai

coderabbitai Bot commented Jul 9, 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: 8070d3ba-275b-4fff-b07a-1867c9b5841c

📥 Commits

Reviewing files that changed from the base of the PR and between c37ad4f and f5daaf6.

📒 Files selected for processing (1)
  • c/parallel/src/scan.cu

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Fixed a scan compilation issue that could cause the runtime to choose a different algorithm than the one selected on the host.
    • Improved compatibility for older CUDA builds by adding an extra safeguard during scan setup.
    • Ensured the slower fallback scan path is disabled when the selected scan mode requires it, helping avoid incorrect behavior.

important: verify the CUDA version threshold (13.4) used in the static_assert actually matches the fixed NVBug version; a wrong boundary silently re-enables the mismatch on affected toolkits.

Walkthrough

In c/parallel/src/scan.cu, cccl_device_scan_compile now adds a static_assert gated on CUDA version to enforce one-way forcing behavior, and conditionally appends -DCCCL_DISABLE_WARPSPEED_SCAN to NVRTC compile arguments when the host-selected policy uses the lookback scan algorithm, aligning host and JIT algorithm selection.

Changes

Scan JIT Compile Fix

Layer / File(s) Summary
NVRTC compile arg and policy gate
c/parallel/src/scan.cu
Adds a CUDA-version static_assert and conditionally passes -DCCCL_DISABLE_WARPSPEED_SCAN during NVRTC compilation when the host-selected algorithm is lookback, preventing a policy mismatch between host and JIT scan selection.

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

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

🥳 CI Workflow Results

🟩 Finished in 1h 36m: Pass: 100%/20 | Total: 5h 44m | Max: 1h 06m | Hits: 98%/1515

See results here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

2 participants