"git@developer.sourcefind.cn:OpenDAS/dgl.git" did not exist on "7f83d7456a5252d313df3e3d4fba263b279789f9"
Unverified Commit d3be9710 authored by Stefan He's avatar Stefan He Committed by GitHub
Browse files

correct the tp_plan logic (#8850)

parent 3e7ff1ab
...@@ -211,16 +211,13 @@ class TransformersForCausalLM(nn.Module): ...@@ -211,16 +211,13 @@ class TransformersForCausalLM(nn.Module):
Apply the model's tensor parallelization plan. Apply the model's tensor parallelization plan.
Currently only supports linear layers. Currently only supports linear layers.
""" """
if not self.model.supports_tp_plan: tp_plan = getattr(self.model.config, "base_model_tp_plan", None) or {}
if tp_size <= 1:
return
if not tp_plan and self.tp_size > 1:
raise ValueError( raise ValueError(
f"{type(self.model)} does not support tensor parallel yet!" f"{type(self.model)} does not support tensor parallel yet!"
) )
tp_plan = getattr(self.model.config, "base_model_tp_plan", None) or {}
def _tensor_parallel(module: nn.Module, prefix: str = ""): def _tensor_parallel(module: nn.Module, prefix: str = ""):
for child_name, child_module in module.named_children(): for child_name, child_module in module.named_children():
qual_name = maybe_prefix(prefix, child_name) qual_name = maybe_prefix(prefix, child_name)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment