Repository navigation
Replies: 1 comment
|
For independent per-region processing, you can keep the read and computation inside the same worker task. For a general Xarray/Dask computation, there is no blanket guarantee that chunks will never move between workers. With ordinary lazy If each region can be processed independently, one approach is to submit a function that opens the store, selects its region, loads it without a nested Dask array graph, and finishes processing before returning a small result. For example, assuming an existing distributed import xarray as xr
def process_region(path: str, start: int, stop: int) -> float:
with xr.open_zarr(path, chunks=None) as ds:
region = ds["value"].isel(row=slice(start, stop)).load()
return float(region.sum().item())
workers = sorted(client.scheduler_info()["workers"])
regions = [(0, 16), (16, 32), (32, 48), (48, 64)]
futures = [
client.submit(
process_region,
"shared/input.zarr",
start,
stop,
workers=[workers[i % len(workers)]],
allow_other_workers=False,
)
for i, (start, stop) in enumerate(regions)
]
partial_sums = client.gather(futures)
Align the regions with the storage chunks. Two workers reading different parts of the same storage chunk can both read that chunk, even with no worker-to-worker transfer. Retries or recomputation can also cause repeated reads. A two-process local test of this pattern produced the correct results with no recorded peer data transfers for aligned regions. A control that loaded chunks on one worker and forced their consumer onto the other did transfer those chunks. This used a shared local store, not your unspecified storage setup. Rechunking or operations needing data from neighboring regions may still require communication. A reduction can communicate small partial results instead of full input chunks, as in the example. Worker pinning, What processing operation are you applying, and what are the storage and Dask chunk shapes? Those determine whether independent region tasks are suitable. |
Uh oh!
There was an error while loading. Please reload this page.
I'm processing an xarray dataset loaded from a zarr file and I'm looking for a way to control data locality. That is, is there a way to force chunks to be processed by a Dask worker to be loaded only by that worker, and no other one, so that no transfer between Dask workers is needed.
All reactions