Data Loading as a Service
Author: mingruimingrui
Pull request: no
Labels: name: wontfix

# 🚀 Not a Feature request, what am I here for then?

Well, mainly I'd just like to get some feedback from fellow software engineers. Some of the frustrations I've experienced might not have been big issues at all or there could have been easy ways to get around them which I've failed to notice. Getting roasted can be a good way for us to identify obvious flaws in our thought processes that aren't so obvious from our own often tunneled point of view.

## Motivation

Data loading in PyTorch requires the user to define the Dataset, collator, as well as a sampling strategy.
I found it rather hard to stick to the framework when I have to deal with
- Extremely large datasets that do not fit in system memory
- The previous point + training with multiple processes and nodes

For Language Modeling and Machine Translation,
- We often have to deal with large text/CSV files that are multiple times the size of system memory.
- Also running training on a single GPU is often slow to the point of frustration.
- Then we have to duplicate the extremely large dataset across each machine.
- To format the data we have into a PyTorch Dataset, we simply just do a hack where we wrap an IO stream into a PyTorch Dataset
- Or preprocess the entire dataset beforehand to speed up data loading.
- Sometimes we would keep an index table to "lookup" the position of a data entry in a file which can be slow if not using SSD to perform random access.

Instead of trying to write code that fits into the format expected by PyTorch. I simply threw everything out the window and just made data loading a standalone service instead...

## Your contribution

Well, I've uploaded my work on https://github.com/mingruimingrui/data-loader-as-a-service-demo.

If you have taken your time to read up to this point, I would like to give you my gratitude as it had made me quite happy (^o^)
I would also like to ask for you to leave some comments for me which can be any of the following.
1. Can you relate to the problems I've faced?
2. Which part of the Data Loading as a Service do you like?
3. Which part of the Data Loading as a Service do you not like or have problems agreeing with?
5. Any other comments would also be appreciated.


Comments:
@lhoestq - this might be interesting for you! Any good tips from your side?

Interesting ! Cool features could be reading from s3, gcp etc.
Also maybe memory mapping can help speed up things a bit.

Streaming datasets this way is something we'd like to add in the `datasets` library at one point since we're seeing more and more common crawl scale datasets.

> Interesting ! Cool features could be reading from s3, gcp etc.
> Also maybe memory mapping can help speed up things a bit.
> 
> Streaming datasets this way is something we'd like to add in the `datasets` library at one point since we're seeing more and more common crawl scale datasets.

This... is something I'd enjoy working on, even for free.
But if you already have plans to do it, please don't hesitate to start (*´∇｀)

@mingruimingrui this fits actually well in a pretty cool larger community project we have. Wanna send me your email by DM/email/LinkedIn and I invite you on our slack to chat a bit more about it? I’ll probably make the project open in early January when it’s more solidly defined but I can give you early access.

@thomwolf I would like that very much (✿◕‿◕)

This issue has been automatically marked as stale and been closed because it has not had recent activity. Thank you for your contributions.

If you think this still needs to be addressed please comment on this thread.