-
Notifications
You must be signed in to change notification settings - Fork 930
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
[REVIEW] Refactor the Buffer
class
#11447
Conversation
Codecov Report
@@ Coverage Diff @@
## branch-22.10 #11447 +/- ##
===============================================
Coverage ? 86.48%
===============================================
Files ? 145
Lines ? 22844
Branches ? 0
===============================================
Hits ? 19756
Misses ? 3088
Partials ? 0 Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Buffer
classBuffer
class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some nits
Co-authored-by: Lawrence Mitchell <[email protected]>
Co-authored-by: Lawrence Mitchell <[email protected]>
I generally like the changes in this PR. Overall I might prefer to make more of the factories
I started writing this comment then had to step out. Looks like @wence- had similar comments! |
Overall, I agree with both of you, my concern with |
Another design issue I like to discuss is how we support I see two approaches:
Initially, I thought that using a So maybe implementing |
I think this needs some thought. Do you envisage that |
On the whole I like interfaces over inheritance (which is what
Note that this is multiply-breaking because you can't |
We want a global configuration switch. I hope at some point we can remove the old
Agree, we could also embrace this fully and introduce a Then we could keep |
Co-authored-by: Bradley Dice <[email protected]>
Co-authored-by: Bradley Dice <[email protected]>
Thanks for the reviews, I think I have addressed all of them? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few nits
Sorry, I had some still in-flight |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! My concerns were addressed. Let's wait for all the other reviewers to approve before merging
@shwina What do think of creating a |
No worries, I think I have addressed them now? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, looks good to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one question -- otherwise LGTM.
@vyasr do you have anything? |
@brandon-b-miller do you have anything more? |
@gpucibot merge |
cuDF's `Buffer` doesn't have `Buffer.empty()` since rapidsai/cudf#11447. Can we remove `CumlArray.copy()`? Authors: - Mads R. B. Kristensen (https://github.com/madsbk) Approvers: - William Hicks (https://github.com/wphicks) - Dante Gama Dessavre (https://github.com/dantegd) URL: #4958
This PR replaces `DeviceBufferLike` with `Buffer` and clear the way for a spillable sub-class of `Buffer`. #### Context The introduction of the [`DeviceBufferLike`](#11447) protocol was motivated by [the spilling work](#11553), 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 ## Authors: - Mads R. B. Kristensen (https://github.com/madsbk) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) - Ashwin Srinath (https://github.com/shwina) URL: #12009
cuDF's `Buffer` doesn't have `Buffer.empty()` since rapidsai/cudf#11447. Can we remove `CumlArray.copy()`? Authors: - Mads R. B. Kristensen (https://github.com/madsbk) Approvers: - William Hicks (https://github.com/wphicks) - Dante Gama Dessavre (https://github.com/dantegd) URL: rapidsai#4958
Description
This PR introduces factory functions to create
Buffer
instances, which makes it possible to change the returned buffer type based on a configuration option in a follow-up PR.Beside simplifying the code base a bit, this is motivated by the spilling work in #10746. We would like to introduce a new spillable Buffer class that requires minimal changes to the existing code and is only used when enabled explicitly. This way, we can introduce spilling in cuDF as an experimental feature with minimal risk to the existing code.
@shwina and I discussed the possibility to let
Buffer.__new__
return different class type instances instead of using factory functions but we concluded that havingBuffer()
return anything other than an instance ofBuffer
is simply too surprising :)Notice, this is breaking because it removes unused methods such as
Buffer.copy()
andBuffer.nbytes
.However, we still support creating a buffer directly by callingBuffer(obj)
. AFAIK, this is the only wayBuffer
is created outside of cuDF, which a github search seems to confirm.This PR doesn't change the signature of
Buffer.__init__()
anymore.Checklist