Skip to main content

rlx_flow/
lib.rs

1// RLX — versatile ML compiler + runtime.
2// Copyright (C) 2026 Eugene Hauptmann, Nataliya Kosmyna.
3
4//! Block assembly-line API for RLX model builders.
5
6pub mod blocks;
7mod composite;
8mod context;
9mod dsl;
10pub mod escape;
11mod execution;
12mod extension;
13mod flow;
14mod layer;
15mod plugin;
16mod profile;
17mod recipe;
18mod side;
19mod stage;
20mod stage_contract;
21mod stage_interfaces;
22pub mod stream;
23mod value;
24mod weight;
25
26pub mod prelude;
27
28pub use blocks::RopeTablesStage;
29pub use blocks::{
30    BertEncoderLayerSpec, BertEncoderLayerStage, BertQkvStyle, ClsTokenPoolStage,
31    NomicEncoderLayerSpec, NomicEncoderLayerStage, Qwen3DecodeLayerSpec, Qwen3DecoderSpec,
32    Qwen3DecoderStage, VitSelfAttnSpec, dinov2_layer_fused, nomic_vision_layer_fused,
33};
34pub use composite::LayerComposition;
35pub use context::{DecodeBindings, FlowState, GdnInputSlots};
36pub use escape::Emit;
37pub use execution::{ExecutionPreset, ModelExecutionConfig};
38pub use extension::FlowExtensionPlan;
39pub use flow::{BuiltModel, ModelFlow};
40pub use layer::LayerStack;
41pub use plugin::{PluginStage, plugin, plugin_named};
42pub use profile::{
43    BackendOverrides, CompileProfile, CpuBackendProfile, FusionPolicyKind, FusionProfile,
44    FusionTargetKind, MetalBackendProfile, MixedPrecisionKind, PassProfile, PrecisionKind,
45    PrecisionProfile,
46};
47pub use recipe::ModelRecipe;
48pub use side::SideOutputs;
49pub use stage::FlowStage;
50pub use stage_contract::{BlockAsLayer, LayerStage, StageArtifacts};
51pub use stage_interfaces::{AttentionStage, FfnStage, KvCacheContract, NormStage};
52pub use stream::{
53    DualStreamStage, LoadStreamStage, StoreStreamStage, dual_stream_stage, id as stream_id,
54};
55pub use value::FlowValue;
56pub use weight::{MapWeights, WeightSource};
57
58use std::collections::HashMap;
59
60/// Compatibility shim: packed GGUF matmul weights (used by some model loaders).
61#[derive(Debug, Clone, Default)]
62pub struct GgufPackedParams {
63    pub linears: HashMap<String, GgufPackedLinear>,
64}
65
66impl GgufPackedParams {
67    pub fn get_linear(&self, key: &str) -> Option<&GgufPackedLinear> {
68        self.linears.get(key)
69    }
70}
71
72/// One packed linear weight: quantized bytes + bias.
73#[derive(Debug, Clone)]
74pub struct GgufPackedLinear {
75    pub w_q: Vec<u8>,
76    pub scheme: rlx_ir::quant::QuantScheme,
77    pub in_dim: usize,
78    pub out_dim: usize,
79    pub bias: Vec<f32>,
80}