Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Configuration

Zyx is configured through a JSON file and environment variables. The file is read once per process, on the first backend access; changing it requires a restart. Missing sections and missing keys fall back to defaults, and a missing or unparsable file simply means “all defaults”.

Config File

The runtime reads $XDG_CONFIG_HOME/zyx/config.json when XDG_CONFIG_HOME is an absolute path, otherwise ~/.config/zyx/config.json. ZYX_DEBUG=1 prints whether the file was found and parsed.

A complete example (every section is optional):

{
    "autotune": {
        "n_launches": 1,
        "n_seeds": 200,
        "n_added_per_step": 200,
        "n_removed_per_step": 0,
        "n_total_opts": 1000
    },
    "c": { "enabled": true },
    "cuda": { "device_ids": [0], "cudnn": true, "queues": 8 },
    "opencl": { "platform_ids": [0], "queues": 8 },
    "vulkan": { "device_ids": [0] },
    "tenstorrent": { "device_ids": [0] }
}

wgpu ("wgpu": { "enabled": true }) exists only when the crate is built with the wgpu feature; the tenstorrent section only has an effect when the crate is built with the tenstorrent feature.

Backend Sections

SectionKeysDefaultDisable with
cenabledtrue"enabled": false
cudadevice_ids, cudnn, queuesall GPUs, cuDNN off, 8 queues"device_ids": []
openclplatform_ids, queuesall platforms, 8 queues"platform_ids": []
vulkandevice_idsall devices"device_ids": []
tenstorrentdevice_idsall devices (with the feature)"device_ids": []
wgpuenabledtrue"enabled": false

device_ids / platform_ids: null/absent means “every device the backend finds”; a list selects exactly those ordinals; an empty list disables the backend. Ordinals are the backend’s own (CUDA driver order, Vulkan device index, OpenCL platform index).

cuda.cudnn enables the cuDNN AOT matmul path (the struct default is false). cuda.queues and opencl.queues set the number of hardware command queues/streams per device used by the submission workers (default 8).

Autotune Section

KeyDefaultMeaning
n_launches1candidates actually launched and timed
n_seeds200initial optimization samples
n_added_per_step200new candidates per expansion
n_removed_per_step0candidates dropped per expansion
n_total_opts1000expansion iterations

See Optimization Passes for how the search uses them.

Environment Variables

ZYX_DEV — device pinning

ZYX_DEV overrides the config file and leaves exactly one device available; every other backend is configured out (and a device with an ordinal keeps only that ordinal). It accepts the same syntax as Dev::from_str:

ZYX_DEV=cpu          # C backend
ZYX_DEV=cuda:0        # CUDA driver ordinal 0
ZYX_DEV=tt            # Tenstorrent, device 0 (feature "tenstorrent")
ZYX_DEV=vulkan        # Vulkan device 0
ZYX_DEV=opencl:1      # OpenCL platform 1

Names are case-insensitive: auto, c/cpu, host, cuda, tt/tenstorrent, vulkan/vk, opencl/cl, wgpu. An index on an indexless device (c:1) is an error. A bad value panics — silently falling back would run on the wrong hardware — and ZYX_DEV=auto is a no-op (no narrowing).

ZYX_DEBUG — trace flags

A bitmask; add the values you want:

ValueOutput
1Devices + configuration
2Graph/e-graph dump
4Kernel IR before linearization (scheduler view)
8Winning kernel IR after the search
16Generated assembly/source
32Kernel launches
64Alloc/dealloc
128Kernel compilation
256Disable the autotune search (NoSearch)
ZYX_DEBUG=8 cargo run     # print the winning kernel IR
ZYX_DEBUG=24 cargo run    # IR (8) + generated code (16)
ZYX_DEBUG=256 cargo run   # NoSearch: compile a cleaned seed once

Other variables

VariableEffect
AGENT=1Colorless debug output (also auto-detected when stdout is not a terminal)
ZYX_DRY_RUN=1Skip device launches; timings are a fixed 1 s placeholder and output buffers are uninitialized — never read them
ZYX_PTXCUDA codegen emits PTX directly instead of CUDA C + NVRTC
ZYX_BENCH_OUTAppend one JSON line per measured autotune candidate to this path
ZYX_BENCH_TAGTag for the benchmark rows (untagged by default)
ZYX_TT_IRDump the Tenstorrent IR before/after tt_tile, tt_reindex, tt_dataflow_select
ZYX_TT_DUMPDump each Tenstorrent role program (bytes, entries, length)
TT_TTSIM_LIBPath to the Tenstorrent simulator library (default vendor/libttsim_bh.so)
TT_TTSIM_LIB_X2 / TT_TTSIM_LIB_X4Simulator library for dual-/quad-chip builds
TT_MATHTenstorrent SFPU math mode: precise (default) or approx
ZYX_KERN_TRACEKernelizer split/store tracing on stderr

API Configuration

Tensor::manual_seed(42);        // reseed the runtime RNG
Tensor::set_training(true);     // enable training mode (autograd graph is kept)
Tensor::set_training(false);    // inference
let t = Tensor::training();     // current mode

Device pinning can also be done per tensor with Tensor::to(Dev); see Backend System.