BrainSurgery is a tool for reliably inspecting and modifying large neural network checkpoints without fragile one-off scripts. It uses declarative YAML plans to perform reproducible tensor transformations, such as reshaping, precision changes, layer restructuring, and LoRA extraction, while built-in checks validate shapes, types, and values to catch errors.</p>\n","updatedAt":"2026-06-10T08:03:47.457Z","author":{"_id":"6652354cb88e4539b2189cd7","avatarUrl":"https://cdn-avatars.huggingface.co/v1/production/uploads/6652354cb88e4539b2189cd7/kZ7Mi6Yz7zbOSLqgFW5jt.jpeg","fullname":"Gianluca Barmina","name":"giannor","type":"user","isPro":false,"isHf":false,"isHfAdmin":false,"isMod":false,"followerCount":1,"isUserFollowing":false}},"numEdits":0,"identifiedLanguage":{"language":"en","probability":0.8730850219726562},"editors":["giannor"],"editorAvatarUrls":["https://cdn-avatars.huggingface.co/v1/production/uploads/6652354cb88e4539b2189cd7/kZ7Mi6Yz7zbOSLqgFW5jt.jpeg"],"reactions":[],"isReport":false}}],"primaryEmailConfirmed":false,"paper":{"id":"2606.09707","authors":[{"_id":"6a2912c7e7d78ea7587e566c","name":"Gianluca Barmina","hidden":false},{"_id":"6a2912c7e7d78ea7587e566d","name":"Annemette Broch Pirchert","hidden":false},{"_id":"6a2912c7e7d78ea7587e566e","name":"Andrea Blasi Núñez","hidden":false},{"_id":"6a2912c7e7d78ea7587e566f","name":"Lukas Galke Poech","hidden":false},{"_id":"6a2912c7e7d78ea7587e5670","name":"Peter Schneider-Kamp","hidden":false}],"mediaUrls":["https://cdn-uploads.huggingface.co/production/uploads/6652354cb88e4539b2189cd7/q8cqoId0GhbKlrA9xyR8q.png"],"publishedAt":"2026-06-08T16:26:09.000Z","submittedOnDailyAt":"2026-06-10T00:00:00.000Z","title":"BrainSurgery: Reproducible and Reliable Declarative Weight Manipulations for Model Editing and Upcycling","submittedOnDailyBy":{"_id":"6652354cb88e4539b2189cd7","avatarUrl":"https://cdn-avatars.huggingface.co/v1/production/uploads/6652354cb88e4539b2189cd7/kZ7Mi6Yz7zbOSLqgFW5jt.jpeg","isPro":false,"fullname":"Gianluca Barmina","user":"giannor","type":"user","name":"giannor"},"summary":"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.","upvotes":6,"discussionId":"6a2912c7e7d78ea7587e5671","githubRepo":"https://github.com/schneiderkamplab/brainsurgery","githubRepoAddedBy":"user","ai_summary":"BrainSurgery is a tool for robust and reproducible tensor manipulation of neural network checkpoints through declarative YAML plans with built-in validation.","ai_keywords":["tensor surgery","neural network checkpoints","declarative YAML plans","structural modifications","mathematical transformations","tensor reshaping","regex","structural targeting","assertions","tensor shapes","data types","values"],"ai_summary_model":"Qwen/Qwen2.5-Coder-32B-Instruct","githubStars":3,"organization":{"_id":"68adbfb1dd070a92488069b1","name":"SDU-Denmark","fullname":"University of Southern Denmark (SDU)","avatar":"https://cdn-avatars.huggingface.co/v1/production/uploads/68adbdb50fdaa186aa43d1ce/f1kfMH47RIckIAOWEi1mv.png"}},"canReadDatabase":false,"canManagePapers":false,"canSubmit":false,"hasHfLevelAccess":false,"upvoted":false,"upvoters":[{"_id":"6652354cb88e4539b2189cd7","avatarUrl":"https://cdn-avatars.huggingface.co/v1/production/uploads/6652354cb88e4539b2189cd7/kZ7Mi6Yz7zbOSLqgFW5jt.jpeg","isPro":false,"fullname":"Gianluca Barmina","user":"giannor","type":"user"},{"_id":"624d671d953e603497e0eb28","avatarUrl":"https://cdn-avatars.huggingface.co/v1/production/uploads/624d671d953e603497e0eb28/8-xsTsJAV0xBfQgqLwIC0.png","isPro":false,"fullname":"Federico Torrielli","user":"EvilScript","type":"user"},{"_id":"65dee4eb2df2dd7ceecb5850","avatarUrl":"https://cdn-avatars.huggingface.co/v1/production/uploads/65dee4eb2df2dd7ceecb5850/WZCx-1X-7944O-BX7h29L.jpeg","isPro":false,"fullname":"Jacob Nielsen","user":"JacobBITLABS","type":"user"},{"_id":"68b031d6aa3a9d6ef8ff91ca","avatarUrl":"https://cdn-avatars.huggingface.co/v1/production/uploads/no-auth/-uFUU2OfVN02ttCtgIVOw.png","isPro":false,"fullname":"Annemette Brok Pirchert","user":"popunicorn","type":"user"},{"_id":"69e73ebbf119e40cb8e83cf4","avatarUrl":"/avatars/7e22f0ac3f4b1e85e90fbdc8a688470a.svg","isPro":false,"fullname":"Filippo Tonini","user":"filo362","type":"user"},{"_id":"62cd65da816d30201adca921","avatarUrl":"https://cdn-avatars.huggingface.co/v1/production/uploads/62cd65da816d30201adca921/M5b4wXhYokQjLzEoGcBmI.jpeg","isPro":false,"fullname":"Lukas Galke Poech","user":"lgalke","type":"user"}],"acceptLanguages":["en"],"dailyPaperRank":0,"organization":{"_id":"68adbfb1dd070a92488069b1","name":"SDU-Denmark","fullname":"University of Southern Denmark (SDU)","avatar":"https://cdn-avatars.huggingface.co/v1/production/uploads/68adbdb50fdaa186aa43d1ce/f1kfMH47RIckIAOWEi1mv.png"},"markdownContentUrl":"https://huggingface.co/buckets/huggingchat/papers-content/resolve/2606/2606.09707.md"}">
BrainSurgery: Reproducible and Reliable Declarative Weight Manipulations for Model Editing and Upcycling
Abstract
BrainSurgery is a tool for robust and reproducible tensor manipulation of neural network checkpoints through declarative YAML plans with built-in validation.
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.
Community
BrainSurgery is a tool for reliably inspecting and modifying large neural network checkpoints without fragile one-off scripts. It uses declarative YAML plans to perform reproducible tensor transformations, such as reshaping, precision changes, layer restructuring, and LoRA extraction, while built-in checks validate shapes, types, and values to catch errors.
Upload images, audio, and videos by dragging in the text input, pasting, or clicking here.
Tap or paste here to upload images
Cite arxiv.org/abs/2606.09707 in a model README.md to link it from this page.
Cite arxiv.org/abs/2606.09707 in a dataset README.md to link it from this page.
Cite arxiv.org/abs/2606.09707 in a Space README.md to link it from this page.
Discussion (0)
Sign in to join the discussion. Free account, 30 seconds — email code or GitHub.
Sign in →No comments yet. Sign in and be the first to say something.