Skip to content
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

Add docs on env vars #11991

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions examples/llm/pretrain/default_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@

def local_executor_torchrun(devices: int = 2) -> run.LocalExecutor:
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",
"TRANSFORMERS_OFFLINE": "1", # Enable online downloads from HuggingFace
"TORCH_NCCL_AVOID_RECORD_STREAMS": "1", # Disable caching NCCL communication buffer memory
"NCCL_NVLS_ENABLE": "0", # Disable NVLink SHARP to save memory
}

executor = run.LocalExecutor(ntasks_per_node=devices, launcher="torchrun", env_vars=env_vars)
Expand Down Expand Up @@ -57,11 +55,9 @@ def slurm_executor(
mounts.extend(custom_mounts)

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",
"TRANSFORMERS_OFFLINE": "1", # Enable online downloads from HuggingFace
"TORCH_NCCL_AVOID_RECORD_STREAMS": "1", # Disable caching NCCL communication buffer memory
"NCCL_NVLS_ENABLE": "0", # Disable NVLink SHARP to save memory
}
if custom_env_vars:
env_vars |= custom_env_vars
Expand Down
14 changes: 6 additions & 8 deletions scripts/llm/performance/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,12 @@ def slurm_executor(
sys.exit(1)

env_vars = {
"TRANSFORMERS_OFFLINE": "1",
"TOKENIZERS_PARALLELISM": "False",
"NCCL_NVLS_ENABLE": "0",
"NVTE_DP_AMAX_REDUCE_INTERVAL": "0",
"NVTE_ASYNC_AMAX_REDUCTION": "1",
"NVTE_FUSED_ATTN": "1",
"NVTE_FLASH_ATTN": "1",
"NEMO_LOG_MEMORY_USAGE": "1",
"TRANSFORMERS_OFFLINE": "1", # Enable online downloads from HuggingFace
"TOKENIZERS_PARALLELISM": "False", # Restrict warning message prints
"NCCL_NVLS_ENABLE": "0", # Disable NVLink SHARP to save memory
"NVTE_FLASH_ATTN": "1", # Enable Flash Attention, which is needed to enable cuDNN fused attention
"NVTE_FUSED_ATTN": "1", # Enable cuDNN fused attention
"NEMO_LOG_MEMORY_USAGE": "1", # Print memory allocation
"NEMORUN_HOME": log_dir,
}
mounts = []
Expand Down
18 changes: 7 additions & 11 deletions scripts/llm/pretraining.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,9 @@ def slurm_executor(
mounts.extend(custom_mounts)

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",
"TRANSFORMERS_OFFLINE": "1", # Enable online downloads from HuggingFace
"TORCH_NCCL_AVOID_RECORD_STREAMS": "1", # Disable caching NCCL communication buffer memory
"NCCL_NVLS_ENABLE": "0", # Disable NVLink SHARP to save memory
}
if custom_env_vars:
env_vars |= custom_env_vars
Expand Down Expand Up @@ -118,12 +116,10 @@ def slurm_executor(

def local_executor_torchrun(nodes: int = 1, devices: int = 2) -> run.LocalExecutor:
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",
"NVTE_FUSED_ATTN": "0",
"TRANSFORMERS_OFFLINE": "1", # Enable online downloads from HuggingFace
"TORCH_NCCL_AVOID_RECORD_STREAMS": "1", # Disable caching NCCL communication buffer memory
"NCCL_NVLS_ENABLE": "0", # Disable NVLink SHARP to save memory
"NVTE_FUSED_ATTN": "0", # Disable cuDNN fused attention
}

executor = run.LocalExecutor(ntasks_per_node=devices, launcher="torchrun", env_vars=env_vars)
Expand Down
6 changes: 2 additions & 4 deletions tests/collections/llm/hf/peft_nemorun.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@
def local_executor_torchrun(nodes: int = 1, devices: int = 2) -> run.LocalExecutor:
# Env vars for jobs are configured here
env_vars = {
"TORCH_NCCL_AVOID_RECORD_STREAMS": "1",
"NCCL_NVLS_ENABLE": "0",
"NVTE_DP_AMAX_REDUCE_INTERVAL": "0",
"NVTE_ASYNC_AMAX_REDUCTION": "1",
"TORCH_NCCL_AVOID_RECORD_STREAMS": "1", # Disable caching NCCL communication buffer memory
"NCCL_NVLS_ENABLE": "0", # Disable NVLink SHARP to save memory
}

executor = run.LocalExecutor(ntasks_per_node=devices, launcher="torchrun", env_vars=env_vars)
Expand Down
8 changes: 3 additions & 5 deletions tests/collections/llm/hf/pretrain_nemorun.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@
def local_executor_torchrun(nodes: int = 1, devices: int = 2) -> run.LocalExecutor:
# Env vars for jobs are configured here
env_vars = {
"TORCH_NCCL_AVOID_RECORD_STREAMS": "1",
"NCCL_NVLS_ENABLE": "0",
"NVTE_DP_AMAX_REDUCE_INTERVAL": "0",
"NVTE_ASYNC_AMAX_REDUCTION": "1",
"NVTE_FUSED_ATTN": "0",
"TORCH_NCCL_AVOID_RECORD_STREAMS": "1", # Disable caching NCCL communication buffer memory
"NCCL_NVLS_ENABLE": "0", # Disable NVLink SHARP to save memory
"NVTE_FUSED_ATTN": "0", # Disable cuDNN fused attention
}

executor = run.LocalExecutor(ntasks_per_node=devices, launcher="torchrun", env_vars=env_vars)
Expand Down
6 changes: 2 additions & 4 deletions tests/collections/llm/hf/sft_nemorun.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@
def local_executor_torchrun(nodes: int = 1, devices: int = 2) -> run.LocalExecutor:
# Env vars for jobs are configured here
env_vars = {
"TORCH_NCCL_AVOID_RECORD_STREAMS": "1",
"NCCL_NVLS_ENABLE": "0",
"NVTE_DP_AMAX_REDUCE_INTERVAL": "0",
"NVTE_ASYNC_AMAX_REDUCTION": "1",
"TORCH_NCCL_AVOID_RECORD_STREAMS": "1", # Disable caching NCCL communication buffer memory
"NCCL_NVLS_ENABLE": "0", # Disable NVLink SHARP to save memory
}

executor = run.LocalExecutor(ntasks_per_node=devices, launcher="torchrun", env_vars=env_vars)
Expand Down
8 changes: 3 additions & 5 deletions tests/collections/llm/hf/sft_nemorun_fsdp2.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@
def local_executor_torchrun(nodes: int = 1, devices: int = 2) -> run.LocalExecutor:
# Env vars for jobs are configured here
env_vars = {
"TORCH_NCCL_AVOID_RECORD_STREAMS": "1",
"NCCL_NVLS_ENABLE": "0",
"NVTE_DP_AMAX_REDUCE_INTERVAL": "0",
"NVTE_ASYNC_AMAX_REDUCTION": "1",
"NVTE_FUSED_ATTN": "0",
"TORCH_NCCL_AVOID_RECORD_STREAMS": "1", # Disable caching NCCL communication buffer memory
"NCCL_NVLS_ENABLE": "0", # Disable NVLink SHARP to save memory
"NVTE_FUSED_ATTN": "0", # Disable cuDNN attention
}

executor = run.LocalExecutor(ntasks_per_node=devices, launcher="torchrun", env_vars=env_vars)
Expand Down
4 changes: 0 additions & 4 deletions tutorials/llm/llama-3/nemo2-sft-peft/nemo2-peft.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,6 @@
" env_vars = {\n",
" \"TORCH_NCCL_AVOID_RECORD_STREAMS\": \"1\",\n",
" \"NCCL_NVLS_ENABLE\": \"0\",\n",
" \"NVTE_DP_AMAX_REDUCE_INTERVAL\": \"0\",\n",
" \"NVTE_ASYNC_AMAX_REDUCTION\": \"1\",\n",
" }\n",
"\n",
" executor = run.LocalExecutor(ntasks_per_node=devices, launcher=\"torchrun\", env_vars=env_vars)\n",
Expand Down Expand Up @@ -454,8 +452,6 @@
" env_vars = {\n",
" \"TORCH_NCCL_AVOID_RECORD_STREAMS\": \"1\",\n",
" \"NCCL_NVLS_ENABLE\": \"0\",\n",
" \"NVTE_DP_AMAX_REDUCE_INTERVAL\": \"0\",\n",
" \"NVTE_ASYNC_AMAX_REDUCTION\": \"1\",\n",
" }\n",
"\n",
" executor = run.LocalExecutor(ntasks_per_node=devices, launcher=\"torchrun\", env_vars=env_vars)\n",
Expand Down
4 changes: 0 additions & 4 deletions tutorials/llm/llama-3/nemo2-sft-peft/nemo2-sft.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,6 @@
" env_vars = {\n",
" \"TORCH_NCCL_AVOID_RECORD_STREAMS\": \"1\",\n",
" \"NCCL_NVLS_ENABLE\": \"0\",\n",
" \"NVTE_DP_AMAX_REDUCE_INTERVAL\": \"0\",\n",
" \"NVTE_ASYNC_AMAX_REDUCTION\": \"1\",\n",
" }\n",
"\n",
" executor = run.LocalExecutor(ntasks_per_node=devices, launcher=\"torchrun\", env_vars=env_vars)\n",
Expand Down Expand Up @@ -562,8 +560,6 @@
" env_vars = {\n",
" \"TORCH_NCCL_AVOID_RECORD_STREAMS\": \"1\",\n",
" \"NCCL_NVLS_ENABLE\": \"0\",\n",
" \"NVTE_DP_AMAX_REDUCE_INTERVAL\": \"0\",\n",
" \"NVTE_ASYNC_AMAX_REDUCTION\": \"1\",\n",
" }\n",
"\n",
" executor = run.LocalExecutor(ntasks_per_node=devices, launcher=\"torchrun\", env_vars=env_vars)\n",
Expand Down
Loading