--worker-preload-modules flag

Hi,

I was wondering how to pass an argument to --worker-preload-modules when using ray start to start a job?

and

mention it.

To pass an argument to --worker-preload-modules when starting Ray, you do not set it directly via the ray start CLI. Instead, you configure the list of modules to preload by setting the preload_python_modules Ray config, which is then used by the Raylet to construct the --worker-preload-modules argument for each worker process. This is handled internally: Ray reads the preload_python_modules config, serializes it as a comma-separated string, and appends it to the worker command as --worker-preload-modules=... (worker_pool.cc, default_worker.py).

To set this, you can use the environment variable RAY_preload_python_modules before starting Ray, e.g., export RAY_preload_python_modules=module1,module2 and then run ray start .... The modules listed will be imported in each worker before any user code is run (ray_config_def.h). There is no direct CLI flag for ray start to set this; it must be set via the environment or Ray config.

Would you like more detail or an example of how to set this in practice?

Sources:

Hint: Mention @RunLLM in the post for followups.