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