Skip to content

Use nosync execution policy everywhere - #20807

Merged
rapids-bot[bot] merged 5 commits into
NVIDIA:mainfrom
bdice:nosync-everywhere
Jan 6, 2026
Merged

Use nosync execution policy everywhere#20807
rapids-bot[bot] merged 5 commits into
NVIDIA:mainfrom
bdice:nosync-everywhere

Conversation

@bdice

@bdice bdice commented Dec 8, 2025

Copy link
Copy Markdown
Contributor

Description

This is a follow-up to #11577 and #12086. We discussed the exec_policy_nosync and we would like to experiment with enabling it everywhere in libcudf.

Since last time we investigated this, we have refined a lot of the library to be more stream-friendly. We also have weekly compute-sanitizer runs now, to help us identify any issues. We would like to see if this changes provides any performance improvements or reduces synchronization in the multi-thread, multi-stream workflow engines that use libcudf.

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@bdice
bdice requested a review from a team as a code owner December 8, 2025 19:20
@bdice
bdice requested review from davidwendt and vuule December 8, 2025 19:20
@github-actions github-actions Bot added the libcudf Affects libcudf (C++/CUDA) code. label Dec 8, 2025
@bdice bdice added improvement Improvement / enhancement to an existing function non-breaking Non-breaking change labels Dec 8, 2025
@vuule

vuule commented Dec 8, 2025

Copy link
Copy Markdown
Contributor

AFAIK compute-sanitizer won't help us find the issues with host object going out of scope because we removed a sync point. I'm not sure we should replace all without examining each instance for this kind of issue.

@bdice

bdice commented Dec 8, 2025

Copy link
Copy Markdown
Contributor Author

It may help to investigate these errors with https://docs.nvidia.com/compute-sanitizer/ComputeSanitizer/index.html#stream-ordered-race-detection: compute-sanitizer memcheck --track-stream-ordered-races all

auto const end = begin + input.num_rows();
auto const indices_end =
thrust::copy_if(rmm::exec_policy(stream), begin, end, indices.begin(), filter);
thrust::copy_if(rmm::exec_policy_nosync(stream), begin, end, indices.begin(), filter);

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.

I guess what worries me is that I can foresee where the nosync policy allows the copy_if to assume the return value is not needed and implement an optimization that no longer performs a synchronize on the stream.
This comment only applies to those few places where we know a sync is needed.
I feel being purposeful also more clearly communicates intent to the reader/reviewer.

@bdice bdice Dec 9, 2025

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.

Thrust cannot implement this algorithm without a sync. Thrust will always uphold the contract of returning a value to host that is ready to use. In other words, “nosync” is best-effort.

@vuule

vuule commented Dec 10, 2025

Copy link
Copy Markdown
Contributor

It may help to investigate these errors with https://docs.nvidia.com/compute-sanitizer/ComputeSanitizer/index.html#stream-ordered-race-detection: compute-sanitizer memcheck --track-stream-ordered-races all

Thought about this a bit more. The scenario I was concerned with is when we use a std::vector and copy it to the device (cudaMemcpyAsync) at the end of its scope. In theory we might perform the copy after the vector is already deallocated. However, pageable H2D copies are synchronous, so this is not an issue in practice, unless I'm missing something.
Still, IMO we might remove some needed sync points if we don't review this PR carefully.

@bdice

bdice commented Dec 10, 2025

Copy link
Copy Markdown
Contributor Author

I'm putting this on pause until after I get #20800 and some other projects finished up first.

@davidwendt

Copy link
Copy Markdown
Contributor

I can take this over in January if you want.

@bdice

bdice commented Dec 18, 2025

Copy link
Copy Markdown
Contributor Author

@davidwendt That would be great! Thank you for offering.

@bdice

bdice commented Jan 6, 2026

Copy link
Copy Markdown
Contributor Author

I'd like to merge this once CI passes since it's a large PR. There are a few follow-up tasks:

  • Check that expectations for nosync are documented
  • Make similar changes in cpp/tests, cpp/benchmarks
  • Make similar changes in java/, python/

@bdice

bdice commented Jan 6, 2026

Copy link
Copy Markdown
Contributor Author

/merge

@rapids-bot
rapids-bot Bot merged commit d9b84df into NVIDIA:main Jan 6, 2026
264 of 270 checks passed
rapids-bot Bot pushed a commit that referenced this pull request Jan 8, 2026
… add docs (#20978)

Follow-up to #20807.

This PR documents the expectations for `nosync` execution policies and applies the changes to remaining tests, benchmarks, Java, and Python code. It also adds pre-commit validation that `rmm::exec_policy` is not used.

Authors:
  - Bradley Dice (https://github.com/bdice)

Approvers:
  - Matthew Roeschke (https://github.com/mroeschke)
  - James Lamb (https://github.com/jameslamb)
  - Tianyu Liu (https://github.com/kingcrimsontianyu)
  - Nghia Truong (https://github.com/ttnghia)
  - Muhammad Haseeb (https://github.com/mhaseeb123)

URL: #20978
galipremsagar pushed a commit to galipremsagar/cudf that referenced this pull request Jan 9, 2026
This is a follow-up to NVIDIA#11577 and NVIDIA#12086. We discussed the `exec_policy_nosync` and we would like to experiment with enabling it everywhere in libcudf.

Since last time we investigated this, we have refined a lot of the library to be more stream-friendly. We also have weekly compute-sanitizer runs now, to help us identify any issues. We would like to see if this changes provides any performance improvements or reduces synchronization in the multi-thread, multi-stream workflow engines that use libcudf.

Authors:
  - Bradley Dice (https://github.com/bdice)

Approvers:
  - Nghia Truong (https://github.com/ttnghia)
  - David Wendt (https://github.com/davidwendt)

URL: NVIDIA#20807
galipremsagar pushed a commit to galipremsagar/cudf that referenced this pull request Jan 9, 2026
… add docs (NVIDIA#20978)

Follow-up to NVIDIA#20807.

This PR documents the expectations for `nosync` execution policies and applies the changes to remaining tests, benchmarks, Java, and Python code. It also adds pre-commit validation that `rmm::exec_policy` is not used.

Authors:
  - Bradley Dice (https://github.com/bdice)

Approvers:
  - Matthew Roeschke (https://github.com/mroeschke)
  - James Lamb (https://github.com/jameslamb)
  - Tianyu Liu (https://github.com/kingcrimsontianyu)
  - Nghia Truong (https://github.com/ttnghia)
  - Muhammad Haseeb (https://github.com/mhaseeb123)

URL: NVIDIA#20978
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Improvement / enhancement to an existing function libcudf Affects libcudf (C++/CUDA) code. non-breaking Non-breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants