pub mod bake;
pub mod bert;
pub mod deepseek4;
pub mod deepseek4_metadata;
pub mod gemma4;
pub mod gemma4_mmproj;
pub mod gemma4_vision_mmproj;
pub mod llama3;
pub mod minimax_m2;
pub mod nomic_bert;
pub mod qwen35moe;
pub mod qwen35moe_full;
pub mod qwen3vl_text;
pub fn should_drop_source_tensor(model_type: &str, hf_name: &str) -> bool {
let stripped = hf_name.strip_prefix("bert.").unwrap_or(hf_name);
match model_type {
"bert" => {
if matches!(
stripped,
"embeddings.position_ids" | "pooler.dense.weight" | "pooler.dense.bias"
) {
return true;
}
if stripped.starts_with("cls.predictions")
|| stripped.starts_with("cls.seq_relationship")
{
return true;
}
}
"nomic_bert" => {
if stripped.contains("mlp.experts.bias") {
return true;
}
if matches!(
stripped,
"embeddings.position_ids" | "pooler.dense.weight" | "pooler.dense.bias"
) {
return true;
}
if stripped.starts_with("cls.predictions")
|| stripped.starts_with("cls.seq_relationship")
{
return true;
}
}
"deepseek_v4" => {
if hf_name.starts_with("mtp.") {
return true;
}
}
_ => {}
}
false
}
#[cfg(test)]
mod drop_list_tests {
use super::*;
#[test]
fn bert_drops_position_ids() {
assert!(should_drop_source_tensor("bert", "embeddings.position_ids"));
assert!(should_drop_source_tensor(
"bert",
"bert.embeddings.position_ids"
));
}
#[test]
fn bert_drops_pooler() {
assert!(should_drop_source_tensor("bert", "pooler.dense.weight"));
assert!(should_drop_source_tensor("bert", "pooler.dense.bias"));
}
#[test]
fn bert_drops_cls_heads() {
assert!(should_drop_source_tensor(
"bert",
"cls.predictions.transform.dense.weight"
));
assert!(should_drop_source_tensor(
"bert",
"cls.seq_relationship.weight"
));
}
#[test]
fn bert_keeps_real_weights() {
assert!(!should_drop_source_tensor(
"bert",
"embeddings.word_embeddings.weight"
));
assert!(!should_drop_source_tensor(
"bert",
"encoder.layer.0.attention.self.query.weight"
));
}
#[test]
fn nomic_bert_drops_expert_bias() {
assert!(should_drop_source_tensor(
"nomic_bert",
"encoder.layer.0.mlp.experts.bias"
));
}
#[test]
fn non_bert_drops_nothing() {
assert!(!should_drop_source_tensor(
"llama",
"embeddings.position_ids"
));
assert!(!should_drop_source_tensor(
"gemma4",
"model.layers.0.self_attn.q_proj.weight"
));
assert!(!should_drop_source_tensor("qwen3_5_moe", "anything"));
}
}