MATE CLI provides command-line utilities for installation checks, configuration inspection, environment diagnostics, and Level 10 dump replay.
All examples below use mate, but python -m mate is equivalent after MATE is installed correctly.
Install the base package:
pip install mate
mate --help
python -m mate --helpIf you plan to load or replay dumps written in safetensors format, install the CLI extra or install safetensors directly.
From a package index:
pip install "mate[cli]"If you only have a local wheel, use the standard direct-reference syntax instead of ./wheel.whl[cli]:
python -m pip install "mate[cli] @ file:///abs/path/mate-0.1.3+mu436torch2.7-cp310-cp310-linux_x86_64.whl"Notes:
- The
name[extra] @ file:///...form is the recommended pip syntax for extras with a local wheel - If your environment cannot access a package index, the extra dependency must also be available locally. For
mate[cli], that meanssafetensors - Installing only the MATE wheel without resolving
safetensorsis still valid, but replaying*.safetensorsdumps will fail untilsafetensorsis installed
| Command | Purpose |
|---|---|
mate show-config |
Show MATE, Python, PyTorch, MUSA, and AOT information |
mate env |
Show relevant environment variables and their current values |
mate check |
Validate a usable MATE runtime environment |
mate replay --dir PATH |
Replay one Level 10 dump or a directory of dumps |
mate list-dumps [PATH] |
List dump directories under a root directory |
Useful global options:
mate --helpmate --version
Show runtime and installation information:
mate show-config
mate show-config --jsonThe command reports:
- MATE version and git version
- Python version
- PyTorch version
torch_musaversion and whether MUSA is available- MUSA device count and device names
- AOT library directory and a short sample of detected
.sofiles - Installed package versions for
mate,torch, andtorch_musa
Use --json when the output will be consumed by scripts.
Print MATE-related environment variables:
mate envThis command is a read-only view of the current process environment. It is useful for checking whether shell exports are in place before launching a workload.
Validate whether the current environment is usable for MATE:
mate checkThe command checks:
- Python version (
>= 3.9) - PyTorch importability
torch_musaimportability- MUSA device availability
- MATE importability
- Presence of AOT libraries
Behavior:
- Hard errors cause exit code
1 - Warnings such as "MUSA not available" or "AOT libraries not found" do not fail the command
Replay API calls captured from Level 10 logging:
mate replay --dir mate_dumps/20260310_xxxx_call0001
mate replay --dir mate_dumps/
mate replay --dir dumps/ --device cpu
mate replay --dir dumps/ --no-run
mate replay --dir dumps/ --no-compare
mate replay --dir dumps/ --verboseSupported options:
| Option | Meaning |
|---|---|
--dir PATH |
Dump directory or dump-root directory to replay |
--device {musa,cpu,musa:N} |
Target device for loading tensors and running replay |
--run/--no-run |
Execute the resolved function or only reconstruct arguments |
--compare/--no-compare |
Compare execution results with dumped outputs |
-v, --verbose |
Print metadata and argument summaries for a single dump |
Replay mode depends on the path passed to --dir:
- If
PATH/metadata.jsonlexists, MATE treatsPATHas a single dump directory. - Otherwise, MATE scans the immediate subdirectories under
PATHand replays each one that containsmetadata.jsonl.
Single-dump replay:
- Honors
--run,--compare, and--verbose - Can be used for argument reconstruction only with
--no-run - Prints a detailed summary for one function call
Directory replay:
- Replays each immediate child dump in sorted order
- Preserves stateful objects across calls by tracking constructor-created objects internally
- Summarizes pass/fail status for the full sequence
- Currently always executes with output comparison for batch replay;
--no-run,--no-compare, and--verbosedo not change batch behavior
Comparison behavior:
- Output comparison only checks tensor outputs
- A single tensor result is compared as
result - Tuple or list results are compared item by item for tensor elements only
- Comparison uses
torch.allclose(..., rtol=1e-3, atol=1e-3) - If the dump has inputs but no saved outputs, comparison is treated as a mismatch
Practical notes:
--device cpuis useful for validating dump loading and argument reconstruction, but execution only succeeds if the target API supports CPU tensors- Replaying
safetensorsdumps requiressafetensorsto be installed - Dumps produced with
MATE_DUMP_SAFETENSORS=1lose original stride and non-contiguous layout information because tensors are saved as contiguous tensors
List Level 10 dump directories:
mate list-dumps
mate list-dumps mate_dumps/
mate list-dumps mate_dumps/ --detailsBehavior:
- Default root directory is
mate_dumps - Only immediate child directories are scanned
- A directory is considered a dump if it contains
metadata.jsonl - The command reads the last record in each
metadata.jsonlfile and displays its status
With --details, the output includes:
- Function name
- Execution status
- Timestamp
- Number of input tensors
- Number of output tensors
When MATE_LOGLEVEL=10, MATE writes one subdirectory per dumped API call under MATE_DUMP_DIR:
mate_dumps/
├── session.jsonl
├── 20260310_153045_123_pid43210_flash_attn_with_kvcache_call0001/
│ ├── metadata.jsonl
│ ├── inputs.pt
│ └── outputs.pt
└── 20260310_153045_456_pid43210_gemm_fp8_nt_groupwise_call0001/
├── metadata.jsonl
├── inputs.safetensors
└── outputs.safetensors
Notes:
- Directory names include timestamp, process id, function name, and call sequence
metadata.jsonlis append-only JSONL; the last line is the latest state of the dumpsession.jsonlaggregates the same metadata records at the dump-root level- If a process crashes after inputs are written but before outputs are saved, the dump directory may contain only
metadata.jsonlplus input files - Typical
execution_statusvalues areinputs_savedandcompleted
The logging and dumping configuration is read when mate.api_logging is imported. Set these variables before launching the Python process you want to observe.
| Variable | Default | Meaning |
|---|---|---|
MATE_LOGLEVEL |
0 |
Logging level: 0, 1, 3, 5, 10 |
MATE_LOGDEST |
stdout |
Log destination: stdout, stderr, or a file path |
MATE_DUMP_DIR |
mate_dumps |
Root directory for Level 10 dumps |
MATE_DUMP_MAX_SIZE_GB |
20 |
Maximum total dump size in GB per process |
MATE_DUMP_MAX_COUNT |
1000 |
Maximum number of dumped calls per process |
MATE_DUMP_SAFETENSORS |
0 |
Save dumps as safetensors instead of torch.save |
MATE_DUMP_INCLUDE |
empty | Comma-separated fnmatch patterns to include |
MATE_DUMP_EXCLUDE |
empty | Comma-separated fnmatch patterns to exclude |
TVM_FFI_MUSA_ARCH_LIST |
unset | MUSA architecture list used by JIT-related workflows |
MATE_AOT_BUILD |
unset | AOT build mode flag |
Log-level meaning:
0: disabled1: function names only3: function names plus structured inputs and outputs5: level 3 plus tensor statistics10: level 5 plus on-disk tensor dumping for replay
MATE_LOGDEST also supports %i in file paths, which is replaced with the current process id.
mate check
mate show-config
mate envexport MATE_LOGLEVEL=10
export MATE_DUMP_DIR=./debug_dumps
python your_script.py
mate list-dumps ./debug_dumps
mate replay --dir ./debug_dumps/20260310_xxxx_call0001 --verboseexport MATE_LOGLEVEL=10
export MATE_DUMP_DIR=./filtered_dumps
export MATE_DUMP_INCLUDE="*gemm*,*attention*"
export MATE_DUMP_EXCLUDE="*benchmark*"
python your_script.pymate replay --dir ./debug_dumps/This mode is useful when later calls depend on objects created by earlier calls.
export MATE_LOGLEVEL=5
export MATE_LOGDEST=/tmp/mate_%i.log
python your_script.pyCommand exit behavior is not identical across all subcommands:
mate show-config: returns0on successful executionmate env: returns0on successful executionmate check: returns1only when hard errors are foundmate replay: returns1on replay failure, execution failure, mismatch, or invalid replay setupmate list-dumps: informational command; missing directories or empty results are currently reported in output and do not force a non-zero exit code
Failed to load MATE API logging module: ensure the installed MATE package is complete and importable in the current Python environmentsafetensors not installed: installsafetensors, or reinstall from a package index withpip install "mate[cli]", or reinstall from a local wheel withpython -m pip install "mate[cli] @ file:///abs/path/your-mate.whl"No dumps found:mate list-dumpsand batch replay only scan immediate child directories, not nested trees recursivelycompare_outputs=True but no output file found: the dump is incomplete, often because the original process crashed after saving inputsAOT libraries not found: MATE may still work in JIT mode, but startup behavior can differ from an AOT-enabled installation- Replay mismatches do not always mean argument reconstruction failed; they can also reflect runtime differences, device differences, or numerical drift
Level 10 logging writes full API inputs and outputs to disk. Do not enable it for sensitive workloads unless the dump directory is adequately protected.