Skip to content

Commit 46aec39

Browse files
justinchubyCopilot
andauthored
Add masked-diffusion GGUF architecture cohort (#582)
## Summary - add pinned llama.cpp GGUF support surfaces for `dream`, `llada`, `llada-moe`, and `rnd1` - implement bidirectional, cache-free dense and MoE masked-token graphs with exact Q/K normalization, routing, tying, fused-QKV, and shifted-logit semantics - enforce mask-token metadata, masked-diffusion-only dispatch, suffix-exact tensor closure, quantization roles, and malformed tensor rejection - keep runtime status deferred pending independent masked-step logits and deterministic multi-step generation parity ## Architecture decisions - the neural ABI is `input_ids -> logits + proposed_tokens`; timestep, noise schedule, remasking, seed, and iteration policy remain external - dense LLaDA alone reverses the pinned interleaved-RoPE Q/K permutation; Dream, LLaDA-MoE, and RND1 do not - LLaDA-MoE uses raw selected softmax weights; RND1 renormalizes selected weights - fused QKV splits by `[Q width, KV width, KV width]`; supported affine/native projection and expert quantization is preserved ## Validation - focused diffusion/config/tensor/builder tests: 822 passed - final cohort regression selection: 112 passed - broad non-integration suite excluding confirmed base failure: 5,854 passed, 52 skipped - full lintrunner: passed - pinned real `LLaDA-1.5-Tiny.Q2_K.gguf` SHA-256 verified; 57-tensor header census, mask token, and quantized CPU masked forward verified The unfiltered broad suite has two `glm_moe_dsa` shape/checker failures that reproduce unchanged on the stacked base (`072a6de`); this PR does not alter that model. --------- Signed-off-by: Justin Chu <[email protected]> Co-authored-by: Copilot App <[email protected]> Copilot-Session: 9db6165f-5116-473a-a5d7-1b68fe8ff095
1 parent 6dc9f43 commit 46aec39

18 files changed

Lines changed: 1462 additions & 75 deletions

‎docs/api/build_from_gguf.md‎

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ reason.
153153
| `cohere2` | — | `cohere2` | runtime deferred | supported |
154154
| `deci` | — | `llama` | supported | supported |
155155
| `deepseek4` | — | `deepseek_v4` | supported | supported |
156+
| `dream` | — | `dream` | runtime deferred | supported |
156157
| `eurobert` | — | — | config deferred; tensor_map deferred; graph deferred; runtime deferred | unreachable |
157158
| `exaone` | — | `exaone` | runtime deferred | supported |
158159
| `falcon` | — | `falcon` | supported | supported |
@@ -167,6 +168,8 @@ reason.
167168
| `internlm2` | — | `internlm2` | supported | rejected |
168169
| `jina-bert-v2` | — | — | config deferred; tensor_map deferred; graph deferred; runtime deferred | unreachable |
169170
| `jina-bert-v3` | — | — | config deferred; tensor_map deferred; graph deferred; runtime deferred | unreachable |
171+
| `llada` | — | `llada` | runtime deferred | supported |
172+
| `llada-moe` | — | `llada` | runtime deferred | supported |
170173
| `llama` | `mistral` | `llama` | supported | supported |
171174
| `mamba` | — | `mamba` | runtime deferred | rejected |
172175
| `mamba2` | — | `mamba2` | runtime deferred | rejected |
@@ -188,6 +191,7 @@ reason.
188191
| `qwen35` | — | `qwen3_5_text` | supported | supported |
189192
| `qwen35moe` | — | `qwen3_5_moe` | supported | supported |
190193
| `qwen3moe` | `qwen3_moe` | `qwen3_moe` | runtime deferred | supported |
194+
| `rnd1` | — | `llada` | runtime deferred | supported |
191195
| `rwkv6` | — | — | config deferred; tensor_map deferred; graph deferred; runtime deferred | unreachable |
192196
| `rwkv6qwen2` | — | — | config deferred; tensor_map deferred; graph deferred; runtime deferred | unreachable |
193197
| `rwkv7` | — | — | config deferred; tensor_map deferred; graph deferred; runtime deferred | unreachable |
@@ -204,6 +208,57 @@ validated against a vendored census of the 147 architectures llama.cpp defines
204208
at commit `8d9af256337d1a501250f9bbf4c0859a654bddd6`. Aliases are spellings
205209
llama.cpp does not emit but that mobius still accepts.
206210

211+
### Masked language-diffusion GGUF contract
212+
213+
`dream`, `llada`, `llada-moe`, and `rnd1` are full-sequence, bidirectional
214+
masked-token predictors. Their neural graph has one `input_ids [batch, sequence]`
215+
input and returns `logits [batch, sequence, vocabulary]` plus
216+
`proposed_tokens [batch, sequence]`. It has no causal mask, timestep/noise input,
217+
or KV cache. The caller owns the initial mask, mask-token insertion, seed,
218+
iteration count, confidence policy, and progressive remasking/commit schedule;
219+
Mobius does not infer a diffusion schedule from the GGUF.
220+
221+
`tokenizer.ggml.mask_token_id` is therefore required and range-checked. The
222+
llama.cpp `diffusion.shift_logits` default is preserved (`true` for Dream/RND1,
223+
explicitly `false` for the pinned LLaDA files). A causal task override or static
224+
cache is rejected before graph construction. Dense LLaDA alone reverses the
225+
llama.cpp interleaved-RoPE Q/K row permutation; Dream, LLaDA-MoE, and RND1 keep
226+
their Q/K rows in converter order. LLaDA-MoE retains raw selected softmax router
227+
weights, while RND1 renormalizes the selected weights. Fused QKV, when admitted
228+
by the pinned loader, is split as `[Q heads, KV heads, KV heads]` on the
229+
float-only path.
230+
231+
Compatible 2-D projections and routed experts retain supported native/affine
232+
quantization. Embeddings, norms, routers, and auxiliary tensors follow their
233+
actual consumer ABI; unrecognized sidecars, neural timestep tensors, and noise
234+
schedule tensors fail suffix-exact closure instead of being dropped.
235+
A fused QKV tensor is rejected whenever any mapped tensor activates
236+
quantization preservation, including a float fused tensor in an otherwise
237+
quantized file. The packed diffusion graph owns separate Q/K/V targets, so
238+
post-load splitting would leave those targets uninitialized. Use
239+
`keep_quantized=False` or `--dequantize` for such files; split-QKV quantized
240+
files remain supported. The pinned diffusion MoE family uses separate stacked
241+
gate, up, and down expert tensors rather than a fused gate-up tensor, and those
242+
tensors map directly to the graph's expert targets.
243+
244+
Runtime remains **deferred**. These immutable artifacts were pinned before
245+
payload download; only the 88.8 MB LLaDA file was downloaded. Its SHA-256,
246+
57-tensor census, mask token `126336`, `diffusion.shift_logits=false`, and
247+
quantized CPU masked-forward smoke test were verified. A successful import is
248+
not parity evidence.
249+
250+
| Architecture | GGUF revision / file | Size / LFS SHA-256 | Source config/tokenizer |
251+
|---|---|---|---|
252+
| `dream` | `mradermacher/Dream-v0-Base-7B-GGUF@8145ed37262d0d5769efefd33e156cd2ef98f4b2` / `Dream-v0-Base-7B.Q2_K.gguf` | 3,015,940,512 bytes / `c28476c7e7b0ea4e00e93f3b456f5e2e9b589f4200f29a975f845b8b9e5b0012` | `Dream-org/Dream-v0-Base-7B@6572adb5535263e4d1a337b56942ba48b6dee2a9` |
253+
| `llada` | `mradermacher/LLaDA-1.5-Tiny-GGUF@752094b7115a2aa5097b6be66187b19a46ff97dc` / `LLaDA-1.5-Tiny.Q2_K.gguf` | 88,765,952 bytes / `31c5fd2c1fc6bcd4e1d8b605774759252c130977562973d721a98c1d810b50a2` | Bundled tokenizer/config metadata verified; `JakeOh/LLaDA-1.5-Tiny` source revision is access-restricted. |
254+
| `llada-moe` | `mradermacher/LLaDA-MoE-7B-A1B-Instruct-GGUF@1080e16761f6f82a92e8bfb54a4c8998dfee0219` / `LLaDA-MoE-7B-A1B-Instruct.Q8_0.gguf` | 7,829,549,248 bytes / `7e50c4764866b64aba502d2b1e98fe20649c76f70df4b10fb9d2ece7c04fd2fd` | `inclusionAI/LLaDA-MoE-7B-A1B-Instruct@783d3467f108d28ac0a78d3e41af16ab05cabd8d` |
255+
| `rnd1` | `vikramkr/RND1-Base-0910-Q8_0-GGUF@93d8d35e3aac7b39311e48fc778777ac21529057` / `rnd1-base-0910-q8_0.gguf` | 32,483,927,584 bytes / `689949d9661c88930045c3511f893cacb41068c5133c43dcd388570abd1af28b` | `radicalnumerics/RND1-Base-0910@f1b49afd26579c1cd4ef7e00ae88376de63f2878` |
256+
257+
The support matrix will remain deferred until at least one artifact for each
258+
architecture passes independent Hugging Face or llama.cpp masked-step logits
259+
and deterministic multi-step generation parity with identical mask, seed, and
260+
remasking policy. The three multi-gigabyte artifacts above were not downloaded.
261+
207262
### Encoder-only GGUF contract
208263

209264
`bert` and `modern-bert` import only backbone files whose metadata requests

‎src/mobius/_configs/_base.py‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,8 @@ class BaseModelConfig:
400400
model_type: str | None = None
401401
bos_token_id: int | None = None
402402
eos_token_id: int | list[int] | None = None
403+
mask_token_id: int | None = None
404+
diffusion_shift_logits: bool = False
403405

404406

405407
@dataclasses.dataclass
@@ -785,6 +787,8 @@ def from_transformers(cls, config, parent_config=None) -> ArchitectureConfig:
785787
model_type=model_type,
786788
bos_token_id=getattr(config, "bos_token_id", None),
787789
eos_token_id=getattr(config, "eos_token_id", None),
790+
mask_token_id=getattr(config, "mask_token_id", None),
791+
diffusion_shift_logits=getattr(config, "diffusion_shift_logits", False),
788792
video_token_id=getattr(
789793
parent_config or config,
790794
"video_token_id",
@@ -1676,8 +1680,10 @@ def from_transformers(cls, config, parent_config=None) -> DFlashConfig:
16761680
"target_layer_ids": getattr(dflash_cfg, "target_layer_ids", None),
16771681
"mask_token_id": getattr(dflash_cfg, "mask_token_id", None),
16781682
}
1683+
base_fields = _shallow_fields(base)
1684+
base_fields.pop("mask_token_id", None)
16791685
return cls(
1680-
**_shallow_fields(base),
1686+
**base_fields,
16811687
target_layer_ids=dflash_cfg.get("target_layer_ids"),
16821688
block_size=getattr(config, "block_size", None),
16831689
mask_token_id=dflash_cfg.get("mask_token_id"),

‎src/mobius/_registry.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
DFlashDraftModel,
5353
DiffLlamaCausalLMModel,
5454
DogeCausalLMModel,
55+
DreamModel,
5556
Eagle3DraftModel,
5657
EncDecRNNTModel,
5758
Ernie45MoECausalLMModel,
@@ -81,6 +82,7 @@
8182
Lfm2CausalLMModel,
8283
Lfm2VlForConditionalGeneration,
8384
LLaDAModel,
85+
LLaDAMoEModel,
8486
Llama4CausalLMModel,
8587
MageVLForConditionalGeneration,
8688
MoECausalLMModel,
@@ -115,6 +117,7 @@
115117
Qwen35VL3ModelCausalLMModel,
116118
Qwen35VLTextModel,
117119
QwenCausalLMModel,
120+
RND1Model,
118121
SmolLM3CausalLMModel,
119122
SortformerDiarizationModel,
120123
WhisperForConditionalGeneration,
@@ -497,7 +500,12 @@ def _detect_fallback_registration(hf_config) -> ModelRegistration | None:
497500
"internlm2": ModelRegistration(InternLM2CausalLMModel),
498501
"llama4_text": ModelRegistration(Llama4CausalLMModel),
499502
"lfm2": ModelRegistration(Lfm2CausalLMModel, config_class=Lfm2Config),
503+
"dream": ModelRegistration(DreamModel, task="masked-diffusion"),
504+
"Dream": ModelRegistration(DreamModel, task="masked-diffusion"),
500505
"llada": ModelRegistration(LLaDAModel, task="masked-diffusion"),
506+
"llada_moe": ModelRegistration(LLaDAMoEModel, task="masked-diffusion"),
507+
"LLaDAMoEModel": ModelRegistration(LLaDAMoEModel, task="masked-diffusion"),
508+
"rnd1": ModelRegistration(RND1Model, task="masked-diffusion"),
501509
"modernbert-decoder": ModelRegistration(ModernBertDecoderModel),
502510
"mpt": ModelRegistration(MPTCausalLMModel),
503511
"nanochat": ModelRegistration(NanoChatCausalLMModel),

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

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,13 @@
124124
"exists."
125125
)
126126

127+
_DIFFUSION_RUNTIME_VALIDATION_PENDING = (
128+
"Config extraction, suffix-exact tensor closure, masked-diffusion task dispatch, "
129+
"and synthetic full-sequence execution are covered, but no pinned real GGUF has "
130+
"passed independent Hugging Face/llama.cpp masked-step logit parity and deterministic "
131+
"multi-step generation parity. Runtime packaging remains deferred until both exist."
132+
)
133+
127134
_ENCODER_GRAPH_MISMATCH = {
128135
"eurobert": (
129136
"EuroBERT uses pre-norm RMSNorm, RoPE, bias-free split Q/K/V attention, and a "
@@ -216,6 +223,65 @@
216223
runtime=Support.DEFERRED,
217224
reason=_RUNTIME_VALIDATION_PENDING,
218225
),
226+
# ----------------------------------------- Masked/diffusion language models
227+
GGUFArchitectureSpec(
228+
gguf_arch="dream",
229+
model_type="dream",
230+
tensor_map_recipe=("llama", "diffusion_fused_qkv"),
231+
config_postprocessor="dream",
232+
required_metadata=("attention.layer_norm_rms_epsilon",),
233+
runtime=Support.DEFERRED,
234+
reason=_DIFFUSION_RUNTIME_VALIDATION_PENDING,
235+
),
236+
GGUFArchitectureSpec(
237+
gguf_arch="llada",
238+
model_type="llada",
239+
tensor_map_recipe=("llama",),
240+
tensor_processor="llama",
241+
llama_qk_permute=True,
242+
config_postprocessor="llada",
243+
required_metadata=("attention.layer_norm_rms_epsilon",),
244+
runtime=Support.DEFERRED,
245+
reason=_DIFFUSION_RUNTIME_VALIDATION_PENDING,
246+
),
247+
GGUFArchitectureSpec(
248+
gguf_arch="llada-moe",
249+
model_type="llada",
250+
module_type="llada_moe",
251+
tensor_map_recipe=(
252+
"llama",
253+
"diffusion_fused_qkv",
254+
"moe_qk_norm_extras",
255+
"moe_extras",
256+
),
257+
config_postprocessor="llada_moe",
258+
required_metadata=(
259+
"attention.layer_norm_rms_epsilon",
260+
"expert_count",
261+
"expert_used_count",
262+
),
263+
runtime=Support.DEFERRED,
264+
reason=_DIFFUSION_RUNTIME_VALIDATION_PENDING,
265+
),
266+
GGUFArchitectureSpec(
267+
gguf_arch="rnd1",
268+
model_type="llada",
269+
module_type="rnd1",
270+
tensor_map_recipe=(
271+
"llama",
272+
"diffusion_fused_qkv",
273+
"moe_qk_norm_extras",
274+
"moe_extras",
275+
),
276+
config_postprocessor="rnd1",
277+
required_metadata=(
278+
"attention.layer_norm_rms_epsilon",
279+
"expert_count",
280+
"expert_used_count",
281+
),
282+
runtime=Support.DEFERRED,
283+
reason=_DIFFUSION_RUNTIME_VALIDATION_PENDING,
284+
),
219285
GGUFArchitectureSpec(
220286
gguf_arch="qwen35",
221287
model_type="qwen3_5_text",

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

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
#: Number of importable architectures. Pinned so that adding support is a
5757
#: deliberate act that also updates the documented support matrix, and so that
5858
#: accidentally losing an architecture is a failure rather than a silence.
59-
_EXPECTED_SUPPORTED_COUNT = 37
59+
_EXPECTED_SUPPORTED_COUNT = 41
6060

6161
# Quantized reachability is separately pinned from float importability. A new
6262
# architecture must explicitly prove that its graph exposes packed projection
@@ -68,6 +68,7 @@
6868
"cohere2",
6969
"deci",
7070
"deepseek4",
71+
"dream",
7172
"exaone",
7273
"falcon",
7374
"gemma",
@@ -77,6 +78,8 @@
7778
"gpt2",
7879
"granitemoe",
7980
"hunyuan-dense",
81+
"llada",
82+
"llada-moe",
8083
"llama",
8184
"modern-bert",
8285
"muse-glimmer",
@@ -92,6 +95,7 @@
9295
"qwen35",
9396
"qwen35moe",
9497
"qwen3moe",
98+
"rnd1",
9599
"smollm3",
96100
"stablelm",
97101
"starcoder2",
@@ -292,6 +296,10 @@ class TestPinnedTensorClosure:
292296
"modern-bert",
293297
"t5",
294298
"t5encoder",
299+
"dream",
300+
"llada",
301+
"llada-moe",
302+
"rnd1",
295303
)
296304

297305
@staticmethod
@@ -314,7 +322,16 @@ def test_every_pinned_tensor_family_closes(self, architecture: str) -> None:
314322
assert not self._unmapped(architecture)
315323

316324
@pytest.mark.parametrize(
317-
"architecture", ["olmoe", "phimoe", "qwen2moe", "qwen3moe", "granitemoe"]
325+
"architecture",
326+
[
327+
"olmoe",
328+
"phimoe",
329+
"qwen2moe",
330+
"qwen3moe",
331+
"granitemoe",
332+
"llada-moe",
333+
"rnd1",
334+
],
318335
)
319336
def test_pinned_expert_suffixes_close_without_drops(self, architecture: str) -> None:
320337
upstream = upstream_architectures()[architecture]
@@ -328,6 +345,38 @@ def test_pinned_expert_suffixes_close_without_drops(self, architecture: str) ->
328345
name = family.replace("{bid}", "0") + f".{suffix}"
329346
assert map_gguf_to_hf_names(name, architecture) is not None, name
330347

348+
@pytest.mark.parametrize("architecture", ["dream", "llada", "llada-moe", "rnd1"])
349+
@pytest.mark.parametrize(
350+
"malformed",
351+
[
352+
"token_embd.scale",
353+
"blk.0.attn_q.weight.extra",
354+
"blk.0.diffusion_timestep.weight",
355+
"blk.0.noise_schedule.weight",
356+
],
357+
)
358+
def test_diffusion_tensor_closure_rejects_unpinned_suffixes(
359+
self, architecture: str, malformed: str
360+
) -> None:
361+
assert map_gguf_to_hf_names(malformed, architecture) is None
362+
363+
@pytest.mark.parametrize("architecture", ["llada-moe", "rnd1"])
364+
@pytest.mark.parametrize(
365+
"malformed",
366+
[
367+
"blk.0.ffn_gate_inp.scale",
368+
"blk.0.ffn_gate_exps.scales",
369+
"blk.0.ffn_down_exps.zero_point",
370+
"blk.0.ffn_gate.weight",
371+
"blk.0.ffn_up.weight",
372+
"blk.0.ffn_down.weight",
373+
],
374+
)
375+
def test_diffusion_moe_rejects_invalid_expert_sidecars(
376+
self, architecture: str, malformed: str
377+
) -> None:
378+
assert map_gguf_to_hf_names(malformed, architecture) is None
379+
331380
def test_deleting_one_mapping_breaks_closure(self) -> None:
332381
"""Falsify the support claim rather than only testing the happy path."""
333382
olmo_mapping = _MAPPING_TABLES["olmo"]

0 commit comments

Comments
 (0)