Environment variables reference#
This document catalogs the main environment variables you might encounter when running Primus on AMD GPUs: distributed launchers, Primus runners and CLI, YAML substitution, libraries (NCCL/RCCL, ROCm, PyTorch, JAX), and optional integrations (Hugging Face, WandB, MLflow). It is a practical reference, not a complete list of every variable accepted by upstream libraries.
Legend
Required: Must be set for the stated workflow; otherwise the job fails or mis-ranks.
Optional: Has a safe default or is only needed for specific features.
Set by: Typical source (launcher,
runner/helpers/envs/*.sh, user shell, container host).Used in: Representative Primus paths; many variables are also read by NVIDIA NCCL, AMD RCCL, PyTorch, or JAX without Primus wrapping them.
1. PyTorch distributed#
Set by torchrun, Slurm launchers, or runner/primus-cli-direct.sh / runner/primus-cli-slurm-entry.sh. Consumed by PyTorch distributed, RCCL, and Primus helpers.
Variable |
Default |
Where set |
Where used |
Description |
|---|---|---|---|---|
|
|
User, Slurm entry ( |
|
Rendezvous hostname or IP for process group initialization. Required for multi-node if not using Slurm auto-detection. |
|
|
Config / CLI / user |
Same as |
TCP port for the store backing |
|
|
|
|
Global rank index. |
|
|
|
Preflight, projection, |
Total number of processes. |
|
|
|
|
GPU index on this node. |
|
|
|
|
Processes (GPUs) per node. |
|
|
|
|
Zero-based node index in multi-node jobs. |
|
|
Direct config ( |
|
Number of nodes in the job. |
|
|
|
|
GPUs per node for world-size math and binding. |
2. Primus core#
Variable |
Default |
Where set |
Where used |
Description |
|---|---|---|---|---|
|
|
User |
|
|
|
|
User; debug paths in |
|
Log verbosity: |
|
|
User |
|
|
|
|
User; tests may set |
|
ANSI colors in runner logs. |
|
|
User |
|
|
|
|
User / tests |
|
|
|
(unset) |
User |
|
When |
|
|
User |
|
Cluster label for RCCL benchmark tooling. |
|
(auto / |
User / CLI |
|
GPU architecture string for performance projection. |
|
(unset) |
User |
Same as |
Optional clock override for projection. |
|
|
User |
|
GPU index for hardware detection in projection. |
|
(unset) |
User |
|
Selects GEMM simulation backend by name. |
|
|
User |
|
Minimum free GPU memory (GB) for preflight checks. |
|
|
User |
|
Minimum TFLOPS threshold for preflight GEMM checks. |
|
(unset) |
User / tests |
|
Enables Turbo auto-tuning in supported Turbo/Megatron test flows; not referenced in core |
|
|
User; hooks may set |
|
MoE dispatch/combine backend selector. |
3. Primus YAML substitution#
Parsed by primus/core/config/yaml_loader.py for patterns ${VAR} (required) and ${VAR:default} (optional). Typical experiment YAMLs under examples/ use these for sweep-friendly overrides.
Variable |
Typical default in YAML |
Where set |
Where used |
Description |
|---|---|---|---|---|
|
|
User |
Resolved before module merge in experiment YAML |
Work group / team segment in paths. |
|
|
User |
Experiment YAML |
User name segment. |
|
per-example |
User |
Experiment YAML |
Experiment folder name. |
|
|
User |
Experiment YAML |
Root workspace for artifacts. |
|
|
User |
Megatron example YAMLs |
|
|
|
User |
Megatron example YAMLs |
|
|
|
User |
Megatron example YAMLs |
|
|
per-model |
User |
Megatron example YAMLs |
Sequence length override. |
|
|
User |
|
Position embedding cap override. |
|
per-model |
User |
Megatron example YAMLs |
Global batch override. |
|
per-model |
User |
Tests and MoE examples |
Transformer layer count override. |
|
MoE patterns |
User |
MoE examples / tests |
MoE layer frequency pattern. |
|
|
User |
Megatron example YAML interpolation |
Existing tokenized training prefix consumed by configs that reference this variable. Unlike |
|
per-stack |
User |
Megatron examples |
Model preset stem (e.g. |
|
|
User |
|
Virtual pipeline stages override. |
4. NCCL / RCCL#
Primus seeds many of these in runner/helpers/envs/base_env.sh. RCCL honors NCCL-compatible variables on AMD GPUs. See NCCL environment and RCCL environment.
Variable |
Default (Primus base) |
Where set |
Where used |
Description |
|---|---|---|---|---|
|
unset |
User / |
Preflight reports, RCCL runtime |
Log verbosity: |
|
derived from |
|
|
Socket NIC for host networking. |
|
same as NCCL if unset |
|
Preflight |
Gloo TCP backend interface. |
|
auto via |
|
Preflight, multi-node tuning |
InfiniBand HCAs to use. |
|
|
|
RCCL |
GID index for IB/RoCE; many sites use |
|
(unset) |
User |
RCCL |
InfiniBand traffic class. |
|
(unset) |
User |
RCCL |
InfiniBand FIFO traffic class. |
|
(unset) |
User |
RCCL |
RoCE version selection. |
|
|
|
RCCL |
Disable PXN (PCIe cross-NIC); set |
|
|
|
RCCL |
P2P network chunk size tuning. |
|
(unset) |
User |
RCCL |
Protocol selection (e.g. |
|
|
|
RCCL |
Cross-NIC communication policy. |
|
(unset) |
User |
RCCL |
IB retry count. |
|
(unset) |
User |
RCCL |
IB timeout. |
|
(unset) |
User |
Preflight summaries |
GPUDirect RDMA level. |
|
|
User / env |
Preflight |
Disable IB; use sockets only. |
|
(unset) |
User |
RCCL |
DMA-BUF registration path. |
|
(unset) |
User |
RCCL |
Ignore CPU affinity hints. |
|
(unset) |
User |
RCCL |
IB QPs per connection. |
|
(unset) |
User |
RCCL |
Cap P2P channels. |
|
(unset) |
User |
RCCL |
Disable GDR flush. |
|
(unset) |
User |
RCCL |
Inline IB sends. |
|
(unset) |
User |
RCCL |
Alternate network plugin (e.g. |
|
|
|
RCCL |
Enable MSCCL algorithms. |
|
|
|
RCCL |
MSCCL++ message-size threshold. |
|
|
|
RCCL |
Stricter GDR flush memory ordering; relevant for some NIC/GPU combos. |
|
|
|
PyTorch + RCCL |
Tensor allocator hook for NCCL registration. |
|
|
|
PyTorch |
High-priority NCCL streams. |
5. ROCm / HSA / HIP#
Variable |
Default |
Where set |
Where used |
Description |
|---|---|---|---|---|
|
|
|
ROCm runtime |
Enable SDMA engines for copies. |
|
|
|
ROCm runtime; documented for MoE stability |
|
|
|
|
ROCm device visibility |
Restricts which GPU indices ROCm exposes. |
|
(unset) |
User |
|
Read for deterministic / accuracy-sensitive GEMM behavior. |
|
(unset) |
|
torch.compile caching |
Gets |
6. CUDA / PyTorch#
Variable |
Default |
Where set |
Where used |
Description |
|---|---|---|---|---|
|
|
|
|
Limits concurrent CUDA connections; often |
|
|
User |
|
Disable |
7. Transformer engine#
Variable |
Default |
Where set |
Where used |
Description |
|---|---|---|---|---|
|
|
|
Transformer Engine on ROCm |
Enable MXFP8 paths. |
|
|
|
TE / CK |
Use CK backward v3 kernels. |
|
(unset; examples print |
User / container passthrough ( |
TE / CK |
Atomic FP32 mode for CK v3 backward. |
|
|
|
|
Trigger TE flash-attn patch hook when |
8. Caches and authentication#
Variable |
Default |
Where set |
Where used |
Description |
|---|---|---|---|---|
|
|
|
Hugging Face libraries |
Cache for models and datasets. |
|
(unset) |
User, container passthrough |
Hugging Face Hub |
Auth for gated models. Required for private/gated assets. |
|
under workspace |
|
PyTorch Hub |
Torch Hub cache root. |
|
aligned with HF layout |
|
|
Model cache for Transformers. |
|
(unset) |
User, container passthrough |
Weights & Biases client, Megatron trainer checks |
API key for logging. Required for Weights & Biases when enabled. |
|
(unset) |
User / TorchTitan patch |
|
Project name. |
|
(unset) |
User / patches |
Same |
Run display name. |
|
(unset) |
User |
TorchTitan metrics (entity) |
WandB team/entity. |
|
(unset) |
User |
|
Required for Databricks-hosted MLflow when MLflow logging is enabled. |
|
(unset) |
User |
Databricks APIs |
Auth token paired with host. |
|
(unset) |
User |
|
MLflow tracking server URI. Optional unless using MLflow. |
|
(unset) |
User |
MLflow |
Model registry endpoint. |
|
(unset) |
User |
|
Punkt and other tokenizer data for preprocessing. |
|
per-hook default |
User |
|
Final Megatron indexed-data prefix ( |
|
per-hook default |
User |
|
Final training prefix when the hook must create a held-out validation split; overrides |
|
per-hook default |
User |
|
Final validation/test prefix generated for a held-out split. |
|
|
User |
|
Maximum time a nonzero node rank waits for rank 0 data preparation. Tokenized prefixes and their completion/failure markers must be on storage shared by all nodes. |
|
|
User |
Backend requirement hooks |
|
9. hipBLASLt tuning#
Variable |
Default |
Where set |
Where used |
Description |
|---|---|---|---|---|
|
|
User |
|
Master switch for the HipBLASLt tuning flow ( |
|
|
User |
|
Stages |
|
(unset) |
User / tuning scripts |
|
Path to tuned-kernel override file for stage |
|
varies |
User |
|
Number of benchmark runs per shape during TE hipBLASLt tuning. |
|
varies |
User |
|
Transformer Engine hipBLASLt search breadth. |
|
(unset; TE uses the first result) |
User |
Transformer Engine |
Index into hipBLASLt’s ranked solution list. TE launches the first entry by default; set |
|
(unset) |
User |
TE + HipBLASLt |
Algorithm file for TE tuning flows. |
|
(unset) |
User |
|
When set, interacts with deterministic mode and tuning stages (disable conflicting modes per hook comments). |
|
(unset) |
User |
HipBLASLt |
Library log level. |
|
(unset) |
User |
HipBLASLt |
Bitmask for log categories. |
10. Build and rebuild#
Variable |
Default |
Where set |
Where used |
Description |
|---|---|---|---|---|
|
|
User, container passthrough |
|
|
|
|
User, container passthrough |
|
Semicolon-separated GPU targets compiled into a Primus-Turbo rebuild. |
|
|
User, container passthrough |
|
|
|
(unset) |
User |
|
|
|
(unset) |
User / tooling |
|
Parallel compile jobs for pip builds. |
|
(unset) |
User |
|
Override checkout path for third-party backends (Megatron, TorchTitan, MaxText). |
11. Container passthrough#
runner/.primus.yaml lists names forwarded from the host into training containers (container.options.env). Primus does not assign values here; it only allowlists keys for --env forwarding.
Forwarded keys:
MASTER_ADDR, MASTER_PORT, NNODES, NODE_RANK, GPUS_PER_NODE, DOCKER_IMAGE, HF_TOKEN, WANDB_API_KEY, DATABRICKS_TOKEN, DATABRICKS_HOST, MLFLOW_TRACKING_URI, MLFLOW_REGISTRY_URI, MLFLOW_ENABLE_SYSTEM_METRICS_LOGGING, ENABLE_NUMA_BINDING, REBUILD_PRIMUS_TURBO, GPU_ARCHS, USING_UEP, REBUILD_UEP, USING_AINIC, PATCH_TE_FLASH_ATTN, REBUILD_BNXT, HSA_NO_SCRATCH_RECLAIM, NVTE_CK_USES_BWD_V3, GPU_MAX_HW_QUEUES, HSA_KERNARG_POOL_SIZE, PRIMUS_TURBO_DEEPEP_TIMEOUT, NCCL_IB_HCA, NCCL_SOCKET_IFNAME, GLOO_SOCKET_IFNAME, NCCL_IB_GID_INDEX, PRIMUS_TURBO_ATTN_V3_ATOMIC_FP32, NVTE_CK_IS_V3_ATOMIC_FP32, PATH_TO_BNXT_TAR_PACKAGE, ANP_HOME_DIR, RCCL_HOME_DIR, MPI_HOME_DIR, DUMP_HLO, DUMP_HLO_DIR, PRIMUS_DETERMINISTIC, PRIMUS_HIPBLASLT_TUNING, PRIMUS_HIPBLASLT_TUNING_STAGE, TE_HIPBLASLT_TUNING_RUN_COUNT, TE_HIPBLASLT_TUNING_ALGO_COUNT, HIPBLASLT_LOG_MASK, HIPBLASLT_LOG_FILE, HIPBLASLT_LOG_LEVEL, HIPBLASLT_TUNING_OVERRIDE_FILE
12. Slurm#
Variable |
Default |
Where set |
Where used |
Description |
|---|---|---|---|---|
|
job-dependent |
Slurm |
|
Node count for the allocation. |
|
job-dependent |
Slurm |
Mapped to |
Node index. |
|
job-dependent |
Slurm |
Fallback for |
Process ID within the Slurm step (entry script). |
|
job-dependent |
Slurm |
|
Job identifier string. |
13. Debug and pipeline#
Variable |
Default |
Where set |
Where used |
Description |
|---|---|---|---|---|
|
|
User |
|
Directory for pipeline-parallel debug dumps. |
|
|
User |
|
|
|
|
User |
|
Record offload memory stats when |
|
|
User |
|
Output directory for offload memory logs. |
|
|
User |
|
Use pinned host memory for offload buffers when |
14. JAX / XLA (MaxText)#
Primus owns these defaults in one place per backend: primus/backends/<backend>/env_spec.py. They are applied by the backend adapter before import jax. For how to override them from a config, see Environment and XLA flags.
Variable |
Default |
Where set |
Where used |
Description |
|---|---|---|---|---|
|
managed string (see below) |
|
JAX / XLA compiler |
Space-separated XLA compiler flags. Primus appends its managed flags to whatever was inherited, so its values win (XLA honors the last occurrence). Setting this in a config |
|
(unset) |
User (config |
|
Appended onto |
|
|
User |
|
Parameterizes |
|
|
|
JAX / XLA allocator |
Fraction of GPU memory pre-allocated for JAX. Raised from the JAX default to avoid HSA OOM during multi-node runs. |
|
|
|
JAX / TF logging |
Suppresses benign JAX/MaxText shutdown errors. |
|
|
User |
|
|
|
|
User |
|
Destination directory when |
|
|
|
|
Coordinator host. Left unset on single-node runs so MaxText uses the local single-controller path. |
|
|
|
|
Coordinator port. |
Managed XLA_FLAGS for MaxText (see _build_xla_flags for the authoritative string): --xla_gpu_memory_limit_slop_factor=95, --xla_gpu_reduce_scatter_combine_threshold_bytes=8589934592, --xla_gpu_all_gather_combine_threshold_bytes=8589934592, --xla_gpu_enable_command_buffer='', --xla_gpu_enable_latency_hiding_scheduler=true, --xla_gpu_enable_triton_gemm=false, --xla_gpu_enable_cublaslt=true, --xla_gpu_autotune_level=4, --xla_gpu_enable_all_gather_combine_by_dim=false.
Note: The MaxDiffusion backend declares no XLA defaults; its example configs set XLA_FLAGS themselves and are used verbatim. MaxText and JAX also read many additional knobs upstream that Primus does not wrap; see the MaxText sources for those.