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

Only use functions in the limited API #1545

Merged
merged 3 commits into from
Apr 30, 2024

Conversation

vyasr
Copy link
Contributor

@vyasr vyasr commented Apr 26, 2024

Description

This PR removes usage of the only method in rmm's Cython that is not part of the Python limited API. Contributes to rapidsai/build-planning#42

Checklist

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

@vyasr vyasr added non-breaking Non-breaking change improvement Improvement / enhancement to an existing function labels Apr 26, 2024
@vyasr vyasr self-assigned this Apr 26, 2024
@github-actions github-actions bot added the Python Related to RMM Python API label Apr 26, 2024
@vyasr vyasr marked this pull request as ready for review April 26, 2024 22:04
@vyasr vyasr requested a review from a team as a code owner April 26, 2024 22:04
@vyasr
Copy link
Contributor Author

vyasr commented Apr 26, 2024

In addition to base rmm testing, compilation under the limited API is tested in rapidsai/devcontainers#278. Note that CI failed when using rmm 24.06, then successfully compiles using this branch.

Copy link
Member

@jakirkham jakirkham left a comment

Choose a reason for hiding this comment

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

Thanks Vyas! 🙏

The original idea of PyBytes_AS_STRING was to indirectly do struct member access (skipping type checking that PyBytes_AsString does), which should be fast

If we want to drop PyBytes_AS_STRING for limited API support (which is reasonable), maybe we should drop the function call altogether and let Cython do this for us. This would improve readability and should do the same thing under-the-hood

python/rmm/rmm/_lib/device_buffer.pyx Outdated Show resolved Hide resolved
python/rmm/rmm/_lib/device_buffer.pyx Outdated Show resolved Hide resolved
@vyasr
Copy link
Contributor Author

vyasr commented Apr 30, 2024

The original idea of PyBytes_AS_STRING was to indirectly do struct member access (skipping type checking that PyBytes_AsString does), which should be fast

Right, but the more relevant question I think is whether that performance difference is even visible or if it's lost in all the other noise of rmm (let alone the noise of other RAPIDS packages that use rmm). I ran some quick tests doing something like a few thousand calls to tobytes and I couldn't detect any noticeable performance change before and after this PR.

@jakirkham
Copy link
Member

Agreed. That was just historical context. Am ok dropping it. For readability alone it seems worth it

@jakirkham
Copy link
Member

/merge

@rapids-bot rapids-bot bot merged commit 01ccf97 into rapidsai:branch-24.06 Apr 30, 2024
52 checks passed
@jakirkham
Copy link
Member

Thanks Vyas! 🙏

@vyasr vyasr deleted the feat/py_limited_api_compat branch May 1, 2024 00:52
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
None yet
Development

Successfully merging this pull request may close these issues.

2 participants