-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add torchrun local executor to recipes (#11342)
* Add torchrun local executor to recipes Signed-off-by: Marc Romeijn <[email protected]> * Remove code from init Signed-off-by: Marc Romeijn <[email protected]> * Fix copyright Signed-off-by: Marc Romeijn <[email protected]> * Apply isort and black reformatting Signed-off-by: marcromeyn <[email protected]> * Fix failing test Signed-off-by: Marc Romeyn <[email protected]> --------- Signed-off-by: Marc Romeijn <[email protected]> Signed-off-by: marcromeyn <[email protected]> Signed-off-by: Marc Romeyn <[email protected]> Co-authored-by: marcromeyn <[email protected]>
- Loading branch information
1 parent
ed05600
commit 34f7408
Showing
3 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
import nemo_run as run | ||
|
||
|
||
@run.cli.factory | ||
def torchrun(devices: int = 8) -> run.Config[run.LocalExecutor]: | ||
"""Local executor using torchrun.""" | ||
env_vars = { | ||
"TRANSFORMERS_OFFLINE": "1", | ||
"TORCH_NCCL_AVOID_RECORD_STREAMS": "1", | ||
"NCCL_NVLS_ENABLE": "0", | ||
"NVTE_DP_AMAX_REDUCE_INTERVAL": "0", | ||
"NVTE_ASYNC_AMAX_REDUCTION": "1", | ||
} | ||
|
||
executor = run.Config( | ||
run.LocalExecutor, | ||
ntasks_per_node=devices, | ||
launcher="torchrun", | ||
env_vars=env_vars, | ||
) | ||
|
||
return executor |