BrainSurgery: Reproducible and Reliable Declarative Weight Manipulations for Model Editing and Upcycling

Gianluca Barmina, Annemette Broch Pirchert, Andrea Blasi Núñez, Lukas Galke Poech, Peter Schneider-Kamp
6/8/2026
cs.LGcs.CL

No confident code implementation found for this paper.

Abstract

As deep learning models scale, managing, inspecting, and modifying large checkpoints has become increasingly challenging. Researchers often need to alter model weights for layer restructuring, precision casting, low-rank factorization, and architectural debugging, yet these workflows often rely on fragile ad-hoc Python scripts. Here, we introduce BrainSurgery, a tool for robust and reproducible "tensor surgery" on neural network checkpoints, and provide a system demonstration covering four examples and three case studies from model upcycling to LoRA extraction. By abstracting storage formats and memory management, BrainSurgery executes complex transformations through declarative YAML plans. It supports structural modifications, mathematical transformations, and tensor reshaping through expressive regex and structural targeting, while built-in assertions validate tensor shapes, data types, and values to prevent silent errors. We envision that BrainSurgery will provide a strong foundation for future research through its reproducible and validated operations.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{barmina2026brainsurgery,
  title  = {BrainSurgery: Reproducible and Reliable Declarative Weight Manipulations for Model Editing and Upcycling},
  author = {Gianluca Barmina and Annemette Broch Pirchert and Andrea Blasi Núñez and Lukas Galke Poech and Peter Schneider-Kamp},
  year   = {2026},
  eprint = {2606.09707},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2606.09707v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2606.09707.svg)](https://codeofpaper.com/paper/2606.09707)

Discussion