model_geometry_test: a qwen4exp fixture with the real Flash-Next key set, equal to the defaults field by field

The qwen4exp reader's optional reads (ssm.*, key_length, the interval, the expert widths, rope dims / sections
/ base, the epsilon) and its four refusals ran only on the six-key fixture, so the one path that could refuse the
working model was untested (review finding 5).  The fixture writer gains f32 and u32-array values for it.
model_geometry_test --real on the Mac's Qwen3.8-Flash-Next-Q2.gguf reads it (48 trunk layers, 1 draft block,
every field the default).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
This commit is contained in:
Robert KarlandClaude Fable 5.1 committed 2026-10-11 11:24:00 -07:00
1 parent 30e3add968
commit afec2f1aea
2 files changed
+51 -1

No files matched your search

+11 -1
View File
@@ -18,14 +18,18 @@ namespace fixture {
struct Kv {
std::string key;
uint32_t type = 8; ///< GGUF value type: 8 string, 2 u16, 4 u32, 5 i32
uint32_t type = 8; ///< GGUF value type: 8 string, 2 u16, 4 u32, 5 i32, 6 f32, 9 array (of u32)
std::string s;
uint64_t u = 0;
float f = 0.0f;
std::vector<uint32_t> a; ///< the elements of a u32 array
};
inline Kv str(const std::string& k, const std::string& v) { return Kv{k, 8, v, 0}; }
inline Kv u16(const std::string& k, uint64_t v) { return Kv{k, 2, {}, v}; }
inline Kv i32(const std::string& k, uint64_t v) { return Kv{k, 5, {}, v}; }
inline Kv u32(const std::string& k, uint64_t v) { return Kv{k, 4, {}, v}; }
inline Kv f32(const std::string& k, float v) { return Kv{k, 6, {}, 0, v}; }
inline Kv u32s(const std::string& k, const std::vector<uint32_t>& v) { return Kv{k, 9, {}, 0, 0.0f, v}; }
struct Tensor {
std::string name;
@@ -65,6 +69,12 @@ inline Written write(const std::filesystem::path& path, const std::vector<Kv>& k
if (k.type == 8) puts(k.s);
else if (k.type == 2) { const uint16_t v = (uint16_t) k.u; put(&v, 2); }
else if (k.type == 4 || k.type == 5) { const uint32_t v = (uint32_t) k.u; put(&v, 4); }
else if (k.type == 6) put(&k.f, 4);
else if (k.type == 9) { // an array: element type u32, count, elements
put32(4);
put64(k.a.size());
for (const uint32_t v : k.a) put32(v);
}
else throw std::runtime_error("fixture: unsupported metadata type");
}
Written w;
+40
View File
@@ -125,6 +125,46 @@ void qwen4exp() {
"qwen4exp: the GDN and expert widths keep Flash-Next's defaults when the file has no key for them");
check(strata::check_architecture(strata::GgufFile(p.string())).empty(), "qwen4exp passes the architecture guard");
// the real Flash-Next key set (the Q2 file's metadata: ssm.*, key_length, the interval, the expert widths, the
// rope keys): the reader's optional reads and its four refusals run on the working model's values and must land
// on the defaults field by field - this is the one path that could refuse the model the engine already serves
const fs::path full = d.path / "flash-full.gguf";
// (block_count 48 with no draft block: the guard's qwen4exp branch wants the literal 48, as it always did)
fixture::write(full, {fixture::str("general.architecture", "qwen4exp"), fixture::u32("qwen4exp.block_count", 48),
fixture::u32("qwen4exp.embedding_length", 2560),
fixture::u32("qwen4exp.expert_count", 512), fixture::u32("qwen4exp.expert_used_count", 10),
fixture::u32("qwen4exp.attention.head_count", 24), fixture::u32("qwen4exp.attention.head_count_kv", 2),
fixture::u32("qwen4exp.attention.key_length", 256), fixture::u32("qwen4exp.full_attention_interval", 4),
fixture::u32("qwen4exp.ssm.conv_kernel", 4), fixture::u32("qwen4exp.ssm.state_size", 128),
fixture::u32("qwen4exp.ssm.group_count", 16), fixture::u32("qwen4exp.ssm.time_step_rank", 48),
fixture::u32("qwen4exp.ssm.inner_size", 6144), fixture::u32("qwen4exp.expert_feed_forward_length", 640),
fixture::u32("qwen4exp.expert_shared_feed_forward_length", 640),
fixture::u32("qwen4exp.rope.dimension_count", 64), fixture::u32s("qwen4exp.rope.dimension_sections", {11, 11, 10, 0}),
fixture::f32("qwen4exp.rope.freq_base", 10000000.0f),
fixture::f32("qwen4exp.attention.layer_norm_rms_epsilon", 1e-6f)},
{});
ModelGeometry gf;
const bool okf = read(full.string(), gf, err);
check(okf, "a qwen4exp file with the full key set reads" + (okf ? std::string() : ": " + err));
const ModelGeometry def; // the struct's defaults are Flash-Next's
check(gf.arch == def.arch && gf.n_embd == def.n_embd && gf.n_layers == def.n_layers && gf.nextn_layers == 0 &&
gf.qsa_interval == def.qsa_interval && gf.n_vocab == def.n_vocab,
"full key set: n_embd, 48 trunk layers, the interval, n_vocab equal the defaults");
check(gf.ssm_state_size == def.ssm_state_size && gf.ssm_k_heads == def.ssm_k_heads && gf.ssm_v_heads == def.ssm_v_heads &&
gf.ssm_d_conv == def.ssm_d_conv && gf.ssm_conv_channels == def.ssm_conv_channels &&
gf.ssm_value_dim == def.ssm_value_dim,
"full key set: the GDN fields and the derived conv channels / value dim equal the defaults");
check(gf.n_head == def.n_head && gf.n_head_kv == def.n_head_kv && gf.head_dim == def.head_dim && gf.n_rot == def.n_rot &&
gf.rope_sections[0] == 11 && gf.rope_sections[1] == 11 && gf.rope_sections[2] == 10 && gf.rope_sections[3] == 0 &&
gf.rope_base == def.rope_base && std::fabs(gf.rms_eps - def.rms_eps) < 1e-12,
"full key set: the attention and rope fields equal the defaults");
check(gf.idx_q_heads == def.idx_q_heads && gf.idx_key_dim == def.idx_key_dim && gf.hc == def.hc && gf.hc_lr == def.hc_lr &&
gf.n_expert == def.n_expert && gf.n_expert_used == def.n_expert_used && gf.n_ff == def.n_ff &&
gf.n_ff_shexp == def.n_ff_shexp && gf.has_ple == def.has_ple && gf.has_indexer(),
"full key set: the indexer, hc, the MoE widths and the PLE equal the defaults");
const std::string guard_full = strata::check_architecture(strata::GgufFile(full.string()));
check(guard_full.empty(), "the full-key file passes the guard" + (guard_full.empty() ? std::string() : ": " + guard_full));
// the guard and the reader refuse an unknown architecture by its name
const fs::path q = d.path / "other.gguf";
fixture::write(q, {fixture::str("general.architecture", "llama"), fixture::u32("llama.block_count", 32)}, {});