Skip to main content

Module source

Module source 

Source
Expand description

The model-agnostic weight seam. rlx-distributed never knows how a model’s weights are stored — a stage worker asks a ParamSource for each parameter by name, and the source (implemented by a model crate, e.g. wrapping an mlx / GGUF / safetensors loader) returns it as dense f32 or as packed/quantized bytes. This is what keeps the crate model-agnostic: RLX provides the API, rlx-models provides the weights.

Ergonomics: a plain HashMap<String, Vec<f32>> is a ParamSource (great for tests and small models), and so is any closure FnMut(&str) -> Option<Param> (great for adapting an existing loader in one line):

ⓘ
// adapt any loader without a newtype:
let mut src = |name: &str| loader.take_typed(name).map(|(b, dt)| Param::typed(b, dt));
serve_stage(addr, stage, &mut src, Device::Cpu, &opts, 1)?;

Enums§

Param
One parameter value: dense f32, or packed bytes with a dtype (quantized / f16 / bf16 weights fed to the runtime without a host cast).

Traits§

ParamSource
Supplies a stage’s parameters on demand, by name. None means “not mine” (the runtime leaves the param unset — useful when a source only owns a shard).