Skip to content

dflash: read the confidence-head metadata key instead of only guessing - #126

Merged
khosravipasha merged 2 commits into
prism-v7from
dflash-explicit-metadata-keys
Aug 27, 2026
Merged

dflash: read the confidence-head metadata key instead of only guessing#126
khosravipasha merged 2 commits into
prism-v7from
dflash-explicit-metadata-keys

Conversation

@bri-prism

Copy link
Copy Markdown

Cleanup and quality-of-life. No behaviour change for any valid checkpoint.

What

These files already write dflash.confidence_head, and nothing read it. The runtime worked the same fact out from whether markov_w1.weight is present.

That is fine for a complete export. The problem is when the two disagree. A DSpark checkpoint that lost its markov head loads as plain DFlash, reads drafts one row late, and acceptance falls off a cliff with nothing in the log to say why. That is the same failure #122 fixed for the CLI flag, still reachable through a bad export.

So: declare the key, read it, and cross-check it against the tensors. If the metadata claims a confidence head and markov_w1.weight is absent, the load fails and the message names the cause. The tensor stays the fallback when the key is absent, so older exports load exactly as before.

3 files, +14/-0.

Verification

  • The real drafter is unchanged: 65.891% acceptance, mean length 3.58, identical to the current prism-v7 tip.
  • The guard is tested rather than assumed. A synthetic GGUF that sets dflash.confidence_head with no markov_w1.weight now fails on load with the new message. Before this change the same file loaded and drafted badly.

Deliberately not in this change

dflash.sample_from_anchor is still only honoured on the DSpark path, so the row offset and the confidence head remain coupled through one flag. Decoupling them properly needs the converter to write sample_from_anchor explicitly for both lineages first: its default is true, which is DSpark-shaped, so honouring it uniformly today would change DFlash behaviour and break those models. Worth deciding together, since it spans the packing side.

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds validation for DFlash confidence-head metadata while preserving tensor-based fallback for older checkpoints.

Changes:

  • Registers the dflash.confidence_head metadata key.
  • Rejects incomplete DSpark exports missing markov_w1.weight.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/models/dflash.cpp Reads and validates confidence-head metadata.
src/llama-arch.h Declares the metadata key enum.
src/llama-arch.cpp Maps the enum to its GGUF key.
Suppressed comments (1)

src/models/dflash.cpp:132

  • This only checks the true/missing mismatch. If the key is explicitly false while markov_w1.weight is present, the loader still treats the model as DSpark, so the metadata is neither preferred nor fully cross-checked as described. Reject the inverse mismatch too, while retaining tensor fallback only when the key is absent.
    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");
    }

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/models/dflash.cpp Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@khosravipasha
khosravipasha merged commit 0c44899 into prism-v7 Aug 27, 2026
3 checks passed
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.

3 participants