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

R/W generated dataset to/from disk #738

Merged
merged 21 commits into from
May 10, 2023
Merged

R/W generated dataset to/from disk #738

merged 21 commits into from
May 10, 2023

Conversation

zhixiangteoh
Copy link
Contributor

@zhixiangteoh zhixiangteoh commented May 3, 2023

Two-step process.

  1. Generate; e.g.,
python case_studies/721_decoder_speedup/main.py mode=generate cached_simulator.file_data_capacity=100 simulator.n_batches=5

generator.py instantiates and uses a SimulatedDataset object to render images in cfg.simulator.prior.batch_size minibatches, then processes these generated minibatches by concatenation and flattening, before writing out to .pkl files via pickle.

  1. Train; e.g.,
python case_studies/721_decoder_speedup/main.py mode=train training.use_cached_simulator=true cached_simulator.file_data_capacity=100 simulator.n_batches=5

training.use_cached_simulator=true config causes the training step to use datamodule=instantiate(cfg.cached_simulator) in PyTorch Lightning's trainer.fit.

Addresses #721.

@zhixiangteoh zhixiangteoh self-assigned this May 3, 2023
@zhixiangteoh zhixiangteoh force-pushed the 721-diskrw-gsimages branch 2 times, most recently from bbfaf2f to 4933705 Compare May 4, 2023 20:35
@codecov
Copy link

codecov bot commented May 4, 2023

Codecov Report

Merging #738 (9c664f1) into master (63d9f35) will increase coverage by 0.07%.
The diff coverage is 92.80%.

@@            Coverage Diff             @@
##           master     #738      +/-   ##
==========================================
+ Coverage   88.33%   88.41%   +0.07%     
==========================================
  Files          13       14       +1     
  Lines        1132     1252     +120     
==========================================
+ Hits         1000     1107     +107     
- Misses        132      145      +13     
Flag Coverage Δ
unittests 88.41% <92.80%> (+0.07%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
bliss/train.py 62.92% <66.66%> (-0.30%) ⬇️
bliss/generate.py 92.95% <92.95%> (ø)
bliss/simulator/simulated_dataset.py 90.38% <95.83%> (-4.36%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@zhixiangteoh zhixiangteoh changed the title [WIP] R/W generated dataset to/from disk R/W generated dataset to/from disk May 4, 2023
@jeff-regier jeff-regier linked an issue May 4, 2023 that may be closed by this pull request
6 tasks
bliss/generate.py Outdated Show resolved Hide resolved
bliss/train.py Outdated Show resolved Hide resolved
bliss/generate.py Outdated Show resolved Hide resolved
bliss/generate.py Outdated Show resolved Hide resolved
bliss/generate.py Outdated Show resolved Hide resolved
bliss/generate.py Outdated Show resolved Hide resolved
Copy link
Contributor

@jeff-regier jeff-regier left a comment

Choose a reason for hiding this comment

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

Looks good! Please see requested changes inline.

@jeff-regier
Copy link
Contributor

jeff-regier commented May 5, 2023

Also, please make sure training iterations / second is at least 5.5.

bliss/generate.py Outdated Show resolved Hide resolved
@zhixiangteoh
Copy link
Contributor Author

Also, please make sure training iterations / second is at least 5.5.

Currently, averaging to about 4 training iterations / second (in each epoch, starts out slower, then speeds up to > 5 it/s).

DiskDataset renders images (in disk_batch_size) chunks and writes/reads
them to/from disk via pickle. Encoder uses this DiskDataset in
ImagePrior.batch_size batches.

Currently does not handle multiple workers—potentially want multiple
workers to write/read at the same time.
`case_studies/721_decoder_speedup/main.py mode=generate` renders images
via decoder and writes to pkl files on disk. Later `.../main.py mode=train` uses
cached image data for training.
DiskDataset renders images (in disk_batch_size) chunks and writes/reads
them to/from disk via pickle. Encoder uses this DiskDataset in
ImagePrior.batch_size batches.

Currently does not handle multiple workers—potentially want multiple
workers to write/read at the same time.
@zhixiangteoh
Copy link
Contributor Author

Also, please make sure training iterations / second is at least 5.5.

With configuration as in case_studies/721_diskrw_gsimages/config.yaml, running

python case_studies/721_diskrw_gsimages/main.py 'mode=train'

gives median 6.1 it/s.

@zhixiangteoh zhixiangteoh marked this pull request as ready for review May 10, 2023 15:22
return DataLoader(self.valid, batch_size=None, num_workers=0)

def test_dataloader(self):
return DataLoader(self, batch_size=None, num_workers=0)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the test set the same as the training set? That seems like a problem. We should probably have separate files that contain the test set.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@jeff-regier
Copy link
Contributor

With configuration as in case_studies/721_diskrw_gsimages/config.yaml, running

python case_studies/721_diskrw_gsimages/main.py 'mode=train'

gives median 6.1 it/s.

Excellent!

Copy link
Contributor

@jeff-regier jeff-regier left a comment

Choose a reason for hiding this comment

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

Looks great!

@jeff-regier jeff-regier merged commit 74da903 into master May 10, 2023
@jeff-regier jeff-regier deleted the 721-diskrw-gsimages branch May 10, 2023 16:55
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.

speed up the ImageDecoder
2 participants