Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Add rechunking workflow #752

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 29 additions & 29 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,36 +32,36 @@ jobs:
matrix:
os: [ubuntu-latest]
python-version: ["3.9"]
pytest_args: [tests]
pytest_args: [tests/workflows/test_rechunk.py]
runtime-version: [upstream, latest]
include:
# Run stability tests on Python 3.8
- pytest_args: tests/stability
python-version: "3.8"
runtime-version: upstream
os: ubuntu-latest
- pytest_args: tests/stability
python-version: "3.8"
runtime-version: latest
os: ubuntu-latest
# Run stability tests on Python 3.10
- pytest_args: tests/stability
python-version: "3.10"
runtime-version: upstream
os: ubuntu-latest
- pytest_args: tests/stability
python-version: "3.10"
runtime-version: latest
os: ubuntu-latest
# Run stability tests on Python Windows and MacOS (latest py39 only)
- pytest_args: tests/stability
python-version: "3.9"
runtime-version: latest
os: windows-latest
- pytest_args: tests/stability
python-version: "3.9"
runtime-version: latest
os: macos-latest
# include:
# # Run stability tests on Python 3.8
# - pytest_args: tests/stability
# python-version: "3.8"
# runtime-version: upstream
# os: ubuntu-latest
# - pytest_args: tests/stability
# python-version: "3.8"
# runtime-version: latest
# os: ubuntu-latest
# # Run stability tests on Python 3.10
# - pytest_args: tests/stability
# python-version: "3.10"
# runtime-version: upstream
# os: ubuntu-latest
# - pytest_args: tests/stability
# python-version: "3.10"
# runtime-version: latest
# os: ubuntu-latest
# # Run stability tests on Python Windows and MacOS (latest py39 only)
# - pytest_args: tests/stability
# python-version: "3.9"
# runtime-version: latest
# os: windows-latest
# - pytest_args: tests/stability
# python-version: "3.9"
# runtime-version: latest
# os: macos-latest

steps:
- name: Checkout
Expand Down
9 changes: 9 additions & 0 deletions cluster_kwargs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ embarrassingly_parallel_cluster:
backend_options:
region: "us-east-1" # Same region as dataset

# For tests/workflows/test_rechunk.py
rechunk_cluster:
n_workers: 20
# TODO: Remove the `m6i.xlarge` worker specification below
# once it's the default worker instance type
worker_vm_types: [m6i.xlarge] # 4 CPU, 16 GiB
backend_options:
region: "us-west-2" # Same region as dataset

# For tests/workflows/test_uber_lyft.py
uber_lyft_cluster:
n_workers: 20
Expand Down
60 changes: 60 additions & 0 deletions tests/workflows/test_rechunk.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import uuid

import coiled
import dask.array as da
import pytest
from dask.distributed import Client


@pytest.fixture(scope="module")
def rechunk_cluster(
dask_env_variables,
cluster_kwargs,
github_cluster_tags,
):
with coiled.Cluster(
f"test-rechunk-{uuid.uuid4().hex[:8]}",
environ=dask_env_variables,
tags=github_cluster_tags,
**cluster_kwargs["rechunk_cluster"],
) as cluster:
yield cluster


@pytest.fixture
def rechunk_client(
rechunk_cluster,
cluster_kwargs,
upload_cluster_dump,
benchmark_all,
):
n_workers = cluster_kwargs["rechunk_cluster"]["n_workers"]
with Client(rechunk_cluster) as client:
rechunk_cluster.scale(n_workers)
client.wait_for_workers(n_workers)
client.restart()
with upload_cluster_dump(client), benchmark_all(client):
yield client


def test_rechunk_simple(rechunk_client, s3_url):
# Dataset is 3.80 TiB (https://registry.opendata.aws/mur)
x = da.from_zarr(
"s3://mur-sst/zarr",
component="sea_ice_fraction",
storage_options={"anon": True, "client_kwargs": {"region_name": "us-west-2"}},
)
assert x.chunksize == (6443, 100, 100) # 61.45 MiB (dtype = int8)
y = x.rechunk((6443, 100, 200)) # 122.89 MiB
y.to_zarr(s3_url)


def test_rechunk_full_shuffle(rechunk_client, s3_url):
# Test a "full shuffle" rechunk where every input chunk goes into every output chunk
# Dataset is 196.72 GiB
x = da.from_zarr(
"s3://yuvipanda-test1/cmr/gpm3imergdl.zarr/HQprecipitation",
storage_options={"anon": True},
)
y = x.rechunk((-1, 36, 180))
y.to_zarr(s3_url)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rabernat we're trying to establish a set of benchmarks for common workloads faced by Dask users. Ideally these are more realistic and less of toy examples.

We were inspired by your thoughts on reading in a dataset stored in one chunking and then performing an analysis in another. This is a quick proxy to that. Do you happen to have anything that we could use that would be better? In terms of complexity we'd love something in between 20-200 lines of code.

Copy link

@rabernat rabernat Mar 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The most difficult / pathological case to test is a "full shuffle" rechunk, where every input chunk goes into every output chunk.

I'd look at this dataset.

An array is at s3://yuvipanda-test1/cmr/gpm3imergdl.zarr/HQprecipitation ... not quite as big as MUR but chunked contiguously in space.

Screen Shot 2023-03-30 at 8 34 37 PM

Try something like

x = da.from_zarr("s3://yuvipanda-test1/cmr/gpm3imergdl.zarr/HQprecipitation")
y = x.rechunk((-1, 36, 180))

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @rabernat . We're also trying to capture a broader set of common operations to keep things real-world-ish. These might eventually graduate into some sort of notebook repository with worked examples that people can take a look at. Is there some icing we could put on this particular cake? Maybe some common analysis and an image that would be produced for example?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or, maybe stated differently, @rabernat , what are 1-3 workflows you'd like run regularly as part of Dask's benchmark suite. These get used day-to-day by engineers as they run AB tests on various changes that they want to make. Workloads in this suite will naturally be optimized over time.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciate the chance to contribute to this. I'll try to follow up with more detail in the coming days.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the pointer @rabernat 🚀 Btw, what region is the dataset located in? I didn't see a region reference on the pangeo-force page or the corresponding feedstock

Try something like

That example seems to run well (albeit with lots of transfers) when I try it here. I'm currently using a large cluster (~750GiB of memory) which is much bigger than the dataset itself (~200 GiB). Under what conditions do you tend to see bad performance? Maybe on a cluster with less memory than the dataset itself?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wanted to check in here -- @rabernat do you have additional details that'd be useful here (e.g. some common follow-up operations/plots like Matt mentioned)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just another gentle ping @rabernat

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for my slow response here. I would recommend you look at https://github.com/pangeo-data/distributed-array-examples/issues. This is our best attempt to collect the sort of workflows you're looking for from the Pangeo Community.