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

Rollback of DeviceBufferLike #12009

Merged
merged 19 commits into from
Nov 2, 2022

Conversation

madsbk
Copy link
Member

@madsbk madsbk commented Oct 27, 2022

This PR replaces DeviceBufferLike with Buffer and clear the way for a spillable sub-class of Buffer.

Context

The introduction of the DeviceBufferLike protocol was motivated by the spilling work, which we initially thought would have to be implemented in Cython. However, it can be done in pure Python, which makes DeviceBufferLike an unneeded complexity.

Review notes

  • In order to introduce a spillable-buffer in the future, we still use a factory function, as_buffer(), to create Buffers.
  • buffer.py is moved into the submodule core.buffer to ease organization when adding the spillable-buffer and spilling manager.

Breaking

This PR breaks external use of Buffer e.g. Buffer.__init__ raise an exception now and the "constructor-kwargs" header from #4164 has been removed.
Submitted a PR to fix this in cuml: rapidsai/cuml#4965

Checklist

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

cc. @shwina @vyasr

@madsbk madsbk added improvement Improvement / enhancement to an existing function non-breaking Non-breaking change labels Oct 27, 2022
@madsbk madsbk requested a review from a team as a code owner October 27, 2022 09:45
@madsbk madsbk requested review from vyasr and isVoid October 27, 2022 09:45
@github-actions github-actions bot added the Python Affects Python cuDF API. label Oct 27, 2022
Copy link
Contributor

@vyasr vyasr left a comment

Choose a reason for hiding this comment

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

Some small questions to address before we finalize this.

python/cudf/cudf/core/abc.py Show resolved Hide resolved
python/cudf/cudf/core/buffer/buffer.py Show resolved Hide resolved
python/cudf/cudf/core/buffer/utils.py Outdated Show resolved Hide resolved
python/cudf/cudf/core/column/column.py Show resolved Hide resolved
@rapidsai rapidsai deleted a comment from shwina Oct 28, 2022
@madsbk
Copy link
Member Author

madsbk commented Oct 28, 2022

Thanks for the review @vyasr. I think it is a good idea to use the as_buffer factory function exclusively.
Now, as_buffer creates a Buffer instance through Buffer.from_device_memory() and Buffer.from_host_memory().

This also enables SpillableBuffer to overwrite specific parts of the buffer constructor.

@madsbk madsbk added breaking Breaking change and removed non-breaking Non-breaking change labels Oct 28, 2022
@codecov
Copy link

codecov bot commented Oct 28, 2022

Codecov Report

Base: 88.09% // Head: 86.86% // Decreases project coverage by -1.23% ⚠️

Coverage data is based on head (25813ac) compared to base (f0b4c4f).
Patch coverage: 87.92% of modified lines in pull request are covered.

❗ Current head 25813ac differs from pull request most recent head ff17377. Consider uploading reports for the commit ff17377 to get more accurate results

Additional details and impacted files
@@               Coverage Diff                @@
##           branch-22.12   #12009      +/-   ##
================================================
- Coverage         88.09%   86.86%   -1.24%     
================================================
  Files               133      135       +2     
  Lines             21982    21985       +3     
================================================
- Hits              19366    19097     -269     
- Misses             2616     2888     +272     
Impacted Files Coverage Δ
python/cudf/cudf/core/frame.py 93.68% <ø> (ø)
python/cudf/cudf/core/groupby/groupby.py 91.30% <ø> (ø)
python/cudf/cudf/core/index.py 92.88% <ø> (ø)
python/cudf/cudf/core/indexed_frame.py 92.03% <ø> (ø)
python/cudf/cudf/core/reshape.py 83.36% <ø> (ø)
python/cudf/cudf/core/series.py 95.78% <ø> (ø)
python/cudf/cudf/io/text.py 91.66% <ø> (ø)
python/cudf/cudf/testing/testing.py 81.81% <ø> (ø)
python/cudf/cudf/utils/docutils.py 97.67% <ø> (ø)
python/cudf/cudf/core/column/timedelta.py 90.75% <50.00%> (ø)
... and 28 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

madsbk added a commit to madsbk/cuml that referenced this pull request Nov 1, 2022
The "constructor-kwargs" is removed in rapidsai/cudf#12009
madsbk added a commit to madsbk/cuml that referenced this pull request Nov 1, 2022
The "constructor-kwargs" is removed in rapidsai/cudf#12009
Copy link
Contributor

@vyasr vyasr left a comment

Choose a reason for hiding this comment

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

One small suggestion, otherwise LGTM!

T = TypeVar("T", bound="Buffer")


def cuda_array_interface_wrapper(ptr: int, size: int, owner: object = None):
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe out of scope for this PR, but we use the SimpleNamespace.__cuda_array_interface__ trick in multiple other places as well (mostly in column code IIRC) and I wonder if we could use the same helper function in multiple places. It's not immediately obvious why one would create this object so having all the places that do so call to a single, well-documented helper function could be nice. Happy to push that to a downstream refactoring PR though.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@shwina
Copy link
Contributor

shwina commented Nov 2, 2022

@gpucibot merge

@rapids-bot rapids-bot bot merged commit d6a9e4a into rapidsai:branch-22.12 Nov 2, 2022
rapids-bot bot pushed a commit to rapidsai/cuml that referenced this pull request Nov 2, 2022
The "constructor-kwargs" is being removed in rapidsai/cudf#12009

Authors:
  - Mads R. B. Kristensen (https://github.com/madsbk)

Approvers:
  - Dante Gama Dessavre (https://github.com/dantegd)

URL: #4965
@madsbk madsbk deleted the device_buffer_like_rollback branch November 3, 2022 08:39
rapids-bot bot pushed a commit to rapidsai/dask-cuda that referenced this pull request Nov 3, 2022
Support the new `Buffer` in rapidsai/cudf#12009

Fixes  #1032

Authors:
  - Mads R. B. Kristensen (https://github.com/madsbk)

Approvers:
  - Peter Andreas Entschev (https://github.com/pentschev)

URL: #1033
jakirkham pushed a commit to jakirkham/cuml that referenced this pull request Feb 27, 2023
The "constructor-kwargs" is being removed in rapidsai/cudf#12009

Authors:
  - Mads R. B. Kristensen (https://github.com/madsbk)

Approvers:
  - Dante Gama Dessavre (https://github.com/dantegd)

URL: rapidsai#4965
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Breaking change improvement Improvement / enhancement to an existing function Python Affects Python cuDF API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants