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>
impl<'a> GemmaFlow<'a>
pub fn new(cfg: &'a GemmaConfig) -> GemmaFlow<'a>
Skip token embedding — feed pre-scaled hidden states at prefill_hidden.
Sourcepub fn prefill_media_attn_bias(self) -> GemmaFlow<'a>
pub fn prefill_media_attn_bias(self) -> GemmaFlow<'a>
Add attn_bias input and bidirectional self-attn on sliding layers.
Sourcepub fn for_prefill(
cfg: &'a GemmaConfig,
batch: usize,
seq: usize,
) -> GemmaFlow<'a>
pub fn for_prefill( cfg: &'a GemmaConfig, batch: usize, seq: usize, ) -> GemmaFlow<'a>
Prefill recipe with common batch/seq defaults.
Sourcepub fn for_decode(
cfg: &'a GemmaConfig,
batch: usize,
past_seq: usize,
) -> GemmaFlow<'a>
pub fn for_decode( cfg: &'a GemmaConfig, batch: usize, past_seq: usize, ) -> GemmaFlow<'a>
Decode recipe with common batch/past defaults (includes LM head).
pub fn prefill(self) -> GemmaFlow<'a>
pub fn decode(self) -> GemmaFlow<'a>
pub fn batch(self, batch: usize) -> GemmaFlow<'a>
Sourcepub fn seq(self, seq: usize) -> GemmaFlow<'a>
pub fn seq(self, seq: usize) -> GemmaFlow<'a>
Prefill sequence length (ignored in decode mode).
Sourcepub fn past(self, past_seq: usize) -> GemmaFlow<'a>
pub fn past(self, past_seq: usize) -> GemmaFlow<'a>
Decode past length (ignored in prefill mode).
Sourcepub fn dynamic_seq(self) -> GemmaFlow<'a>
pub fn dynamic_seq(self) -> GemmaFlow<'a>
Symbolic sequence dim (sym::SEQ) for dynamic prefill specialization.
Sourcepub fn dynamic_past(self) -> GemmaFlow<'a>
pub fn dynamic_past(self) -> GemmaFlow<'a>
Symbolic past dim (sym::PAST_SEQ) for dynamic decode specialization.
pub fn lm_head(self) -> GemmaFlow<'a>
Hidden states only — skip LM head (default for prefill unless .lm_head()).
pub fn last_token_logits(self) -> GemmaFlow<'a>
pub fn export_kv(self) -> GemmaFlow<'a>
pub fn custom_mask(self) -> GemmaFlow<'a>
pub fn profile(self, profile: CompileProfile) -> GemmaFlow<'a>
Sourcepub fn profile_prefill(self) -> GemmaFlow<'a>
pub fn profile_prefill(self) -> GemmaFlow<'a>
Fusion-first prefill profile preset.
pub fn profile_decode(self) -> GemmaFlow<'a>
pub fn profile_near(self, weights_path: &Path) -> GemmaFlow<'a>
Sourcepub fn before_layers(
self,
stages: impl IntoIterator<Item = FlowStage>,
) -> GemmaFlow<'a>
pub fn before_layers( self, stages: impl IntoIterator<Item = FlowStage>, ) -> GemmaFlow<'a>
Insert custom stages after embedding, before the layer stack.
Sourcepub fn after_layers(
self,
stages: impl IntoIterator<Item = FlowStage>,
) -> GemmaFlow<'a>
pub fn after_layers( self, stages: impl IntoIterator<Item = FlowStage>, ) -> GemmaFlow<'a>
Insert custom stages after the layer stack, before final norm / LM head.
Sourcepub fn layer<F>(self, f: F) -> GemmaFlow<'a>
pub fn layer<F>(self, f: F) -> GemmaFlow<'a>
Override per-layer construction (prefill or decode depending on mode).
Call GemmaLayerCtx::default_stage to keep stock blocks for unmodified layers.
Sourcepub fn patch_flow<F>(self, f: F) -> GemmaFlow<'a>
pub fn patch_flow<F>(self, f: F) -> GemmaFlow<'a>
Patch the assembled ModelFlow before build — full flexibility escape hatch.
pub fn build(self, weights: &mut dyn WeightLoader) -> Result<BuiltModel, Error>
Trait Implementations§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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