Skip to content

Core Multiprocessing - crashes cloudpicklinglru_cache #31099

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

Open
garrettwrong opened this issue Dec 14, 2022 · 2 comments
Open

Core Multiprocessing - crashes cloudpicklinglru_cache #31099

garrettwrong opened this issue Dec 14, 2022 · 2 comments
Labels
bug Something that is supposed to be working; but isn't core Issues that should be addressed in Ray Core core-correctness Leak, crash, hang dependencies Pull requests that update a dependency file P3 Issue moderate in impact or severity

Comments

@garrettwrong
Copy link

What happened + What you expected to happen

I recently added lru_cache to some simple grid generating methods in a Python class. This class is later used inside a ray multiprocessing Pool.

Expected behavior: Not crash. Ideally we could ship the lru_cache. I would also be fine with clearing it and losing any optimization when distributed, but it can't crash. This will block us from doing some pretty common optimizations without reimplementing standard library tools.

I believe this is cloudpipe/cloudpickle#178

Thanks

Versions / Dependencies

ray==2.2.0
Python 3.10.6
Linux

But I this is not version dependent...

Reproduction script

performed on osx. 11.6.2

conda create -n rpb python=3.8
pip install ray

from functools import lru_cache
import ray
from ray.util.multiprocessing import Pool

class Frog:
    def __init__(self):
        # We want a local cache per instance
        self.f = lru_cache(maxsize=8)(self.f)

    @staticmethod
    @lru_cache(maxsize=8)
    def g(n):
        print(f"expensive stuff {n}")
        return n
    
    def f(self, n):
        print(f"more expensive stuff {n} composed with expensive stuff g({n}).")
        return n * Frog.g(n)

    def compute_all_the_things(self):
        print(list(map(self.f, range(3))))

    def compute_all_the_things_par(self):
        ray.init()
        with Pool() as p:
            res = p.map(self.f, range(3))
        ray.shutdown()
        print(list(res))

a = Frog()
a.compute_all_the_things()
a.compute_all_the_things_par()

Issue Severity

Medium: It is a significant difficulty but I can work around it.

@garrettwrong garrettwrong added bug Something that is supposed to be working; but isn't triage Needs triage (eg: priority, bug/not-bug, and owning component) labels Dec 14, 2022
@rkooo567 rkooo567 added the core Issues that should be addressed in Ray Core label Dec 14, 2022
@hora-anyscale hora-anyscale added P1 Issue that should be fixed within a few weeks and removed triage Needs triage (eg: priority, bug/not-bug, and owning component) labels Dec 16, 2022
@scv119 scv119 added the dependencies Pull requests that update a dependency file label Feb 16, 2023
@rkooo567 rkooo567 added the core-correctness Leak, crash, hang label Mar 24, 2023
@ericl ericl added P2 Important issue, but not time-critical and removed P1 Issue that should be fixed within a few weeks labels Mar 24, 2023
@garrettwrong
Copy link
Author

Hi, is this fixed? I don't see an associated PR or updates on the referenced cloudpickle issue. Thanks!

@anyscalesam anyscalesam added triage Needs triage (eg: priority, bug/not-bug, and owning component) and removed P2 Important issue, but not time-critical labels Aug 12, 2024
@anyscalesam anyscalesam reopened this Aug 12, 2024
@jjyao jjyao added P2 Important issue, but not time-critical and removed triage Needs triage (eg: priority, bug/not-bug, and owning component) labels Aug 12, 2024
@jjyao
Copy link
Collaborator

jjyao commented Aug 12, 2024

We are blocked by cloudpickle fix.

@jjyao jjyao added P3 Issue moderate in impact or severity and removed P2 Important issue, but not time-critical labels Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that is supposed to be working; but isn't core Issues that should be addressed in Ray Core core-correctness Leak, crash, hang dependencies Pull requests that update a dependency file P3 Issue moderate in impact or severity
Projects
None yet
Development

No branches or pull requests

7 participants