-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Ray serialization problems #557
Comments
Here is one that fits into 3.:
|
We actually can handle this case. If you try |
Ok, the issue here is that That said, it seems like we shouldn't actually need to do |
more resources: https://github.com/jsonpickle/jsonpickle/tree/master/tests and https://github.com/jsonpickle/jsonpickle/issues Ideally we would port all the tests to Ray. |
Is category (2) a real thing? Cloudpickle is supposed to be more general. It is true, that pickle "succeeds" at serializing some things that cloudpickle fails at, e.g., class Foo(object):
def __init__(self):
super
cloudpickle.dumps(Foo) # PicklingError: Could not pickle object as excessively deep recursion required.
pickle.dumps(Foo) # b'\x80\x03c__main__\nFoo\nq\x00.' However, this is misleading. Pickle only succeeds because it doesn't capture the class definition (you couldn't unpickle it in another process). After #550, I think category (3) should more or less be nonexistent. I'm probably wrong about this, but we'll see. Category (4) is a big problem. E.g., #319. |
I just remembered an important class of types that fall in category (3), which is subtypes of standard types like lists/dicts/tuples (see #512 for an example). For example, if we serialize a |
I opened https://issues.apache.org/jira/browse/ARROW-1059 with the goal of being able to more easily expand the kinds of objects that can be serialized using the Arrow IPC machinery. So if you had objects that don't fit the set of "fast storage" types (tensors and the other primitive types supported), then these could be stored as pickles. pyarrow could register a pickle deserializer to be able to understand this user "message" type |
Ray currently fails to serialize xarray objects #748 (this is category (3) above). |
Ray also fails to serialize tensorflow-related objects, like Tensor. |
This is already possible with a helper function, see docs. |
@ProgrammerLWJ the underlying problem is that TensorFlow objects can't easily be serialized (e.g., with pickle). The preferable solution is to only ship the neural net weights or the gradient (e.g., as a list or dictionary of numpy arrays). |
This is a bit of a doozy, but I would really like to be able to use The
Is there any hope for ever serializing experiment? If not, there is an early stage discussion about an OO-based interface to Update: I have managed to get tune running without having to serialize experiment and am now no longer sure that is required |
We encountered many difficulties with serialization. #3917 |
@JessicaSchrouff yes definitely, can you see if |
@pcmoritz Great work ! |
@alaameloh Can you share an example that you would like to get working? |
custom_model = spacy.load('path_to_model')
for doc in documents:
result_ids.append(processing_function.remote(doc, custom_model)) here ray falls back to using pickle to serialize the spacy model. however , with the current spacy version i'm working with (2.0.16), pickle doesn't work (but cloud pickle does). it gets stuck afterwards and crashed after some time (due to memory i believe). depending on the model, the loading time for spacy would be an inconvenience if i simply loaded the model inside the processing_function and executed it with every call. |
@alaameloh hm, when we say "falling back to pickle" I think we actually mean "cloudpickle". Can you provide a runnable code snippet that we can use to reproduce the issue? |
import spacy
import ray
@ray.remote
def processing(nlp,text):
processed = nlp(text)
return processed
ray.init()
texts_list = ['this is just a random text to illustrate the serializing use case for ray',
'Ray is a flexible, high-performance distributed execution framework.To launch a Ray cluster, \
either privately, on AWS, or on GCP, follow these instructions.',
'This document describes what Python objects Ray can and cannot serialize into the object store. \
Once an object is placed in the object store, it is immutable.']
processed_id = []
nlp = spacy.load('en')
for text in texts_list:
processed_id.append(processing.remote(nlp,text))
processed_list = ray.get(processed_id)
|
Wanted to add a couple of notes here for problems that I am experiencing related to serialization.
Now let's test this code:
Running the test results in Now, here's something interesting, that I can't seem to get passed when trying to create unit tests for your own recommended solution (https://ray.readthedocs.io/en/latest/serialization.html#last-resort-workaround)
And the result... is.... ??? huh?
|
This are all fixed I think. |
I am sending an opened file as argument to the function. Trying to run that function as remote using ray but getting below errors. Error: |
We should try to understand better what we can serialize and what we cannot, so I'm making this issue to collect problems with our serialization.
There are five categories of problems:
If you run into problems like the above, please post a minimal example here or create a new issue for it.
The text was updated successfully, but these errors were encountered: