diff --git a/arch/museglimmer/museglimmer.cpp b/arch/museglimmer/museglimmer.cpp index b9d7513b..0f493245 100644 --- a/arch/museglimmer/museglimmer.cpp +++ b/arch/museglimmer/museglimmer.cpp @@ -70,19 +70,6 @@ using namespace rad::arch; * the bare spelling too, so a text-only GGUF container of the same family reads the same way. */ namespace { -double cfg_f(const RadModelMeta* m, const char* key, double dflt) { - return rad_meta_getf(m, (std::string("text_config.") + key).c_str(), - rad_meta_getf(m, key, dflt)); -} -long long cfg_i(const RadModelMeta* m, const char* key, long long dflt) { - return rad_meta_geti(m, (std::string("text_config.") + key).c_str(), - rad_meta_geti(m, key, dflt)); -} -const char* cfg_s(const RadModelMeta* m, const char* key, const char* dflt) { - return rad_meta_gets(m, (std::string("text_config.") + key).c_str(), - rad_meta_gets(m, key, dflt)); -} - } // namespace /* One trunk layer. The rope ops exist only where layer_rope_theta says so; the branch is fixed @@ -177,13 +164,13 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c /* ---- the family's own config. Everything that changes the mathematics is required or read * from the family defaults the reference config class states; a wrong default yields fluent * wrong text, so nothing here falls back to a "reasonable" value silently. */ - m.qk_mult = (float)cfg_f(meta, "qk_scale_factor", 3.87); - m.post_eps = (float)cfg_f(meta, "post_norm_eps", 1e-8); - m.out_mult = (float)cfg_f(meta, "output_multiplier", 0.19611613513818404); - m.softcap = (float)cfg_f(meta, "final_logit_softcapping", 20.0); - m.window = cfg_i(meta, "sliding_window", 2048); - const double theta_rope = cfg_f(meta, "rope_parameters.rope_theta", - cfg_f(meta, "rope_theta", 0.0)); + m.qk_mult = (float)meta_text_getf(meta, "qk_scale_factor", 3.87); + m.post_eps = (float)meta_text_getf(meta, "post_norm_eps", 1e-8); + m.out_mult = (float)meta_text_getf(meta, "output_multiplier", 0.19611613513818404); + m.softcap = (float)meta_text_getf(meta, "final_logit_softcapping", 20.0); + m.window = meta_text_geti(meta, "sliding_window", 2048); + const double theta_rope = meta_text_getf(meta, "rope_parameters.rope_theta", + meta_text_getf(meta, "rope_theta", 0.0)); if (!(m.qk_mult > 0.0f) || !(m.out_mult > 0.0f) || !(m.post_eps > 0.0f) || m.window <= 0 || !(theta_rope > 0.0)) { fprintf(stderr, "radiance: museglimmer: qk_scale_factor %g output_multiplier %g " @@ -206,7 +193,7 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c * interval rule stands in. The two must agree where both exist: the schedule decides which * layers keep a long context, and a wrong layer still generates fluent text. */ std::vector full; - const char* kinds = cfg_s(meta, "layer_types", nullptr); + const char* kinds = meta_text_gets(meta, "layer_types", nullptr); if (kinds && *kinds) RAD_ARCH_TRY(parse_layer_kinds("museglimmer", kinds, {"full_attention"}, "sliding_attention", &full)); @@ -234,7 +221,7 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c /* Per-layer rotary: the shipped `layer_rope_theta`, else the family pattern (theta on the * sliding layers, 0 -- NoPE -- on the full ones). */ std::vector theta((size_t)g.n_layer, 0.0f); - const char* thetas = cfg_s(meta, "layer_rope_theta", nullptr); + const char* thetas = meta_text_gets(meta, "layer_rope_theta", nullptr); if (thetas && *thetas) { size_t i = 0; for_each_token(thetas, [&](const char* t, size_t n) { diff --git a/arch/museglimmer_ct/museglimmer_ct.cpp b/arch/museglimmer_ct/museglimmer_ct.cpp index 7e7cd981..44dea15c 100644 --- a/arch/museglimmer_ct/museglimmer_ct.cpp +++ b/arch/museglimmer_ct/museglimmer_ct.cpp @@ -50,19 +50,6 @@ using namespace rad::arch; * the bare spelling too, so a text-only GGUF container of the same family reads the same way. */ namespace { -double cfg_f(const RadModelMeta* m, const char* key, double dflt) { - return rad_meta_getf(m, (std::string("text_config.") + key).c_str(), - rad_meta_getf(m, key, dflt)); -} -long long cfg_i(const RadModelMeta* m, const char* key, long long dflt) { - return rad_meta_geti(m, (std::string("text_config.") + key).c_str(), - rad_meta_geti(m, key, dflt)); -} -const char* cfg_s(const RadModelMeta* m, const char* key, const char* dflt) { - return rad_meta_gets(m, (std::string("text_config.") + key).c_str(), - rad_meta_gets(m, key, dflt)); -} - } // namespace /* ---- one trunk linear, encoding-aware. The gemma3 G3Linear shape with gemma4_bf16's grids: the @@ -489,13 +476,13 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c /* ---- the family's own config. Everything that changes the mathematics is required or read * from the family defaults the reference config class states; a wrong default yields fluent * wrong text, so nothing here falls back to a "reasonable" value silently. */ - m.qk_mult = (float)cfg_f(meta, "qk_scale_factor", 3.87); - m.post_eps = (float)cfg_f(meta, "post_norm_eps", 1e-8); - m.out_mult = (float)cfg_f(meta, "output_multiplier", 0.19611613513818404); - m.softcap = (float)cfg_f(meta, "final_logit_softcapping", 20.0); - m.window = cfg_i(meta, "sliding_window", 2048); - const double theta_rope = cfg_f(meta, "rope_parameters.rope_theta", - cfg_f(meta, "rope_theta", 0.0)); + m.qk_mult = (float)meta_text_getf(meta, "qk_scale_factor", 3.87); + m.post_eps = (float)meta_text_getf(meta, "post_norm_eps", 1e-8); + m.out_mult = (float)meta_text_getf(meta, "output_multiplier", 0.19611613513818404); + m.softcap = (float)meta_text_getf(meta, "final_logit_softcapping", 20.0); + m.window = meta_text_geti(meta, "sliding_window", 2048); + const double theta_rope = meta_text_getf(meta, "rope_parameters.rope_theta", + meta_text_getf(meta, "rope_theta", 0.0)); if (!(m.qk_mult > 0.0f) || !(m.out_mult > 0.0f) || !(m.post_eps > 0.0f) || m.window <= 0 || !(theta_rope > 0.0)) { fprintf(stderr, "radiance: museglimmer: qk_scale_factor %g output_multiplier %g " @@ -518,7 +505,7 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c * interval rule stands in. The two must agree where both exist: the schedule decides which * layers keep a long context, and a wrong layer still generates fluent text. */ std::vector full; - const char* kinds = cfg_s(meta, "layer_types", nullptr); + const char* kinds = meta_text_gets(meta, "layer_types", nullptr); if (kinds && *kinds) RAD_ARCH_TRY(parse_layer_kinds("museglimmer", kinds, {"full_attention"}, "sliding_attention", &full)); @@ -546,7 +533,7 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c /* Per-layer rotary: the shipped `layer_rope_theta`, else the family pattern (theta on the * sliding layers, 0 -- NoPE -- on the full ones). */ std::vector theta((size_t)g.n_layer, 0.0f); - const char* thetas = cfg_s(meta, "layer_rope_theta", nullptr); + const char* thetas = meta_text_gets(meta, "layer_rope_theta", nullptr); if (thetas && *thetas) { size_t i = 0; for_each_token(thetas, [&](const char* t, size_t n) {