Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions crates/larql-compute/examples/compare_decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ fn main() {
ffn_up_bias: None,
ffn_down_bias: None,
moe: None,
ffn_is_remote: false,
moe_combined_output_norm: false,
moe_outer_post_norm: None,
})
Expand Down Expand Up @@ -282,6 +283,7 @@ fn main() {
ffn_up_bias: None,
ffn_down_bias: None,
moe: None,
ffn_is_remote: false,
moe_combined_output_norm: false,
moe_outer_post_norm: None,
})
Expand Down
3 changes: 3 additions & 0 deletions crates/larql-compute/examples/compare_formats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ fn main() {
ffn_up_bias: None,
ffn_down_bias: None,
moe: None,
ffn_is_remote: false,
moe_combined_output_norm: false,
moe_outer_post_norm: None,
})
Expand Down Expand Up @@ -293,6 +294,7 @@ fn main() {
ffn_up_bias: None,
ffn_down_bias: None,
moe: None,
ffn_is_remote: false,
moe_combined_output_norm: false,
moe_outer_post_norm: None,
})
Expand Down Expand Up @@ -396,6 +398,7 @@ fn main() {
ffn_up_bias: None,
ffn_down_bias: None,
moe: None,
ffn_is_remote: false,
moe_combined_output_norm: false,
moe_outer_post_norm: None,
})
Expand Down
5 changes: 5 additions & 0 deletions crates/larql-compute/examples/compare_ollama.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ fn main() {
ffn_up_bias: None,
ffn_down_bias: None,
moe: None,
ffn_is_remote: false,
moe_combined_output_norm: false,
moe_outer_post_norm: None,
})
Expand Down Expand Up @@ -279,6 +280,7 @@ fn main() {
ffn_up_bias: None,
ffn_down_bias: None,
moe: None,
ffn_is_remote: false,
moe_combined_output_norm: false,
moe_outer_post_norm: None,
})
Expand Down Expand Up @@ -365,6 +367,7 @@ fn main() {
ffn_up_bias: None,
ffn_down_bias: None,
moe: None,
ffn_is_remote: false,
moe_combined_output_norm: false,
moe_outer_post_norm: None,
})
Expand Down Expand Up @@ -458,6 +461,7 @@ fn main() {
ffn_up_bias: None,
ffn_down_bias: None,
moe: None,
ffn_is_remote: false,
moe_combined_output_norm: false,
moe_outer_post_norm: None,
})
Expand Down Expand Up @@ -541,6 +545,7 @@ fn main() {
ffn_up_bias: None,
ffn_down_bias: None,
moe: None,
ffn_is_remote: false,
moe_combined_output_norm: false,
moe_outer_post_norm: None,
})
Expand Down
2 changes: 2 additions & 0 deletions crates/larql-compute/examples/compare_pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ fn main() {
ffn_up_bias: None,
ffn_down_bias: None,
moe: None,
ffn_is_remote: false,
moe_combined_output_norm: false,
moe_outer_post_norm: None,
})
Expand Down Expand Up @@ -300,6 +301,7 @@ fn main() {
ffn_up_bias: None,
ffn_down_bias: None,
moe: None,
ffn_is_remote: false,
moe_combined_output_norm: false,
moe_outer_post_norm: None,
})
Expand Down
1 change: 1 addition & 0 deletions crates/larql-compute/examples/demo_architecture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ fn main() {
ffn_up_bias: None,
ffn_down_bias: None,
moe: None,
ffn_is_remote: false,
moe_combined_output_norm: false,
moe_outer_post_norm: None,
};
Expand Down
3 changes: 3 additions & 0 deletions crates/larql-compute/examples/diag_decode_pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ fn main() {
ffn_up_bias: None,
ffn_down_bias: None,
moe: None,
ffn_is_remote: false,
moe_combined_output_norm: false,
moe_outer_post_norm: None,
};
Expand Down Expand Up @@ -299,6 +300,7 @@ fn main() {
ffn_up_bias: None,
ffn_down_bias: None,
moe: None,
ffn_is_remote: false,
moe_combined_output_norm: false,
moe_outer_post_norm: None,
};
Expand Down Expand Up @@ -388,6 +390,7 @@ fn main() {
ffn_up_bias: None,
ffn_down_bias: None,
moe: None,
ffn_is_remote: false,
moe_combined_output_norm: false,
moe_outer_post_norm: None,
};
Expand Down
1 change: 1 addition & 0 deletions crates/larql-server/examples/bench_expert_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ fn main() {
// first half — but we set this *after* peeking at num_experts below.
expert_filter: None,
unit_filter: None,
moe_remote: None,
};

let path_str = args[1].clone();
Expand Down
1 change: 1 addition & 0 deletions crates/larql-server/examples/openai_demo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ fn load_default(path: &str) -> Result<LoadedModel, Box<dyn std::error::Error + S
release_mmap_after_request: false,
expert_filter: None,
unit_filter: None,
moe_remote: None,
};
load_single_vindex(path, opts)
}
Expand Down
21 changes: 21 additions & 0 deletions crates/larql-server/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,13 @@ pub fn model_functional(id: &str) -> Arc<LoadedModel> {
ffn_l2_cache: larql_server::ffn_l2_cache::FfnL2Cache::new(1),
expert_filter: None,
unit_filter: None,
moe_remote: None,
#[cfg(feature = "metal-experts")]
metal_backend: std::sync::OnceLock::new(),
#[cfg(feature = "metal-experts")]
moe_scratches: std::sync::Mutex::new(std::collections::HashMap::new()),
#[cfg(feature = "metal-experts")]
metal_ffn_layer_bufs: std::sync::OnceLock::new(),
})
}

Expand Down Expand Up @@ -171,6 +178,13 @@ pub fn model_infer_enabled(id: &str) -> Arc<LoadedModel> {
ffn_l2_cache: larql_server::ffn_l2_cache::FfnL2Cache::new(1),
expert_filter: None,
unit_filter: None,
moe_remote: None,
#[cfg(feature = "metal-experts")]
metal_backend: std::sync::OnceLock::new(),
#[cfg(feature = "metal-experts")]
moe_scratches: std::sync::Mutex::new(std::collections::HashMap::new()),
#[cfg(feature = "metal-experts")]
metal_ffn_layer_bufs: std::sync::OnceLock::new(),
})
}

Expand Down Expand Up @@ -240,6 +254,13 @@ impl ModelBuilder {
ffn_l2_cache: FfnL2Cache::new(1),
expert_filter: None,
unit_filter: None,
moe_remote: None,
#[cfg(feature = "metal-experts")]
metal_backend: std::sync::OnceLock::new(),
#[cfg(feature = "metal-experts")]
moe_scratches: std::sync::Mutex::new(std::collections::HashMap::new()),
#[cfg(feature = "metal-experts")]
metal_ffn_layer_bufs: std::sync::OnceLock::new(),
})
}
}
Expand Down
21 changes: 18 additions & 3 deletions crates/larql-server/tests/test_expert_endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ fn make_loaded_model(
down_top_k: 1,
has_model_weights: false,
model_config: None,
fp4: None,
ffn_layout: None,
};

// Build ModelWeights with expert data in raw_bytes (no mmap needed).
Expand All @@ -238,6 +240,7 @@ fn make_loaded_model(
vectors,
raw_bytes,
packed_mmaps: HashMap::new(),
skipped_tensors: Vec::new(),
packed_byte_ranges: HashMap::new(),
embed: embed.clone(),
lm_head: embed,
Expand All @@ -253,7 +256,7 @@ fn make_loaded_model(
};

let lock = OnceLock::new();
lock.set(weights).ok();
lock.set(std::sync::RwLock::new(weights)).ok();

LoadedModel {
id: "test-moe".into(),
Expand All @@ -272,7 +275,14 @@ fn make_loaded_model(
probe_labels: HashMap::new(),
ffn_l2_cache: FfnL2Cache::new(1),
expert_filter: None,
unit_filter: None,
moe_remote: None,
#[cfg(feature = "metal-experts")]
metal_backend: std::sync::OnceLock::new(),
#[cfg(feature = "metal-experts")]
moe_scratches: std::sync::Mutex::new(HashMap::new()),
#[cfg(feature = "metal-experts")]
metal_ffn_layer_bufs: std::sync::OnceLock::new(),
}
}

Expand Down Expand Up @@ -307,11 +317,16 @@ fn local_output(
router_proj: &[f32],
pre_norm: &[f32],
) -> Vec<f32> {
let gate_up_per_expert = gate_up.len() / NUM_EXPERTS;
let down_per_expert = down.len() / NUM_EXPERTS;
let experts_gate_up: Vec<&[u8]> = gate_up.chunks(gate_up_per_expert).collect();
let experts_down: Vec<&[u8]> = down.chunks(down_per_expert).collect();
cpu_moe_forward(
h,
&MoeLayerWeights {
experts_gate_up: gate_up,
experts_down: down,
experts_gate_up,
experts_down,
expert_data_format: larql_compute::QuantFormat::BF16,
router_proj,
router_scale: &[],
router_per_expert_scale: &[],
Expand Down
7 changes: 7 additions & 0 deletions crates/larql-server/tests/test_http_full_routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ fn model_functional_with_labels(id: &str) -> Arc<LoadedModel> {
ffn_l2_cache: larql_server::ffn_l2_cache::FfnL2Cache::new(1),
expert_filter: None,
unit_filter: None,
moe_remote: None,
#[cfg(feature = "metal-experts")]
metal_backend: std::sync::OnceLock::new(),
#[cfg(feature = "metal-experts")]
moe_scratches: std::sync::Mutex::new(std::collections::HashMap::new()),
#[cfg(feature = "metal-experts")]
metal_ffn_layer_bufs: std::sync::OnceLock::new(),
})
}

Expand Down
7 changes: 7 additions & 0 deletions crates/larql-server/tests/test_unit_band_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,13 @@ fn make_minimal_model(layer_bands: Option<LayerBands>) -> Arc<LoadedModel> {
ffn_l2_cache: FfnL2Cache::new(1),
expert_filter: None,
unit_filter: None,
moe_remote: None,
#[cfg(feature = "metal-experts")]
metal_backend: std::sync::OnceLock::new(),
#[cfg(feature = "metal-experts")]
moe_scratches: std::sync::Mutex::new(std::collections::HashMap::new()),
#[cfg(feature = "metal-experts")]
metal_ffn_layer_bufs: std::sync::OnceLock::new(),
})
}

Expand Down
14 changes: 14 additions & 0 deletions crates/larql-server/tests/test_unit_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ fn make_tiny_model(id: &str) -> Arc<LoadedModel> {
ffn_l2_cache: FfnL2Cache::new(1),
expert_filter: None,
unit_filter: None,
moe_remote: None,
#[cfg(feature = "metal-experts")]
metal_backend: std::sync::OnceLock::new(),
#[cfg(feature = "metal-experts")]
moe_scratches: std::sync::Mutex::new(std::collections::HashMap::new()),
#[cfg(feature = "metal-experts")]
metal_ffn_layer_bufs: std::sync::OnceLock::new(),
})
}

Expand Down Expand Up @@ -172,6 +179,13 @@ fn make_loaded_model_for_warmup() -> Arc<LoadedModel> {
ffn_l2_cache: FfnL2Cache::new(1),
expert_filter: None,
unit_filter: None,
moe_remote: None,
#[cfg(feature = "metal-experts")]
metal_backend: std::sync::OnceLock::new(),
#[cfg(feature = "metal-experts")]
moe_scratches: std::sync::Mutex::new(std::collections::HashMap::new()),
#[cfg(feature = "metal-experts")]
metal_ffn_layer_bufs: std::sync::OnceLock::new(),
})
}

Expand Down
Loading