Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for cupy.cuda.stream.ExternalStream #1559

Conversation

lilohuang
Copy link
Contributor

@lilohuang lilohuang commented May 9, 2024

Description

Cupy offers the cupy.cuda.stream.ExternalStream for utilizing external CUDA streams. Moreover, cupy.cuda.get_current_stream() will return an instance of cupy.cuda.stream.ExternalStream instead of cupy.cuda.stream.Stream, particularly when the current cuPy stream has been changed.

Therefore, we must verify both types of instances to avoid errors.

See details in the https://docs.cupy.dev/en/stable/user_guide/interoperability.html#cuda-stream-pointers

Checklist

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

Cupy offers the `cupy.cuda.stream.ExternalStream` for utilizing external CUDA streams. Moreover, `cupy.cuda.get_current_stream()` will return an instance of `cupy.cuda.stream.ExternalStream` instead of `cupy.cuda.stream.Stream`, particularly when the current cuPy stream has been changed.

Therefore, we must verify both types of instances to avoid errors.

See details in the https://docs.cupy.dev/en/stable/user_guide/interoperability.html#cuda-stream-pointers
@lilohuang lilohuang requested a review from a team as a code owner May 9, 2024 05:54
Copy link

copy-pr-bot bot commented May 9, 2024

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions github-actions bot added the Python Related to RMM Python API label May 9, 2024
@harrism
Copy link
Member

harrism commented May 9, 2024

/ok to test

@lilohuang
Copy link
Contributor Author

Hi @harrism @miscco @jrhemstad,

Would you kindly inform me if there are any additional steps required for this fix to be accepted?

Thank you so much,
Lilo

@wence- wence- added non-breaking Non-breaking change improvement Improvement / enhancement to an existing function labels May 13, 2024
@wence-
Copy link
Contributor

wence- commented May 13, 2024

/ok to test

@harrism
Copy link
Member

harrism commented May 13, 2024

/ok to test

Copy link
Member

@harrism harrism left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks fine to me. Thanks for the fix @lilohuang ! I would like someone more expert with cupy to review and approve before we merge, such as @leofang or @wence-.

@harrism
Copy link
Member

harrism commented May 13, 2024

/ok to test

@bdice
Copy link
Contributor

bdice commented May 13, 2024

Can we add a test for this change?

@harrism
Copy link
Member

harrism commented May 13, 2024

Can we add a test for this change?

Agree, that's a good suggestion. However looking, we don't appear to have any tests of this Stream Cython class.

Copy link
Member

@leofang leofang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks fine to me. In theory we can just test isinstance(obj, cupy.cuda.stream._BaseStream), since both Stream and ExternalStream are child classes of it. But it's considered an implementation detail (though it's been stable for some time).

@harrism
Copy link
Member

harrism commented May 15, 2024

/ok to test

@harrism
Copy link
Member

harrism commented May 15, 2024

BTW, I did not mean to negate @bdice's request for tests. Just to say that we don't have existing tests to base this off of. @bdice do you want to block merging until a test is added?

@bdice
Copy link
Contributor

bdice commented May 15, 2024

No need to block on tests if existing functionality is untested, but this is a gap that might be worth addressing in the future.

@wence-
Copy link
Contributor

wence- commented May 16, 2024

/ok to test

@wence-
Copy link
Contributor

wence- commented May 16, 2024

/merge

@rapids-bot rapids-bot bot merged commit cab7e06 into rapidsai:branch-24.06 May 16, 2024
57 checks passed
@wence-
Copy link
Contributor

wence- commented May 16, 2024

Thanks @lilohuang!

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 non-breaking Non-breaking change Python Related to RMM Python API
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

5 participants