Environment Variables

This document describes the environment variables involved in FSDPTurbo training, including variables related to cluster configuration, the runtime environment, and NPU performance tuning.

Cluster Configuration Environment Variables

The training launch script run.sh supports overriding the cluster configuration through environment variables:

Environment VariableDefault ValueDescription
NNODES1Number of nodes; 1 for a single machine
GPUS_PER_NODE16Number of devices per node
MASTER_ADDR127.0.0.1IP address of the master node; in multi-node setups, all nodes are configured with the master node IP
MASTER_PORT29500Port of the master node
CONFIG_FILEconfig.yamlPath to the training configuration file

Multi-node training example:

# Run on all nodes (MASTER_ADDR is the master node IP)
NNODES=2 GPUS_PER_NODE=16 MASTER_ADDR=10.0.0.1 MASTER_PORT=29500 bash run.sh

Runtime Environment Variables

Environment VariableDescription
HCCL_NPU_SOCKET_PORT_RANGEPort range of the NPU communication socket (set to auto in the example script)
ASCEND_LAUNCH_BLOCKINGSwitch for synchronous NPU execution (set to 1 in the example script for easier debugging)
ASCEND_SLOG_PRINT_TO_STDOUTOutput NPU logs to standard output (for debugging; disabled by default)

In an NPU environment, the Ascend environment must be loaded correctly before training:

source /usr/local/Ascend/cann/set_env.sh

NPU Performance Tuning Environment Variables

The following environment variables are used for Ascend NPU training performance tuning and can be set in the launch script as appropriate:

Environment VariableRecommended ValueDescription
HCCL_CONNECT_TIMEOUT1800HCCL communication connection timeout in seconds; increase it for large multi-node clusters
TASK_QUEUE_ENABLE2Task queue mode, improving the overlap efficiency of communication and computation
CPU_AFFINITY_CONF1CPU affinity configuration, reducing process scheduling overhead
MULTI_STREAM_MEMORY_REUSE2Multi-stream memory reuse, reducing memory usage
PYTORCH_NPU_ALLOC_CONFexpandable_segments:TrueNPU memory allocator configuration, reducing memory fragmentation
CUBLAS_WORKSPACE_CONFIG:4096:8Workspace configuration for matrix operations

Environment variable configuration in the example run.sh:

export HCCL_NPU_SOCKET_PORT_RANGE="auto"
export ASCEND_LAUNCH_BLOCKING=1
# export ASCEND_SLOG_PRINT_TO_STDOUT=1   # Enable during debugging

The NPU performance tuning variables above are recommended configurations; the actual effects vary with the model scale, hardware model, and parallelism strategy. It is recommended to tune them in conjunction with performance data profiling.