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: usizeTransformer block this expert belongs to.
expert: usizeExpert 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
impl MoeExpertWeights
Sourcepub fn is_complete(&self) -> bool
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
impl Clone for MoeExpertWeights
Auto Trait Implementations§
impl Forget for MoeExpertWeights
impl Freeze for MoeExpertWeights
impl Move for MoeExpertWeights
impl RefUnwindSafe for MoeExpertWeights
impl Send for MoeExpertWeightswhere
RawVecInner: Send,
impl Sync for MoeExpertWeightswhere
RawVecInner: Sync,
impl Unpin for MoeExpertWeights
impl UnsafeUnpin for MoeExpertWeightswhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<usize>: UnsafeUnpin,
impl UnwindSafe for MoeExpertWeightswhere
RawVecInner: UnwindSafe,
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
Mutably borrows from an owned value. Read more