TAPIOCA: Why Task-Aware Pruning Improves OOD model Capability
Abstract
Recent work [Peer et al., 2022, Naim et al., 2026] has shown that task-aware layer pruning can improve model performance on particular tasks. We investigate when and why such improvements occur, using small transformers trained from scratch as testbeds on controlled polynomial regression tasks, then confirming our findings on large language models (LLMs). In both cases, such pruning yields no increase in accuracy on in-distribution (ID) data but consistently improves out-of-distribution (OOD) performance and generalizes such gains across multiple distribution shifts. We offer a geometric explanation of this phenomenon. Each task with an ID distribution induces a task-adapted geometry. OOD inputs induce layerwise norm, pairwise-distance and variance structure profiles that can deviate from the corresponding ID profiles. Task-aware pruning identifies layers that amplify this distortion; removing these layers shifts OOD profiles toward those of the adapted distribution. We provide causal evidence that this geometric realignment improves OOD performance through controlled distribution shifts and residual-scaling interventions. This behavior is consistent across model scales.