FAILURE MAP
← Case archive

FA-98576 / KV cache position mapping / Open access

Packed segments reset logical positions at boundaries · case 01

A new packed sequence inherits the prior segment’s final position.

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

ROOT CAUSE

Position IDs are generated over the flattened row without segment awareness.

THE FAILURE

Position IDs are generated over the flattened row without segment awareness.

Unsuccessful approach: Counting positions by segment ID merges separated runs that reuse the same ID.

Case contract

Given one segment ID per token, assign positions starting at zero within each contiguous segment run.

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(segments):
    return list(range(len(segments)))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('two segments',solve(['a']*N+['b']*2),list(range(N))+[0,1])
check('alternating runs',solve(['a','b','a']),[0,0,0])
check('same run',solve(['x']*3),[0,1,2])
check('empty',solve([]),[])
check('single segment',solve(['q']),[0])
check('repeated after intervening segment',solve([1,1,2,1]),[0,1,0,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
two segments[0, 1, 2][0, 0, 1]Failed
alternating runs[0, 1, 2][0, 0, 0]Failed
same run[0, 1, 2][0, 1, 2]Passed
empty[][]Passed
single segment[0][0]Passed
repeated after intervening segment[0, 1, 2, 3][0, 1, 0, 0]Failed

SHA-256 / b2181f97252868308aba4f6a354ec834a6ede8c1a6cf7ea0b64a096123ea9932

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(segments):
    out=[]; counts={}
    for s in segments:
        out.append(counts.get(s,0)); counts[s]=counts.get(s,0)+1
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('two segments',solve(['a']*N+['b']*2),list(range(N))+[0,1])
check('alternating runs',solve(['a','b','a']),[0,0,0])
check('same run',solve(['x']*3),[0,1,2])
check('empty',solve([]),[])
check('single segment',solve(['q']),[0])
check('repeated after intervening segment',solve([1,1,2,1]),[0,1,0,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
two segments[0, 0, 1][0, 0, 1]Passed
alternating runs[0, 0, 1][0, 0, 0]Failed
same run[0, 1, 2][0, 1, 2]Passed
empty[][]Passed
single segment[0][0]Passed
repeated after intervening segment[0, 1, 0, 2][0, 1, 0, 0]Failed

SHA-256 / d5baccaf4c70cdd0f094c6e0db752a5eb7e3bfb1d84b060dc88e7cf9aac0dbe6

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.544856+00:00.

Case digest / d5ab8ee91fdfed24f8fde4b7d00a2f8f4e1488dbd6232f9c4111c523532d97c9