Skip to content

Commit

Permalink
Remove precision args in trainer due to PTL update (NVIDIA#8908)
Browse files Browse the repository at this point in the history
* Fix precision args in trainer due to PTL update

Signed-off-by: yaoyu-33 <yaoyu.094@gmail.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* roll back one change

Signed-off-by: yaoyu-33 <yaoyu.094@gmail.com>

---------

Signed-off-by: yaoyu-33 <yaoyu.094@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Abhishree Thittenamane <47577437+athitten@users.noreply.github.com>
Co-authored-by: Pablo Garay <palenq@gmail.com>
  • Loading branch information
4 people authored and alxzhang-amazon committed Apr 26, 2024
1 parent 19bdda9 commit 31e309e
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def convert(args):
nemo_config.precision = precision
print(f"nemo_config: {nemo_config}")

trainer = Trainer(plugins=plugins, accelerator='cpu', precision=precision, strategy=NLPDDPStrategy())
trainer = Trainer(plugins=plugins, accelerator='cpu', strategy=NLPDDPStrategy())

hidden_size = hf_config["hidden_size"]
head_num = hf_config["num_attention_heads"]
Expand Down
10 changes: 3 additions & 7 deletions examples/nlp/language_modeling/megatron_change_num_partitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,7 @@ def main():
# Set precision None after precision plugins are created as PTL >= 2.1 does not allow both
# precision plugins and precision to exist
precision = None
trainer = Trainer(plugins=plugins, devices=1, strategy=NLPDDPStrategy(), accelerator="cpu", precision=precision)
trainer = Trainer(plugins=plugins, devices=1, strategy=NLPDDPStrategy(), accelerator="cpu")

if tp_size < 0 or pp_size < 0:
logging.info(f"Loading model config from {args.model_file} to get TP and PP size")
Expand Down Expand Up @@ -1205,9 +1205,7 @@ def main():
if vp_size > 1:
set_virtual_parallel_rank_safely(None)

trainer = Trainer(
plugins=plugins, devices=1, strategy=NLPDDPStrategy(), accelerator="cpu", precision=precision
)
trainer = Trainer(plugins=plugins, devices=1, strategy=NLPDDPStrategy(), accelerator="cpu")

with open_dict(model.cfg):
if args.tokenizer_model_path is not None:
Expand Down Expand Up @@ -1413,9 +1411,7 @@ def main():
app_state.pipeline_model_parallel_size * app_state.tensor_model_parallel_size
)

trainer = Trainer(
plugins=plugins, devices=1, strategy=NLPDDPStrategy(), accelerator="cpu", precision=precision
)
trainer = Trainer(plugins=plugins, devices=1, strategy=NLPDDPStrategy(), accelerator="cpu")
if args.tokenizer_model_path is not None:
with open_dict(model.cfg):
model.cfg.tokenizer.model = args.tokenizer_model_path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def convert(args):
nemo_config.precision = precision
print(f"nemo_config: {nemo_config}")

trainer = Trainer(plugins=plugins, accelerator='cpu', precision=precision, strategy=NLPDDPStrategy())
trainer = Trainer(plugins=plugins, accelerator='cpu', strategy=NLPDDPStrategy())

hidden_size = hf_config["hidden_size"]
head_num = hf_config["num_attention_heads"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def convert(args):

nemo_config.precision = precision

trainer = Trainer(plugins=plugins, accelerator='cpu', precision=precision, strategy=NLPDDPStrategy())
trainer = Trainer(plugins=plugins, accelerator='cpu', strategy=NLPDDPStrategy())

hidden_size = hf_config["hidden_size"]
head_num = hf_config["num_attention_heads"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def convert(args):
nemo_config.precision = precision
logging.info(f"nemo_config: {nemo_config}")

trainer = Trainer(plugins=plugins, accelerator='cpu', precision=precision, strategy=NLPDDPStrategy())
trainer = Trainer(plugins=plugins, accelerator='cpu', strategy=NLPDDPStrategy())

hidden_size = nemo_config.hidden_size
head_num = nemo_config.num_attention_heads
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def convert(args):
nemo_config.precision = precision
print(f"nemo_config: {nemo_config}")

trainer = Trainer(plugins=plugins, accelerator='cpu', precision=precision, strategy=NLPDDPStrategy())
trainer = Trainer(plugins=plugins, accelerator='cpu', strategy=NLPDDPStrategy())

hidden_size = nemo_config.hidden_size
head_num = nemo_config.num_attention_heads
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def convert(args):
nemo_config.precision = precision
logging.info(f"nemo_config: {nemo_config}")

trainer = Trainer(plugins=plugins, accelerator='cpu', precision=precision, strategy=NLPDDPStrategy())
trainer = Trainer(plugins=plugins, accelerator='cpu', strategy=NLPDDPStrategy())

hidden_size = nemo_config.hidden_size
head_num = nemo_config.num_attention_heads
Expand Down

0 comments on commit 31e309e

Please sign in to comment.