Skip to content

Implement CupyArrayContext #251

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

Open
wants to merge 43 commits into
base: main
Choose a base branch
from
Open

Implement CupyArrayContext #251

wants to merge 43 commits into from

Conversation

matthiasdiener
Copy link
Collaborator

@matthiasdiener matthiasdiener commented Feb 16, 2024

Please squash

@matthiasdiener matthiasdiener self-assigned this Feb 16, 2024
@matthiasdiener matthiasdiener force-pushed the cupyactx branch 4 times, most recently from ce508df to 55b4cbf Compare February 16, 2024 23:03
Co-authored-by: Kaushik Kulkarni <[email protected]>
Comment on lines 1254 to 1256
if isinstance(actx, CupyArrayContext):
pytest.skip("CupyArrayContext does not support object arrays")

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@inducer: We had briefly discussed adding support for object arrays via a wrapper (?), but I'm not sure how that should look like.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Turns out this was caused by the incomplete array container support, fixed in e9c42dd. Thanks to @majosm for the help!

@matthiasdiener
Copy link
Collaborator Author

This is ready for a first look @inducer

Copy link
Collaborator

@alexfikl alexfikl left a comment

Choose a reason for hiding this comment

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

Was curious a bit about this and left some comments. Hope that's ok!

What's the use of adding a cupy backend? I thought eager ones don't really give good performance and we already have both the pyopencl and the jax ones that can use CUDA (behind some abstraction layers, at least).

@matthiasdiener
Copy link
Collaborator Author

Was curious a bit about this and left some comments. Hope that's ok!

What's the use of adding a cupy backend? I thought eager ones don't really give good performance and we already have both the pyopencl and the jax ones that can use CUDA (behind some abstraction layers, at least).

Thank you for the review!

I don't have experience with jax, and we generally don't run mirgecom with it. Regarding the pyopencl-eager backend(s), it does not support all operations that we need (e.g., broadcasting), so we can't run all our drivers with it. This only leaves us with numpy or pytato backends. pytato has generally high compile times, so it's sometimes not great for debugging etc. Numpy time step times are often much slower than with cupy, as indicated above.

@alexfikl
Copy link
Collaborator

I don't have experience with jax, and we generally don't run mirgecom with it. Regarding the pyopencl-eager backend(s), it does not support all operations that we need (e.g., broadcasting), so we can't run all our drivers with it. This only leaves us with numpy or pytato backends. pytato has generally high compile times, so it's sometimes not great for debugging etc. Numpy time step times are often much slower than with cupy, as indicated above.

Ah.. broadcasting.. the bane of everyone's existence! Fair enough :(

@matthiasdiener
Copy link
Collaborator Author

This is ready for another review @inducer @alexfikl

@@ -25,7 +25,7 @@ implementations for:
- Profiling
Copy link
Collaborator Author

@matthiasdiener matthiasdiener Feb 17, 2025

Choose a reason for hiding this comment

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

Out of curiosity, what are the implementations for debugging/profiling? (also mentioned in doc/)

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think there are any at the moment (?). Unless passing a CommandQueue with profiling enabled counts there..

It would be nice to have some fancier profiling for things though 😁

Copy link
Collaborator

@alexfikl alexfikl left a comment

Choose a reason for hiding this comment

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

Left a little nitpick, but otherwise this looks good to me! Thanks!

Co-authored-by: Alex Fikl <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants