Skip to main content

rlx_driver/
lib.rs

1// RLX — versatile ML compiler + runtime.
2// Copyright (C) 2026 Eugene Hauptmann, Nataliya Kosmyna.
3// SPDX-License-Identifier: MIT OR Apache-2.0
4
5//! RLX driver layer — devices, arenas, buffers, command streams
6//! (plan #58).
7//!
8//! Borrowed from MAX's three-layer separation: graph (IR) →
9//! engine (compiled artifacts, sessions) → driver (devices,
10//! buffers). The Rust spelling sits one crate below
11//! `rlx-runtime`: this crate owns the *physical* concerns
12//! (which device, which buffer slot, which command stream),
13//! `rlx-runtime` owns the *logical* engine (Session, CompiledGraph,
14//! compile cache).
15//!
16//! Why split? Three reasons.
17//!   1. **Backend symmetry.** rlx-cpu / rlx-metal don't currently
18//!      depend on rlx-runtime; before this split they couldn't
19//!      reach the `Device` enum without a circular dep. The
20//!      `rlx-ir → rlx-driver → backends → rlx-runtime` chain is
21//!      strictly one-way.
22//!   2. **Testability.** A `Buffer` parity test doesn't need to
23//!      pull in the entire compile + execute pipeline.
24//!   3. **Future swaps.** Replacing the engine layer (e.g. for
25//!      AOT compilation) doesn't touch the driver.
26//!
27//! `rlx-runtime` re-exports every type here, so existing callers
28//! keep working without import changes.
29
30pub mod arena;
31pub mod buffer;
32pub mod collective;
33pub mod device;
34pub mod handle;
35#[cfg(feature = "iroh")]
36pub mod iroh_transport;
37#[cfg(feature = "mpi")]
38pub mod mpi_transport;
39pub mod net;
40pub mod node;
41pub mod stream;
42pub mod symmetric;
43pub mod transport;
44
45pub use arena::DeviceArena;
46pub use buffer::Buffer;
47pub use collective::{ReduceKind, all_gather, all_reduce, reduce_scatter, ring_all_reduce};
48pub use device::{
49    BackendSupport, Device, DeviceFromStrError, STANDARD_DEVICES, StandardBackends, validate_device,
50};
51pub use handle::BufferHandle;
52#[cfg(feature = "iroh")]
53pub use iroh_transport::{
54    IrohPeer, IrohTransport, RLX_PIPELINE_ALPN, RelayMap, RelayMode, process_group_from_env,
55};
56#[cfg(feature = "mpi")]
57pub use mpi_transport::MpiTransport;
58pub use net::{DEFAULT_HEAP_BYTES, NetTransport, TcpTransport, ThunderboltTransport};
59pub use node::{
60    Node, Topology, announce_coordinator, discover_coordinator, discover_peers, local_ip,
61};
62pub use stream::{CommandStream, SyncStream};
63pub use symmetric::{
64    CollectiveError, LocalTransport, Rank, SymmetricBuffer, SymmetricHeap, SymmetricTransport,
65};
66pub use transport::{ProcessGroup, ReduceMode, Transport, default_barrier, env_reduce_mode};