#!/bin/sh # tiercross.sh -- two conversations through the KV tiers at once; checks that neither is served # the other's state. # # tierident.sh checks that one session survives the round trip, but with one conversation there is # nothing else to be served. Cross-contamination (an entry holding reassigned block ids, a # checkpoint slot freed by one session and still named by another) needs two sessions in flight. # # Start the server with a host tier the filler overflows, so the arena's drops run as well as its # restores: # # --prefix-cache-mib 512 # # It also needs snapshot slots for both sessions. On a hybrid model a hit is clamped to the deepest # snapshot it reaches; a store too small for both makes each session retire the other's, and every # arm re-prefills from zero (checked below via the device arm's reuse). The default # --checkpoint-slots holds both. # # Each session is compared only to itself: A's restored answer must equal A's reference. Corrupt # state typically shows as B's train of thought under A's question. set -e P=${P:-8100} H=${H:-127.0.0.1} TO_HOST=${TO_HOST:-10} FILL=${FILL:-1200} N=${N:-48} work=$(mktemp -d "${TMPDIR:-/tmp}/tiercross.XXXXXX") trap 'rm -rf "$work"' EXIT INT TERM command -v jq >/dev/null || { echo "tiercross: jq is required" >&2; exit 2; } # Two prompts that diverge at the first token: a shared opening would legitimately share blocks # and blur the comparison. # # Each must produce a real answer. An instruction-tuned model may answer a wall of repeated # sentences with a single EOS, and every arm would then compare empty strings; both lengths are # checked below. mk() { # mk : > "$1" i=0 while [ $i -lt 300 ]; do printf '%s %d. %s ' "$2" "$i" "$3" >> "$1" i=$((i + 1)) done printf '\n%s\n\nAnswer: ' "$4" >> "$1" } mk "$work/a.txt" "Chapter" "The paged pool is layer-major, so one logical block is many small fragments rather than one extent." \ "Using only the passage above, write three sentences about it." mk "$work/b.txt" "Entry" "The linear layer keeps one state per sequence and updates it token by token." \ "Using only the passage above, write three sentences about it." # The files are sent verbatim through jq's --rawfile. Shell variables would lose the line breaks, # and a question joined to the passage's last sentence gets an immediate EOS (as in tierident.sh). ask() { # ask