You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just throwing this up here for now, need to investigate more.
I'm working on a distributed cudf join using UCX. Things progress fine until, in the Client process, we attempt to deserialize some data (I think the final result?). We end up calling calling loads with deserialize=True:
which attempt to convert the data to a byte string.
At this point in the client process, frames is a list of objects representing device memory. If possible (and I think it's possible), I'd like to avoid copying to the host here.
Actually, this may only be possible if the Client happens to have a GPU as well. In this case that's true, but not in general.
TODO:
figure out exactly where the client is calling this
This is somewhat surprising, especially given that UCX handles message framing itself. I wonder if this is a case where we should be using nbytes rather than len.
Ahh... I completely missed those lines. That may actually explain it. I've been hacking up the serialization code to make things work. I likely have a bug in there.
At the cost of another memory allocation (and a numba dependency), we can do something similar to the host-memory case. For each of the 3 "expected" frames, I allocate an empty numba DeviceNDArray with the expected length. I then iterate over the "split" frames, filling in the empty DeviceNDArray. When I do that, returning the 3 new DeviceArrays from merge_frames, the join complete successfully (kinda, the float dtypes are integers. Probably a bug in deserialization).
After writing this up, I had the bright idea of confirming that maybe_split_size is the culprit by commenting it out. And indeed that seems to remove the need for my hacky "gpu merge frames."
And, finally getting to the point where we're starting to see some payoff:
My guess is that we need a concat function that dispatchs on the type of the frame objects. Dask will include implementations for bytes, bytearray, and memoryview, and maybe we include a lazily registered function that does something like what you describe. Thoughts?
Yeah, I think that seems to be necessary. We would dispatch upon header['type'], right?
It's a little unfortunate. bytes/memoryview is sufficient for all host-memory things. It'd be nice if there was a device-equivalent, so we would just need to include a kind of 'is_gpu' key in the header and dispatch to host or GPU based on that.
This is the first time I've thought "I could see this being a PEP someday".
I suspect that we would start with something that was lighter weight, like a protocol (like __cuda_array_interface__) or a small library that ucx-py and possibly others would depend on.
Hmm...I'm not actually sure how one should run that these days. It looks like we need to setup our own scheduler. Also distributed.protocol.cudf no longer exists. At least a naive attempt to get this to run locally doesn't seem to work. In any event, we are able to run similar routines today. So my guess is this can work if the code were updated.
To the spirit of the issue, we do have cuda_dumps and cuda_loads. Thus far merge_frames doesn't behave how we would expect ( #3580 ) so we mostly avoid it. Though PR ( #3732 ) has merge and split frame style functions. So maybe that solves that piece of this issue?
Activity
mrocklin commentedon Mar 15, 2019
Hrm, that does seem like incorrect behavior in the GPU memory case
It also means that these lines weren't triggered.
distributed/distributed/protocol/utils.py
Lines 60 to 61 in fb30c33
This is somewhat surprising, especially given that UCX handles message framing itself. I wonder if this is a case where we should be using
nbytesrather thanlen.TomAugspurger commentedon Mar 15, 2019
Ahh... I completely missed those lines. That may actually explain it. I've been hacking up the serialization code to make things work. I likely have a bug in there.
TomAugspurger commentedon Mar 15, 2019
So, after looking at this further, there may still be some merit to this issue.
I'm sending a cudf DataFrame with three columns and no nulls, so that's a total of 3 numba device arrays (I ignore the index for now).
Somewhere on the send size (
frame_split_sizeperhaps?) the three arrays are split into 9. Which means that the condition for the early return atdistributed/distributed/protocol/utils.py
Lines 60 to 61 in fb30c33
At the cost of another memory allocation (and a numba dependency), we can do something similar to the host-memory case. For each of the 3 "expected" frames, I allocate an empty numba DeviceNDArray with the expected length. I then iterate over the "split" frames, filling in the empty DeviceNDArray. When I do that, returning the 3 new DeviceArrays from
merge_frames, the join complete successfully (kinda, the float dtypes are integers. Probably a bug in deserialization).TomAugspurger commentedon Mar 15, 2019
After writing this up, I had the bright idea of confirming that
maybe_split_sizeis the culprit by commenting it out. And indeed that seems to remove the need for my hacky "gpu merge frames."And, finally getting to the point where we're starting to see some payoff:
I wouldn't put too much stock in those numbers yet, but it's at least encouraging. In particular this is mixing
but it's something :)
mrocklin commentedon Mar 15, 2019
My guess is that we need a
concatfunction that dispatchs on the type of the frame objects. Dask will include implementations forbytes,bytearray, andmemoryview, and maybe we include a lazily registered function that does something like what you describe. Thoughts?TomAugspurger commentedon Mar 15, 2019
Yeah, I think that seems to be necessary. We would dispatch upon
header['type'], right?It's a little unfortunate. bytes/memoryview is sufficient for all host-memory things. It'd be nice if there was a device-equivalent, so we would just need to include a kind of 'is_gpu' key in the header and dispatch to host or GPU based on that.
mrocklin commentedon Mar 15, 2019
Or, at this point, on the type of the frames (so that this wouldn't be as tied to Dask's protocol).
We are probably the most qualified group to start defining what that looks like. I encourage you to consider what requirements would look like.
TomAugspurger commentedon Mar 15, 2019
mrocklin commentedon Mar 15, 2019
I suspect that we would start with something that was lighter weight, like a protocol (like
__cuda_array_interface__) or a small library that ucx-py and possibly others would depend on.jakirkham commentedon Apr 27, 2020
Am curious what other things we wanted to support here @TomAugspurger 🙂 Are there things that we still haven't implemented today?
Edit: It may be that PR ( #3732 ) solves this or at least makes it much easier to solve whatever is left here IIUC what is being asked.
TomAugspurger commentedon Apr 27, 2020
Does the benchmark in https://github.com/TomAugspurger/dask-perf/blob/master/bench_cudf_join.py run (I don't have easy access to a GPU anymore, otherwise I would check)? If so, I'm guessing things are sufficiently fixed :)
jakirkham commentedon Apr 27, 2020
Hmm...I'm not actually sure how one should run that these days. It looks like we need to setup our own scheduler. Also
distributed.protocol.cudfno longer exists. At least a naive attempt to get this to run locally doesn't seem to work. In any event, we are able to run similar routines today. So my guess is this can work if the code were updated.jakirkham commentedon Apr 28, 2020
To the spirit of the issue, we do have
cuda_dumpsandcuda_loads. Thus farmerge_framesdoesn't behave how we would expect ( #3580 ) so we mostly avoid it. Though PR ( #3732 ) has merge and split frame style functions. So maybe that solves that piece of this issue?TomAugspurger commentedon Apr 28, 2020
I think we'll close this and reopen if we come across it with the current implementations.