From 4acc58d5c137c80858ab633bfe71cfa83b4cc925 Mon Sep 17 00:00:00 2001 From: bri-prism <288398250+bri-prism@users.noreply.github.com> Date: Thu, 27 Aug 2026 12:06:04 -0700 Subject: [PATCH 1/2] dflash: read the confidence-head metadata key instead of only guessing Cleanup, no behaviour change for any valid checkpoint. These files already write dflash.confidence_head, and nothing read it. The runtime inferred the same fact from whether markov_w1.weight was present. That works for a complete export, but the two can disagree, and when they do the model loads as plain DFlash and reads drafts one row late. Acceptance drops hard and nothing says why. This declares the key and cross-checks it against the tensors: if the metadata claims a confidence head and markov_w1.weight is absent, the load fails with a message that names the cause. The tensor remains the fallback when the key is absent, so older exports load exactly as before. Verified: - the real drafter is unchanged, 65.891% acceptance and mean length 3.58, the same as on the current prism-v7 tip - a synthetic GGUF that sets dflash.confidence_head with no markov_w1.weight now fails on load with the new message, instead of loading and drafting badly Not in this change: dflash.sample_from_anchor is still only honoured on the DSpark path, so the row offset and the confidence head are still coupled through one flag. Decoupling them needs the converter to write sample_from_anchor explicitly for both lineages, because its default of true is DSpark-shaped and applying it uniformly today would change DFlash behaviour. --- src/llama-arch.cpp | 1 + src/llama-arch.h | 1 + src/models/dflash.cpp | 12 ++++++++++++ 3 files changed, 14 insertions(+) diff --git a/src/llama-arch.cpp b/src/llama-arch.cpp index 5761850c9bc..8e0b369e2e6 100644 --- a/src/llama-arch.cpp +++ b/src/llama-arch.cpp @@ -340,6 +340,7 @@ static const std::map LLM_KV_NAMES = { { LLM_KV_CLASSIFIER_OUTPUT_LABELS, "%s.classifier.output_labels" }, { LLM_KV_TARGET_LAYERS, "%s.target_layers" }, + { LLM_KV_CONFIDENCE_HEAD, "%s.confidence_head" }, { LLM_KV_LOG_SNR_CONDITIONING, "%s.log_snr_conditioning" }, { LLM_KV_MIN_LOG_SNR, "%s.min_log_snr" }, { LLM_KV_MAX_LOG_SNR, "%s.max_log_snr" }, diff --git a/src/llama-arch.h b/src/llama-arch.h index 3a58ed98af2..2b7172e8f82 100644 --- a/src/llama-arch.h +++ b/src/llama-arch.h @@ -386,6 +386,7 @@ enum llm_kv { LLM_KV_CLASSIFIER_OUTPUT_LABELS, LLM_KV_TARGET_LAYERS, + LLM_KV_CONFIDENCE_HEAD, LLM_KV_LOG_SNR_CONDITIONING, LLM_KV_MIN_LOG_SNR, LLM_KV_MAX_LOG_SNR, diff --git a/src/models/dflash.cpp b/src/models/dflash.cpp index eec013755f7..fe5c95abac3 100644 --- a/src/models/dflash.cpp +++ b/src/models/dflash.cpp @@ -118,7 +118,19 @@ void llama_model_dflash::load_arch_tensors(llama_model_loader &) { // // TODO: only Qwen3-style backbones are supported for now; other backbones (e.g. Gemma4) // need their own conversion path and graph tweaks + // The file states whether it has a confidence head. Prefer that over guessing from + // the tensors, and fail loudly if the two disagree: a DSpark export that lost its + // markov head would otherwise load as plain DFlash and quietly halve acceptance. + bool kv_confidence_head = false; + const bool has_kv_confidence_head = ml->get_key(LLM_KV_CONFIDENCE_HEAD, kv_confidence_head, false); + const struct ggml_tensor * markov_meta = ml->get_tensor_meta("markov_w1.weight"); + + if (has_kv_confidence_head && kv_confidence_head && !markov_meta) { + throw std::runtime_error("dflash: metadata declares a confidence head, but markov_w1.weight is missing. " + "The export is incomplete; it would load as plain DFlash and read drafts one row late"); + } + if (markov_meta) { const int64_t dspark_markov_rank = markov_meta->ne[0]; From 96983a32fc110a2dee76c8e8c3391800041b243a Mon Sep 17 00:00:00 2001 From: Pasha Khosravi Date: Thu, 27 Aug 2026 15:40:32 -0700 Subject: [PATCH 2/2] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- src/models/dflash.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/models/dflash.cpp b/src/models/dflash.cpp index fe5c95abac3..8f98f332b42 100644 --- a/src/models/dflash.cpp +++ b/src/models/dflash.cpp @@ -118,9 +118,7 @@ void llama_model_dflash::load_arch_tensors(llama_model_loader &) { // // TODO: only Qwen3-style backbones are supported for now; other backbones (e.g. Gemma4) // need their own conversion path and graph tweaks - // The file states whether it has a confidence head. Prefer that over guessing from - // the tensors, and fail loudly if the two disagree: a DSpark export that lost its - // markov head would otherwise load as plain DFlash and quietly halve acceptance. +// Reject a declared confidence head when its required Markov head is missing. bool kv_confidence_head = false; const bool has_kv_confidence_head = ml->get_key(LLM_KV_CONFIDENCE_HEAD, kv_confidence_head, false);