lenskit.config.ParallelSettings#

class lenskit.config.ParallelSettings#

Bases: pydantic_settings.BaseSettings

Configuration for LensKit’s parallel processing. These settings are in the [parallel] table in lenskit.toml.

model_config#
num_cpus: int = 0#

The number of CPUs LensKit should consider using. This is auto-detected from the system environment, and should only be configured manually if you want to override LensKit’s CPU detection for some reason. Note that the auto-detected values do account for operating system scheduling affinities and CPU limits.

This value is not used directly as a limit, but is used to derive the default values for the other concurrency controls (threads, etc.).

use_ray: bool = False#

Use Ray to parallelize batch operations, hyperparameter tuning, etc.

num_batch_jobs: int = 0#

Number of batch inference jobs to run in parallel. Can be overridden with the LK_NUM_BATCH_JOBS environment variable.

num_procs: int = 0#

Number of processes to use.

num_threads: int = 0#

Number of threads to use. Can be overridden with the LK_NUM_THREADS environment variable. Specify -1 to use all available threads.

num_backend_threads: int = 0#

Number of threads for compute backends to use. Can be overridden with the LK_NUM_BACKEND_THREADS environment variable. Specify -1 to leave threading limits unmodified.

property total_threads#
resolve_defaults()#

Resolve default values for thread/process counts.

env_vars()#

Get the parallel configuration as a set of environment variables to configure a child process. The set also includes OMP_NUM_THREADS and related variables for BLAS and MKL to configure OMP early.

Return type:

dict[str, str]