FAILURE MAP
← Case archive

FA-100496 / Sparse tensor canonicalization / Open access

Sparse tensor: diagonal extraction includes off-diagonal values · case 01

diagonal extraction includes off-diagonal values.

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

ROOT CAUSE

Only coordinates on the main diagonal contribute to this extraction.

THE FAILURE

Only coordinates on the main diagonal contribute to this extraction.

Unsuccessful approach: The upper triangle is broader than the diagonal and admits off-diagonal entries.

Case contract

Return the sum of values at coordinates whose row equals column.

Why this case matters

A small offline sparse-array operation has explicit coordinate and storage semantics.

1 / The failure

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

N = 1
observations = []
def solve(entries):
    return sum(v for r,c,v in entries)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('mixed',solve([[0,0,N],[0,1,5],[2,2,3]]),N+3)
check('empty',solve([]),0)
check('off diagonal',solve([[0,N,8],[N,0,4]]),0)
check('singleton diagonal',solve([[N,N,7]]),7)
check('negative diagonal',solve([[1,1,-N],[1,2,9]]),-N)
check('multiple diagonal entries',solve([[0,0,2],[1,1,3],[2,0,8]]),5)
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
mixed94Failed
empty00Passed
off diagonal120Failed
singleton diagonal77Passed
negative diagonal8-1Failed
multiple diagonal entries135Failed

SHA-256 / 487591e8c5b62374512adf11e502f2c48a88c1ce9162fde135120938a53ede19

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(entries):
    return sum(v for r,c,v in entries if r<=c)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('mixed',solve([[0,0,N],[0,1,5],[2,2,3]]),N+3)
check('empty',solve([]),0)
check('off diagonal',solve([[0,N,8],[N,0,4]]),0)
check('singleton diagonal',solve([[N,N,7]]),7)
check('negative diagonal',solve([[1,1,-N],[1,2,9]]),-N)
check('multiple diagonal entries',solve([[0,0,2],[1,1,3],[2,0,8]]),5)
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
mixed94Failed
empty00Passed
off diagonal80Failed
singleton diagonal77Passed
negative diagonal8-1Failed
multiple diagonal entries55Passed

SHA-256 / 4b9defa85946f6bfc16075f8b973f368ee9a898da97c785fd02e97bd8b1583fa

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 are toy integer-valued COO or CSR contracts; they make no claim about a framework API, floating point policy, or large tensor performance. 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:36.272759+00:00.

Case digest / 3c98bc017a28171a2ec99c5f47e810de6dec3a4e54a37fc88830ed41ca3c9419