-
Notifications
You must be signed in to change notification settings - Fork 79
Further IO improvements for CosmoFlow #2477
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
Merged
fiedorowicz1
merged 1 commit into
LBANN:develop
from
fiedorowicz1:more-cosmoflow-io-perf
Oct 18, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
33 changes: 19 additions & 14 deletions
33
applications/physics/cosmology/cosmoflow/cosmoflow_dataset.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,31 +1,36 @@ | ||
| import numpy as np | ||
| from glob import glob | ||
| from lbann.util.data import Sample, SampleDims, Dataset, DistConvDataset | ||
| from lbann.util.data import Sample, SampleDims, DistConvDataset | ||
| import h5py as h5 | ||
| import os | ||
|
|
||
|
|
||
| class CosmoFlowDataset(DistConvDataset): | ||
| def __init__(self, data_dir, input_width, num_secrets): | ||
| self.data_dir = data_dir | ||
| self.input_width = input_width | ||
| self.num_secrets = num_secrets | ||
| self.samples = glob(os.path.join(data_dir, '*.hdf5')) | ||
| self.samples = glob(os.path.join(data_dir, "*.hdf5")) | ||
| self.samples.sort() | ||
|
|
||
| def __len__(self): | ||
| return len(self.samples) | ||
|
|
||
| def __getitem__(self, index) -> Sample: | ||
| data = h5.File(self.samples[index], 'r') | ||
| data = h5.File(self.samples[index], "r") | ||
| slice_width = self.input_width // self.num_io_partitions | ||
| slice_ind = self.rank % self.num_io_partitions | ||
| full = data['full'][:, | ||
| slice_ind*slice_width:(slice_ind+1)*slice_width, | ||
| :self.input_width, | ||
| :self.input_width].astype(np.float32) | ||
| par = data['unitPar'][:].astype(np.float32) | ||
| return Sample(sample=np.ascontiguousarray(full), response=par) | ||
|
|
||
| full = data["full"][ | ||
| :, | ||
| slice_ind * slice_width : (slice_ind + 1) * slice_width, | ||
| : self.input_width, | ||
| : self.input_width, | ||
| ] | ||
| par = data["unitPar"][:].astype(np.float32) | ||
| return Sample(sample=full, response=par) | ||
|
|
||
| def get_sample_dims(self): | ||
| return SampleDims(sample=[4, self.input_width, self.input_width, self.input_width], response=self.num_secrets) | ||
| return SampleDims( | ||
| sample=[4, self.input_width, self.input_width, self.input_width], | ||
| response=self.num_secrets, | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.