-
Notifications
You must be signed in to change notification settings - Fork 444
feat: Enhance dataset loading efficiency with tensor parallelism #2405
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
720715d
2fcee68
ffcb3a5
67b7faa
fc80103
4baae7b
63c7e53
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,6 +32,7 @@ | |
| from megatron.bridge.training.losses import masked_next_token_loss | ||
| from megatron.bridge.training.post_training.distillation import loss_func_kd | ||
| from megatron.bridge.training.state import GlobalState | ||
| from megatron.bridge.training.utils.batch_utils import get_batch_on_this_tp_rank | ||
| from megatron.bridge.training.utils.packed_seq_utils import get_packed_seq_params | ||
| from megatron.bridge.training.utils.pg_utils import get_pg_collection | ||
|
|
||
|
|
@@ -169,13 +170,19 @@ def get_batch( | |
| if (not is_first) and (not is_last): | ||
| return None, None, None, None, None, None, None, None, None, None | ||
|
|
||
| batch = get_batch_from_iterator( | ||
| data_iterator, | ||
| use_mtp, | ||
| getattr(cfg.dataset, "skip_getting_attention_mask_from_dataset", True), | ||
| is_first_pp_stage=is_first, | ||
| is_last_pp_stage=is_last, | ||
| ) | ||
| broadcast_data = getattr(cfg.dataset, "broadcast_data_across_tp", False) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since the dataloader config is shared, this setting is also exposed for vlm datasets. there needs to be handling here for
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added |
||
| if broadcast_data: | ||
| # TP-rank-0 loads data and broadcasts to other TP ranks. | ||
| # Reduces I/O by a factor of TP on high-latency storage. | ||
| batch = get_batch_on_this_tp_rank(data_iterator, cfg, use_mtp, pg_collection=pg_collection) | ||
| else: | ||
| batch = get_batch_from_iterator( | ||
| data_iterator, | ||
| use_mtp, | ||
| getattr(cfg.dataset, "skip_getting_attention_mask_from_dataset", True), | ||
| is_first_pp_stage=is_first, | ||
| is_last_pp_stage=is_last, | ||
| ) | ||
|
|
||
| cp_size = pg_collection.cp.size() | ||
| has_packed = batch.get("cu_seqlens") is not None | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check if rank contains MTP layer, required to support placing MTP layers into standalone stages (Not the last PP stage)
https://github.com/NVIDIA/Megatron-LM/blob/3d1a4ba71ecc49f1a0c9480c90f819d2b00f9915/pretrain_gpt.py#L209
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added