{"abstract":"Unequal example batches receive equal mean-gradient weight.","category":"Gradient accumulation weighting","checks":7,"contract":"Gradient sums and example counts describe microbatches. Return their global example-weighted mean; zero total examples returns zero.","contract_signature":"sums, counts","evaluation_group":"gradient-accumulation-sample_mean","failed_approach":"Weighting each batch mean equally only matches the contract when batch sizes are equal.","family":"w3-gradient-accumulation-weighting-sample-mean","id":"FA-98841","implementations":{"attempt":{"sha256":"647fe9a2a2d27e8bf125a4ecb8bf419c20a2f99215990c25dc189448f198937d","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(sums, counts):\n    return sum(s / c for s, c in zip(sums, counts) if c) / max(1, len(sums))\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('unequal batches',solve([2*N,12*N],[N,3*N]),3.5)\ncheck('equal batches',solve([2*N,4*N],[N,N]),3)\ncheck('single batch',solve([7*N],[N]),7)\ncheck('empty window',solve([],[]),0)\ncheck('zero numerator',solve([0,9*N],[N,3*N]),2.25)\ncheck('one large batch',solve([12*N],[4*N]),3)\ncheck('three batches',solve([N,6*N,8*N],[1,2,4]),15*N/7)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"broken":{"sha256":"3e6d17b77c9a172ed11f6907e093bb9b84b5685d3eaca38a3ee1437a914b20fa","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(sums, counts):\n    return sum(s / max(1, c) for s, c in zip(sums, counts))\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('unequal batches',solve([2*N,12*N],[N,3*N]),3.5)\ncheck('equal batches',solve([2*N,4*N],[N,N]),3)\ncheck('single batch',solve([7*N],[N]),7)\ncheck('empty window',solve([],[]),0)\ncheck('zero numerator',solve([0,9*N],[N,3*N]),2.25)\ncheck('one large batch',solve([12*N],[4*N]),3)\ncheck('three batches',solve([N,6*N,8*N],[1,2,4]),15*N/7)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"}},"limitations":"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.","method":"Deterministic executable model with adversarial boundary fixtures.","provenance":{"created_by":"Failure Map","dependencies":"Python standard library","family":"w3-gradient-accumulation-weighting-sample-mean","generated_at":"2026-09-30T16:48:17.605217+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"A deterministic toy model isolates one local accumulation contract.","root_cause":"Each microbatch is represented by a summed gradient and its example count; the implementation averages microbatch means instead of weighting by examples.","sha256":"495faca851ccd317ff9373e1212e905e6f24e08c6bc5ccd686ebfd4618c24543","title":"Unequal example batches receive equal mean-gradient weight · case 01","variant":1,"variant_policy":"The fixture code references N, supplied as 1 through 5. Fixed boundary checks may repeat. These records share one mechanism and must remain together in evaluation splits.","verified":true,"visibility":"public","verification":{"attempt":{"elapsed_ms":27.136,"exit_code":1,"observations":[{"actual":3.0,"check":"unequal batches","expected":3.5,"passed":false},{"actual":3.0,"check":"equal batches","expected":3,"passed":true},{"actual":7.0,"check":"single batch","expected":7,"passed":true},{"actual":0.0,"check":"empty window","expected":0,"passed":true},{"actual":1.5,"check":"zero numerator","expected":2.25,"passed":false},{"actual":3.0,"check":"one large batch","expected":3,"passed":true},{"actual":2.0,"check":"three batches","expected":2.142857142857143,"passed":false}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"unequal batches\", \"actual\": 3.0, \"expected\": 3.5, \"passed\": false}, {\"check\": \"equal batches\", \"actual\": 3.0, \"expected\": 3, \"passed\": true}, {\"check\": \"single batch\", \"actual\": 7.0, \"expected\": 7, \"passed\": true}, {\"check\": \"empty window\", \"actual\": 0.0, \"expected\": 0, \"passed\": true}, {\"check\": \"zero numerator\", \"actual\": 1.5, \"expected\": 2.25, \"passed\": false}, {\"check\": \"one large batch\", \"actual\": 3.0, \"expected\": 3, \"passed\": true}, {\"check\": \"three batches\", \"actual\": 2.0, \"expected\": 2.142857142857143, \"passed\": false}], \"passed\": false}\n"},"broken":{"elapsed_ms":28.688,"exit_code":1,"observations":[{"actual":6.0,"check":"unequal batches","expected":3.5,"passed":false},{"actual":6.0,"check":"equal batches","expected":3,"passed":false},{"actual":7.0,"check":"single batch","expected":7,"passed":true},{"actual":0,"check":"empty window","expected":0,"passed":true},{"actual":3.0,"check":"zero numerator","expected":2.25,"passed":false},{"actual":3.0,"check":"one large batch","expected":3,"passed":true},{"actual":6.0,"check":"three batches","expected":2.142857142857143,"passed":false}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"unequal batches\", \"actual\": 6.0, \"expected\": 3.5, \"passed\": false}, {\"check\": \"equal batches\", \"actual\": 6.0, \"expected\": 3, \"passed\": false}, {\"check\": \"single batch\", \"actual\": 7.0, \"expected\": 7, \"passed\": true}, {\"check\": \"empty window\", \"actual\": 0, \"expected\": 0, \"passed\": true}, {\"check\": \"zero numerator\", \"actual\": 3.0, \"expected\": 2.25, \"passed\": false}, {\"check\": \"one large batch\", \"actual\": 3.0, \"expected\": 3, \"passed\": true}, {\"check\": \"three batches\", \"actual\": 6.0, \"expected\": 2.142857142857143, \"passed\": false}], \"passed\": false}\n"}},"member_only":{"stages":["fixed"],"fields":["implementations.fixed","verification.fixed","harness","repair"],"note":"The verified repair, its recorded checks, the repair description, and the scoring harness are available to members."}}