lenskit.parallel.ray#
Support for parallelism with Ray.
Functions
|
|
|
|
|
Initialize or connect to a Ray cluster, with the LensKit options. |
Determine whether the current process is running on a Ray worker. |
|
Query whether Ray is active. |
|
Check if Ray is available. |
|
Check if this Ray setup is supported by LensKit. |
|
|
Classes
|
- lenskit.parallel.ray.init_cluster(*, num_cpus=None, proc_slots=None, resources=None, worker_parallel=None, limit_slots=True, **kwargs)#
Initialize or connect to a Ray cluster, with the LensKit options.
The resulting cluster can be used by an invoker, or it can be used directly. The Ray invoker uses batching, though, so it only works well with many small tasks.
- Parameters:
num_cpus (int | None) – The total number of CPUs to allow. Defaults to :fun:`effective_cpu_count`.
proc_slots (int | None) – The number of “process slots” for LensKit parallel operations. Defaults to the LensKit process count. These slots are recorded as the
lk_process
resource on the Ray cluster.resources (dict[str, float] | None) – Additional custom resources to register in the Ray cluster.
worker_parallel (ParallelConfig | None) – Parallel processing configuration for worker processes. If
None
, uses the default.limit_slots (bool) –
False
to disable the LensKit slot interface.kwargs – Other options to pass to
ray.init()
.
- Stability:
Experimental
- lenskit.parallel.ray.ray_supported()#
Check if this Ray setup is supported by LensKit.
- Return type:
- lenskit.parallel.ray.is_ray_worker()#
Determine whether the current process is running on a Ray worker.
- Return type:
- class lenskit.parallel.ray.RayOpInvoker(model, func)#
Bases:
ModelOpInvoker
[A
,R
],Generic
[M
,A
,R
]- Parameters:
model (M)
func (InvokeOp[M, A, R])
- map(tasks)#
Apply the configured function to the model and iterables. This is like
map()
, except it supplies the invoker’s model as the first object tofunc
.- Parameters:
iterables – Iterables of arguments to provide to the function.
tasks (Iterable[A])
- Returns:
An iterable of the results.
- Return type:
iterable
- shutdown()#
Shut down this invoker.