Skip to content

bug: Qwen3.8 DFlash/MTP speculative emits OOB token id == n_vocab (248320) on Vulkan #28158

Description

@maciejdzialo

Summary

On AMD Strix Point (gfx1150) Vulkan with llama.cpp b10724, Qwen3.8-27B + z-lab DFlash2 (or ggml MTP draft) fails decode with:

init: invalid token[1] = 248320
decode: failed to initialize batch

248320 equals tokenizer.ggml.tokens array length — valid token ids are 0..248319. This looks like a classic off-by-one in draft sampling / logits indexing.

Environment

  • GPU: AMD Strix Point gfx1150, Vulkan/RADV
  • Runtime: llama.cpp b10724 (also reproduced earlier on b10666)
  • Target: Qwen3.8-27B-UD-Q4_K_XL.gguf (architecture qwen35)
  • Draft A: z-lab/Qwen3.8-27B-DFlash2-GGUFQwen3.8-27B-DFlash2-Q4_K_M.gguf (dflash)
  • Draft B: Unsloth mtp-Qwen3.8-27B-Q4_0.gguf (qwen35) — same 248320 with ggml MTP
  • Flags: --spec-type draft-dflash --spec-draft-n-max 2 (or draft-mtp)

Note: Muse-Glimmer + DFlash on the same binary/hardware works (different vocab/arch ~200k). Vanilla Qwen3.8 without speculation is fine (~4.3 t/s).

GGUF metadata (streaming count of tokenizer.ggml.tokens)

Field Value
n_vocab (tokenizer.ggml.tokens len) 248320
bos_token_id 248044
eos_token_id 248046

Same n_vocab / bos / eos on target, DFlash draft, and MTP draft.

Expected

Draft sampling never emits token id >= n_vocab.

Actual

First decode step emits token 248320 (exactly n_vocab). Server returns HTTP 500 / "Invalid input batch."

Suggested fix

  1. Clamp draft token ids to [0, n_vocab - 1] after sampling in the DFlash/MTP verify path.
  2. Audit qwen35 / dflash draft-head logits indexing for < n_vocab vs <= last index (or argmax over n_vocab+1 slots).

Repro

llama-server \
  --model Qwen3.8-27B-UD-Q4_K_XL.gguf \
  --model-draft Qwen3.8-27B-DFlash2-Q4_K_M.gguf \
  --spec-type draft-dflash --spec-draft-n-max 2 \
  --device Vulkan0 -ngl 999 --ctx-size 8192 \
  --cache-type-k f16 --cache-type-v f16 --flash-attn on \
  --host 127.0.0.1 --port 8080 --no-webui
# POST /v1/chat/completions → 500; log shows invalid token 248320

Related

Happy to provide full server logs / GGUF SHA if useful.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions