Skip to content

Commit

Permalink
Always set RMM's strides in the header (#4039)
Browse files Browse the repository at this point in the history
As newer versions of RMM have `DeviceBuffer` setting `strides` in
`__cuda_array_interface__` to `None` (as they are C-contiguous) and some
deserializers rely on this to be a non-`None` value, make sure to just
explicitly set `strides` to a non-`None` value.
  • Loading branch information
jakirkham authored Aug 12, 2020
1 parent 25d5a33 commit 0030729
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions distributed/protocol/rmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
@cuda_serialize.register(rmm.DeviceBuffer)
def cuda_serialize_rmm_device_buffer(x):
header = x.__cuda_array_interface__.copy()
header["strides"] = (1,)
header["lengths"] = [x.nbytes]
frames = [x]
return header, frames
Expand Down
2 changes: 2 additions & 0 deletions distributed/protocol/tests/test_rmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ def test_serialize_rmm_device_buffer(size, serializers):
y_np = y.copy_to_host()

if serializers[0] == "cuda":
assert header["strides"] == (1,)
assert all(hasattr(f, "__cuda_array_interface__") for f in frames)
elif serializers[0] == "dask":
assert header["strides"] == (1,)
assert all(isinstance(f, memoryview) for f in frames)

assert (x_np == y_np).all()

0 comments on commit 0030729

Please sign in to comment.