Skip to content

qwen4exp MTP: refuse a draft vocabulary whose d2t ids are out of range or repeated - #57

Merged
bong-water-water-bong merged 1 commit into
1bit/vulkan-upstreamfrom
1bit/flash-next-d2t-check
Oct 1, 2026
Merged

bong-water-water-bong merged 1 commit into
1bit/vulkan-upstreamfrom
1bit/flash-next-d2t-check

Conversation

@bong-water-water-bong

Copy link
Copy Markdown

Review follow-up to #56.

The reduced draft head scatters its K logits into a full-vocabulary row with ggml_set_rows at the d2t ids, and set_rows trusts those ids:

  • an id < 0 or >= n_vocab writes outside the row;
  • a repeated id silently drops a row.

#56 checked only d2t's type, rank and length. Now qwen4exp_draft_vocab_rows reads the K int64 ids from the file, before any graph uses them, and fails the load naming the offending index and id. The change is in our own qwen4exp-draft-vocab.{h,cpp} only.

Tested on strixhalo (CPU build of this branch, llama-cli -m <draft> --spec-type draft-mtp):

file result
mtp-Qwen3.8-Flash-Next-shared-Q4_K_M-dv65k.gguf (65,536 ids, max 248,076) passes the check. Tensor loading completes, and the run stops later at context creation, as expected for a draft model loaded without its target.
the same file with d2t[5] = 10000000 error loading model: QWEN4EXP MTP: d2t[5] = 10000000 is outside the 248320-token vocabulary
the same file with d2t[5] = d2t[4] error loading model: QWEN4EXP MTP: d2t repeats token id 4

Cost: one K x 8 byte read (512 KiB at K = 65,536) and an n_vocab-bit table at load.

🤖 Generated with Claude Code

…e or repeated

The reduced draft head scatters its K logits into a full-vocabulary row with
set_rows at the d2t ids, which trusts them: an id < 0 or >= n_vocab writes
outside the row, and a repeated id silently drops a row. The loader now reads
the K int64 ids from the file (before any graph uses them) and fails with the
offending index and id. Review follow-up to #56.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added the model label Oct 1, 2026
@bong-water-water-bong
bong-water-water-bong merged commit 8a5e8d8 into 1bit/vulkan-upstream Oct 1, 2026
8 of 11 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the 1bit/flash-next-d2t-check branch November 12, 2026 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant