Environment Variables

June 23, 2026 ยท View on GitHub

MATE reads configuration from the current process environment. Set variables before launching the Python process or CLI command that should observe them.

Use mate env to print the MATE-related variables visible to the current shell.

API Logging and Dumps

The logging and dumping configuration is read when mate.api_logging is imported.

VariableDefaultMeaning
MATE_LOGLEVEL0API logging level: 0, 1, 3, 5, or 10
MATE_LOGDESTstdoutLog destination: stdout, stderr, or a file path
MATE_DUMP_DIRmate_dumpsRoot directory for Level 10 tensor dumps
MATE_DUMP_MAX_SIZE_GB20Maximum total dump size in GB per process
MATE_DUMP_MAX_COUNT1000Maximum number of dumped calls per process
MATE_DUMP_SAFETENSORS0Save dumps as safetensors instead of torch.save
MATE_DUMP_INCLUDEemptyComma-separated fnmatch patterns to include for dumping
MATE_DUMP_EXCLUDEemptyComma-separated fnmatch patterns to exclude from dumping

Log-Level Meanings

  • 0: Disabled.
  • 1: Function names only.
  • 3: Function names plus structured inputs and outputs, including tensor VA ranges.
  • 5: Level 3 plus tensor statistics.
  • 10: Level 5 plus on-disk tensor dumping for replay.
- `MATE_LOGDEST` supports `%i` in file paths. MATE replaces it with the current process ID.
- Dumps produced with `MATE_DUMP_SAFETENSORS=1` do not preserve original stride or non-contiguous layout information. Use the default `torch.save` format when replay must preserve strides.
- Level 10 logging writes full API inputs and outputs to disk. Do not enable it for sensitive workloads unless the dump directory is appropriately protected.

JIT, AOT, and Cache

VariableDefaultMeaning
MATE_MUSA_ARCH_LISTauto-detect visible devicesMUSA architecture list used by JIT/AOT workflows; accepts space-separated major.minor values such as 3.1 or 3.1 4.0.
MATE_WORKSPACE_BASEhome directoryBase directory for the MATE cache workspace.
MATE_DISABLE_JIT0Disable runtime JIT and require matching AOT modules.
MATE_JIT_VERBOSE0Show verbose ninja output for runtime JIT builds.

Runtime loading prefers a matching AOT library when one exists. MATE_DISABLE_JIT=1 switches to AOT-only behavior and raises an error if no matching AOT module exists. MATE does not provide an environment variable to bypass AOT and force runtime JIT when a matching AOT module is present.

Set MATE_MUSA_ARCH_LIST explicitly for offline diagnostics when no MUSA device is visible:

MATE_MUSA_ARCH_LIST=3.1 mate module-status

Runtime Wrapper Controls

VariableDefaultMeaning
MATE_DEEPGEMM_MK_ALIGNMENT128Override the M-axis padding alignment returned by DeepGEMM wrapper get_mk_alignment_for_contiguous_layout(); supported values are 128 and 256

Use MATE_DEEPGEMM_MK_ALIGNMENT when DeepGEMM-compatible contiguous grouped GEMM call sites need a non-default M-axis alignment. Callers should pad each expert segment and build m_indices using the same value returned by get_mk_alignment_for_contiguous_layout(). Set this variable before starting the Python process; the helper reads and caches the value on first use.

Compiler and Build Controls

VariableDefaultMeaning
MATE_EXTRA_CFLAGSemptyExtra host compiler flags for JIT builds.
MATE_EXTRA_MUSAFLAGSemptyExtra mcc flags for JIT builds.
MATE_EXTRA_LDFLAGSemptyExtra linker flags for JIT builds.
MATE_MCCauto-detectedOverride the mcc compiler path used by JIT builds.

MATE JIT builds also honor common build-tool variables such as CXX for the host C++ compiler and MAX_JOBS for ninja parallelism.

Guard Allocator Debugging

VariableDefaultMeaning
MATE_GUARD_ALLOCATOR_AUTO_INSTALLunsetInternal bootstrap flag used by mate guard-run
MATE_GUARD_ALLOCATOR_MODEunsetInternal guard allocator mode for bootstrap and replay
MATE_GUARD_ALLOCATOR_SYNC_ON_FREEunsetInternal flag controlling device sync before guarded frees
MATE_GUARD_ALLOCATOR_LOG_ALLOCATIONSunsetInternal flag controlling guarded alloc/free logging

The MATE_GUARD_ALLOCATOR_* variables are internal bootstrap details and are usually set by MATE itself when preparing guarded child processes. Use mate guard-run or the Python mate.memory_debug.install_guard_allocator() API for normal guard allocator debugging. The guard allocator is host-only C++ and does not need MATE_MUSA_ARCH_LIST; that variable only controls MATE JIT/AOT modules that compile MUSA kernels.

Diagnostic and Test-Only Variables

VariableDefaultMeaning
MATE_PYTEST_GUARD_ALLOC0Enable the guarded allocator by default for MATE repository pytest runs
MATE_PYTEST_GUARD_MODEtailDefault MATE repository pytest guard allocator mode: tail or head
MATE_PYTEST_GUARD_LOG_ALLOCATIONS0Log guarded alloc/free events during MATE repository pytest runs
MATE_DRY_RUN0Internal test/diagnostic mode used by MATE tests; not intended as a normal user runtime setting
MATE_PYTEST_SHARD_TOTAL1Number of shards to dispatch all the tests to
MATE_PYTEST_SHARD_INDEX0Index of current shard
MATE_PYTEST_SHARD_MODEfileShard dispatch mode. Currently, only file mode is supported

When MATE_PYTEST_SHARD_TOTAL > 1, test_fmha.py tests will dominate the last shard.

The MATE_PYTEST_GUARD_* variables are consumed by MATE's in-repository pytest conftest.py; they are not installed as a general pytest plugin for external projects. Prefer mate guard-run for user-facing guarded allocator debug sessions.