fuel_parallel/lib.rs
1// SPDX-License-Identifier: MIT OR Apache-2.0
2//! # fuel-parallel
3//!
4//! **Layer**: Use-Case Orchestration | **Stability**: experimental
5//!
6//! Multi-GPU parallelism primitives for the Fuel ML framework. This crate
7//! provides the building blocks for distributing model computation across
8//! multiple devices.
9//!
10//! ## What is here
11//!
12//! - **Device topology** — [`topology`] models device interconnects and
13//! bandwidth for cost-aware placement decisions.
14//! - **Device groups** — [`device_group`] provides real single-process,
15//! multi-device collectives over the lazy graph, staging through the host
16//! when a hop crosses vendors.
17//! - **Tensor parallelism** — [`tensor_parallel`] provides column-parallel and
18//! row-parallel sharding strategies for linear layers with all-reduce
19//! communication.
20//! - **Pipeline parallelism** — [`pipeline_parallel`] provides stage assignment
21//! and micro-batch scheduling (1F1B, GPipe) for models too large for a single
22//! device.
23//! - **Distributed cache** — [`distributed_cache`] coordinates KV cache state
24//! across devices for paged and prefix caches.
25//!
26//! ## Lazy-only
27//!
28//! Every tensor-touching surface here takes [`Tensor`](fuel::lazy::Tensor).
29//! Fuel retired eager entirely in B6, and a collective written against the old
30//! eager `Tensor` could not have reduced lazy shards — the most likely reason
31//! this crate sat unwired. Only [`comm`] and [`tensor_parallel`] ever touched
32//! tensors; [`topology`], [`pipeline_parallel`] and [`distributed_cache`] are
33//! pure policy and metadata, so they were already dtype- and tensor-free.
34//!
35//! ## Design principles
36//!
37//! This crate is a **leaf crate** — nothing in the Fuel ecosystem depends on
38//! it. It provides policy, metadata, and strategies.
39//!
40//! Two collective surfaces live here and serve different deployments:
41//! [`device_group::DeviceGroup`] is the one-process/N-devices form and works
42//! today; [`comm::Communicator`] is the SPMD seam an out-of-process transport
43//! (NCCL, Gloo, MPI) plugs into, which Fuel does not implement because rank
44//! assignment and rendezvous are consumer policy.
45//!
46//! ## What is NOT here
47//!
48//! - **An out-of-process collective transport** — see [`comm::Communicator`],
49//! the seam one would plug into.
50//! - **Model definitions** — those stay in `fuel-transformers`.
51//! - **Inference orchestration** — that's `fuel-inference`.
52//! - **Training loops** — that's `fuel-training`.
53//!
54//! ## Layer placement
55//!
56//! ```text
57//! fuel-parallel ← you are here (multi-GPU orchestration)
58//! fuel-transformers (model definitions)
59//! fuel-core (Tensor, Device)
60//! fuel-graph (the DAG + optimizer)
61//! fuel-ir (Shape, DType, Op, errors)
62//! ```
63//!
64//! *(This block previously listed `fuel-nn (layers, optimisers, VarBuilder)`
65//! between `fuel-transformers` and `fuel-core`, and the "NOT here" list pointed
66//! at `baracuda_nccl`. **No `fuel-nn` crate exists** in the workspace — the
67//! `Linear` in [`tensor_parallel`] says outright that it was inlined so this
68//! crate need not depend on it, so the diagram contradicted the code beside it.
69//! `fuel-core-types` is likewise gone: it is now `fuel-ir`.)*
70
71pub mod comm;
72pub mod device_group;
73pub mod distributed_cache;
74pub mod pipeline_parallel;
75pub mod tensor_parallel;
76pub mod topology;