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

Skip 2nd serialization pass of DeviceSerialized #309

Merged
merged 3 commits into from
Jun 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion conda/recipes/dask-cuda/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ requirements:
run:
- python x.x
- dask-core >=2.4.0
- distributed >=2.15.0
- distributed >=2.18.0
- pynvml >=8.0.3
- numpy >=1.16.0
- numba >=0.40.1
Expand Down
17 changes: 7 additions & 10 deletions dask_cuda/device_host_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from distributed.utils import nbytes
from distributed.worker import weight

import numpy
from zict import Buffer, File, Func
from zict.common import ZictBase

Expand All @@ -31,37 +30,35 @@ class DeviceSerialized:
that are in host memory
"""

def __init__(self, header, parts):
def __init__(self, header, frames):
self.header = header
self.parts = parts
self.frames = frames

def __sizeof__(self):
return sum(map(nbytes, self.parts))
return sum(map(nbytes, self.frames))


@dask_serialize.register(DeviceSerialized)
def device_serialize(obj):
headers, frames = serialize(obj.parts)
header = {"sub-headers": headers, "main-header": obj.header}
header = {"obj-header": obj.header}
frames = obj.frames
return header, frames


@dask_deserialize.register(DeviceSerialized)
def device_deserialize(header, frames):
parts = deserialize(header["sub-headers"], frames)
return DeviceSerialized(header["main-header"], parts)
return DeviceSerialized(header["obj-header"], frames)


@nvtx_annotate("SPILL_D2H", color="red", domain="dask_cuda")
def device_to_host(obj: object) -> DeviceSerialized:
header, frames = serialize(obj, serializers=["dask", "pickle"])
frames = [numpy.asarray(f) for f in frames]
return DeviceSerialized(header, frames)


@nvtx_annotate("SPILL_H2D", color="green", domain="dask_cuda")
def host_to_device(s: DeviceSerialized) -> object:
return deserialize(s.header, s.parts)
return deserialize(s.header, s.frames)


class DeviceHostFile(ZictBase):
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
dask>=2.9.0
distributed>=2.15.0
distributed>=2.18.0
pynvml>=8.0.3
numpy>=1.16.0
numba>=0.40.1