deepspeedai / deepspeedai/DeepSpeedExamples
Tokenization extremely inefficient -- 1 example at a time appended to python list
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 6.8k
- Forks
- 1.1k
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 1
Description
I was trying to finetune on a large dataset (>1m examples), and I was noticing that my entire machine was running out of RAM and resources. I did some digging, and I think I identified the bottleneck:
In my understanding, this is extremely inefficient. Ideally, this should be using native datasets object (i.e. call Dataset.map, and saving the tokenized items to pytorch tensors, instead of a native python list. As it it currently written, you can only perform SFT on a small amount of examples, otherwise the script will take too long.
Let me know if this understanding is correct. If so, I believe it should be in scope for later development to refactor it.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read applications/DeepSpeed-Chat/training/utils/data/data_utils.py around line 162 and trace the SFT dataset preprocessing path. Reproduce the tokenization behavior with a large dataset of over 1 million examples, then compare memory use and runtime with the proposed Dataset.map and tensor-backed approach. Done means large-dataset SFT no longer exhausts machine resources or becomes impractically slow.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- data-engineering, machine-learning
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100