Skip to content

Feature Request: Add DFlash 2 support for Qwen 3.8 / 3.6 (upstream llama.cpp PR #27342) #134

Description

@BloedeBleidd

Prerequisites

  • I am running the latest code. Mention the version if possible as well.
  • I carefully followed the README.md.
  • I searched using keywords relevant to my issue to make sure that I am creating a new issue that is not already open (or closed).
  • I reviewed the Discussions, and have a new and useful enhancement to share.

Feature Description

Add support for DFlash 2 block-diffusion speculative decoding draft models (e.g. z-lab/Qwen3.8-27B-DFlash2-GGUF and incoai/Qwen3.8-27B-DFlash2-GGUF).

Upstream llama.cpp has an implementation under PR ggml-org#27342 (feat(speculative): add DFlash 2 block-diffusion speculative decoding). It would be great to have this supported in BeeLlama to allow DFlash 2 drafters to be used alongside BeeLlama's adaptive --spec-dm-controller profit and KVarN KV cache optimizations.

Motivation

Currently in BeeLlama v0.4.3, attempting to use a DFlash 2 GGUF draft model fails at startup with a tensor count mismatch:

Command:

llama-server \
  -hf unsloth/Qwen3.8-27B-GGUF \
  -hff Qwen3.8-27B-UD-Q5_K_XL.gguf \
  --spec-type draft-dflash \
  --spec-draft-hf z-lab/Qwen3.8-27B-DFlash2-GGUF:Q4_K_M \
  --spec-dm-controller profit \
  --port 8080 \
  --alias Jarvis

Logs:

1.08.699.199 I srv    load_model: loading model 'unsloth/Qwen3.8-27B-GGUF'
1.09.116.086 E llama_model_load: error loading model: done_getting_tensors: wrong number of tensors; expected 81, got 58
1.09.116.100 E llama_model_load_from_file_impl: failed to load model
1.09.116.154 W srv    load_model: [spec] failed to measure draft model memory: failed to load model
...
1.12.591.756 I common_speculative_init_result: loading draft model '/cache/models--z-lab--Qwen3.8-27B-DFlash2-GGUF/snapshots/.../Qwen3.8-27B-DFlash2-Q4_K_M.gguf'
1.12.952.819 E llama_model_load: error loading model: done_getting_tensors: wrong number of tensors; expected 81, got 58
1.12.952.826 E llama_model_load_from_file_impl: failed to load model
1.12.952.827 E common_speculative_init_result: failed to load draft model
1.12.952.834 E srv    load_model: failed to load draft model
1.12.953.108 E srv  llama_server: exiting due to model loading error

Why it happens:

  • DFlash 1 (supported in v0.4.3) uses 58 tensors.
  • DFlash 2 GGUFs contain 81 tensors because of two architectural additions:
    1. Path Selector: selector_hidden.weight, selector_predecessor.weight, selector_successor.weight
    2. Two-tap Dynamic Convolution: blk.*.attn_conv_base, blk.*.attn_conv_proj.weight, blk.*.ffn_conv_base, blk.*.ffn_conv_proj.weight
  • Because the current GGUF loader does not recognize these 23 new tensor names, llama_model_load detects unmapped tensors and aborts with wrong number of tensors; expected 81, got 58.

Possible Implementation

  1. Port tensor mapping and graph execution from upstream llama.cpp PR spec : add DFlash2 support (local convolution + candidate selector) ggml-org/llama.cpp#27342:
    • Register the new DFlash 2 tensor types (LLM_TENSOR_ATTN_CONV_*, LLM_TENSOR_FFN_CONV_*, LLM_TENSOR_SELECTOR_*).
    • Update the GGUF tensor map for architecture dflash to recognize and load all 81 tensors.
    • Add the two-tap convolution and path selector forward pass in the speculative computation graph.
  2. Preserve BeeLlama enhancements:
    • Ensure compatibility with --spec-dm-controller profit (dynamic draft length) and KVarN draft cache offloading (--cache-type-k-draft / --cache-type-v-draft).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions