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

Legate HDF5 using kerchunk #222

Merged
merged 18 commits into from
May 30, 2023
Merged

Conversation

madsbk
Copy link
Member

@madsbk madsbk commented May 23, 2023

Support reading of HDF5 files using kerchunk.

Limitations

  • Only read is supported.
  • Can only read whole arrays -- no partial access.
  • No compression -- only HDF5 files written without compression is supported.
  • Groups not supported -- only access to individual Zarr arrays are implemented.

Example

import h5py
import numpy as np

import legate_kvikio.kerchunk
import legate_kvikio.zarr


def hdf5_io(filename):
    a = np.arange(10000).reshape((100, 100))

    # Write array using h5py
    with h5py.File(filename, "w") as f:
        f.create_dataset("mydataset", chunks=(10, 10), data=a)

    # Read hdf5 file using legate+kerchunk
    b = legate_kvikio.kerchunk.hdf5_read(filename, dataset_name="mydataset")

    # They should be equal
    assert (a == b).all()


if __name__ == "__main__":
    hdf5_io("/tmp/legate-kvikio-io.hdf5")

@madsbk madsbk added improvement Improves an existing functionality non-breaking Introduces a non-breaking change legate labels May 23, 2023
@madsbk madsbk force-pushed the legate_kerchunk branch from 43c916d to 42d5a6e Compare May 23, 2023 12:54
@madsbk madsbk marked this pull request as ready for review May 23, 2023 14:33
@madsbk madsbk self-assigned this May 24, 2023
Copy link
Contributor

@wence- wence- left a comment

Choose a reason for hiding this comment

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

Some minor suggestions and a few queries.

legate/benchmarks/hdf5_read.py Show resolved Hide resolved
legate/benchmarks/hdf5_read.py Outdated Show resolved Hide resolved
legate/benchmarks/hdf5_read.py Outdated Show resolved Hide resolved
legate/cpp/tile_io.cpp Outdated Show resolved Hide resolved
Comment on lines 127 to 129
for (int32_t dim = 0; dim < DIM; ++dim) {
idx = idx * extents[dim] + point[dim] - lo[dim];
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe translate to zero-origin up front? (Does this do the right thing if point_dp is not in the box described by lo and hi?)

legate::Point<DIM> point = point_dp - lo_dp;
...
for (...) {
   idx = idx * extents[dim] + points[dim];

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.
point_dp must be within lo and hi. Since they come from context.get_task_index() and context.get_launch_domain() directly , I don't we need a check here.

legate/legate_kvikio/kerchunk.py Outdated Show resolved Hide resolved
legate/cpp/tile_io.cpp Outdated Show resolved Hide resolved
legate/legate_kvikio/tile.py Outdated Show resolved Hide resolved
@madsbk
Copy link
Member Author

madsbk commented May 30, 2023

Thanks @wence- , I think I have addressed all of your comments.

Copy link
Contributor

@wence- wence- left a comment

Choose a reason for hiding this comment

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

Thanks @madsbk , one required correctness-checking change and I've now had a chance to go through the C++ task description and have one more query there.

legate/legate_kvikio/kerchunk.py Outdated Show resolved Hide resolved
legate/legate_kvikio/tile.py Outdated Show resolved Hide resolved
legate/legate_kvikio/tile.py Outdated Show resolved Hide resolved
legate/legate_kvikio/tile.py Show resolved Hide resolved
legate/legate_kvikio/tile.py Show resolved Hide resolved
legate/cpp/tile_io.cpp Outdated Show resolved Hide resolved
legate/cpp/tile_io.cpp Outdated Show resolved Hide resolved
@madsbk
Copy link
Member Author

madsbk commented May 30, 2023

Thanks @wence-!

@madsbk madsbk requested a review from wence- May 30, 2023 14:05
Copy link
Contributor

@wence- wence- left a comment

Choose a reason for hiding this comment

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

I think there was one "fixed" that you didn't push, but looks good, thanks

legate/cpp/tile_io.cpp Outdated Show resolved Hide resolved
@madsbk
Copy link
Member Author

madsbk commented May 30, 2023

Thanks @wence- !

@madsbk
Copy link
Member Author

madsbk commented May 30, 2023

/merge

@rapids-bot rapids-bot bot merged commit 6503c23 into rapidsai:branch-23.06 May 30, 2023
@madsbk madsbk mentioned this pull request Jun 7, 2023
@madsbk madsbk deleted the legate_kerchunk branch June 23, 2023 08:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Improves an existing functionality non-breaking Introduces a non-breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants