Skip to main content

GemmaFlow

Struct GemmaFlow 

Source
pub struct GemmaFlow<'a> { /* private fields */ }
Expand description

Fluent Gemma flow builder — reads config once, chain modifiers, then build.

use rlx_models::gemma::{GemmaConfig, GemmaFlow};

let built = GemmaFlow::new(&cfg)
    .prefill()
    .batch(1)
    .seq(128)
    .lm_head()
    .last_token_logits()
    .build(&mut weights)?;

Implementations§

Source§

impl<'a> GemmaFlow<'a>

Source

pub fn new(cfg: &'a GemmaConfig) -> GemmaFlow<'a>

Source

pub fn prefill_from_hidden(self) -> GemmaFlow<'a>

Skip token embedding — feed pre-scaled hidden states at prefill_hidden.

Source

pub fn prefill_media_attn_bias(self) -> GemmaFlow<'a>

Add attn_bias input and bidirectional self-attn on sliding layers.

Source

pub fn for_prefill( cfg: &'a GemmaConfig, batch: usize, seq: usize, ) -> GemmaFlow<'a>

Prefill recipe with common batch/seq defaults.

Source

pub fn for_decode( cfg: &'a GemmaConfig, batch: usize, past_seq: usize, ) -> GemmaFlow<'a>

Decode recipe with common batch/past defaults (includes LM head).

Source

pub fn prefill(self) -> GemmaFlow<'a>

Source

pub fn decode(self) -> GemmaFlow<'a>

Source

pub fn batch(self, batch: usize) -> GemmaFlow<'a>

Source

pub fn seq(self, seq: usize) -> GemmaFlow<'a>

Prefill sequence length (ignored in decode mode).

Source

pub fn past(self, past_seq: usize) -> GemmaFlow<'a>

Decode past length (ignored in prefill mode).

Source

pub fn dynamic_seq(self) -> GemmaFlow<'a>

Symbolic sequence dim (sym::SEQ) for dynamic prefill specialization.

Source

pub fn dynamic_past(self) -> GemmaFlow<'a>

Symbolic past dim (sym::PAST_SEQ) for dynamic decode specialization.

Source

pub fn lm_head(self) -> GemmaFlow<'a>

Source

pub fn hidden_only(self) -> GemmaFlow<'a>

Hidden states only — skip LM head (default for prefill unless .lm_head()).

Source

pub fn last_token_logits(self) -> GemmaFlow<'a>

Source

pub fn export_kv(self) -> GemmaFlow<'a>

Source

pub fn custom_mask(self) -> GemmaFlow<'a>

Source

pub fn profile(self, profile: CompileProfile) -> GemmaFlow<'a>

Source

pub fn profile_prefill(self) -> GemmaFlow<'a>

Fusion-first prefill profile preset.

Source

pub fn profile_decode(self) -> GemmaFlow<'a>

Source

pub fn profile_near(self, weights_path: &Path) -> GemmaFlow<'a>

Source

pub fn before_layers( self, stages: impl IntoIterator<Item = FlowStage>, ) -> GemmaFlow<'a>

Insert custom stages after embedding, before the layer stack.

Source

pub fn after_layers( self, stages: impl IntoIterator<Item = FlowStage>, ) -> GemmaFlow<'a>

Insert custom stages after the layer stack, before final norm / LM head.

Source

pub fn layer<F>(self, f: F) -> GemmaFlow<'a>
where F: Fn(GemmaLayerCtx<'_>) -> FlowStage + Send + Sync + 'static,

Override per-layer construction (prefill or decode depending on mode).

Call GemmaLayerCtx::default_stage to keep stock blocks for unmodified layers.

Source

pub fn patch_flow<F>(self, f: F) -> GemmaFlow<'a>
where F: Fn(ModelFlow) -> ModelFlow + Send + Sync + 'static,

Patch the assembled ModelFlow before build — full flexibility escape hatch.

Source

pub fn build(self, weights: &mut dyn WeightLoader) -> Result<BuiltModel, Error>

Trait Implementations§

Source§

impl<'a> Clone for GemmaFlow<'a>

Source§

fn clone(&self) -> GemmaFlow<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for GemmaFlow<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for GemmaFlow<'a>

§

impl<'a> !UnwindSafe for GemmaFlow<'a>

§

impl<'a> Freeze for GemmaFlow<'a>

§

impl<'a> Send for GemmaFlow<'a>

§

impl<'a> Sync for GemmaFlow<'a>

§

impl<'a> Unpin for GemmaFlow<'a>

§

impl<'a> UnsafeUnpin for GemmaFlow<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V