# Jacobi > A machine learning framework for Rust compiled via XLA and PJRT to CPUs, GPUs (CUDA, Metal, ROCm), and TPUs. Zero C++ build tools, `protoc`, or `libclang` required. Use this file as the exact ground truth when writing Rust code with `jacobi` (v0.1.2, Rust edition 2024). For full runnable multi-GPU, FP8, MoE, Hugging Face, and export recipes in a single file, fetch [llms-full.txt](https://henryndubuaku.github.io/jacobi/llms-full.txt). Never invent PyTorch, Burn, or Candle method names that do not appear below. ## 1. Cargo Setup and Prelude ```toml [dependencies] jacobi = "0.1" # Minimal build without Hugging Face tokenizers or hf-hub # jacobi = { version = "0.1", default-features = false } ``` Always start files with `use jacobi::prelude::*;`. `jacobi::prelude` exports: `Error`, `Result`, `Dtype`, `Precision`, `with_autocast`, `with_precision`, `set_default_precision`, `sync`, `debug_print`, `set_debug_nans`, `debug_nans_enabled`, `with_debug_nans`, `with_debug_print_capture`, `Module`, `#[module]`, `Unravel`, `ravel_module`, `to_device`, `Tensor`, `einsum`, `einsum_in`, `SentencePiece`, `WeightLoader`, `HfExporter`, `DlPackCapsule`, `to_dlpack`, `from_dlpack`, `custom_call`, `ffi_call`, `ffi_call_one`, `ffi_call_with_vjp`, `register_ffi_handler`, `nn` (`Linear`, `LoraLinear`, `Sequential`, `Layer`, `Conv1d`, `Conv2d`, `Conv3d`, `ConvTranspose1d`, `ConvTranspose2d`, `BatchNorm2d`, `BatchNormStats`, `GroupNorm`, `LayerNorm`, `RmsNorm`, `Embedding`, `Dropout`, `RoPE`, `MultiheadAttention`, `KvCache`, `RolloutKvCache`, `MoeDispatchConfig`, `batch_fused_apply`, `moe_swiglu_dispatch`, `moe_swiglu_dispatch_local`, `moe_swiglu_dispatch_all_to_all`, `moe_swiglu_dispatch_all_to_all_fused_tn`, `chunked_lm_head_loss`, `chunked_lm_head_loss_tn`, `chunked_cross_entropy`, `chunked_cross_entropy_with_softcap`, `chunked_cross_entropy_tn`, `chunked_cross_entropy_indexed`, `chunked_cross_entropy_indexed_tn`, `sage_attention`, `kv_cache_sliding_window_mask`, `nn::rl`, `nn::diffusion`, `nn::audio`), `optim` (`Sgd`, `Adam`, `AdamW`, `EfficientAdamW`, `RMSprop`, `Muon`, `Ema`, `Fp8UpdateMode`, `stochastic_round`), `manual_seed`, `set_seed`, `rand`, `rand_uniform`, `randn`, `randint`, `randperm`, `bernoulli`, `truncated_normal`, `kaiming_normal`, `kaiming_uniform`, `sample_top_k`, `sample_top_p`, `Backend`, `DeviceInfo`, `HostTensor`, `MemoryStats`, `Prefetcher`, `StageFactory`, `StageStream`, `Dataset`, `DataLoader`, `use_backend`, `backend_name`, `devices`, `num_devices`, `num_global_devices`, `num_processes`, `process_index`, `init_distributed`, `memory_stats`, `memory_stats_on`, `all_memory_stats`, `jit`, `jit_autocast`, `jit_on`, `eval`, `eval_shape`, `TensorSpec`, `JitFn`, `PendingCall`, `checkpoint`, `remat`, `custom_vjp`, `grad`, `value_and_grad`, `efficient_grad`, `efficient_grad_with`, `value_and_efficient_grad`, `value_and_efficient_grad_with`, `value_and_efficient_grad_warm`, `EfficientGrad`, `EfficientGradConfig`, `FactoredTensor`, `jvp`, `jacfwd`, `hvp`, `hessian`, `jacobian`, `vmap`, `auto_ckpt_steps`, `for_loop`, `for_loop_selective`, `for_loop_auto`, `scan`, `scan_selective`, `scan_auto`, `map_chunks`, `while_loop`, `cond`, `switch`, `pmap`, `pmap_on`, `PmapFn`, `replicate`, `replicate_n`, `unreplicate`, `shard_batch`, `shard_batch_n`, `gather_shards`, `psum`, `pmean`, `pmax`, `pmin`, `all_gather`, `replica_id`, `Mesh`, `PartitionSpec`, `NamedSharding`, `ShardMapFn`, `Sharded`, `shard_map`, `shard_map_on`, `with_sharding_constraint`, `axis_index`, `psum_axis`, `pmean_axis`, `pmax_axis`, `pmin_axis`, `all_gather_axis`, `all_to_all_axis`, `barrier`, `barrier_on`, and (under default `hf` feature) `hub` and `Tokenizer`. ## 2. Hard Rules (Avoid PyTorch / Burn / Candle Hallucinations) 1. Mark model structs with `#[module]`. It derives `Clone` and implements `Module`. Plain config fields (`usize`, `isize`, `i32`, `i64`, `f32`, `f64`, `bool`, `String`, arrays, tuples, `Option`, `Vec`) pass through automatically with no skip attributes needed. 2. Do NOT write `loss.backward()` or `opt.zero_grad()`. Optimizers are stateful and separate from the model (`let (loss, grads) = value_and_grad(|p| p.loss(&x, &y), &model); opt.step(&mut model, &grads);`). 3. `jit` takes ONE argument implementing `Module` (pass tuples like `jit(move |(mut m, mut o): (Net, AdamW)| { ... (m, o, loss) })`) and runs with `.call((model, opt))?` or `.call_async(...)?.wait()?`. 4. `Tensor` ops return `Tensor` and never panic mid-expression. Errors propagate lazily and return `Result` at `.item()?`, `.item_f64()?`, `.to_vec_f32()?`, `.to_vec_f64()?`, `.to_host()?`, `.check()?`, or `jit.call(...)?`. 5. Scalar operators take `f64` (`&x * 2.0 + 1.0`). Use `t.powf(2.0)` for scalar exponents and `t.pow(&other)` for tensor exponents. 6. Slicing and indexing methods are `t.index(-1)` (static axis-0 row), `t.slice_axis(axis, start, end)` (NOT `.slice(...)`), `t.dynamic_slice(&start, size)`, `t.dynamic_update_slice_axis(&upd, axis, &start)`, `t.take(&ids)`, `t.take_axis(&ids, axis)`, `t.gather(axis, &indices)`, and `t.scatter_add(axis, &indices, &updates)`. 7. Convolutions (`Conv1d`, `Conv2d`, `Conv3d`) use channels-last layout (`[B, L, C]`, `[B, H, W, C]`, `[B, D, H, W, C]`) and PyTorch constructor order (`Conv2d::new(in_ch, out_ch, kernel)`). 8. RNG is implicit on device (`manual_seed(42)`, `Tensor::rand`, `Tensor::randn`, `Tensor::randint`, `Tensor::randperm`, `nn::dropout`, `logits.sample()`). Do NOT thread manual PRNG keys unless explicitly using `jacobi::rng::Key`. 9. `for_loop` and `scan` inside `grad(...)` use compiled reverse-mode `stablehlo.while` loops without unrolling (`O(1)` compiled graph size, `O(1)` in-place scatter-add for stacked layer weights, and automatic scaled `F8E5M2` outer gradient accumulation for large FP8 weights). 10. `nn::flash_attention` automatically uses NVIDIA cuDNN FlashAttention-2/3 on CUDA (`BF16`/`F16`, `16 <= D <= 256`, `S >= 64`) with analytical tiled FlashAttention-2 backward on Blackwell for `128 < D <= 256` and causal block-tiled FlashAttention for `D > 256` or non-CUDA backends. 11. `BatchNorm2d` is functional. Inside `grad`, use `forward_train` (returns `(Tensor, BatchNormStats)`) or `forward(&x, true)` and update stats via `apply_stats(stats)`. When `&mut self` is available, `forward_mut(&mut self, &x, training)` updates stats in place. 12. `io::serve::serve_mlir(path, port: u16)` binds `127.0.0.1` by default (use `serve_mlir_on(path, host, port)` or `JACOBI_SERVE_HOST` to bind another interface). ## 3. Dtypes (`Dtype`) `Dtype::F32`, `Dtype::F64`, `Dtype::BF16`, `Dtype::F16`, `Dtype::F8E4M3FN`, `Dtype::F8E5M2`, `Dtype::F4E2M1FN`, `Dtype::I1`, `Dtype::I8`, `Dtype::I16`, `Dtype::I32`, `Dtype::I64`, `Dtype::U8`, `Dtype::U32`. ## 4. Tensor API (`jacobi::Tensor`) ### Constructors - `Tensor::from_f32(data: &[f32], shape: &[usize]) -> Tensor`, `Tensor::from_f64(data: &[f64], shape: &[usize])`, `Tensor::from_f16(bits: &[u16], shape: &[usize]) -> Result`, `Tensor::from_bf16(bits: &[u16], shape: &[usize]) -> Result` - `Tensor::from_i8`, `Tensor::from_i16`, `Tensor::from_u8`, `Tensor::from_i32`, `Tensor::from_i64`, `Tensor::from_bool` - Direct-to-device uploads: `Tensor::from_host_on(&host, dev)`, `Tensor::from_raw_bytes_on(bytes, shape, dtype, dev)`, `Tensor::from_{f32,f64,f16,bf16,i8,i16,i32,i64,u8,u32,bool}_on(..., dev) -> Result` - `Tensor::from_host(host: &HostTensor)`, `Tensor::from_raw_bytes(bytes: &[u8], shape: &[usize], dtype: Dtype) -> Result` - `Tensor::spec(shape: &[usize], dtype: Dtype)` (zero-allocation AOT placeholder) - `Tensor::scalar(v: f64)`, `Tensor::scalar_f32`, `Tensor::scalar_f64`, `Tensor::scalar_i32`, `Tensor::scalar_i64` - `Tensor::zeros(shape)`, `Tensor::ones(shape)`, `Tensor::full(shape, val: f64, dtype)`, `t.zeros_like()`, `t.ones_like()`, `t.full_like(val: f64)` - `Tensor::arange(start: f64, stop: f64, step: f64)`, `Tensor::linspace(start: f64, stop: f64, steps: usize)`, `Tensor::eye(n)`, `Tensor::meshgrid(&x, &y) -> (xx, yy)` ### Implicit RNG - `manual_seed(seed: u64)` / `set_seed(seed: u64)` - `Tensor::rand(shape)`, `Tensor::rand_uniform(shape, lo: f32, hi: f32)`, `Tensor::randn(shape)`, `Tensor::randint(low: i64, high: i64, shape)`, `Tensor::randperm(n)` - `bernoulli(p, shape)`, `truncated_normal(shape, lo, hi)`, `kaiming_normal(shape)`, `kaiming_uniform(shape)` - `t.sample()`, `t.sample_temperature(temp)`, `t.sample_top_k(k, temp)`, `t.sample_top_p(p, temp)` ### Metadata, Host Reads, and Casts - `shape() -> Vec`, `ndim() -> usize`, `numel() -> usize`, `dtype() -> Dtype`, `device_index()`, `to_device(idx)`, `eval() -> Result<()>` - `check() -> Result<()>`, `detach() -> Tensor` - `item() -> Result`, `item_f64`, `item_i32`, `item_i64`, `item_bool`, `to_vec_f32`, `to_vec_f64`, `to_vec_i32`, `to_vec_i64`, `to_host`, `to_raw_bytes` - `cast(dtype)` / `to_dtype(dtype)`, `to_f32()`, `to_f64()`, `to_bf16()`, `to_f16()`, `to_fp8_e4m3()`, `to_fp8_e5m2()`, `to_fp4()`, `to_i8()`, `to_i16()`, `to_i32()`, `to_i64()`, `to_u8()`, `to_u32()` ### Elementwise, Linear Algebra, Shapes, Indexing, and Vision - Binary: `add`, `sub`, `mul`, `div`, `pow(&Tensor)`, `powf(f64)`, `atan2`, `logaddexp`, `maximum`, `minimum`, `max_scalar`, `min_scalar`, `clamp(lo, hi)`, `modulo` - Unary: `neg`, `abs`, `exp`, `expm1`, `log`, `log2`, `log10`, `log1p`, `erf`, `sqrt`, `rsqrt`, `sin`, `cos`, `tan`, `asin`, `acos`, `atan`, `sinh`, `cosh`, `tanh`, `sigmoid`, `log_sigmoid`, `relu`, `leaky_relu(slope)`, `elu(alpha)`, `softplus`, `mish`, `gelu`, `gelu_exact`, `silu`, `floor`, `ceil`, `round`, `sign` - Comparisons and predicates: `eq_tensor`, `ne_tensor`, `lt`, `le`, `gt`, `ge`, `eq_scalar`, `ne_scalar`, `lt_scalar`, `le_scalar`, `gt_scalar`, `ge_scalar`, `allclose(&other, rtol, atol)`, `Tensor::where_select(cond, on_true, on_false)`, `cond.where_scalars(on_true, on_false)`, `masked_fill(&mask, value)`, `logical_and`, `logical_or`, `logical_xor`, `logical_not`, `is_nan()`, `is_inf()`, `is_finite()` - Reductions: `sum`, `sum_axis`, `sum_axes`, `mean`, `mean_axis`, `mean_axes`, `max`, `max_axis`, `min`, `min_axis`, `prod`, `prod_axis`, `prod_axes`, `all`, `all_axis`, `any`, `any_axis`, `var`, `var_axis`, `std`, `std_axis`, `norm`, `norm_axis`, `logsumexp`, `logsumexp_axis`, `softmax`, `softmax_axis`, `log_softmax`, `log_softmax_axis` - Linear algebra and FFT: `matmul`, `matmul_in(&b, out_dtype)`, `dot`, `outer`, `cross`, `kron`, `trace`, `einsum(spec, &[...])`, `einsum_in(spec, &[...], out_dtype)`, `cholesky`, `triangular_solve`, `cholesky_solve`, `solve`, `inv`, `pinv`, `matrix_rank`, `qr`, `det`, `eigh`, `svd`, `rfft`, `Tensor::irfft`, `Tensor::fft`, `Tensor::ifft` - Shapes and indexing: `reshape`, `flatten`, `unsqueeze`, `squeeze`, `broadcast_to`, `transpose`, `permute`, `reverse`, `triu`, `tril`, `diag`, `chunk`, `split`, `repeat`, `repeat_interleave`, `roll`, `pad`, `Tensor::concat`, `Tensor::stack`, `slice_axis`, `dynamic_slice`, `dynamic_update_slice`, `dynamic_update_slice_axis`, `take`, `take_axis`, `index`, `gather`, `scatter_add`, `scatter_set`, `segment_sum`, `sort`, `sort_axis`, `argsort`, `argsort_axis`, `argsort_stable`, `argsort_stable_axis`, `top_k`, `top_k_axis`, `argmax`, `argmax_axis`, `argmin`, `argmin_axis`, `searchsorted`, `unique`, `one_hot`, `bincount`, `cumsum`, `cumsum_axis`, `cumprod`, `cumprod_axis`, `cumlogsumexp`, `cumlogsumexp_axis` - Vision: `conv1d`, `conv1d_grouped`, `conv_transpose1d`, `conv2d`, `conv2d_grouped`, `conv_transpose2d`, `conv3d`, `conv3d_grouped`, `max_pool1d`, `avg_pool1d`, `max_pool2d`, `avg_pool2d`, `adaptive_avg_pool2d`, `upsample_nearest`, `resize_bilinear`, `crop` ## 5. Transforms (`jacobi::transform`) - Compilation: `jit(f)` (`.donate(bool)`, `.autocast(dt)`, `.compile_for(&spec)?`, `.call(inp)?`, `.call_async(inp)?`, `.mlir(&ex)?`), `jit_autocast(dt, f)`, `jit_on(&eng, f)`, `PendingCall`, `eval(f)`, `eval_shape(&inp, f)`, `with_autocast(dt, f)` - Autodiff: `grad(f, &p)`, `value_and_grad(f, &p)`, `efficient_grad(f, &p, rank)`, `efficient_grad_with(f, &p, cfg)`, `value_and_efficient_grad(f, &p, rank)`, `value_and_efficient_grad_with`, `value_and_efficient_grad_warm`, `jvp`, `jacfwd`, `hvp`, `hessian`, `jacobian`, `checkpoint` / `remat`, `custom_vjp`, `vmap` - Control flow: `for_loop(steps, init, |step, st| ...)`, `for_loop_selective`, `for_loop_auto`, `scan(&xs, init, |carry, x_t| (next, y))`, `scan_selective`, `scan_auto`, `auto_ckpt_steps(steps, &sample_state)`, `map_chunks(chunk_size, &inputs, |chunk| ...)`, `while_loop(init, cond, body)`, `cond(&pred, &op, on_true, on_false)`, `switch(&idx, &op, &[...])` - Multi-device and SPMD: `Sharded` (`from_shards`, `from_fn`, `replicate`, `replicate_n`, `unreplicate`, `map`, `try_map`, `into_map`, `try_into_map`, `zip`, `zip3`, `unzip`, `unzip3`), `pmap` (`.call`, `.call_sharded`), `pmap_on`, `replicate`, `replicate_n`, `unreplicate`, `shard_batch`, `shard_batch_n`, `gather_shards`, `psum`, `pmean`, `pmax`, `pmin`, `all_gather`, `replica_id`, `Mesh::new` / `Mesh::data_parallel` / `Mesh::hybrid_dp_ep`, `PartitionSpec`, `NamedSharding`, `with_sharding_constraint`, `shard_map` (`.call`, `.call_sharded`, `.call_sharded_handle`, `.compile_for`), `shard_map_on`, `axis_index`, `psum_axis`, `pmean_axis`, `pmax_axis`, `pmin_axis`, `all_gather_axis`, `all_to_all_axis(&t, axis_name, split_dim, concat_dim)`, `barrier`, `barrier_on` ## 6. Layers (`jacobi::nn`) and Optimizers (`jacobi::optim`) ### Layers (`jacobi::nn`) - `Linear::new(in_f, out_f)`, `LoraLinear::from_linear(lin, rank, alpha)` (`.merge()`), `Sequential::new().add(...).add_fn(...).add_residual(...)`, `Embedding::new(vocab, dim)`, `LayerNorm::new(dim)`, `RmsNorm::new(dim)`, `GroupNorm::new(groups, ch)`, `BatchNorm2d::new(ch)`, `Dropout::new(p)` - `Conv1d`, `Conv2d`, `Conv3d`, `ConvTranspose1d`, `ConvTranspose2d` - `RoPE::new(head_dim, max_seq)` / `RoPE::with_base(head_dim, max_seq, base)` (symbolic O(1) MLIR) - `KvCache::new(b, kv_h, max_seq, d)` / `with_dtype(...)` (`.append`, `.update_dynamic`, `.reset`) - `MultiheadAttention::new(dim, heads)` / `MultiheadAttention::gqa(dim, heads, kv_heads)` ### Functional `nn` Primitives - Activations and norms: `nn::relu`, `nn::gelu`, `nn::gelu_exact`, `nn::silu`, `nn::sigmoid`, `nn::log_sigmoid`, `nn::leaky_relu`, `nn::elu`, `nn::softplus`, `nn::mish`, `nn::swiglu`, `nn::softcap(&x, cap)`, `nn::softmax`, `nn::log_softmax`, `nn::log_softmax_axis`, `nn::layer_norm(&x, &g, &b, eps)`, `nn::rms_norm(&x, &g, eps)`, `nn::dropout`, `nn::sample`, `nn::sample_top_k`, `nn::sample_top_p` - Attention: `nn::flash_attention(&q, &k, &v, causal, scale)`, `nn::flash_attention_masked`, `nn::flash_attention_varlen`, `nn::sage_attention(&q, &k, &v, mask, scale)` (per-head K-smoothing + GQA/MQA collapse + native FP8 `Q @ K^T`), `nn::cudnn_fmha_custom_call`, `nn::scaled_dot_product_attention`, `nn::causal_mask`, `nn::kv_cache_mask`, `nn::kv_cache_sliding_window_mask` - RL & Rollout (`nn::rl`): `RolloutConfig` (defaults `group_size=16`, `sliding_window=Some(512)`, `kv_dtype=F8E4M3FN`, `use_sage_attention=true`), `RolloutKvCache` (`default_rollout`, `default_asymmetric`, `from_config`, `new`, `new_sliding_window`, `new_asymmetric`, `new_asymmetric_sliding_window`, `update_layer`, `repeat_for_group`, `repeat_default_group`, `gather_batch`, `reset`), `kv_cache_attention`, `kv_cache_attention_with_options`, `batched_rollout_loop`, `gather_token_log_probs`, `grpo_advantages`, `grpo_loss`, `ppo_clipped_loss`, `gae_advantages`, `dpo_loss` - Diffusion & Flow Matching (`nn::diffusion`): `timestep_embedding`, `modulate`, `ada_ln_zero`, `patchify_2d`, `unpatchify_2d`, `rope_2d`, `logit_normal_timesteps`, `flow_matching_interpolate`, `flow_matching_loss`, `NoiseSchedule` (`linear`, `cosine`, `q_sample`, `v_target`) - Speech & Audio (`nn::audio`): `hann_window`, `mel_filterbank`, `stft_power`, `log_mel_spectrogram`, `spec_augment`, `CausalConv1d`, `ConformerConvModule`, `ctc_loss` - Sparse MoE: `MoeDispatchConfig::default()` (`.capacity_factor`, `.softcap`, `.swiglu_clamp`, `.native_fp8_dot`), `nn::moe_swiglu_dispatch`, `nn::moe_swiglu_dispatch_local`, `nn::moe_swiglu_dispatch_all_to_all`, `nn::moe_swiglu_dispatch_all_to_all_fused_tn` (accepts `[S, H]` or `[B, T, H]`) - Large-vocab losses and stream fusion: `nn::chunked_lm_head_loss(&hidden, &lm_head_w, chunk_tokens, loss_fn)`, `nn::chunked_lm_head_loss_tn`, `nn::chunked_cross_entropy(&hidden, &lm_head_w, &targets, chunk_tokens)`, `nn::chunked_cross_entropy_tn(&hidden, &embed_w, &targets, chunk_tokens, softcap)`, `nn::chunked_cross_entropy_indexed`, `nn::chunked_cross_entropy_indexed_tn`, `nn::batch_fused_apply(&[&x1, &x2], |merged| ...)` - Losses: `nn::mse`, `nn::mse_loss`, `nn::l1_loss`, `nn::smooth_l1_loss`, `nn::huber_loss`, `nn::bce_with_logits`, `nn::kl_div`, `nn::cosine_similarity`, `nn::cross_entropy`, `nn::cross_entropy_with_options` - Quantized matmuls: `nn::quantized_matmul(&x, &w)`, `nn::quantized_linear(&x, &w_tn)` (native FP8/FP4 weights with automatic CUDA/TPU Tensor Cores and CPU/Metal fallback), `nn::fp8_matmul`, `nn::fp8_linear`, `nn::fp4_matmul`, `nn::fp4_linear` ### Optimizers (`jacobi::optim`) - FP8 weight update modes: `Fp8UpdateMode::{MasterF32, MasterBf16, StochasticRounding}`, `optim::stochastic_round(&x_f32, dtype)` - `Sgd`, `Adam`, `AdamW`, `RMSprop`, `Muon`, `Ema` (all support `with_fp8_mode`, `spec_for_with_fp8_mode` where applicable, `set_lr`, `set_lr_tensor`) - `EfficientAdamW::new(&model, lr, rank)` (`with_fp8_mode`, `spec_for_with_fp8_mode`, `.weight_decay`, `.update_proj_gap`, `.power_iters`, `.scale`, `.value_and_grad`, `.value_and_grad_dp`, `.value_and_grad_hybrid`, `.state_bytes`, `.moment_state_bytes`, `.dense_adamw_bytes_for_mode`, `.compression_ratio`, `.moment_compression_ratio`, `.set_lr`, `.set_lr_tensor`, `.step`) - Utilities and schedules: `optim::global_norm`, `optim::clip_grad_norm`, `optim::clip_grad_value`, `optim::linear_warmup`, `optim::step_decay`, `optim::one_cycle`, `optim::cosine_decay`, `optim::warmup_cosine`, `optim::wsd_schedule` ## 7. Runtime, Hugging Face, I/O, and Environment Variables - Runtime and multi-node: `use_backend`, `backend_name`, `devices`, `num_devices`, `num_global_devices`, `num_processes`, `process_index`, `init_distributed(addr, num_procs, proc_id)`, `memory_stats`, `memory_stats_on`, `all_memory_stats`, `Engine::with_config`, `HostTensor` (`from_f32..from_bf16/from_f16`), `Dataset`, `DataLoader` (`.num_workers`, `.shard`, `.start_batch`, `.iter_epoch_from`), `Prefetcher` (`new`, `parallel`, `staged`, `pooled` + `.recycle`), `StageFactory`, `StageStream` - Key env vars: `JACOBI_BACKEND`, `PJRT_PLUGIN_PATH`, `JACOBI_GPU_MEMORY_FRACTION`, `JACOBI_GPU_PREALLOCATE`, `JACOBI_LAZY_MAX_NODES`, `JACOBI_LAZY_MAX_BYTES`, `JACOBI_CKPT_LAYERS`, `JACOBI_AUTO_CKPT_MULT`, `JACOBI_CUDNN_FMHA=0`, `JACOBI_FP8_BWD=0|1`, `JACOBI_FP8_GRAD_ACC=0`, `JACOBI_COORDINATOR_ADDR`, `JACOBI_COORDINATOR_TOKEN` (required by default for all distributed coordinator binds unless `JACOBI_COORDINATOR_ALLOW_UNAUTHENTICATED=1`), `JACOBI_SERVE_READ_TIMEOUT_SECS`, `JACOBI_SERVE_WRITE_TIMEOUT_SECS`, `JACOBI_NUM_PROCESSES`, `JACOBI_PROCESS_ID`, `JACOBI_LOGS=1`, `JACOBI_DEBUG_NANS=1`, `HF_TOKEN` - FFI: `register_ffi_handler`, `ffi_call`, `ffi_call_one`, `custom_call`, `custom_call_with_layouts`, `ffi_call_with_vjp` - Hugging Face (`hf` feature): `hub::weights`, `hub::weights_revision`, `WeightLoader`, `HfExporter`, `Tokenizer::from_pretrained`, `hub::load_config`, `hub::load_safetensors`, `hub::load_into`, `hub::load_dataset` (`.rows`, `.column_strings`, `.tokenize_column`, `.collect_tokens`), `hub::load_token_bin` - I/O: `io::dlpack`, `io::safetensors`, `io::onnx`, `io::export`, `io::serve`, `io::npy`, `io::image`, `io::audio`, `io::table`, `io::text`, `io::plot` ## 8. Documentation Links - [Full Single-File LLM Reference (llms-full.txt)](https://henryndubuaku.github.io/jacobi/llms-full.txt) - [Home](https://henryndubuaku.github.io/jacobi/) - [Getting Started](https://henryndubuaku.github.io/jacobi/getting-started/) - [Hardware Backends](https://henryndubuaku.github.io/jacobi/guide/backends/) - [Tensors and Randomness](https://henryndubuaku.github.io/jacobi/guide/tensors/) - [Transforms](https://henryndubuaku.github.io/jacobi/guide/transforms/) - [Models and Optimizers](https://henryndubuaku.github.io/jacobi/guide/models/) - [Mixed Precision](https://henryndubuaku.github.io/jacobi/guide/precision/) - [Distributed Training](https://henryndubuaku.github.io/jacobi/guide/distributed/) - [Hugging Face](https://henryndubuaku.github.io/jacobi/guide/huggingface/) - [Export and Serving](https://henryndubuaku.github.io/jacobi/guide/export/) - [Data Formats and Plotting](https://henryndubuaku.github.io/jacobi/guide/io/) - [Examples](https://henryndubuaku.github.io/jacobi/examples/) - [Diffusion Transformer (Flow Matching) Example](https://henryndubuaku.github.io/jacobi/examples/diffusion/) - [Streaming Conformer Speech-to-Speech Example](https://henryndubuaku.github.io/jacobi/examples/speech_to_speech/) - [Batched Rollout and GRPO Example](https://henryndubuaku.github.io/jacobi/examples/grpo/) - [Actor-Critic PPO with GAE Example](https://henryndubuaku.github.io/jacobi/examples/ppo/) - [Gemma-4-E4B (7.4B FP8) Example](https://henryndubuaku.github.io/jacobi/examples/gemma4_e4b/) - [Distributed Inkling-2-Mini (26B MoE) Example](https://henryndubuaku.github.io/jacobi/examples/inkling_mini_2_26b/) - [Multi-Node DeepSeek-V4-Flash (283B MoE) Example](https://henryndubuaku.github.io/jacobi/examples/deepseek_v4_flash/) - [Low-Rank Training (efficient_grad) Example](https://henryndubuaku.github.io/jacobi/examples/efficient_grad/) - [Hardware and Production Benchmarks](https://henryndubuaku.github.io/jacobi/examples/benchmark/) - [API Reference Overview](https://henryndubuaku.github.io/jacobi/api-reference/) - [API Reference: Tensors, Dtypes, and RNG](https://henryndubuaku.github.io/jacobi/api-reference/tensor/) - [API Reference: Transforms and Distributed](https://henryndubuaku.github.io/jacobi/api-reference/transforms/) - [API Reference: Modules and Neural Networks](https://henryndubuaku.github.io/jacobi/api-reference/nn/) - [API Reference: Optimizers and Schedules](https://henryndubuaku.github.io/jacobi/api-reference/optim/) - [API Reference: Runtime, FFI, Hub, and I/O](https://henryndubuaku.github.io/jacobi/api-reference/runtime-and-io/) - [GitHub Repository](https://github.com/HenryNdubuaku/jacobi)