Hardware Backends¶
Jacobi compiles graphs through XLA and PJRT. On first run it checks your hardware, downloads the matching pinned PJRT plugin into ~/.jacobi/ after verifying its SHA-256 checksum, and caches compiled executables in memory (bounded LRU, default 256 entries) and on disk (~/.jacobi/cache/, bounded at 512 MiB by default).
Selecting a Backend¶
By default, Jacobi picks the best available accelerator (CUDA, Metal, ROCm, or TPU) and falls back to CPU if none is available.
You can override the backend in Rust before running your workload.
use jacobi::prelude::*;
fn main() -> Result<()> {
use_backend(Backend::Cpu)?;
println!("active backend {}", backend_name()?);
Ok(())
}
Available variants are Backend::Auto, Backend::Cpu, Backend::Cuda, Backend::Metal, Backend::Tpu, Backend::Rocm, Backend::OneApi, and Backend::PluginPath(path).
Custom Engine Configuration¶
Use EngineConfig when you want custom cache locations, cache caps, offline execution, or an explicit plugin path.
use jacobi::runtime::{Backend, Engine, EngineConfig, set_engine};
let engine = Engine::with_config(
EngineConfig::default()
.backend(Backend::Cpu)
.cache_dir("/tmp/jacobi-cache")
.max_cached_executables(256)
.max_disk_cache_bytes(512 * 1024 * 1024)
.auto_download(false),
)?;
set_engine(engine);
Environment Variables¶
| Variable | Effect |
|---|---|
JACOBI_BACKEND |
Force cpu, cuda, metal, tpu, rocm, or oneapi |
PJRT_PLUGIN_PATH |
Load a specific PJRT .so or .dylib file directly |
JACOBI_OFFLINE=1 |
Disable automatic PJRT plugin downloads |
JACOBI_SKIP_PLUGIN_CHECKSUM=1 |
Skip SHA-256 verification on downloaded PJRT archives |
JACOBI_EXEC_CACHE_MAX |
Maximum in-memory compiled executables per Engine (default 256) |
JACOBI_DISK_CACHE_MAX_MB |
Maximum on-disk cache size in MiB (default 512, 0 disables disk cache) |
JACOBI_LAZY_MAX_NODES |
Maximum pending lazy-eager IR nodes before auto-flush (default 128) |
JACOBI_SERVE_HOST |
Default bind host for io::serve::serve_mlir (default 127.0.0.1) |
JACOBI_SEED |
Set the initial default RNG seed |
JACOBI_LOGS=1 |
Show verbose XLA runtime logs |
JACOBI_DEBUG_NANS=1 |
Fail immediately when any floating-point output contains NaN or Inf |
JACOBI_CUDNN_FMHA=0 |
Disable automatic cuDNN FlashAttention-2/3 (__cudnn$fmhaSoftmax) on CUDA and use portable tiled SDPA |
JACOBI_CUDNN_FMHA_BWD_256=1 |
Force cuDNN backward for head dim 128 < D <= 256 (Hopper only, Blackwell uses analytical tiled backward by default) |
JACOBI_FP8_BWD |
Override dynamic per-tensor FP8 backward GEMMs (1 or 0; auto-enabled on Blackwell and TPU, BF16 default on Hopper) |
JACOBI_FP8_GRAD_ACC=0 |
Disable scaled F8E5M2 outer gradient accumulation for large FP8 weights inside checkpointed for_loop backward |
JACOBI_COORDINATOR_ADDR |
Multi-node PJRT coordinator host:port for distributed training via init_distributed |
JACOBI_NUM_PROCESSES |
Total process (node) count in a multi-node PJRT job |
JACOBI_PROCESS_ID |
Zero-based process (node) rank in a multi-node PJRT job |
JACOBI_GPU_MEMORY_FRACTION |
Fraction of GPU memory reserved by PJRT BFC allocator (e.g. 0.90, falls back to XLA_PYTHON_CLIENT_MEM_FRACTION) |
JACOBI_GPU_PREALLOCATE |
Enable or disable PJRT GPU memory preallocation (true or false, falls back to XLA_PYTHON_CLIENT_PREALLOCATE) |
JACOBI_GPU_ALLOCATOR |
Override PJRT GPU allocator (bfc, cuda_async, or platform, falls back to XLA_PYTHON_CLIENT_ALLOCATOR) |
HF_TOKEN |
Authenticate with gated Hugging Face repositories and datasets |