pub struct GdnConfig {
pub hidden_dim: usize,
pub num_key_heads: usize,
pub num_value_heads: usize,
pub key_head_dim: usize,
pub value_head_dim: usize,
pub conv_kernel_size: usize,
pub rms_norm_eps: f32,
}Expand description
Dims for one Qwen35-style GDN block, with independent K/V head counts and K/V head dims (see the module docs for why all four are separate numbers).
Invariant: num_key_heads > 0 and num_value_heads % num_key_heads == 0. The quotient is the q/k replication factor; a config that violated
it would leave V heads with no K head to read from, so
gdn_forward_token asserts it instead of flooring the division and
silently pairing a V head with a K head that never fed it.
Fields§
§num_key_heads: usizeNumber of Q/K heads in the checkpoint (≤ num_value_heads).
num_value_heads: usizeNumber of V heads — also the length of ssm_dt / ssm_a and the
row count of ssm_beta / ssm_alpha.
key_head_dim: usizeWidth of one Q/K head (dk; sets the dk^-0.5 q scale).
value_head_dim: usizeWidth of one V head (dv; also the width of ssm_norm).
conv_kernel_size: usize§rms_norm_eps: f32Implementations§
Source§impl GdnConfig
impl GdnConfig
Sourcepub fn key_dim(&self) -> usize
pub fn key_dim(&self) -> usize
Channels occupied by Q (and, separately, by K) in the fused
projection: num_key_heads · key_head_dim.
Sourcepub fn value_dim(&self) -> usize
pub fn value_dim(&self) -> usize
Channels occupied by V in the fused projection — also the width of
the attn_gate (z) projection and of ssm_out’s input.
Sourcepub fn qkv_dim(&self) -> usize
pub fn qkv_dim(&self) -> usize
Fused Q‖K‖V width: key_dim + key_dim + value_dim.
This is the number the equal-head formula got wrong: 3 · num_value_heads · head_dim only coincides with the real width
when both head counts and both head dims match. It is the same
arithmetic that yields the split offsets, so a wrong total means
wrong Q/K/V slices — not a length mismatch anyone would notice.
Sourcepub fn heads_per_key_group(&self) -> usize
pub fn heads_per_key_group(&self) -> usize
q/k replication factor: how many V heads share one K head (the
repeat_interleave count in the reference). 1 for the
equal-head geometry.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for GdnConfig
impl RefUnwindSafe for GdnConfig
impl Send for GdnConfig
impl Sync for GdnConfig
impl Unpin for GdnConfig
impl UnsafeUnpin for GdnConfig
impl UnwindSafe for GdnConfig
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