Use the same toy residual model as the patching grid (embedding plus component writes, a reader head at the last position) and measure what removing one component does under three different replacement rules.
reader_metric(R, W_r, d_vec) and assemble(embed, writes) as before: scores , softmax over positions, output the attended mixture, metric its dot with d_vec; residuals are embed + writes.sum(axis=0).
ablate_component(writes, c, mode, mean_writes=None, resample_writes=None)
writes (C, P, d) with component c replaced at every position: by zeros for mode="zero", by mean_writes[c] (a (P, d) array) for "mean", by resample_writes[c] for "resample". Raise ValueError for other modes.ablation_effects(embed, writes, W_r, d_vec, mean_writes, resample_writes, decimals=4)
{"zero": [...], "mean": [...], "resample": [...]} of metric drops m_full - m_ablated, one list entry per component, rounded.residual_shift(embed, writes, c, mode, mean_writes=None, resample_writes=None, decimals=4)
(norm_ratio, cosine) between the ablated and the original residual at the last position: the ratio of norms (ablated over original) and their cosine similarity, rounded.assemble and reader_metric; do not special-case the arithmetic.writes.