Skip to content

server: persist vision KV with exact conditioning provenance - #961

Open
JordiPosthumus wants to merge 1 commit into
antirez:mainfrom
JordiPosthumus:codex/fix-vision-kv-hash-provenance
Open

server: persist vision KV with exact conditioning provenance#961
JordiPosthumus wants to merge 1 commit into
antirez:mainfrom
JordiPosthumus:codex/fix-vision-kv-hash-provenance

Conversation

@JordiPosthumus

@JordiPosthumus JordiPosthumus commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Persist image-conditioned KV under a key containing the exact conditioning that
produced it, and retain that provenance through prefix reuse.

Why

Equal text tokens do not imply equal KV when images contributed embeddings. The
key therefore includes image count, token spans, hashes of the final
conditioning vectors and canonical token text. Loading reattaches image metadata
only when the key and restored frontier agree.

A retained prefix still contains its old conditioning even if a fresh encoder
call produces different candidate bytes. Sync reports what was actually kept:
wholly retained images keep their old hashes, rebuilt images use new hashes, and
partial or unknown provenance cannot be persisted. A GLM dense-cache gap does
not itself erase the authoritative compact prefix; the dense repair bridge is
separately marked unknown.

Compatibility

Text-only cache files and payload ABI remain unchanged. Changed, moved or
missing images cannot select the checkpoint. Appended-image disk recovery is
excluded; live appended-image reuse remains #927. No model math, sampling,
launcher or default change.

Validation

Rebuilt as one commit directly on main
b0a147a7fba6d1a104d047d5a140e9bb4bfc13cd. Unit/backend coverage includes
retained, rebuilt and appended images, interrupted sync, partial-image rejection,
malformed metadata and text-only compatibility.

Apple M3 Ultra, Metal default build; CPU is compile/link portability only:

make clean
make -j2
make -j2 ds4_test ds4_agent_test
./ds4_test --server
./ds4_agent_test
make -j2 cpu
git diff --check upstream/main...HEAD

All commands passed on 2026-09-04. Earlier C ASan+UBSan server checks passed.
A fresh M3 Ultra/Metal Vision-Exp MXFP4 run saved an image-conditioned
checkpoint on shutdown and recovered it after restart; changed-image and
text-only controls explicitly rebuilt cold. The server invocation was:

./ds4-server --model "$MODEL" --vision "$VISION" \
  --host 127.0.0.1 --port 8001 --ctx 65536 --tokens 4096 \
  --prefill-chunk 4096 --warm-weights --batched-session 1 \
  --kv-disk-dir "$CACHE" --kv-disk-space-mb 16384 \
  --kv-cache-cold-max-tokens 0 \
  --kv-cache-continued-interval-tokens 0

GLM compact-path behavior is source-checked but not GLM-model-tested. No full
aggregate model suite or GPU sanitizer result is claimed.

Matched speed/correctness check

Two mirrored runs per build, M3 Ultra/Metal, 2,048 and 16,384-token text
frontiers, 262,144 allocated context, 4,096 prefill chunk, 64 greedy output
tokens, warmed weights and no MTP:

Frontier Main prefill PR prefill Main generation PR generation
2,048 630.45 629.54 42.800 42.855
16,384 573.94 573.32 37.430 37.410

Frontier-logit dumps were byte-identical; all differences were below 0.5%.
This short engine check is not an image-throughput, server-scheduling or
long-context production guarantee.

Merge coordination: #943 changes the same disk lookup call site. If either lands
first, preserve both canonical-text fallback and image filtering, plus both
regression groups.

@JordiPosthumus
JordiPosthumus force-pushed the codex/fix-vision-kv-hash-provenance branch from 81b2cf9 to d28b29e Compare September 4, 2026 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant