FAILURE MAP
← Case archive

FA-98856 / Gradient accumulation weighting / Open access

An empty microbatch dilutes the equal-microbatch mean · case 01

An empty microbatch dilutes the equal-microbatch mean.

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

ROOT CAUSE

Empty segments are included in the divisor, although only participating segment means belong in this contract.

THE FAILURE

Empty segments are included in the divisor, although only participating segment means belong in this contract.

Unsuccessful approach: Using participation counts as weights turns equal segment influence into count weighting.

Case contract

Inputs are already per-microbatch means and a positive participation count. Average nonempty microbatch means equally; empty batches are ignored.

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(means, nonempty):
    return sum(means) / max(1,len(means))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('different batch sizes',solve([2*N,4*N],[N,3*N]),3*N)
check('empty batch skipped',solve([0,7*N],[0,1]),7*N)
check('all empty',solve([0,0],[0,0]),0)
check('single batch',solve([5*N],[1]),5*N)
check('three batch means',solve([N,3*N,8*N],[1,1,1]),4*N)
check('empty input',solve([],[]),0)
check('one of two',solve([9*N,0],[1,0]),9*N)
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
different batch sizes3.03Passed
empty batch skipped3.57Failed
all empty0.00Passed
single batch5.05Passed
three batch means4.04Passed
empty input0.00Passed
one of two4.59Failed

SHA-256 / 1d6c1e0cc372d90da0e46f85c5072ad1e9d60bbc47e6c13e75be98c85d8123c0

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(means, nonempty):
    return sum(m for m,c in zip(means,nonempty) if c) / max(1,sum(nonempty))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('different batch sizes',solve([2*N,4*N],[N,3*N]),3*N)
check('empty batch skipped',solve([0,7*N],[0,1]),7*N)
check('all empty',solve([0,0],[0,0]),0)
check('single batch',solve([5*N],[1]),5*N)
check('three batch means',solve([N,3*N,8*N],[1,1,1]),4*N)
check('empty input',solve([],[]),0)
check('one of two',solve([9*N,0],[1,0]),9*N)
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
different batch sizes1.53Failed
empty batch skipped7.07Passed
all empty0.00Passed
single batch5.05Passed
three batch means4.04Passed
empty input0.00Passed
one of two9.09Passed

SHA-256 / 50c7a6d4db0413ca25302dc8610618b5d7d105bdfeb21ac4fc4e8cba0e1237b6

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

Case digest / b7dd0e370bf5a4744302b1a9b702ae4e72e2dfb2a43bfb18efed7636e2c6c777