Skip to content

[cuda.compute]: fix h_init + d_out type mismatch bug in reduction algorithms - #10937

Draft
NaderAlAwar wants to merge 3 commits into
NVIDIA:mainfrom
NaderAlAwar:cuda-compute-reduce-dtype-mismatch-bug
Draft

[cuda.compute]: fix h_init + d_out type mismatch bug in reduction algorithms#10937
NaderAlAwar wants to merge 3 commits into
NVIDIA:mainfrom
NaderAlAwar:cuda-compute-reduce-dtype-mismatch-bug

Conversation

@NaderAlAwar

Copy link
Copy Markdown
Contributor

Description

closes #10935

This also makes this behavior consistent with CUB

Checklist

  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@NaderAlAwar
NaderAlAwar requested review from a team as code owners August 21, 2026 15:35
@NaderAlAwar
NaderAlAwar requested a review from rwgk August 21, 2026 15:35
@github-project-automation github-project-automation Bot moved this to Todo in CCCL Aug 21, 2026
@cccl-authenticator-app cccl-authenticator-app Bot moved this from Todo to In Review in CCCL Aug 21, 2026
@coderabbitai

coderabbitai Bot commented Aug 21, 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: c2191ac4-4123-42a2-91e6-8573f04a9e70

📥 Commits

Reviewing files that changed from the base of the PR and between 140f853 and 8b1495b.

📒 Files selected for processing (1)
  • python/cuda_cccl/cuda/compute/algorithms/_reduce.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • python/cuda_cccl/cuda/compute/algorithms/_reduce.py

Included review availability: Your plan provides up to 12 included reviews per hour; 10 remain after this review.


📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Reduction and segmented-reduction results can now be written to scalar output types that differ from the accumulation type.
    • Accumulation continues in the configured initializer type, with safe value conversion when storing results.
  • Documentation

    • Updated reduction documentation to describe mixed scalar input, accumulator, and output types.
  • Tests

    • Added coverage for conversions to integer, half-precision, single-precision, and double-precision outputs.

Walkthrough

Reduce and segmented-reduce now convert accumulator values to the output iterator type during final stores. Native and Python tests cover differing output dtypes, and Python documentation describes scalar accumulation and output conversion.

Changes

Reduce output conversion

Layer / File(s) Summary
Native output store conversion
c/parallel/src/reduce.cu, c/parallel/src/segmented_reduce.cu
Output iterator specialization uses the output value type instead of the accumulator type.
Native conversion validation
c/parallel/test/test_reduce.cpp, c/parallel/test/test_segmented_reduce.cpp
Tests validate value conversion from floating-point accumulators to integer and double outputs.
Python dtype contract and tests
python/cuda_cccl/cuda/compute/algorithms/_reduce.py, python/cuda_cccl/cuda/compute/algorithms/_segmented_reduce.py, python/cuda_cccl/tests/compute/test_reduce.py, python/cuda_cccl/tests/compute/test_segmented_reduce.py
Documentation describes mixed scalar dtypes. Tests cover float16, int32, float32, and float64 outputs with float32 accumulation.

Assessment against linked issues

Objective Addressed Explanation
Fix reduce_into and segmented_reduce when d_out has a different dtype from h_init [#10935]

Suggested reviewers: rwgk

Merge Risk: ⚪ Minimal · up to 8b149

This change is merge-ready after normal checks and review; no actionable merge-blocking risk remains.


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

@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


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 88c92229-3c97-4892-b855-8d1bde5fb47d

📥 Commits

Reviewing files that changed from the base of the PR and between d10a88a and 140f853.

📒 Files selected for processing (8)
  • c/parallel/src/reduce.cu
  • c/parallel/src/segmented_reduce.cu
  • c/parallel/test/test_reduce.cpp
  • c/parallel/test/test_segmented_reduce.cpp
  • python/cuda_cccl/cuda/compute/algorithms/_reduce.py
  • python/cuda_cccl/cuda/compute/algorithms/_segmented_reduce.py
  • python/cuda_cccl/tests/compute/test_reduce.py
  • python/cuda_cccl/tests/compute/test_segmented_reduce.py

Included review availability: Your plan provides up to 12 included reviews per hour; 10 remain after this review.

Comment thread python/cuda_cccl/cuda/compute/algorithms/_reduce.py
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

🥳 CI Workflow Results

🟩 Finished in 3h 32m: Pass: 100%/112 | Total: 1d 15h | Max: 1h 00m | Hits: 100%/1467

See results here.

@NaderAlAwar
NaderAlAwar marked this pull request as draft August 21, 2026 20:33
@copy-pr-bot

copy-pr-bot Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@cccl-authenticator-app cccl-authenticator-app Bot moved this from In Review to In Progress in CCCL Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

[BUG]: cuda.compute: reduce_into / segmented_reduce with d_out dtype != h_init dtype silently write reinterpreted accumulator bytes

2 participants