Skip to main content

MoeExpertWeights

Struct MoeExpertWeights 

Source
pub struct MoeExpertWeights {
    pub block: usize,
    pub expert: usize,
    pub gate: Option<RawTensor>,
    pub up: Option<RawTensor>,
    pub down: Option<RawTensor>,
}
Expand description

Raw weights for a single MoE expert.

Fields are Option<_> because GGUF checkpoints differ on which expert projections they store. OLMoE exposes gate / up / down; other MoE families may omit or rename a subset.

Fields§

§block: usize

Transformer block this expert belongs to.

§expert: usize

Expert index within the block.

§gate: Option<RawTensor>

ffn_gate projection, if present in the checkpoint.

§up: Option<RawTensor>

ffn_up projection, if present.

§down: Option<RawTensor>

ffn_down projection, if present.

Implementations§

Source§

impl MoeExpertWeights

Source

pub fn is_complete(&self) -> bool

Convenience: true if all three projections were located.

Examples found in repository?
examples/inspect_gguf.rs (line 126)
109fn print_moe_summary(layout: &GgufLayout) {
110    let experts = list_experts(layout);
111    println!("moe_pairs:     {} (block,expert)", experts.len());
112    if experts.is_empty() {
113        return;
114    }
115
116    let show = experts.len().min(8);
117    println!("moe_pairs_hd:  {:?}", &experts[..show]);
118
119    let (b, e) = experts[0];
120    let t1 = Instant::now();
121    match extract_expert(layout, b, e) {
122        Ok(w) => {
123            let extract_ms = t1.elapsed().as_secs_f64() * 1000.0;
124            println!(
125                "extract ({b},{e}): complete={} extract_ms={extract_ms:.2}",
126                w.is_complete()
127            );
128            let roles = [
129                ("gate", &w.gate, true),
130                ("up", &w.up, false),
131                ("down", &w.down, false),
132            ];
133            for (name, opt, show_stacked) in roles {
134                if let Some(t) = opt.as_ref() {
135                    let mut line = format!(
136                        "  {name}: dims={:?} bytes={} dtype={:?}",
137                        t.dims,
138                        t.bytes.len(),
139                        t.dtype
140                    );
141                    if show_stacked {
142                        line.push_str(&format!(" stacked={}", t.stacked_slice));
143                    }
144                    println!("{line}");
145                }
146            }
147        }
148        Err(err) => println!("extract ({b},{e}) failed: {err}"),
149    }
150}

Trait Implementations§

Source§

impl Clone for MoeExpertWeights

Source§

fn clone(&self) -> Self

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 MoeExpertWeights

Source§

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

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> 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> 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.