Skip to content

MTP fixes - #390

Open
danielhanchen wants to merge 47 commits into
base/upstream-184862801from
mtp-fixes
Open

danielhanchen wants to merge 47 commits into
base/upstream-184862801from
mtp-fixes

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Fixes for the DSpark (MTP) draft from ggml-org#32218, including the looped Inkling-2-Small architecture (#389).

  • Converting a draft from a checkpoint folder that also holds the target's quantization config no longer fails. The draft is BF16, so it skips the dequant step.
  • Looped targets: draft taps count layer visits, so the last tap may equal the visit count.
  • llama-quantize keeps the DSpark fuse weights F32. Before, they fell back to F16 and the soft_max asserted on CUDA.

The diff is based on the upstream merge base, so it also shows ggml-org#32218 and #389. The new code is 3 files, additions only.

Tests:

  • New conversion tests fail without the fixes and pass with them.
  • Draft parity against a float32 reference: mean KLD below 1e-3.
  • BF16 and Q8_0 drafts give the same acceptance.

Decode per-layer NVFP4 and MXFP8 schemes, validate companions, and use stored scale shapes with a warning for the declared MXFP8 [32,32] grid. Reorder packed w13 rows and their scale rows together. Keep normal GGUF outtype selection and 3D expert tensors.

Stream 128 rows per expert through LazyChunkedTensor. Real w13 (384x4608x4608) needs a 2.25 MiB F32 chunk instead of a 30.375 GiB expanded layer. Real-shaped sparse probes peak below 5.8 MiB of Python/NumPy chunk allocations, plus 5.2 MiB of callback metadata: budget about 16 MiB per projection including mapped pages, excluding runtime, other tensors and OS cache. Full-model chunk metadata is roughly 370 MiB.

Packed synthetic GGUF weights match the independent pinned vLLM decode bit-for-bit. CPU prefill/decode logits remain within 3.1e-6 absolute error, with 100% argmax agreement. Float fixtures, original-name conversion and CPU architecture checks pass. Real checkpoint conversion remains untested.

Assisted-by: Codex
pwilkin and others added 16 commits November 14, 2026 17:15
A looped model runs the layers [loop.core_start, loop.core_end) num_loops
times. The GGUF has one block per layer visit, so every visit keeps its own
KV cache and recurrent state, while the weights stay per physical layer.
The loader validates the layout, the generic scale pass runs over the
physical layers, every visit then shares its layer's weights, and the graph
node budget scales with the pass count.

Inkling 2 uses it for its looped variant (Inkling2LoopForConditionalGeneration):
later passes restart from the prelude state and mix in the previous pass
through low-rank message controllers.
# Conflicts:
#	conversion/inkling2.py
The Inkling-2-Small checkpoint ships hf_quant_config.json for the target
weights next to the BF16 mtp.safetensors. The base prepare_tensors picks
it up and dequant_model then fails with an empty quant method, so
--dspark could not convert the released folder.
The DSpark taps of a looped Inkling 2 trunk are layer visits, so the final
normed hidden state is tap num_hidden_layers + (num_passes - 1) * core
length instead of num_hidden_layers.
Original checkpoints ship hf_quant_config.json for the trunk experts, which
the generic dequant step rejects. The mtp.safetensors tensors are BF16.
llama-quantize cannot store the 8-wide dspark_fuse.weight as Q8_0 and
falls back to F16, and the CUDA soft_max then aborts on the F16 input
(GGML_ASSERT(src0->type == GGML_TYPE_F32)). Keep the tensor unquantized,
and cast it before the soft_max so drafts quantized before this fix
still load.
Register Inkling2LoopForConditionalGeneration with its own calls instead of
editing the shared register lines, so the change stays additive next to
other edits around the Inkling 2 converters.
# Conflicts:
#	conversion/inkling2.py
The skip of the target quant config now comes from the Inkling-2-Small fixes.
…ed check

Map num_hidden_layers to the visit count before the tap check instead of
rewriting the check, so the pin set keeps the ggml-org#32218 lines unchanged.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-20T19:40:27.509708Z 1cd3338 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants