Tensor parallel distributed strategy without using deepspeed#280
Merged
2 commits merged intoJul 15, 2024
Merged
Conversation
msinnha1
reviewed
Jul 12, 2024
msinnha1
left a comment
There was a problem hiding this comment.
This is a big patch and reviewing it further
| global has_fused_rope | ||
| has_fused_rope = False | ||
|
|
||
|
|
Author
There was a problem hiding this comment.
minor: please remove this
Done
| [GaudiLlamaDecoderLayer(config, layer_idx) for layer_idx in range(config.num_hidden_layers)] | ||
| ) | ||
| layers = [] | ||
| for i in range(config.num_hidden_layers): |
Author
There was a problem hiding this comment.
minor: layer_idx in place of 'i'
Done
| import torch.distributed | ||
| from torch import nn | ||
|
|
||
| #from optimum.habana.distributed import tp_wrapping |
There was a problem hiding this comment.
minor: please remove the commented code
Author
There was a problem hiding this comment.
minor: please remove the commented code
Done
| pass | ||
|
|
||
|
|
||
| class NotDistributed(DistributedStrategy): |
There was a problem hiding this comment.
why derived class is NotDistributed for the base class as DistributedStrategy? It is creating some confusion in readability, may require some other name?
| def distribute_layer(self, block: nn.Module, layer: int) -> nn.Module: | ||
| device = self.layer_to_device[layer] | ||
| if self.from_meta: | ||
| # https://github.com/pytorch/pytorch/pull/113647 |
There was a problem hiding this comment.
this PR is closed, and we can possibly remove the reference to such comments from foundation repo, #Comment
| ) | ||
| if par_mod.bias is not None: | ||
| par_mod.bias.copy_(torch.split(mod.bias, output_size_per_partition)[rank]) | ||
| # print(f"For rank {rank}, we have the following weights: Base weight {mod.weight} bias {mod.bias}; Par weight {par_mod.weight}, bias {par_mod.bias}") |
| par_mod.bias.copy_(mod.bias) | ||
| else: | ||
| par_mod.bias.zero_() | ||
| # print(f"For rank {rank}, we have the following weights: Base weight {mod.weight}, bias {mod.bias}; Par weight {par_mod.weight}, bias {par_mod.bias}") |
| par_mod.weight.copy_( | ||
| torch.split(mod.weight, output_size_per_partition, dim=1)[rank] | ||
| ) | ||
| # print(f"For rank {rank}, we have the following weights: Base weight {mod.weight} bias {mod.bias}; Par weight {par_mod.weight}, bias {par_mod.bias}") |
| # The transposes here are to avoid excessive recompilation due to split() | ||
| # specializing the dimension where the all_gather is happening | ||
| last_dim = input_.dim() - 1 | ||
| # Starting PT 2.3, we can go back to funcol.all_gather_tensor |
576860d to
1e82fac
Compare
msinnha1
approved these changes
Jul 15, 2024
ghost
approved these changes
Jul 15, 2024
ghost
approved these changes
Jul 15, 2024
kalyanjk
added a commit
to kalyanjk/optimum-habana-fork
that referenced
this pull request
Jul 15, 2024
…I#280) * TP reference - ibm foundation-model-stack * Code cleanup -removed unused code --------- Co-authored-by: Kalyan <kkumar@habana.ai>
ghost
pushed a commit
that referenced
this pull request
Jul 15, 2024
kalyanjk
pushed a commit
to kalyanjk/optimum-habana-fork
that referenced
this pull request
Jul 31, 2024
…abanaAI#280) (HabanaAI#299)" This reverts commit 32c86d3.
kalyanjk
pushed a commit
to kalyanjk/optimum-habana-fork
that referenced
this pull request
Jul 31, 2024
…abanaAI#280)" This reverts commit c6e5f9c.
ghost
pushed a commit
that referenced
this pull request
Jul 31, 2024
* Revert "Tensor parallel distributed strategy without using deepspeed (#280) (#299)" This reverts commit 32c86d3. * Tensor parallel distributed strategy without using deepspeed (huggingface#1121) Co-authored-by: Kalyan <kkumar@habana.ai> --------- Co-authored-by: Kalyan <kkumar@habana.ai>
ghost
pushed a commit
that referenced
this pull request
Jul 31, 2024
* Revert "Tensor parallel distributed strategy without using deepspeed (#280)" This reverts commit c6e5f9c. * Tensor parallel distributed strategy without using deepspeed (huggingface#1121) Co-authored-by: Kalyan <kkumar@habana.ai> --------- Co-authored-by: Kalyan <kkumar@habana.ai>
astachowiczhabana
pushed a commit
that referenced
this pull request
Aug 6, 2024
* Revert "Tensor parallel distributed strategy without using deepspeed (#280)" This reverts commit c6e5f9c. * Tensor parallel distributed strategy without using deepspeed (huggingface#1121) Co-authored-by: Kalyan <kkumar@habana.ai> --------- Change-Id: Ic30c85e697dbd6a51767e21e1c06c9a20120d9f6 Co-authored-by: Kalyan <kkumar@habana.ai>
astachowiczhabana
pushed a commit
that referenced
this pull request
Aug 6, 2024
* Revert "Tensor parallel distributed strategy without using deepspeed (#280)" This reverts commit c6e5f9c. * Tensor parallel distributed strategy without using deepspeed (huggingface#1121) Co-authored-by: Kalyan <kkumar@habana.ai> --------- Change-Id: Ic30c85e697dbd6a51767e21e1c06c9a20120d9f6 Co-authored-by: Kalyan <kkumar@habana.ai>
xinyu-intel
pushed a commit
that referenced
this pull request
Mar 4, 2025
* TP reference - ibm foundation-model-stack * Code cleanup -removed unused code --------- Change-Id: I236c615a2523057ecf556800ba6d82062c9c9a82 Co-authored-by: Kalyan <kkumar@habana.ai>
xinyu-intel
pushed a commit
that referenced
this pull request
Mar 4, 2025
* Revert "Tensor parallel distributed strategy without using deepspeed (#280)" This reverts commit c6e5f9c. * Tensor parallel distributed strategy without using deepspeed (huggingface#1121) Co-authored-by: Kalyan <kkumar@habana.ai> --------- Change-Id: Ic30c85e697dbd6a51767e21e1c06c9a20120d9f6 Co-authored-by: Kalyan <kkumar@habana.ai>
astachowiczhabana
pushed a commit
that referenced
this pull request
May 13, 2025
astachowiczhabana
pushed a commit
that referenced
this pull request
May 22, 2025
This pull request was closed.
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.
Tensor parallel by extending GaudiLlamaAttention -> TPGaudiLlamaAttention and GaudiLlamaMLP -> TPGaudiLlamaMLP
use parameter --distributed_strategy="tp" to invoke this code path