[CUB] Make ReduceByKey run-to-run deterministic - #11032
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 12 included reviews per hour; 10 remain after this review. 📝 WalkthroughSummary by CodeRabbit
WalkthroughThe reduce-by-key policy now carries a stable reduction-order flag. Dispatch enables the flag for both kernel paths. A regression test checks bit-identical fp64 results across repeated multi-tile reductions. ChangesReduce-by-key determinism
Assessment against linked issues
Suggested reviewers: Merge Risk: ⚪ Minimal · up to The change makes ReduceByKey results deterministic with targeted tests and reported validation; no actionable merge-blocking risk remains beyond normal checks and review. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 69b6565e-8ae2-4392-844b-369f6c27dc16
📒 Files selected for processing (3)
cub/cub/agent/agent_reduce_by_key.cuhcub/cub/device/dispatch/dispatch_reduce_by_key.cuhcub/test/catch2_test_device_reduce_by_key.cu
Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review.
0720444 to
009b23f
Compare
@nanan-nvidia @guillaume-michel
Description
closes #9995
DeviceReduce::ReduceByKeycan produce different FP64 result bits across identical calls when a segment spans multiple tiles. Cross-tile partial reductions are combined in an order that can depend on tile completion.This change opts the current public ReduceByKey dispatch into the stable ordering already supported by
TilePrefixCallbackOp. The shared kernel defaults to the previous ordering, so RLE and the deprecated dispatcher retain their current behavior. The virtual shared-memory sizing path uses the same stable policy as the kernel.The regression reproduces the reported 65,536-item input with a 50,000-item first run and compares that aggregate bit-for-bit across 20 identical calls. It runs in one generated test shard. Existing parameterized tests cover the run count and complete output correctness.
Verification
0xbfa59be1de5076d4versus0xbfa59be1de5076d8.0xbfa59be1de5076d8in all 200 calls on an RTX 5090.Performance
Measurements used CUDA 13.3 on the RTX 5090. The exact reported workload changed from 13.477 us to 13.997 us, a 3.86% increase based on the median of three order-balanced process pairs.
Selected U64/F64/I32 runs of the existing ReduceByKey NVBench benchmark:
2^162^82^202^82^242^12^242^42^242^8Checklist