Skip to content

Commit b592189

Browse files
committed
Close final GGUF review gaps
Reject DBRX head geometries that cannot satisfy grouped-query attention and lock Jina-v3 explicit feature extraction to the pooled GGUF output ABI with builder regressions. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 71862fcb-bc9a-4734-b047-b5376afabc3e Signed-off-by: Justin Chu <[email protected]>
1 parent 7a1d648 commit b592189

3 files changed

Lines changed: 26 additions & 2 deletions

File tree

‎src/mobius/integrations/gguf/_builder.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3399,6 +3399,7 @@ def _raise_for_invalid_moe_cohort_tensor_contract(gguf_model) -> None:
33993399
if (
34003400
min(hidden, intermediate, layers, heads, kv_heads, experts, top_k, vocab) <= 0
34013401
or hidden % heads
3402+
or heads % kv_heads
34023403
or top_k > experts
34033404
):
34043405
raise ValueError(f"{architecture} GGUF has invalid MoE geometry")

‎src/mobius/integrations/gguf/_moe_cohort_test.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,14 @@ def test_cohort_tensor_contract_rejects_mutations(architecture: str, mutation: s
572572
_raise_for_invalid_moe_cohort_tensor_contract(source)
573573

574574

575+
def test_dbrx_tensor_contract_rejects_non_grouped_kv_heads() -> None:
576+
source = _fixture("dbrx")
577+
source.metadata["dbrx.attention.head_count_kv"] = 3
578+
579+
with pytest.raises(ValueError, match="invalid MoE geometry"):
580+
_raise_for_invalid_moe_cohort_tensor_contract(source)
581+
582+
575583
def test_cohort_config_preserves_routing_and_schedule_semantics() -> None:
576584
arctic = gguf_to_config(_fixture("arctic"))
577585
assert arctic.norm_topk_prob

‎src/mobius/integrations/gguf/_specialized_encoders_test.py‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ def test_jina_v3_rejects_unknown_rope_scaling_type() -> None:
225225
gguf_to_config(_FakeGGUF("jina-bert-v3", metadata, _jina_v3_tensors()))
226226

227227

228-
def _write_tiny_jina_v3(path: Path) -> None:
228+
def _write_tiny_jina_v3(path: Path, *, pooling_type: int = 0) -> None:
229229
from gguf import GGUFWriter
230230

231231
arch = "jina-bert-v3"
@@ -241,7 +241,7 @@ def _write_tiny_jina_v3(path: Path) -> None:
241241
writer.add_rope_dimension_count(4)
242242
writer.add_bool(f"{arch}.attention.causal", False)
243243
writer.add_float32(f"{arch}.attention.layer_norm_epsilon", 1e-5)
244-
writer.add_uint32(f"{arch}.pooling_type", 0)
244+
writer.add_uint32(f"{arch}.pooling_type", pooling_type)
245245
writer.add_uint32("tokenizer.ggml.token_type_count", 2)
246246
for name, shape in _jina_v3_tensors(fused_qkv=True).items():
247247
writer.add_tensor(name, np.zeros(shape, dtype=np.float32))
@@ -392,6 +392,21 @@ def test_jina_v3_builder_rejects_cache_and_incompatible_task_before_dispatch(
392392
build_from_gguf(path, task="text-generation")
393393

394394

395+
def test_jina_v3_explicit_feature_extraction_preserves_pooled_output_abi(
396+
tmp_path: Path,
397+
) -> None:
398+
from mobius.integrations.gguf import build_from_gguf
399+
400+
path = tmp_path / "jina-v3-pooled.gguf"
401+
_write_tiny_jina_v3(path, pooling_type=1)
402+
403+
default = build_from_gguf(path)["model"].graph
404+
explicit = build_from_gguf(path, task="feature-extraction")["model"].graph
405+
406+
assert [value.name for value in default.outputs] == ["sentence_embedding"]
407+
assert [value.name for value in explicit.outputs] == ["sentence_embedding"]
408+
409+
395410
def test_jina_v3_exact_tensor_mapping_and_singleton_token_type_transform() -> None:
396411
from mobius.integrations.gguf._builder import _normalize_gguf_weights
397412

0 commit comments

Comments
 (0)