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

Gianluca Barmina, Annemette Broch Pirchert, Andrea Blasi, Lukas Galke Poech, Peter Schneider-Kamp

BrainSurgery: Reproducible and Reliable Declarative Weight Manipulations for Model Editing and Upcycling: 7 upvotes on Hugging Face Daily Papers, #22 of 46 papers on 2026-06-10. Day-by-day upvote history.

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.

Paper page on Hugging Face · arXiv

Data: hysts-bot-data/daily-papers-stats and the Daily Papers API. Open data: tardellirs/paper-pulse-data. Sister project: Model Pulse, the download history of every model on the Hub.