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 calibrate;
34pub mod coop_f16_vk;
35pub mod device;
36pub mod fft_dispatch;
37pub mod fft_host;
38pub mod gdn_host;
39pub mod gguf_host;
40pub mod im2col_host;
41pub mod kernels;
42pub mod llada2_gate_host;
43pub mod log_mel_host;
44#[cfg(feature = "splat")]
45pub mod splat;
46#[cfg(feature = "native-splat")]
47pub mod splat_native;
48pub mod training_bwd_host;
49pub mod umap_knn_host;
50pub mod unfuse;
51pub mod welch_peaks_dispatch;
52pub mod welch_peaks_host;
53
54/// True if a wgpu adapter is reachable on this system. Always
55/// available at the crate level; the runtime registry only registers
56/// the backend when this returns `true` so tests on weird CI machines
57/// without a GPU don't trip up.
58pub fn is_available() -> bool {
59 device::wgpu_device().is_some()
60}
61
62pub use device::{is_vulkan_available, select_vulkan_backend};