Running tasks in parallel (ray.get in a loop)
If your tasks run one at a time, you are probably calling eugo.hpc.get inside the loop that submits them. .remote(...) returns at once, but eugo.hpc.get waits for the result, so a get in the loop makes each task wait for the one before it. Submit every task first, then call eugo.hpc.get once on the whole list. Use eugo.hpc.wait to handle results as they finish, group tiny tasks into bigger ones, and share large inputs with eugo.hpc.put.
eugo.hpc is Ray's API under Eugo's name, so the same fix applies to ray.get in a loop.
Applies to: the EugoLab image, November 2026.
Before you start
Section titled “Before you start”- A notebook open in EugoLab.
- A running cluster in the Eugo HPC Clusters panel.
- The notebook connected to that cluster: on the cluster card, in the Notebook tab, select Connect this notebook. EugoLab adds and runs a two-line cell that connects the notebook. Connect before you run any task; otherwise the work runs on a private local Ray inside the notebook, not on the cluster. Connecting a notebook to your cluster explains what Connect does and how to check the connection.
Why do my tasks run one at a time?
Section titled “Why do my tasks run one at a time?”.remote(...) returns at once with an ObjectRef, a reference to a result that may not exist yet. eugo.hpc.get blocks until that result is ready. With a list of references, it waits for all of them and returns the results in the same order as the list.
-
In a new cell, define the function once with
@eugo.hpc.distribute:import timeimport eugo.hpc@eugo.hpc.distributedef slow_square(x):time.sleep(0.5)return x * x -
This loop is the slow pattern. Each
eugo.hpc.getwaits for its task before the next task is submitted, so the tasks run one after another:results = []for i in range(100):results.append(eugo.hpc.get(slow_square.remote(i))) # waits every time -
This is the fast pattern. Submit every task, then call
eugo.hpc.getonce on the list. The tasks run at the same time, as far as the cluster's free CPUs allow:refs = [slow_square.remote(i) for i in range(100)] # returns at onceresults = eugo.hpc.get(refs) # waits once, results in orderprint(results[:5])[0, 1, 4, 9, 16]
Define a remote function once and reuse it. Calling eugo.hpc.distribute(fn) inside a loop makes and exports a new remote function each time, which Ray lists as an anti-pattern.
How do I handle results as they finish?
Section titled “How do I handle results as they finish?”eugo.hpc.wait(refs, num_returns=k, timeout=s) returns two lists, (ready, not_ready), as soon as k results are done or the timeout passes.
-
Submit the tasks, then take each result as soon as it is ready:
refs = [slow_square.remote(i) for i in range(10)]while refs:ready, refs = eugo.hpc.wait(refs, num_returns=1)print(eugo.hpc.get(ready[0]))The results print in the order the tasks finish, which need not be the order you submitted them.
How do I speed up many tiny tasks?
Section titled “How do I speed up many tiny tasks?”Each task has a fixed scheduling cost. When the work in a task is smaller than that cost, group the work so each task does more.
-
Send a chunk of inputs to each task instead of one value:
@eugo.hpc.distributedef square_chunk(xs):return [x * x for x in xs]chunks = [list(range(i, i + 1000)) for i in range(0, 100_000, 1000)]results = eugo.hpc.get([square_chunk.remote(c) for c in chunks])print(len(results), len(results[0]))100 1000The cell runs 100 tasks of 1,000 inputs each instead of 100,000 tasks of one input.
How do I share a large input between tasks?
Section titled “How do I share a large input between tasks?”eugo.hpc.put(value) stores a value once in the cluster's object store and returns a reference. Pass the reference to every task instead of the value, so the value is not copied once per task.
-
Store the array once, then pass its reference:
import numpy as npbig = np.random.rand(10_000, 1_000)big_ref = eugo.hpc.put(big)@eugo.hpc.distributedef column_mean(arr, col):return arr[:, col].mean()means = eugo.hpc.get([column_mean.remote(big_ref, c) for c in range(100)])print(len(means))100A reference passed as a task argument arrives in the task as the value itself, so
column_meanreceives the array, not the reference. Memory for distributed jobs explains the object store and how big it is.
Why do only some of my tasks run at once?
Section titled “Why do only some of my tasks run at once?”A function decorated with @eugo.hpc.distribute(num_cpus=2) reserves 2 CPUs for each call (the default is 1). How many tasks run at the same time is bounded by the cluster's free CPUs.
-
Check the cluster's free resources:
eugo.hpc.available_resources()The result is a dictionary. Its
CPUentry is the number of CPUs free right now, and a cluster with GPU workers also has aGPUentry. -
To run more at once, lower
num_cpusfor a light task, or give the cluster more or larger workers (see Cluster settings).
Troubleshooting
Section titled “Troubleshooting”This notebook is already running Ray, started by a cell rather than through Connect
Section titled “This notebook is already running Ray, started by a cell rather than through Connect”Cause: a cell ran work before you connected, so the notebook started its own Ray. The cluster card offers Disconnect instead of Connect this notebook, with this message as its tooltip.
Fix:
- Stop the notebook's own Ray: on the cluster card, select Disconnect, or restart the notebook's kernel.
- On the cluster card, in the Notebook tab, select Connect this notebook.
- Run your task cells again.
My tasks ran in the notebook, not on the cluster
Section titled “My tasks ran in the notebook, not on the cluster”Cause: without Connect, the first call that runs work (.remote(...), eugo.hpc.put or eugo.hpc.get) starts a private local Ray inside the notebook.
Fix:
- Stop the notebook's own Ray: on the cluster card, select Disconnect, or restart the notebook's kernel.
- On the cluster card, in the Notebook tab, select Connect this notebook.
- Run your task cells again.
Error: eugo.hpc.use_auth_token_file: cannot use the Ray token file
Section titled “Error: eugo.hpc.use_auth_token_file: cannot use the Ray token file”The full message names the file and ends in "it does not exist", "it is a folder, not a file" or "this process is not allowed to read it".
Cause: the connect code was copied before an update, or before the lab restarted.
Fix:
- On the cluster card, in the Notebook tab, select Copy code.
- Paste the code into the notebook and run it.
If the notebook is already connected, the call raises RuntimeError: eugo.hpc.use_auth_token_file: this process is connected to Ray; call eugo.hpc.shutdown() first. Run eugo.hpc.shutdown(), then run the new code.
Related
Section titled “Related”- The eugo.hpc API
- Distributed Python on a GPU cluster
- Batch inference with Ray Data on GPUs
- Ray: Anti-pattern: Calling ray.get in a loop harms parallelism
- Ray: Anti-pattern: Over-parallelizing with too fine-grained tasks harms speedup
- Ray: Anti-pattern: Passing the same large argument by value repeatedly harms performance
- Example notebooks: map over a list, wait for the first ready result, put a shared object
© 2026 Eugo Inc. · Third-party licenses · LinkedIn (opens in new tab) · YouTube (opens in new tab) · GitHub (opens in new tab)

