Skip to main content

rlx_flow/
recipe.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//! Composable model recipes — arch presets that remain patchable.
17
18use crate::flow::ModelFlow;
19
20/// Assemble a [`ModelFlow`] from config — use for arch-specific presets (LLaMA, Qwen, FLUX, …).
21///
22/// Recipes return an unbuilt flow so callers can still `.raw_stage()`, `.custom()`, or
23/// `.patch()` before `build()`.
24pub trait ModelRecipe {
25    fn name(&self) -> &str;
26    fn assemble(&self) -> ModelFlow;
27}
28
29impl<F> ModelRecipe for F
30where
31    F: Fn() -> ModelFlow,
32{
33    fn name(&self) -> &str {
34        "closure_recipe"
35    }
36
37    fn assemble(&self) -> ModelFlow {
38        self()
39    }
40}