Open-Source Wikis

/

PyTorch

/

Reference

/

Configuration

pytorch/pytorch

Configuration

Environment variables and runtime configuration objects you'll encounter.

Build-time

Variable Effect
USE_CUDA=0 Skip CUDA build
USE_ROCM=1 ROCm build
USE_MPS=0 Skip MPS
USE_DISTRIBUTED=0 Skip distributed
USE_NCCL=0 Skip NCCL
USE_GLOO=0 Skip Gloo
USE_FBGEMM=0 Skip FBGEMM
USE_KINETO=0 Skip Kineto profiler
USE_NNPACK=0 Skip NNPACK
USE_XNNPACK=0 Skip XNNPACK
USE_MKLDNN=0 Skip oneDNN/MKLDNN
USE_OPENMP=0 Skip OpenMP
BUILD_TEST=0 Skip C++ test binaries
MAX_JOBS=N Limit parallel build jobs
CMAKE_BUILD_PARALLEL_LEVEL CMake parallelism
DEBUG=1 -O0 -g
REL_WITH_DEB_INFO=1 -O2 -g
TORCH_CUDA_ARCH_LIST e.g., 7.0;8.0;9.0
CUDA_HOME, CUDNN_HOME, MKL_ROOT Toolkit paths
BUILD_CAFFE2=0 Skip residual Caffe2 (default off)
BUILD_BINARY=0 Skip binary build

CUDA runtime

Variable Effect
CUDA_LAUNCH_BLOCKING=1 Serialize CUDA launches
CUBLAS_WORKSPACE_CONFIG=:16:8 or :4096:8 Make cuBLAS deterministic
PYTORCH_CUDA_ALLOC_CONF Caching allocator knobs
PYTORCH_NO_CUDA_MEMORY_CACHING=1 Disable allocator caching (debug)
CUDA_VISIBLE_DEVICES Restrict visible GPUs
TORCH_USE_CUDA_DSA Enable device-side asserts
TORCH_CUDNN_V8_API_ENABLED=1 Use cuDNN v8 frontend

PYTORCH_CUDA_ALLOC_CONF accepts comma-separated key:value pairs:

Key Default Notes
max_split_size_mb unlimited Don't split blocks larger than this
garbage_collection_threshold 0 Aggressively collect to keep below threshold
expandable_segments False Use cuMemMap segments
roundup_power2_divisions 0 More size classes per power-of-2 bucket
pinned_use_cuda_host_register False Pin host memory via cudaHostRegister
pinned_num_register_threads 1 Worker threads for the above

Compile stack

Variable Effect
TORCH_LOGS Comma-separated logger names; +/- prefix for level adjust
TORCHDYNAMO_VERBOSE=1 Verbose dynamo
TORCH_COMPILE_DEBUG=1 Dump every IR / kernel artefact to torch_compile_debug/
TORCHINDUCTOR_CACHE_DIR Where Inductor caches generated kernels
TORCHINDUCTOR_FX_GRAPH_CACHE=1 Enable FX graph cache (default 1)
TORCHINDUCTOR_AUTOTUNE_LOCAL_CACHE=1 Enable autotune local cache
TORCHINDUCTOR_MAX_AUTOTUNE=1 Try every choice, pick fastest (slow but maximum perf)
TORCHINDUCTOR_TRITON_DEBUG_SYNC_KERNEL Synchronize after every kernel for debugging
TORCH_INDUCTOR_LOG_KERNELS=1 Log every kernel emitted
TORCH_TRACE Path for structured tracing dump

The Python configs are objects: torch._dynamo.config, torch._inductor.config, torch.compiler.config. Use torch._dynamo.config.patch(...) as a contextmanager / decorator to change values temporarily — per CLAUDE.md, do not manually save/restore.

Distributed

Variable Effect
MASTER_ADDR, MASTER_PORT Default rendezvous endpoint
WORLD_SIZE, RANK, LOCAL_RANK Set by torchrun / elastic launcher
NCCL_DEBUG=INFO NCCL chatter
NCCL_SOCKET_IFNAME=eth0 Restrict NCCL to specific NIC
NCCL_IB_HCA=mlx5_0 InfiniBand device
TORCH_NCCL_TRACE_BUFFER_SIZE Flight-recorder buffer entries
TORCH_NCCL_DUMP_ON_TIMEOUT=1 Dump flight recorder on watchdog timeout
TORCH_NCCL_DESYNC_DEBUG=1 Detect mismatched collectives
TORCH_DISTRIBUTED_DEBUG=DETAIL Per-rank diagnostic logging
TORCH_NCCL_BLOCKING_WAIT=1 Synchronize after every collective
TORCH_NCCL_HEARTBEAT_TIMEOUT_SEC=600 Heartbeat watchdog period

Autograd / numerics

Variable Effect
TORCH_USE_DETERMINISTIC_ALGORITHMS=1 Equivalent of torch.use_deterministic_algorithms(True)
TORCH_WARN_ALWAYS=1 Don't deduplicate warnings
TORCH_LOGS=structured Structured trace logging
TORCH_DISABLE_AUTOGRAD_FALLBACK=1 Don't auto-fallback for missing autograd kernels (dev only)

Profiling

Variable Effect
KINETO_LOG_LEVEL=INFO Kineto profiler logging
KINETO_DAEMON_INIT_DELAY_S Delay before daemon connects

Where to look

File Purpose
torch/_dynamo/config.py Dynamo configs
torch/_inductor/config.py Inductor configs
torch/_logging/ TORCH_LOGS parser
c10/cuda/CUDAAllocatorConfig.cpp PYTORCH_CUDA_ALLOC_CONF
torch/distributed/elastic/ Distributed launcher env vars

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

Configuration – PyTorch wiki | Factory