secretflow.distributed#

Functions:

get(object_refs)

kill(actor, *[, no_restart])

production_mode()

remote(*args, **kwargs)

set_production(mode)

shutdown()

secretflow.distributed.get(object_refs: Union[ObjectRef, List[ObjectRef], FedObject, List[FedObject]])[源代码]#
secretflow.distributed.kill(actor, *, no_restart=True)[源代码]#
secretflow.distributed.production_mode()[源代码]#
secretflow.distributed.remote(*args, **kwargs)[源代码]#
secretflow.distributed.set_production(mode: bool)[源代码]#
secretflow.distributed.shutdown()[源代码]#

secretflow.distributed.primitive#

Functions:

set_production(mode)

production_mode()

remote(*args, **kwargs)

get(object_refs)

kill(actor, *[, no_restart])

shutdown()

ray_remote(*args, **kwargs)

Classes:

RemoteFunctionWrapper(language, function, ...)

ActorClassWrapper(name, bases, attr)

secretflow.distributed.primitive.set_production(mode: bool)[源代码]#
secretflow.distributed.primitive.production_mode()[源代码]#
secretflow.distributed.primitive.remote(*args, **kwargs)[源代码]#
secretflow.distributed.primitive.get(object_refs: Union[ObjectRef, List[ObjectRef], FedObject, List[FedObject]])[源代码]#
secretflow.distributed.primitive.kill(actor, *, no_restart=True)[源代码]#
secretflow.distributed.primitive.shutdown()[源代码]#
class secretflow.distributed.primitive.RemoteFunctionWrapper(language, function, function_descriptor, task_options)[源代码]#

基类:RemoteFunction

Methods:

party(party)

options(**task_options)

Configures and overrides the task invocation parameters.

party(party: str)[源代码]#
options(**task_options)[源代码]#

Configures and overrides the task invocation parameters.

The arguments are the same as those that can be passed to ray.remote. Overriding max_calls is not supported.

参数:
  • num_returns – It specifies the number of object refs returned by the remote function invocation.

  • num_cpus – The quantity of CPU cores to reserve for this task or for the lifetime of the actor.

  • num_gpus – The quantity of GPUs to reserve for this task or for the lifetime of the actor.

  • resources (Dict[str, float]) – The quantity of various custom resources to reserve for this task or for the lifetime of the actor. This is a dictionary mapping strings (resource names) to floats.

  • accelerator_type – If specified, requires that the task or actor run on a node with the specified type of accelerator. See ray.util.accelerators for accelerator types.

  • memory – The heap memory request in bytes for this task/actor, rounded down to the nearest integer.

  • object_store_memory – The object store memory request for actors only.

  • max_calls – This specifies the maximum number of times that a given worker can execute the given remote function before it must exit (this can be used to address memory leaks in third-party libraries or to reclaim resources that cannot easily be released, e.g., GPU memory that was acquired by TensorFlow). By default this is infinite for CPU tasks and 1 for GPU tasks (to force GPU tasks to release resources after finishing).

  • max_retries – This specifies the maximum number of times that the remote function should be rerun when the worker process executing it crashes unexpectedly. The minimum valid value is 0, the default is 4 (default), and a value of -1 indicates infinite retries.

  • runtime_env (Dict[str, Any]) – Specifies the runtime environment for this actor or task and its children. See runtime-environments for detailed documentation.

  • retry_exceptions – This specifies whether application-level errors should be retried up to max_retries times.

  • scheduling_strategy – Strategy about how to schedule a remote function or actor. Possible values are None: ray will figure out the scheduling strategy to use, it will either be the PlacementGroupSchedulingStrategy using parent’s placement group if parent has one and has placement_group_capture_child_tasks set to true, or “DEFAULT”; “DEFAULT”: default hybrid scheduling; “SPREAD”: best effort spread scheduling; PlacementGroupSchedulingStrategy: placement group based scheduling; NodeAffinitySchedulingStrategy: node id based affinity scheduling.

  • _metadata – Extended options for Ray libraries. For example, _metadata={“workflows.io/options”: <workflow options>} for Ray workflows.

Examples:

@ray.remote(num_gpus=1, max_calls=1, num_returns=2)
def f():
   return 1, 2
# Task g will require 2 gpus instead of 1.
g = f.options(num_gpus=2)
class secretflow.distributed.primitive.ActorClassWrapper(name, bases, attr)[源代码]#

基类:ActorClass

Methods:

party(party)

options(**actor_options)

Configures and overrides the actor instantiation parameters.

remote(*args, **kwargs)

Create an actor.

party(party: str)[源代码]#
options(**actor_options)[源代码]#

Configures and overrides the actor instantiation parameters.

The arguments are the same as those that can be passed to ray.remote.

参数:
  • num_cpus – The quantity of CPU cores to reserve for this task or for the lifetime of the actor.

  • num_gpus – The quantity of GPUs to reserve for this task or for the lifetime of the actor.

  • resources (Dict[str, float]) – The quantity of various custom resources to reserve for this task or for the lifetime of the actor. This is a dictionary mapping strings (resource names) to floats.

  • accelerator_type – If specified, requires that the task or actor run on a node with the specified type of accelerator. See ray.util.accelerators for accelerator types.

  • memory – The heap memory request in bytes for this task/actor, rounded down to the nearest integer.

  • object_store_memory – The object store memory request for actors only.

  • max_restarts – This specifies the maximum number of times that the actor should be restarted when it dies unexpectedly. The minimum valid value is 0 (default), which indicates that the actor doesn’t need to be restarted. A value of -1 indicates that an actor should be restarted indefinitely.

  • max_task_retries – How many times to retry an actor task if the task fails due to a system error, e.g., the actor has died. If set to -1, the system will retry the failed task until the task succeeds, or the actor has reached its max_restarts limit. If set to n > 0, the system will retry the failed task up to n times, after which the task will throw a RayActorError exception upon ray.get. Note that Python exceptions are not considered system errors and will not trigger retries.

  • max_pending_calls – Set the max number of pending calls allowed on the actor handle. When this value is exceeded, PendingCallsLimitExceeded will be raised for further tasks. Note that this limit is counted per handle. -1 means that the number of pending calls is unlimited.

  • max_concurrency – The max number of concurrent calls to allow for this actor. This only works with direct actor calls. The max concurrency defaults to 1 for threaded execution, and 1000 for asyncio execution. Note that the execution order is not guaranteed when max_concurrency > 1.

  • name – The globally unique name for the actor, which can be used to retrieve the actor via ray.get_actor(name) as long as the actor is still alive.

  • namespace – Override the namespace to use for the actor. By default, actors are created in an anonymous namespace. The actor can be retrieved via ray.get_actor(name=name, namespace=namespace).

  • lifetime – Either None, which defaults to the actor will fate share with its creator and will be deleted once its refcount drops to zero, or “detached”, which means the actor will live as a global object independent of the creator.

  • runtime_env (Dict[str, Any]) – Specifies the runtime environment for this actor or task and its children. See runtime-environments for detailed documentation.

  • scheduling_strategy – Strategy about how to schedule a remote function or actor. Possible values are None: ray will figure out the scheduling strategy to use, it will either be the PlacementGroupSchedulingStrategy using parent’s placement group if parent has one and has placement_group_capture_child_tasks set to true, or “DEFAULT”; “DEFAULT”: default hybrid scheduling; “SPREAD”: best effort spread scheduling; PlacementGroupSchedulingStrategy: placement group based scheduling; NodeAffinitySchedulingStrategy: node id based affinity scheduling.

  • _metadata – Extended options for Ray libraries. For example, _metadata={“workflows.io/options”: <workflow options>} for Ray workflows.

Examples:

@ray.remote(num_cpus=2, resources={"CustomResource": 1})
class Foo:
    def method(self):
        return 1
# Class Bar will require 1 cpu instead of 2.
# It will also require no custom resources.
Bar = Foo.options(num_cpus=1, resources=None)
remote(*args, **kwargs)[源代码]#

Create an actor.

参数:
  • args – These arguments are forwarded directly to the actor constructor.

  • kwargs – These arguments are forwarded directly to the actor constructor.

返回:

A handle to the newly created actor.

secretflow.distributed.primitive.ray_remote(*args, **kwargs)[源代码]#