Skip to main content

Qwen3Config

Struct Qwen3Config 

Source
pub struct Qwen3Config {
Show 22 fields pub vocab_size: usize, pub hidden_size: usize, pub intermediate_size: usize, pub num_hidden_layers: usize, pub num_attention_heads: usize, pub num_key_value_heads: usize, pub head_dim: usize, pub max_position_embeddings: usize, pub rms_norm_eps: f64, pub rope_theta: f64, pub hidden_act: String, pub tie_word_embeddings: bool, pub attention_bias: bool, pub qk_norm: bool, pub sliding_window: Option<usize>, pub max_window_layers: usize, pub use_sliding_window: bool, pub num_experts: usize, pub num_experts_used: usize, pub expert_ffn_size: usize, pub shared_expert_ffn_size: usize, pub expert_weights_scale: f32,
}

Fields§

§vocab_size: usize§hidden_size: usize§intermediate_size: usize§num_hidden_layers: usize§num_attention_heads: usize§num_key_value_heads: usize§head_dim: usize§max_position_embeddings: usize§rms_norm_eps: f64§rope_theta: f64§hidden_act: String§tie_word_embeddings: bool§attention_bias: bool§qk_norm: bool

Whether the model uses per-head RMS-norm on Q/K before RoPE (a.k.a. “QK-norm”). Qwen 3 has it; Qwen 2 does NOT. Defaults to true to match the historical Qwen 3 build path.

§sliding_window: Option<usize>

Sliding-window size; None (or absent) means full causal.

§max_window_layers: usize

Number of leading layers that use full causal attention; layers [max_window_layers, num_hidden_layers) use sliding window when use_sliding_window is true. HF default: all layers full.

§use_sliding_window: bool§num_experts: usize

Total number of routed experts per MoE layer (0 = dense model). HF key: num_experts / n_routed_experts. GGUF key: qwen3.expert_count.

§num_experts_used: usize

Number of experts activated per token (top-k routing). HF key: num_experts_per_tok. GGUF key: qwen3.expert_used_count.

§expert_ffn_size: usize

FFN inner width for each routed expert. When 0 falls back to intermediate_size / num_experts_used to match upstream defaults. GGUF key: qwen3.expert_feed_forward_length.

§shared_expert_ffn_size: usize

FFN inner width for the always-on shared expert (0 = no shared expert). GGUF key: qwen3.expert_shared_feed_forward_length.

§expert_weights_scale: f32

Multiplier applied to routed-expert logits before softmax (default 1.0). GGUF key: qwen3.expert_weights_scale.

Implementations§

Source§

impl Qwen3Config

Source

pub fn from_file(path: &Path) -> Result<Qwen3Config, Error>

Source

pub fn kv_group_size(&self) -> usize

Repetition factor for GQA: how many Q heads share each KV head.

Source

pub fn q_proj_dim(&self) -> usize

Q projection output width (num_attention_heads * head_dim).

Source

pub fn kv_proj_dim(&self) -> usize

K/V projection output width (num_key_value_heads * head_dim).

Source

pub fn is_moe(&self) -> bool

True when the config carries MoE routing (num_experts > 0). qwen3-30b-a3b-instruct and qwen3-coder-next MoE variants will return true; dense Qwen3 returns false.

Source

pub fn expert_ffn_dim(&self) -> usize

Routed-expert SwiGLU inner width. Falls back to intermediate_size / num_experts_used when the explicit expert_ffn_size is absent (matches upstream defaults).

Source

pub fn shared_expert_ffn_dim(&self) -> usize

Shared-expert SwiGLU inner width (0 when there’s no shared expert).

Source

pub fn layer_uses_swa(&self, idx: usize) -> bool

Does layer idx use sliding-window attention?

Trait Implementations§

Source§

impl Clone for Qwen3Config

Source§

fn clone(&self) -> Qwen3Config

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 Qwen3Config

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Qwen3Config

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<Qwen3Config, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. 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<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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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