雷中的演员抽象

问题描述

在学习分布式Python的Ray技术时,我阅读了以下有关Ray的声明,但我并不完全理解它的真正含义是什么?赞赏有关某些应用程序上下文的任何解释。

Actors: An important part of the Ray API is the actor abstraction for sharing mutable state between tasks (e.g.,the state of a neural network or the state of a simulator). This blends very nicely with the side-effect free dataflow abstraction and is important for our workloads both to share state and to avoid expensive initializations. I don't think there is an analogue in Dask.

解决方法

想象一下您正在编写分布式应用程序。最常见的工作流程是使用“无副作用”任务并同时运行它们。我们称之为“无状态”工作流。这意味着运行这些任务不会更改应用程序的任何状态。雷对这种事情(称为任务)具有抽象性。

self.estimator.export_saved_model

但是有时候,您想要具有“状态”。例如,假设您运行分布式强化学习应用程序。您可能希望为任务可以访问的模拟器共享状态。 Ray的actor API用于支持这种类型的“有状态”工作流。

简而言之,Ray actor只是在您群集中的一台计算机中实例化的Python类。您可以使用actor API,以允许您的任务访问actor的方法。