Logging¶
MATE logging helps you trace API calls, inspect inputs and outputs, and capture replayable dumps for crash reproduction. At Level 10, MATE acts as a flight recorder: it saves inputs before execution, appends outputs after successful execution, and writes JSONL metadata for scanning and replay.
Quick Start¶
Enable basic logging:
export MATE_LOGLEVEL=3
export MATE_LOGDEST=stdout
Enable replayable dumps:
export MATE_LOGLEVEL=10
export MATE_DUMP_DIR=mate_dumps
Logging Levels¶
Level |
Name |
What it records |
Best for |
|---|---|---|---|
|
Disabled |
No logging. The decorator returns the original function unchanged. |
Production |
|
Function Names |
Function names only, logged before execution. |
Basic tracing |
|
Inputs and Outputs |
Function names, arguments, outputs, and structured tensor metadata. |
Standard debugging |
|
Statistics |
Level 3 plus tensor statistics such as min, max, mean, and NaN or Inf counts. |
Numerical debugging |
|
Flight Recorder |
Level 5 plus on-disk tensor dumps and replay metadata. |
Crash reproduction and replay |
Environment Variables¶
Main Configuration¶
Variable |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Logging level. Supported values are |
|
|
|
Log destination: |
Dump Configuration (Level 10)¶
When MATE_LOGLEVEL=10, the following variables control dump behavior:
Variable |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Root directory for dump files. |
|
|
|
Maximum total dump size per process, in gigabytes. |
|
|
|
Maximum number of API calls to dump per process. |
|
|
empty |
Comma-separated include patterns in |
|
|
empty |
Comma-separated exclude patterns in |
|
|
|
Set to |
Level 10 Dumping and Replay¶
Level 10 is MATE’s replayable dump mode. When it is enabled, MATE:
creates a per-call dump directory
saves input tensors before execution
writes a metadata record with
execution_status: "inputs_saved"executes the function
saves output tensors after successful execution
appends a second metadata record with
execution_status: "completed"
This design makes dumps crash-safe. If a process fails after inputs are saved but before outputs are written, the input dump and the first metadata record are still available for inspection or replay.
Typical workflow:
export MATE_LOGLEVEL=10
export MATE_DUMP_DIR=mate_dumps
python app.py
mate list-dumps mate_dumps/
mate replay --dir mate_dumps/
mate replay accepts either the dump root directory or a single dump
subdirectory.
Dump Filtering¶
Use MATE_DUMP_INCLUDE and MATE_DUMP_EXCLUDE to control which API calls
are written to disk.
Pattern syntax:
*matches any number of characters?matches a single charactermatching is case-sensitive
method names are recorded as
ClassName.method_namewhen applicable
Filter logic:
if
MATE_DUMP_INCLUDEis set, only matching APIs are dumpedif
MATE_DUMP_EXCLUDEis set, matching APIs are skippedinclude filtering runs first, then exclude filtering
Examples:
export MATE_DUMP_INCLUDE="*attention*,*gemm*"
export MATE_DUMP_EXCLUDE="*.__init__,*.plan"
SafeTensors Format¶
By default, MATE writes dump tensors with torch.save. This preserves stride
and non-contiguous layout information.
To use safetensors instead:
export MATE_DUMP_SAFETENSORS=1
Warning
safetensors does not preserve tensor strides or non-contiguous layout.
Tensors are saved as contiguous. Use the default torch.save format when
stride preservation matters for debugging.
Replay is format-aware. MATE automatically loads inputs.pt or
inputs.safetensors, and outputs.pt or outputs.safetensors, based on
which files exist in the dump directory.
Dump Directory Structure¶
When Level 10 logging is enabled, MATE writes a root session log and one subdirectory per dumped API call.
MATE_DUMP_DIR/
├── session.jsonl
├── 20260601_120000_123_pid12345_<function_name>_call0001/
│ ├── metadata.jsonl
│ ├── inputs.pt # or inputs.safetensors
│ └── outputs.pt # or outputs.safetensors
└── ...
How to read this structure:
session.jsonlis the session-wide event log. Each record is one JSON line.metadata.jsonlis the per-dump record file.the first record uses
execution_status: "inputs_saved"the second record uses
execution_status: "completed"if outputs are missing, the process may have failed after input capture
Process ID Substitution¶
Use %i in MATE_LOGDEST file paths for automatic process ID substitution.
This is useful for multi-process or multi-GPU jobs.
export MATE_LOGLEVEL=3
export MATE_LOGDEST="logs/mate_api_%i.log"
This produces per-process log files such as logs/mate_api_12345.log.
Advanced Notes¶
At Level 5, tensor statistics are skipped during MUSA graph capture to avoid synchronization issues.
At Level 0, the decorator returns the original function unchanged, so logging has zero overhead.
Replay can load a single dump directory or replay a sequence from the dump root.
See Also¶
For CLI commands such as
mate replayandmate list-dumps, see Command Line Interface.For the broader troubleshooting path, see Diagnostic Overview.