BiomedSciAI / fuse-med-ml

A python framework accelerating ML based discovery in the medical field by encouraging code reuse. Batteries included :)
Apache License 2.0
137 stars 34 forks source link

Uncollate is not needed and slows down training #267

Closed avihu111 closed 1 year ago

avihu111 commented 1 year ago

During training, every batch goes through uncollate (from dict of batches to list of sample dicts) This loops over: |dataset| * |keys| and is not done with multiprocessing, so it is a major bottleneck.

This is actually not needed, because we can easily gather batches without looping over the dataset samples.

for k in keys:
   torch.cat(batch[k], for batch in batches], dim=0)

Attaching the profiler output on my code (50K samples, each sample is a dictionary of ~10 vectors): image

mosheraboh commented 1 year ago

Fixed