Skip to main content

rlx_wgpu/
lib.rs

1// RLX — versatile ML compiler + runtime.
2// Copyright (C) 2026 Eugene Hauptmann, Nataliya Kosmyna.
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, version 3.
7//
8// This program is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11// GNU General Public License for more details.
12//
13// You should have received a copy of the GNU General Public License
14// along with this program. If not, see <https://www.gnu.org/licenses/>.
15
16//! RLX wgpu backend — cross-platform GPU execution via the `wgpu`
17//! Rust crate (Metal on macOS, Vulkan on Linux, DX12 on Windows,
18//! WebGPU in browsers).
19//!
20//! Compared to rlx-metal: same overall shape (device singleton, buffer
21//! arena, per-op compute pipelines, command-buffer-per-forward-pass)
22//! but with WGSL kernels and the wgpu Rust API instead of MSL + the
23//! `metal` crate. Pure Rust deps — no FFI / submodules to manage.
24//!
25//! Layout:
26//! - `device`   — wgpu instance/adapter/device singleton (sync wrapper)
27//! - `buffer`   — typed GPU buffer + arena
28//! - `kernels`  — WGSL source strings + per-kernel pipeline cache
29//! - `backend`  — Backend trait impl + per-op dispatch
30
31pub mod backend;
32pub mod buffer;
33pub mod device;
34pub mod fft_dispatch;
35pub mod fft_host;
36pub mod gdn_host;
37pub mod gguf_host;
38pub mod kernels;
39pub mod llada2_gate_host;
40#[cfg(feature = "splat")]
41pub mod splat;
42#[cfg(feature = "native-splat")]
43pub mod splat_native;
44pub mod training_bwd_host;
45pub mod umap_knn_host;
46pub mod unfuse;
47
48/// True if a wgpu adapter is reachable on this system. Always
49/// available at the crate level; the runtime registry only registers
50/// the backend when this returns `true` so tests on weird CI machines
51/// without a GPU don't trip up.
52pub fn is_available() -> bool {
53    device::wgpu_device().is_some()
54}
55
56pub use device::{is_vulkan_available, select_vulkan_backend};