FAILURE MAP
← Case archive

FA-98896 / Gradient accumulation weighting / Open access

A changing loss scale is applied after gradient summation · case 01

A changing loss scale is applied after gradient summation.

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

ROOT CAUSE

The broken path applies only the last observed scale to all accumulated gradients.

THE FAILURE

The broken path applies only the last observed scale to all accumulated gradients.

Unsuccessful approach: Replacing zero scales by one invents a contribution for an undefined scaled step.

Case contract

Each microbatch sum uses its own positive loss scale. Unscale each sum before combining and divide by total examples; zero-scale contributions are omitted.

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(scaled_sums, scales, counts):
    return sum(scaled_sums) / max(1,sum(counts)) / max(1,scales[-1] if scales else 0)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('different scales',solve([8*N,24*N],[4,12],[1,3]),N)
check('same scale',solve([8*N,16*N],[4,4],[1,3]),1.5*N)
check('one step',solve([15*N],[3],[1]),5*N)
check('empty window',solve([],[],[]),0)
check('zero numerator',solve([0,12*N],[2,6],[1,2]),2*N/3)
check('zero scale step omitted',solve([6*N,12*N],[0,6],[1,2]),2*N/3)
check('different counts',solve([12*N,24*N],[3,6],[2,2]),2*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 scales0.66666666666666661Failed
same scale1.51.5Passed
one step5.05Passed
empty window0.00Passed
zero numerator0.66666666666666660.6666666666666666Passed
zero scale step omitted1.00.6666666666666666Failed
different counts1.52Failed

SHA-256 / 1b68c64a315cd5d0cb39766123209f639b6b4071dff1f60b962cf124977170dd

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(scaled_sums, scales, counts):
    return sum(s / max(1,scale) for s,scale in zip(scaled_sums,scales)) / max(1,sum(counts))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('different scales',solve([8*N,24*N],[4,12],[1,3]),N)
check('same scale',solve([8*N,16*N],[4,4],[1,3]),1.5*N)
check('one step',solve([15*N],[3],[1]),5*N)
check('empty window',solve([],[],[]),0)
check('zero numerator',solve([0,12*N],[2,6],[1,2]),2*N/3)
check('zero scale step omitted',solve([6*N,12*N],[0,6],[1,2]),2*N/3)
check('different counts',solve([12*N,24*N],[3,6],[2,2]),2*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 scales1.01Passed
same scale1.51.5Passed
one step5.05Passed
empty window0.00Passed
zero numerator0.66666666666666660.6666666666666666Passed
zero scale step omitted2.66666666666666650.6666666666666666Failed
different counts2.02Passed

SHA-256 / 1c8013c233472f8d5e69e1164410ed78ea5a960df862c4e3092d4dce1ca0df88

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

Case digest / 7da75d5a588fd8b75413942092636351225d7a5d47eabbdc5478b8b2ffda36c0