pub enum BertFfn {
GeluSeq,
SwigluPar,
GegluPar,
GegluFusedUp,
SwigluFusedUp,
}Expand description
The two FFN shapes bert.cpp builds on this graph for the
architectures frink serves.
bert and nomic-bert-moe’s dense layers take the ungated GELU
with both biases (:179-187); nomic-bert takes the gated SiLU
with none (:195-201, the final else). The variant is the
architecture’s, read once at load, so a layer body cannot ask
“is there a gate tensor” and answer differently on two files.
Variants§
GeluSeq
down(gelu(up(x))), biases where the file has them.
SwigluPar
down(silu(gate(x)) * up(x)), no biases.
GegluPar
down(gelu(gate(x)) * up(x)): jina-bert-v2 with a separate
ffn_gate (bert.cpp:188-194 picks LLM_FFN_GELU under
LLM_FFN_PAR, which build_ffn turns into ggml_geglu_split).
GegluFusedUp
The same function with the gate FUSED into ffn_up: the matrix
is 2 * n_ff rows and ggml_geglu splits it, the FIRST half
being the gate (bert.cpp:189, up_contains_gate).
SwigluFusedUp
SwiGLU with the gate fused into ffn_up the same way:
neo-bert.cpp:35,110-115 creates a 2 * n_ff-wide matrix and
passes LLM_FFN_SWIGLU under LLM_FFN_SEQ, which is
ggml_swiglu over the doubled row.
Trait Implementations§
impl Copy for BertFfn
impl Eq for BertFfn
impl StructuralPartialEq for BertFfn
Auto Trait Implementations§
impl Freeze for BertFfn
impl RefUnwindSafe for BertFfn
impl Send for BertFfn
impl Sync for BertFfn
impl Unpin for BertFfn
impl UnsafeUnpin for BertFfn
impl UnwindSafe for BertFfn
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
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