FAILURE MAP
← Case archive

FA-98596 / KV cache position mapping / Open access

Prefix reuse reports the common token prefix length · case 01

Reuse stops at the first differing token but reports the final sequence length.

Verified by executionVariant 1 · 6 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

The comparison does not track the last matching boundary.

THE FAILURE

The comparison does not track the last matching boundary.

Unsuccessful approach: Comparing membership instead of aligned token equality overestimates reuse for reordered tokens.

Case contract

Return the length of the longest shared prefix of two token sequences.

Why this case matters

A small in-memory model makes the cache address contract explicit for a serving component.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(cached_tokens, requested_tokens):
    return min(len(cached_tokens),len(requested_tokens))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('full prefix',solve(['a']*N+['b'],['a']*N+['c']),N)
check('first mismatch',solve(['x','a'],['y','a']),0)
check('short request',solve(['a','b','c'],['a','b']),2)
check('empty cached',solve([],['a']),0)
check('empty request',solve(['a'],[]),0)
check('reordered tokens',solve(['a','b'],['b','a']),0)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
full prefix21Failed
first mismatch20Failed
short request22Passed
empty cached00Passed
empty request00Passed
reordered tokens20Failed

SHA-256 / 7133e21b105f74d510af1e056b35c25b375e54cf203db65d01d7174f888288b7

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(cached_tokens, requested_tokens):
    return sum(t in requested_tokens for t in cached_tokens)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('full prefix',solve(['a']*N+['b'],['a']*N+['c']),N)
check('first mismatch',solve(['x','a'],['y','a']),0)
check('short request',solve(['a','b','c'],['a','b']),2)
check('empty cached',solve([],['a']),0)
check('empty request',solve(['a'],[]),0)
check('reordered tokens',solve(['a','b'],['b','a']),0)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
full prefix11Passed
first mismatch10Failed
short request22Passed
empty cached00Passed
empty request00Passed
reordered tokens20Failed

SHA-256 / 634f6c3c16b808189b473db3a457f7c033624ff27aeb07dd13ab844706744825

HELD IN THE MEMBER ARCHIVE

The verified repair and its recorded checks are member-only.

This mechanism has 6 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.

Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.

Member access is invitation-based. Sign in with your invited account to inspect the repair.

Sign in to the archive ↗

Verification & scope

These toy integer maps omit tensor layout, concurrency, device memory, and model-specific cache formats. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-30T16:48:14.544796+00:00.

Case digest / 0dd48b74e1de07e0cff18a7d0dac0cbfb86c843445008b7d86922a87344ad0e6