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

Improve more on new dataset API #434

Merged
merged 11 commits into from
Mar 22, 2020
Merged

Improve more on new dataset API #434

merged 11 commits into from
Mar 22, 2020

Conversation

zasdfgbnm
Copy link
Contributor

@zasdfgbnm zasdfgbnm commented Mar 22, 2020

The new suggested way to use dataset is:

training, validation = torchani.data.load(dspath).subtract_self_energies(energy_shifter).species_to_indices().shuffle().split(0.8, None)
training = training.collate(batch_size).cache()
validation = validation.collate(batch_size).cache()

which is cleaner than the previous

dataset = torchani.data.load(dspath).subtract_self_energies(energy_shifter).species_to_indices().shuffle()
size = len(dataset)
training, validation = dataset.split(int(0.8 * size), None)
training = training.collate(batch_size).cache()
validation = validation.collate(batch_size).cache()

The memory usage has reduced from the previous 18GB to 16GB, this is a small improvement, but it is hard to make it as good as the previously API by @yueyericardo because we are now not chunking, so we have to spend lots of memories to store padding.

If we don't want to use that much memory, we can remove the .cache() from the last two lines, but we now need a data loader to achieve comparable performance:

training, validation = torchani.data.load(dspath).subtract_self_energies(energy_shifter).species_to_indices().shuffle().split(0.8, None)
training = torch.utils.data.DataLoader(list(training), batch_size=batch_size, collate_fn=torchani.data.collate_fn, num_workers=64)
validation = torch.utils.data.DataLoader(list(validation), batch_size=batch_size, collate_fn=torchani.data.collate_fn, num_workers=64)

The above code uses ~9GB RAM

@zasdfgbnm zasdfgbnm changed the title [WIP] Improve more on new dataset API Improve more on new dataset API Mar 22, 2020
Copy link
Member

@farhadrgh farhadrgh left a comment

Choose a reason for hiding this comment

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

LGTM

@farhadrgh farhadrgh merged commit f8edffe into master Mar 22, 2020
@farhadrgh farhadrgh deleted the improve-more branch March 22, 2020 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants