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

Feature request: make SyclQueue picklable #1716

Open
olegkkruglov opened this issue Jun 19, 2024 · 2 comments
Open

Feature request: make SyclQueue picklable #1716

olegkkruglov opened this issue Jun 19, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@olegkkruglov
Copy link

Currently SyclQueue is not picklable. The error message is the following:

File "<stringsource>", line 2, in dpctl._sycl_queue.SyclQueue.__reduce_cython__
TypeError: no default __reduce__ due to non-trivial __cinit__

The queue is used for dispatching in scikit-learn-intelex and the fact that it is unpickleable prevents classes with SyclQueue type attribute from being pickleable.

@oleksandr-pavlyk
Copy link
Collaborator

@olegkkruglov Unfortunately this can not be done since sycl::queue C++ class itself can not be serialized (i.e. pickled). It is a stateful object whose state can not be saved and recreated as far as I am aware.

@oleksandr-pavlyk oleksandr-pavlyk added the enhancement New feature or request label Jul 25, 2024
@olegkkruglov
Copy link
Author

olegkkruglov commented Jul 25, 2024

@oleksandr-pavlyk but how then MemoryUSMDevice is picklable if it has SyclQueue as its attribute?

Pickling of USM allocation occurs by copying data from device to host and recording the USM type. The information about the device is lost (at present), and restoring to the default-selected device:

In [1]: import dpctl.tensor as dpt

In [2]: import pickle

In [3]: x = dpt.linspace(0, 1, num=30, device="cpu")

In [4]: m = x.usm_data

In [5]: m_roundtrip = pickle.loads(pickle.dumps(m))

In [6]: m.sycl_device
Out[6]: <dpctl.SyclDevice [backend_type.opencl, device_type.cpu,  11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz] at 0x7f2ded29b5f0>

In [7]: m_roundtrip.sycl_device
Out[7]: <dpctl.SyclDevice [backend_type.level_zero, device_type.gpu,  Intel(R) Graphics [0x9a49]] at 0x7f2de44ab430>

The queue associated with the round-tripped memory object is the cached queue corresponding to the default-selected device.

Pickling of dpctl.tensor.usm_ndarray is not supported at all yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants