Skip to main content

GpuModelConfig

Struct GpuModelConfig 

Source
pub struct GpuModelConfig {
Show 19 fields pub vocab_size: usize, pub hidden_dim: usize, pub num_heads: usize, pub num_kv_heads: usize, pub num_layers: usize, pub intermediate_dim: usize, pub eps: f32, pub rope_theta: f32, pub explicit_head_dim: Option<usize>, pub layer_types: Option<Vec<String>>, pub linear_key_head_dim: Option<usize>, pub linear_value_head_dim: Option<usize>, pub linear_num_key_heads: Option<usize>, pub linear_num_value_heads: Option<usize>, pub linear_conv_kernel_dim: Option<usize>, pub constraints: Option<ArchConstraints>, pub num_experts: Option<usize>, pub num_experts_per_tok: Option<usize>, pub expert_intermediate_size: Option<usize>,
}
Expand description

Configuration for GPU model

Fields§

§vocab_size: usize

Vocabulary size

§hidden_dim: usize

Hidden dimension

§num_heads: usize

Number of attention heads (Q heads)

§num_kv_heads: usize

Number of key-value heads for GQA (IMP-088) For standard MHA: num_kv_heads == num_heads For GQA (Qwen, Llama-3): num_kv_heads < num_heads

§num_layers: usize

Number of transformer blocks

§intermediate_dim: usize

FFN intermediate dimension

§eps: f32

Layer normalization epsilon

§rope_theta: f32

RoPE theta for rotary position embeddings (Phase 21) Default: 10000.0 (standard LLaMA)

§explicit_head_dim: Option<usize>

GH-278: Explicit head dimension override Qwen3.5 uses head_dim=256 (vs Qwen2’s computed 128). When None, computed as hidden_dim / num_heads.

§layer_types: Option<Vec<String>>

GH-278: Per-layer attention type for hybrid models (Qwen3.5) None = all layers use standard attention Some(vec) = “attention” or “linear” per layer

§linear_key_head_dim: Option<usize>

GH-278: Linear attention key head dimension (Qwen3.5: 128)

§linear_value_head_dim: Option<usize>

GH-278: Linear attention value head dimension (Qwen3.5: 128)

§linear_num_key_heads: Option<usize>

GH-278: Number of key heads in linear attention (Qwen3.5: 16)

§linear_num_value_heads: Option<usize>

GH-278: Number of value heads in linear attention (Qwen3.5: 32)

§linear_conv_kernel_dim: Option<usize>

GH-278: Conv1D kernel size for linear attention (Qwen3.5: 4)

§constraints: Option<ArchConstraints>

GH-279: Architecture constraints for weight validation

§num_experts: Option<usize>

ALB-010: Number of MoE experts per layer (None = dense FFN) Qwen3.5-35B-A3B: 256 experts

§num_experts_per_tok: Option<usize>

ALB-010: Number of experts selected per token Qwen3.5-35B-A3B: 8 (top-8 routing)

§expert_intermediate_size: Option<usize>

ALB-010: Expert FFN intermediate dimension Qwen3.5-35B-A3B: 512 (vs 2048 for dense intermediate_dim)

Implementations§

Source§

impl GpuModelConfig

Source

pub fn head_dim(&self) -> usize

Head dimension — uses explicit override if set, otherwise hidden_dim / num_heads

Source

pub fn kv_dim(&self) -> usize

K/V dimension for GQA (num_kv_heads * head_dim)

Source

pub fn qkv_dim(&self) -> usize

Total QKV projection output dimension Q = num_heads * head_dim, K = V = num_kv_heads * head_dim When explicit_head_dim is set (e.g., Qwen3-Coder: head_dim=128, hidden=2048), num_heads * head_dim != hidden_dim, so we must use the actual head_dim.

Source

pub fn q_dim(&self) -> usize

Q projection output dimension (num_heads * head_dim) May differ from hidden_dim when explicit_head_dim is set.

Source

pub fn is_gqa(&self) -> bool

Whether this is a GQA model (num_kv_heads < num_heads)

Source

pub fn is_linear_layer(&self, block_idx: usize) -> bool

GH-278: Whether a specific layer uses linear attention

Accepts both HF naming (linear_attention) and short naming (linear).

Source

pub fn linear_key_dim(&self) -> usize

GH-278: Linear attention key dimension (num_key_heads * key_head_dim)

Source

pub fn linear_value_dim(&self) -> usize

GH-278: Linear attention value dimension (num_value_heads * value_head_dim)

Source

pub fn linear_conv_dim(&self) -> usize

GH-278: Linear attention conv dimension (2 * key_dim + value_dim)

Source

pub fn is_moe(&self) -> bool

ALB-010: Whether this model uses Mixture-of-Experts

Trait Implementations§

Source§

impl Clone for GpuModelConfig

Source§

fn clone(&self) -> GpuModelConfig

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 GpuModelConfig

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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<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> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more