diff --git a/core/format/checkpoint.cpp b/core/format/checkpoint.cpp index 982aef00..57a82abf 100644 --- a/core/format/checkpoint.cpp +++ b/core/format/checkpoint.cpp @@ -233,6 +233,9 @@ int meta_from_config_json(const std::string& dir, MetaOwn* out) { /* LFM2-VL names the wrapper, not the text model; one plugin serves LFM2 with or without * its tower. `model_type` stays in the free-form keys. */ if (out->arch == "lfm2vl") out->arch = "lfm2"; + /* Gemma 4 12B (`gemma4_unified`): its text model is Gemma 4's, served by the gemma4 + * plugins; `model_type` tells them apart. */ + if (out->arch == "gemma4unified") out->arch = "gemma4"; } if (const char* nm = gs("_name_or_path")) out->name = nm; diff --git a/tests/checkpoint_test.cpp b/tests/checkpoint_test.cpp index 227d1a40..29b1cb27 100644 --- a/tests/checkpoint_test.cpp +++ b/tests/checkpoint_test.cpp @@ -1925,6 +1925,21 @@ TEST(config_json_fills_the_model_meta_as_each_family_spells_it) { "lfm2", 0, 1024, 16, 8, 64, 0, 0, 0, 0, 0, 0, 1e-5, 1e4, { { "layer_types", "conv full_attention conv" }, { "hidden_size", "7" }, { "vision_config.hidden_size", "768" } } }, + { "Gemma 4 12B: the unified wrapper maps to gemma4, its model_type stays, null experts", + R"({"model_type":"gemma4_unified","eos_token_id":[1,106], + "text_config":{"model_type":"gemma4_unified_text","hidden_size":3840, + "num_attention_heads":16,"num_key_value_heads":8,"num_global_key_value_heads":1, + "head_dim":256,"global_head_dim":512,"num_hidden_layers":48, + "intermediate_size":15360,"moe_intermediate_size":null,"num_experts":null, + "rms_norm_eps":1e-06,"vocab_size":262144,"max_position_embeddings":262144, + "rope_parameters":{"full_attention":{"rope_theta":1000000.0}, + "sliding_attention":{"rope_theta":10000.0}}}, + "vision_config":{"model_type":"gemma4_unified_vision"}})", + "gemma4", 48, 3840, 16, 8, 256, 15360, 262144, 262144, 0, 0, 0, 1e-6, 1e4, + { { "model_type", "gemma4_unified" }, { "global_head_dim", "512" }, + { "num_global_key_value_heads", "1" }, + { "rope_parameters.full_attention.rope_theta", "1000000" }, + { "vision_config.model_type", "gemma4_unified_vision" } } }, { "rope_parameters wins over rope_theta", R"({"model_type":"llama","rope_theta":10000,"rope_parameters":{"rope_theta":5000000}})", "llama", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1e-6, 5e6, {} },