-
-
Notifications
You must be signed in to change notification settings - Fork 924
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
Threaded MultipackDistributedDataloader with prefetched samples #759
Merged
casper-hansen
merged 23 commits into
axolotl-ai-cloud:main
from
casper-hansen:multithreading
Oct 26, 2023
Merged
Threaded MultipackDistributedDataloader with prefetched samples #759
casper-hansen
merged 23 commits into
axolotl-ai-cloud:main
from
casper-hansen:multithreading
Oct 26, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
casper-hansen
changed the title
Multithreading implementation
Threaded MultipackDistributedDataloader with prefetched samples
Oct 22, 2023
@winglian Please have a look when you find some time. I have updated the start of threads so that the E2E tests do not hang and the startup is now faster than before. The problem was that CPU was being maxed out by the DataLoader while the model, deepspeed, and other things were loading - causing a massive slowdown. |
winglian
approved these changes
Oct 25, 2023
mkeoliya
pushed a commit
to mkeoliya/axolotl
that referenced
this pull request
Dec 15, 2023
…otl-ai-cloud#759) * Multithreading implementation [WIP] * Added benchmarking * 35% increased throughput * Memory pinning * Start threads in init * Correct print of samples * Sleep if queue is full * Remove pin_memory (worse) * Simplify logic to one thread * Remove benchmark * Use deque for constant speed * Formatting * Formatting * Formatting * Formatting * Rollback to use queue * Fix multi-epoch training * Add num epochs arg * Start thread in __iter__ * Formatting * Use is_alive correctly * Simplify loading thread
djsaunde
pushed a commit
that referenced
this pull request
Dec 17, 2024
* Multithreading implementation [WIP] * Added benchmarking * 35% increased throughput * Memory pinning * Start threads in init * Correct print of samples * Sleep if queue is full * Remove pin_memory (worse) * Simplify logic to one thread * Remove benchmark * Use deque for constant speed * Formatting * Formatting * Formatting * Formatting * Rollback to use queue * Fix multi-epoch training * Add num epochs arg * Start thread in __iter__ * Formatting * Use is_alive correctly * Simplify loading thread
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary: We achieve a ~10-20% speed boost in multi-GPU training. We prefetch samples and put them into a queue with a max size of 1000. The DataLoader then yields from the queue.
This is what normal training with zero1 looks like now:
TODO:
num_threads > 1
makes performance much worse.Speed testing - TinyLlama 1B
Must run
accelerate launch -m axolotl.cli.train examples/llama-2/fft_optimized.yml --prepare_ds_only
to prepare dataset first in order to get proper benchmark values.Main:
offload_optimizer
)offload_optimizer
)PR:
offload_optimizer
)offload_optimizer
)Config
Config
The problem
GPU utilization on main looks like the following image. You see large dips in utilization. This is even more pronounced when you move to multi-GPU.
Zero1 vs Zero2
The main problem is the large spikes down when using zero2. This is likely from communication overhead. As we saw in the image at the start of the PR, zero1 is super smooth compared to zero2.
Main: Zero2 without offloading optimizer to CPU - same dips as we see on 1x GPU.
PR: Zero2 without offloading optimizer to CPU - just straight GPU utilization at 100%.