[libcu++] Adds a cuda::execution::tie_break requirement #9238
Conversation
cuda::execution::tie_break requirement
|
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 (4)
OverviewThis PR introduces a new ChangesNew Files
Modified Files
SemanticsThe tie-break requirement specifies selection semantics for choosing which items are included in the result set when multiple items compete for the K-th slot. It operates orthogonally to
Static assertions will enforce that tie-break requirements are only meaningful when paired with appropriate determinism requirements. WalkthroughThis PR adds a new CUDA execution tie-break preference system for deterministic ordering in concurrent execution contexts. It defines an internal preference enum with three states, requirement holders for type-safe wrapping, a queryable preference interface, and public type aliases and global instances for use in execution environments and algorithms. ChangesTie-break requirement framework
Suggested reviewers
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Infer (1.2.0)libcudacxx/test/libcudacxx/cuda/execution/tie_break.pass.cpplibcudacxx/test/libcudacxx/cuda/execution/tie_break.pass.cpp:11:10: fatal error: 'cuda/execution.tie_break.h' file not found ... [truncated 1183 characters] ... nternal-isystem" "/usr/local/include" "-internal-isystem" Comment |
This comment has been minimized.
This comment has been minimized.
🥳 CI Workflow Results🟩 Finished in 1h 35m: Pass: 100%/115 | Total: 1d 18h | Max: 53m 16s | Hits: 99%/339232See results here. |
cuda::execution::tie_break requirement cuda::execution::tie_break requirement
|
If |
Yeah, but no strong opinion. I just think determinism is a requirement that most algorithms have a meaning for ( Also, I think they answer different questions: determinism is "how reproducible" a result is, whereas |
|
I think we could make the determinism guarantee to be constructible without a |
Would you envision something like this: It's worth noting that with |
@pciolkosz, I've opened a separate PR that implements this: |
Closes #9255
Note, this is an alternative proposal to #9269
Adds
cuda::execution::tie_breakrequirement.cuda::execution::tie_breakis a requirement (sibling todeterminism/output_ordering) with valuesunspecified,prefer_smaller_index, andprefer_larger_index. It describes how the top-k algorithm breaks ties among elements that compare equal at its selection boundary.A word on the motivation in top-k: ties at the K-th element are the source of non-determinism; pairing a determinism requirement with a tie-break lets users specify which amongst the competing items should make it into the result set.
The four determinism options I envision for top-k:
require(...)determinism::not_guaranteeddeterminism::run_to_rundeterminism::run_to_run, tie_break::prefer_smaller_indexdeterminism::run_to_run, tie_break::prefer_larger_indexMy mental model:
tie_breakis purely a criterion about which items are selected, i.e., it operates on the result set. Ordering, i.e.,{stable,unstable}/sorted/unsorted, is the orthogonal concern that operates on the result sequence (output_ordering). A tie-break says nothing about order, and is only meaningful together with a deterministic requirement (we willstatic_asserton this in the relevant implementation, making sure that if a tie_break is demanded, a determinism requirement is accompanying it).I think exposing it as a
cuda::executionrequirement (rather than burying it in a CUB/top-k namespace) keeps the requirements interface homogeneous for users.