Repository navigation
Closed
Description
I'm encountering the following exception when trying to perform a custom tree-reduce on a set of large cupy objects. I don't get this exception with smaller objects, so I have not been able to reproduce it with the normal pytests. The n_features in the HashingVectorizer that is used as input to the Naive Bayes pytest, however, can be modified to 8M in order to reproduce this exception.
Traceback (most recent call last):
File "/raid/cnolet/miniconda3/envs/cuml_dev_013/lib/python3.7/site-packages/distributed/protocol/core.py", line 124, in loads
value = _deserialize(head, fs, deserializers=deserializers)
File "/raid/cnolet/miniconda3/envs/cuml_dev_013/lib/python3.7/site-packages/distributed/protocol/serialize.py", line 255, in deserialize
deserializers=deserializers,
File "/raid/cnolet/miniconda3/envs/cuml_dev_013/lib/python3.7/site-packages/distributed/protocol/serialize.py", line 268, in deserialize
return loads(header, frames)
File "/raid/cnolet/miniconda3/envs/cuml_dev_013/lib/python3.7/site-packages/distributed/protocol/cuda.py", line 28, in cuda_loads
return loads(header, frames)
File "/raid/cnolet/miniconda3/envs/cuml_dev_013/lib/python3.7/site-packages/distributed/protocol/serialize.py", line 608, in deserialize
v = deserialize(h, f)
File "/raid/cnolet/miniconda3/envs/cuml_dev_013/lib/python3.7/site-packages/distributed/protocol/serialize.py", line 268, in deserialize
return loads(header, frames)
File "/raid/cnolet/miniconda3/envs/cuml_dev_013/lib/python3.7/site-packages/distributed/protocol/cuda.py", line 28, in cuda_loads
return loads(header, frames)
File "/raid/cnolet/miniconda3/envs/cuml_dev_013/lib/python3.7/site-packages/distributed/protocol/cupy.py", line 63, in cuda_deserialize_cupy_ndarray
frame = PatchedCudaArrayInterface(frame)
File "/raid/cnolet/miniconda3/envs/cuml_dev_013/lib/python3.7/site-packages/distributed/protocol/cupy.py", line 26, in __init__
self.__cuda_array_interface__ = ary.__cuda_array_interface__
AttributeError: 'bytes' object has no attribute '__cuda_array_interface__'
distributed.utils - ERROR - 'bytes' object has no attribute '__cuda_array_interface__'
Traceback (most recent call last):
File "/raid/cnolet/miniconda3/envs/cuml_dev_013/lib/python3.7/site-packages/distributed/utils.py", line 665, in log_errors
yield
File "/raid/cnolet/miniconda3/envs/cuml_dev_013/lib/python3.7/site-packages/distributed/comm/ucx.py", line 207, in read
frames, deserialize=self.deserialize, deserializers=deserializers
File "/raid/cnolet/miniconda3/envs/cuml_dev_013/lib/python3.7/site-packages/distributed/comm/utils.py", line 73, in from_frames
res = await offload(_from_frames)
File "/raid/cnolet/miniconda3/envs/cuml_dev_013/lib/python3.7/site-packages/distributed/utils.py", line 1458, in offload
return await loop.run_in_executor(_offload_executor, lambda: fn(*args, **kwargs))
File "/raid/cnolet/miniconda3/envs/cuml_dev_013/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/raid/cnolet/miniconda3/envs/cuml_dev_013/lib/python3.7/site-packages/distributed/utils.py", line 1458, in <lambda>
return await loop.run_in_executor(_offload_executor, lambda: fn(*args, **kwargs))
File "/raid/cnolet/miniconda3/envs/cuml_dev_013/lib/python3.7/site-packages/distributed/comm/utils.py", line 61, in _from_frames
frames, deserialize=deserialize, deserializers=deserializers
File "/raid/cnolet/miniconda3/envs/cuml_dev_013/lib/python3.7/site-packages/distributed/protocol/core.py", line 124, in loads
value = _deserialize(head, fs, deserializers=deserializers)
File "/raid/cnolet/miniconda3/envs/cuml_dev_013/lib/python3.7/site-packages/distributed/protocol/serialize.py", line 255, in deserialize
deserializers=deserializers,
File "/raid/cnolet/miniconda3/envs/cuml_dev_013/lib/python3.7/site-packages/distributed/protocol/serialize.py", line 268, in deserialize
return loads(header, frames)
File "/raid/cnolet/miniconda3/envs/cuml_dev_013/lib/python3.7/site-packages/distributed/protocol/cuda.py", line 28, in cuda_loads
return loads(header, frames)
File "/raid/cnolet/miniconda3/envs/cuml_dev_013/lib/python3.7/site-packages/distributed/protocol/serialize.py", line 608, in deserialize
v = deserialize(h, f)
File "/raid/cnolet/miniconda3/envs/cuml_dev_013/lib/python3.7/site-packages/distributed/protocol/serialize.py", line 268, in deserialize
return loads(header, frames)
File "/raid/cnolet/miniconda3/envs/cuml_dev_013/lib/python3.7/site-packages/distributed/protocol/cuda.py", line 28, in cuda_loads
return loads(header, frames)
File "/raid/cnolet/miniconda3/envs/cuml_dev_013/lib/python3.7/site-packages/distributed/protocol/cupy.py", line 63, in cuda_deserialize_cupy_ndarray
frame = PatchedCudaArrayInterface(frame)
File "/raid/cnolet/miniconda3/envs/cuml_dev_013/lib/python3.7/site-packages/distributed/protocol/cupy.py", line 26, in __init__
self.__cuda_array_interface__ = ary.__cuda_array_interface__
AttributeError: 'bytes' object has no attribute '__cuda_array_interface__'
distributed.worker - ERROR - 'bytes' object has no attribute '__cuda_array_interface__'
I believe this is the same as rapidsai/ucx-py#421, and while it only occurs when protocol=ucx, the stack trace is giving me all dask.distributed errors, so I've opted to start a fresh thread here.
cc @jakirkham
Metadata
Metadata
Assignees
Labels
No labels
Activity
cjnolet commentedon Mar 17, 2020
I think I found the culprit here. I raised this value [1] to
2^28and everything seems to execute successfully. @jakirkham pointed out that it looks like something is modifying the frames but not the header and I've verified the large frames that are causing the issue are passing through [2] insideframe_split_size.I also verified this is where it's being called [3] and I don't see the header being updated to reflect that the
cupyarray being serialized is now on host. However, IIUC, modifying the header here would mean the deserializer would produce a different object than what was serialized.I'd think we would still want a CuPy array to be returned from the deserializer, right? This would imply that we either want the the CuPy deserializer to understand how to deserialize
memoryviewobjects or that we don't want cuda frames moved to host when broken into smaller chunks.cc @pentschev @quasiben
[1] https://github.com/dask/distributed/blob/master/distributed/protocol/utils.py#L6
[2] https://github.com/dask/distributed/blob/master/distributed/protocol/utils.py#L49
[3] https://github.com/dask/distributed/blob/master/distributed/protocol/core.py#L56
quasiben commentedon Mar 17, 2020
@cjnolet I'm confused about how the byte array is getting to frame_split_size to begin with. Is the
daskserializer being used in cuML ?cjnolet commentedon Mar 17, 2020
@quasiben, it's a cupy ndarray all the way through the
frame_split_size. I believe it might be getting turned into the byte array in the msgpack serialization, somehow.We are using the dask serializer and also the cuda serializer in cuml. This error seems to only happen when UCX protocol is used in Dask, however.
mrocklin commentedon Mar 17, 2020
I would be surprised if a cupy array arrived at msgpack. I would certainly expect this to fail.
The
frame_split_sizefunction was designed to cut up very large frames (some communication and compression libraries can't handle things above a certain size). In Numpy+TCP-land we cut up large memoryviews into many smaller memoryviews. I don't know what CuPy+UCX does though in this case.quasiben commentedon Mar 17, 2020
Running the MRE posted in rapidsai/ucx-py#421 and I'll get back with an update shortly
cjnolet commentedon Mar 17, 2020
@mrocklin, my mistake. I saw the
msgpack.dumpsat the end ofprotocol.core.dumpsand assumed it was doing this for the payload.The part I find weird is that everything works when my arrays are smaller than
BIG_BYTES_SHARD_SIZEand the serialization fails with a mismatched header in the deserializer when the threshold is surpassed. Increasing the value ofBIG_BYTES_SHARD_SIZEappears to cause successful execution (not saying we need to change this value, btw).quasiben commentedon Mar 17, 2020
I ran with latest ucx-py/distributed/cuml and was not able to reproduce the error
quasiben commentedon Mar 17, 2020
Sorry not latest of cuml:
cjnolet commentedon Mar 17, 2020
@quasiben Did you make the changes outlined in the Github issue?
cjnolet commentedon Mar 17, 2020
@quasiben, actually, here's a more simple reproducible example:
This is the exception I get:
jakirkham commentedon Mar 17, 2020
Thanks for that simple reproducer Corey! 😄
cjnolet commentedon Mar 17, 2020
Lol, it took me awhile to figure out the behavior that was causing it to be able to reproduce it.
quasiben commentedon Mar 17, 2020
Still digging through this but I think it's possible we are inadvertently calling
memoryviewon part of the data during merge_frames:distributed/distributed/protocol/utils.py
Line 88 in f2f82c6
jakirkham commentedon Mar 17, 2020
FWIW CuPy doesn't support the Python Buffer Protocol ( cupy/cupy#1532 ). So if it got there, we would see an error. Not sure how Distributed would handle that (if at all).
quasiben commentedon Mar 17, 2020
I think I found the issue. With large and irregular sizes, within merge_frames is logic which calls
ensure_bytes:distributed/distributed/protocol/utils.py
Lines 94 to 95 in f2f82c6
ensure_bytescallsbytes, not on a CuPy array, but rather and rmm.DeviceBuffer:We can avoid this routine by a check at the end of the merge_frames routine:
jakirkham commentedon Mar 17, 2020
That's a nice find Ben! 😄
IIUC this function is used to combine frames into their original sizes. So how do we wind up in
merge_framesfrom the UCX side? Are we splitting and merging the frames there somehow?cjnolet commentedon Mar 17, 2020
Thank you for digging into this, Ben!
I ran the Naive Bayes example again after making the change and I'm getting a little strange behavior. I modified the reproducer script slightly so that I could try to see the values in the resulting arrays, but I'm getting an exception. Maybe it's possible there's still something being done on the UCX side that is causing this one.
Here's the exception:
Can you guys see if this error occurs for you?
mrocklin commentedon Mar 17, 2020
Alternatively, maybe with UCX we shouldn't be splitting and merging frames at all?
quasiben commentedon Mar 17, 2020
@cjnolet, yup I am seeing that as well.
@mrocklin @jakirkham seems like you two both want the same thing :)
cjnolet commentedon Mar 17, 2020
I just verified that not splitting frames with
__cuda_array_interface__appear to make the reproducible example succeed.https://github.com/dask/distributed/blob/master/distributed/protocol/utils.py#L41
quasiben commentedon Mar 17, 2020
I think we want to check if we are using UCX not if the frame has cuda_array_interface
cjnolet commentedon Mar 17, 2020
Sounds good to me! I just wanted to verify that it works when the frame has not been split
jakirkham commentedon Mar 17, 2020
@cjnolet, can you please give PR ( #3584 ) a try? 🙂