arXiv:2610.38382cs.AIOct 2026

Manuscript Offprint

arXiv:2610.38382

Compute Has Shape: Self-Morphing the Internal Computation of Frozen LLMs

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.

1 INTRODUCTION

Scaling test-time computation has become a important way to improve large language models. Chain-of-thought increases serial computation by generating longer reasoning traces (Wei et al., 2022), while self-consistency increases parallel computation by sampling multiple traces and aggregates answers (Wang et al., 2023). These approaches organize additional computation through generated sequences. Computation can also be allocated within the network, raising a further question: can a frozen LLM adapt its internal computation to each input by choosing among serial reuse, local parallel processing, and its original execution path?

Recent work provides two foundations for this question. Looped (recurrent-depth) models repeatedly apply shared transformations to deepen serial processing (Dehghani et al., 2019; Geiping et al., 2026; Zhu et al., 2025), while parallel models maintain multiple latent streams and aggregate their outputs (Chen et al., 2026b; You et al., 2026). These studies establish mechanisms for organizing computation within models designed or trained to support them. Another line of work shows that the pretrained layers can be skipped or repeated at inference time (Li et al., 2026; Chen et al., 2026a), demonstrating that frozen weights can support more than one execution path. However, these methods operate within a single axis, and do not place different topologies under a shared cost model. This motivates a broader view: test-time computation has shape, not only scale. We investigate whether these computational shapes offer complementary benefits and whether the backbone's own hidden state trajectory can guide their selection.

†^{\dagger}Corresponding authors.

Figure

Figure 1: Overview of SELFMORPH. (a) Probe: During prompt prefill along the original forward path, we collect a depth-wise trajectory. (b) Select: A lightweight selector encodes the trajectory and aggregates them through bidirectional attention with a learned token. Before response generation, it selects the highest-probability action. (c) Morph: Three morphology types.

We formalize computational shape through a parameterized morphology space over a frozen backbone. BASE preserves the original forward path; REPEAT applies a selected layer span repeatedly in series; BRANCH forks perturbed hidden states at the start of the span and merges at the end. The morphology type describes the topology of the computation, while the intervention span and intensity further specify where and how much of the computation is applied. Evaluating these interventions on the same problems reveals complementary effects: REPEAT and BRANCH each solve problems that the other does not, and neither uniformly subsumes the other across tasks and backbones. This heterogeneity motivates selecting a morphology for each input rather than applying a single fixed intervention.

As the model encodes the prompt, its hidden state traces a depth-wise trajectory across layers. We introduce SELFMORPH, which reads the trajectory of the LLM itself to decide the shape it ought to adopt. Specifically, SELFMORPH predicts the parameterized morphology, including type, span, and intensity before the first response token is generated. To train the selector, we evaluate candidate actions offline and assign each a utility combining task score and analytic cost. We distill the resulting utility-based teacher distribution into the selector. At inference time, the selected morphology reshapes the model's internal computation throughout generation without evaluating candidate responses. To reduce execution overhead, we reuse prompt computation shared by probing, and share identical cache storage across branch replicas where supported.

Our contributions are as follows.

  • We formulate the internal computation of a frozen LLM as a structured choice over BASE, REPEAT, and BRANCH, jointly parameterized by morphology type, span, and intensity. This formulation places serial reuse and local branching within a shared action space over pretrained weights.

  • We introduce SELFMORPH, a lightweight attention-based selector that reads the frozen LLM's hidden state trajectory on the prompt and predicts which morphology to apply before generation. We train the selector by distilling utility-based distribution from offline morphing that jointly account for task performance and computational cost.

  • We evaluate SELFMORPH on three frozen LLMs across nine benchmarks. Relative to the unmodified backbones, it achieves a mean relative score improvement of 8.06% on five in-distribution benchmarks and 4.45% across on four unseen benchmarks. It also outperforms a per-benchmark selected fixed action in all 15 settings, supporting the value of input-level selection. Extensive ablations also confirm the contributions of morphology diversity, hidden trajectory and attention-based architecture.

References (70)