SelfMorph adapts large language model computation to each input
Compute Has Shape: Self-Morphing the Internal Computation of Frozen LLMs
Artificial Intelligence
Summary
Large language models typically perform the same internal steps for every input, but this can be inefficient or less accurate for some tasks. The authors introduce SelfMorph, a technique that changes the model’s computational structure based on the input it receives at runtime. It decides whether to reuse layers, branch computations, or follow the usual path to improve task performance while balancing cost. Tests show SelfMorph improves results across different models and tasks, suggesting new ways to make language models smarter without adding more tokens.
What this means in practice
- •For ai platform engineers: Implement input-sensitive layer reuse and branching in LLM services to improve response quality and efficiency without costly retraining.
- •For ai product developers: Integrate adaptive computation morphing into chatbots and assistants to tailor performance for varied user queries dynamically.
Authors
Junxi Wu, Yiwen Guo, Shu-Tao Xia
Abstract
Test-time scaling improves large language models through additional computation, but how to adapt the topology of internal computation to individual inputs remains underexplored. Existing approaches largely fix recurrent or parallel architectures during training, or reconfigure frozen models along a single structural axis. We introduce SelfMorph, which makes computational shape an input-dependent inference-time decision. It unifies the original forward path (BASE), serial reuse of a layer span (REPEAT), and local branching and merging of perturbed hidden states (BRANCH) in a unified space parameterized by type, location, and intensity. Since they offer complementary benefits rather than uniform dominance, we use a lightweight selector that reads the backbone's depth-wise hidden state trajectory on the prompt to choose a morphology before response generation. We train the selector by distilling utility-based distribution from offline morphing that jointly account for task performance and computational cost. Evaluated on three LLMs spanning 4B-27B, SelfMorph achieves a 8.06% mean relative improvement on five in-distribution benchmarks and 4.45% on four unseen benchmarks. It achieves the strongest performance in 24 of 27 settings. These findings identify input-adaptive computational topology as a complementary axis of test-time scaling beyond generating more tokens. Our code is available at https://github.com/creator-xi/SelfMorph.