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 examples |
Path to tokenized training data. |
|
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. |
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 / |
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 |
|
Pre-tokenized dataset location for Megatron data prep 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) |
User |
TE + HipBLASLt |
Algorithm file for TE tuning flows. |
|
(unset) |
User |
|
When set, interacts with deterministic mode and tuning stages (disable conflicting modes per script 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 |
|
|
|
(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, ENABLE_NUMA_BINDING, REBUILD_PRIMUS_TURBO, 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 MaxText hooks print recommended values in runner/helpers/hooks/train/pretrain/maxtext/prepare.py; MaxText and JAX read them directly.
Variable |
Default |
Where set |
Where used |
Description |
|---|---|---|---|---|
|
e.g. |
User / hook output |
JAX / XLA allocator |
Fraction of GPU memory pre-allocated for JAX. |
|
|
User |
XLA via |
Directory for HLO dumps when enabled. |
|
|
User |
Prepare hook → XLA flags |
Gate HLO dumping ( |
Note: MaxText also propagates many knobs through XLA_FLAGS and LIBTPU_INIT_ARGS upstream; see MaxText sources for the full list.