docs.rs failed to build rlx-runtime-0.2.18
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build:
rlx-runtime-0.2.17
rlx-runtime
User-facing API for RLX — Session::new(Device).compile(graph) →
CompiledGraph, which holds the executable, the arena, the weights,
and the device handle.
What's here
Session— entry point; selects a backend viaDevice.CompiledGraph(compiled.rs) —run/set_param/set_input. Zero allocation per call.Backendtrait +ExecutableGraph— every backend (CPU, Metal, MLX, CUDA, ROCm, wgpu, TPU) implements these. Every backend declares its supportedOpKinds, andlegalize_for_backendrejects unsupported graphs at compile time.registry.rs/op_registry.rs— backend factory + per-op registration plumbing for downstream extension.Devicelives inrlx-driver::device; this crate just consumes it. Variants:Cpu,Metal,Mlx,Ane,Cuda,Rocm,Tpu,Gpu(wgpu),Vulkan,OpenGl,DirectX,WebGpu.device_ext.rs—Device::is_available()lookup against the registry (keeps the runtime→driver dep direction one-way).hwinfo.rs— host + GPU introspection.HwSnapshot(CPU topology / caches / Apple thermal state) plus live GPU telemetry and control:device_thermal(device, index)/all_gpu_thermal()read temperature / power / clock / fan across CUDA & ROCm (unprivileged), andset_power_cap/set_locked_clocks/set_fan_percent(+ resets,power_cap_range) are root-only knobs returning a typedThermalError. Drives therlx-gpuCLI (inrlx-bench).weights.rs—WeightLoadertrait +BytesWeightLoader. Promote to registry per plan #24 / #56.arena.rs— device-side arena buffer.CompileCache(compile_cache.rs) — graph-fingerprint → compiled-artifact cache.subgraph.rs—run_if/run_whilehelpers; the IR has If/While ops but executor wiring is pending (see Op::If/While docstring).PrecisionPolicy— re-export fromrlx-opt. AMP / always-f16 / always-f32 / always-bf16.trace.rs— runtime tracing (verbose env-gated).cost.rs— heterogeneous cost model that picks Cpu vs. Metal vs. MLX per graph; CUDA / ROCm / wgpu use on-disk calibration caches.- Multi-backend runtime —
GraphDevices,DeviceRouter,FlexibleSession,DevicePolicy,BackendsManifest. Seedocs/backend-selection.md. - FFT dispatch —
Op::Ffton CPU / Metal / MLX / CUDA / ROCm / wgpu / TPU. Pow-2 f32 uses native GPU kernels where available; other shapes and dtypes use partial host sync. Graph helpers (rfft,irfft,stft, …) live inrlx_ir::ops::fft_ops. stream.rs— async command stream (Metal-side; CPU is sync).paged_kv— paged KV cache + continuous batching primitives.quantized_kv— block-quantized KV cache (q4_0 / q5_0 / q8_0 / f16 per-layer). Cuts decode-history memory ~2–4× vs f16. Opt-in mmap path behind themmap-kvfeature spills the K/V buffers to a file-backed mapping so the kernel pages cold history in/out on demand — useful for 100k-token decodes that exceed RAM.samplers— backend-agnostic sampler chain. Implements Temperature, DynamicTemperature, TopK, TopP, TopNSigma, TypicalP, Mirostat v1 / v2, XTC, DRY, RepetitionPenalty. Compose via [SamplerChain::builder()] or via the flat fields on [SampleOpts] —SampleOpts::into_chain()builds the canonical llama.cpp-ordered chain from the configured fields. Use [SampleOpts::is_classic()] to short-circuit the fast path when only legacy top-k/top-p/temperature are configured.- In-graph RNG — [
Op::RngNormal] / [Op::RngUniform] (ONNXRandom*) with [CompileOptions::rng] and runtime [CompiledGraph::set_rng]. Backends: Philox (default), Ort (CPU parity), Zero (deterministic tests). GPU backends host-fill unified memory (Metal/MLX) or D2H→fill→H2D segments (CUDA/ROCm/wgpu). TPU lowers to XLArng. (Added in 0.2.7 — seeCHANGELOG.md.)
Re-exports: Tick, time_ns from rlx_ir::measure. Use these for any
sub-ms timing in the user-facing layer.
Cargo features
| feature | backend |
|---|---|
cpu (default) |
rlx-cpu |
metal |
rlx-metal (macOS) |
mlx |
rlx-mlx (macOS) |
gpu |
rlx-wgpu (cross-platform) |
cuda |
rlx-cuda |
rocm |
rlx-rocm |
tpu |
rlx-tpu |
blas-accelerate |
macOS Accelerate |
blas-mkl |
Intel MKL |
blas-openblas |
OpenBLAS |
mmap-kv |
file-backed quantized KV (memmap2) |
Install
[]
= { = "0.2.18", = ["cpu"] }
Heads-up. The
mlxandrocmfeatures pull inrlx-mlxandrlx-rocm, which aren't on crates.io (workspace-relative submodule / kernel-source paths). Enabling those features on a crates.io build ofrlx-runtimemay fail to resolve. Use a git source on the whole workspace instead:= { = "https://github.com/MIT-RLX/rlx", = ["mlx"] }
Most users want the rlx prelude
crate; it re-exports rlx_runtime::Session and friends at the top
level.
Quickstart
use ;
use ;
let mut g = new;
let x = g.input;
let w = g.param;
let y = g.matmul;
g.set_outputs;
let mut compiled = new.compile;
compiled.set_param;
let out = compiled.run;
Multi-backend (optional)
use ;
let mut runner = with_policy;
runner.set_param;
let out = runner.run_resolved_with_inputs?;
let mut router = from_env?;
let = router.run?;
Full guide: docs/backend-selection.md.
Build / test
Gotchas
- Backend selection is feature-gated.
--features metalis mandatory to instantiateDevice::Metal; otherwiseSession::new(Metal)panics at registry lookup. Same applies tocuda,rocm,mlx,wgpu. set_paramaccepts&[f32]of the declared shape's element count. Mismatched len is a runtime panic, not a compile-time error.- Compile cache key includes the graph fingerprint and the precision policy — bumping precision invalidates entries.
- For long-running serving paths, prefer
CompileCacheover recompiling per request.
License
MIT OR Apache-2.0.