[错误] 由于缺少 ctx_other 和非自回归图执行, DFlash 2 的推测解码在 Python 中崩溃并失败
作者: ilperev创建于 2026年8月20日更新于 2026年8月20日
Prerequisites
- I am running the latest code. Development is very rapid, so there are no tagged versions as of now.
- 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 bug or useful enhancement to share.
Expected Behavior
When loading the target model utautako/Qwen3.8-27B-NVFP4-MTP-Q8attn-GGUF (Qwen3.8-27B-NVFP4-MTP-Q8attn.gguf) together with the DFlash 2 draft model incoai/Qwen3.8-27B-DFlash2-GGUF (Qwen3.8-27B-DFlash2-Q4_K_M.gguf), LLaMA-cpp-Python should link the draft context to the target context via cparams.ctx_other = target_context and execute the native C++ block-diffusion speculative decoding pipeline, producing speculative speedups.
Current Behavior
- Calling
draft_llm = LLaMA(model_path="Qwen3.8-27B-DFlash2-Q4_K_M.gguf")fails in GGML with:dflash requires ctx_other to be set->ValueError: Failed to create llama_contextbecause DFlash 2 sidecar GGUF files do not contain their ownlm_head/output.weighttensors and requirectx_otherto be set during context initialization. - Setting
draft_llm.model = draft_model_ptrfails with:AttributeError: property 'model' of 'LLaMA' object has no setter. - Calling
LlamaDraftModel(draft_llm, num_pred_tokens=5)fails with:TypeError: LlamaDraftModel() takes no argumentsbecauseLlamaDraftModelis an abstract base class. - When subclassing
LlamaDraftModeland returning a Pythonlist, it crashes insideLLaMA.pywith:AttributeError: 'list' object has no attribute 'astype'. - When returning a
numpy.ndarraywithdtype=np.intc, the Python loop callsdraft_llm.sample(). This bypasses the C++ DFlash 2 pipeline (target hidden layer extractionllama_get_embeddings_layer_inp, encoder passllama_encode, and candidate lattice selectionbuild_post_sampling), resulting in a 0% draft acceptance rate and dropping generation speed to baseline autoregressive throughput (~34.27 tok/s).
Environment and Context
- Hardware: NVIDIA RTX PRO 6000 Blackwell Server Edition (
sm_120), 24+ GB VRAM - Environment: Hugging Face ZeroGPU Space
- Operating System: Debian GNU/Linux 13 (trixie) / Linux 6.12.94-123.192.amzn2023.x86_64
- glibc Version: Debian GLIBC 2.41-12
- Python Version: 3.12.12
- NVIDIA Driver: 580.159.03 (CUDA 13.0)
- LLaMA-cpp-Python: v0.3.35 compiled against submodule
vendor/LLaMA.cppusing: - Repository: https://GitHub.com/z-lab/LLaMA.cpp-fork/tree/5ecbe1ac17ec0484c5b44af0bd580cdc9c428ed4
- Branch:
dflash2 - Commit Hash:
5ecbe1ac17ec0484c5b44af0bd580cdc9c428ed4 - Upstream Pull Request: https://GitHub.com/ggml-org/LLaMA.cpp/pull/27342/changes
Steps to Reproduce
内容来源: abetlen/llama-cpp-python