Fix index errors on world size > 0 - #252
Merged
Merged
Conversation
for more information, see https://pre-commit.ci
…ing-ai/litdata into bugfix/resume-index-error
for more information, see https://pre-commit.ci
awaelchli
commented
Jul 22, 2024
| chunk_indexes_per_nodes: Any = [[] for _ in range(distributed_env.num_nodes)] | ||
| process_per_node = distributed_env.world_size // distributed_env.num_nodes | ||
| for rank, chunks_per_rank in enumerate(chunks_per_ranks): | ||
| chunk_indexes_per_nodes[0 if distributed_env.num_nodes == 1 else rank // process_per_node].extend( |
Contributor
Author
There was a problem hiding this comment.
Since chunks are now associated by worker and not rank (#237), the grouping by node here was still wrong. I extracted this grouping to a new function so I can more easily test it.
|
|
||
| chunks_per_ranks = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15]] | ||
| shuffled_indexes = _intra_node_chunk_shuffle(_DistributedEnv(8, 7, 2), chunks_per_ranks, 42, 2) | ||
| assert shuffled_indexes == [5, 2, 0, 7, 6, 1, 3, 4, 13, 10, 8, 15, 14, 9, 11, 12] |
Contributor
Author
There was a problem hiding this comment.
Previously, the test was asserting the final output list which by itself is not very meaningful (apart from asserting it doesn't change from one version to the next).
I extended the test to show the other important properities:
- The shuffle is consistent across all ranks
- The shuffle is different from one epoch to the next.
awaelchli
marked this pull request as ready for review
July 22, 2024 12:02
This file contains hidden or 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
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.
Fixes #251
Fixes:
I validated this fix using Multi-Node training in Lightning AI.