FAILURE MAP
← Case archive

FA-98851 / Gradient accumulation weighting / Open access

Sample weights are normalized by raw item count · case 01

Sample weights are normalized by raw item count.

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

ROOT CAUSE

The broken path divides weighted contributions by the number of batches, dropping the weight mass denominator.

THE FAILURE

The broken path divides weighted contributions by the number of batches, dropping the weight mass denominator.

Unsuccessful approach: Unweighted batch count happens to work only when total weight mass equals that count.

Case contract

Weighted sums already include per-example weights. Divide by total weight mass; zero mass yields zero.

Why this case matters

A deterministic toy model isolates one local accumulation contract.

1 / The failure

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

N = 1
observations = []
def solve(weighted_sums, weight_sums):
    return sum(weighted_sums) / max(1,len(weighted_sums))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('unequal weight mass',solve([2*N,12*N],[N,3*N]),3.5)
check('unit weights',solve([2*N,4*N],[N,N]),3)
check('one batch',solve([9*N],[3*N]),3)
check('zero total weight',solve([0],[0]),0)
check('empty',solve([],[]),0)
check('zero loss',solve([0,8*N],[N,3*N]),2)
check('three batches',solve([N,6*N,8*N],[1,2,4]),15*N/7)
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
unequal weight mass7.03.5Failed
unit weights3.03Passed
one batch9.03Failed
zero total weight0.00Passed
empty0.00Passed
zero loss4.02Failed
three batches5.02.142857142857143Failed

SHA-256 / 5f2acf9a59aaa99483595e3cae6e0327ec0a55821785c3d2b6936c3ad2598a94

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(weighted_sums, weight_sums):
    return sum(s / w for s,w in zip(weighted_sums,weight_sums) if w) / max(1,len(weighted_sums))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('unequal weight mass',solve([2*N,12*N],[N,3*N]),3.5)
check('unit weights',solve([2*N,4*N],[N,N]),3)
check('one batch',solve([9*N],[3*N]),3)
check('zero total weight',solve([0],[0]),0)
check('empty',solve([],[]),0)
check('zero loss',solve([0,8*N],[N,3*N]),2)
check('three batches',solve([N,6*N,8*N],[1,2,4]),15*N/7)
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
unequal weight mass3.03.5Failed
unit weights3.03Passed
one batch3.03Passed
zero total weight0.00Passed
empty0.00Passed
zero loss1.33333333333333332Failed
three batches2.02.142857142857143Failed

SHA-256 / a135344a6ee6523f85a7ffa51aee2ea52bf326a724e351a9ea1a875a408299a0

HELD IN THE MEMBER ARCHIVE

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

This mechanism has 7 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

Inputs are scalar or short-list summaries and do not model autodiff, devices, or an optimizer. 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:17.605183+00:00.

Case digest / 89df7a20abd7200c8a92cdb8d9937f0bfe9a845f03088984a11c1f11bc4eb1b1