Grafy News
Try Grafy free

Model Carving: Training Transformers to Optimize Their Own Topology

Researchers have introduced Model Carving, a method that allows Transformers to learn their own architecture during training, resulting in faster models.

Illustration for the news story: Model Carving: Training Transformers to Optimize Their Own TopologySource: Grafy Research Lab

Machine learning researchers have developed a new method called Model Carving that allows Transformer models to determine their own optimal architecture during the training process. Instead of using a fixed, uniform structure, this approach enables the model to prune unnecessary components in real-time, leading to smaller and more efficient networks.

How does Model Carving work?

Traditionally, training a Transformer involves optimizing the weights of a pre-defined architecture. This usually means every layer has the same number of attention and MLP sublayers, regardless of whether every part of the network is actually needed for a specific task. According to the research by Kaden Zheng and Pratyusha Sharma, this uniformity is a convention that is likely suboptimal.

Model Carving changes this by starting with an overparameterized network and applying learnable, scalar gates to each sublayer. During training, the system calculates a "pressure" for each sublayer. This pressure represents the value of the compute that the sublayer consumes, measured by how much that compute could instead be used to process more training tokens.

As shown in Figure 1, if a sublayer's contribution to reducing the training loss is less than its assigned pressure, its gate shrinks toward zero. Once a gate reaches zero, the sublayer is physically removed from the computation graph. This process allows the training loss itself to shape the model's topology, effectively "carving" a specialized, heterogeneous network out of a larger, denser one.

What are the performance benefits?

The researchers evaluated Model Carving on standard and looped Transformers ranging from 140M to 2.7B parameters. The results indicate significant improvements in both efficiency and capability. At an equal training compute budget, carved models achieved a lower validation loss than dense models that were given up to 1.7 times more compute.

Beyond accuracy, the structural changes lead to direct hardware advantages. Because the removed sublayers are no longer part of the active computation, the models require fewer resources during use. Figure 4 demonstrates that carved models can cost up to 34% fewer FLOPs per token and can decode up to 1.6 times faster than their full-depth counterparts, all without sacrificing quality.

Figure 4: Carved models have lower loss, cost fewer inference FLOPs, and decode faster. Validation bpb against whole-model inference FLOPs per token for (a) looped and (b…
Figure 4. Carved models have lower loss, cost fewer inference FLOPs, and decode faster. Validation bpb against whole-model inference FLOPs per token for (a) looped and (b) standard Transformers. (c) Validation bpb against measured decode tokens per second, each model at its largest batch. We decode on one H100 GPU at a 4,096-token context, with one compiled call per decode step. Each arrow shows the carved/… Figure 4 of “Model Carving: Training Transformers That Optimize Their Own Topology” by Kaden Zheng, Pratyusha Sharma (arXiv.org), CC BY 4.0.

How does it compare to pruning and distillation?

For developers looking to deploy models on edge devices, the standard approach is to take a large, high-performing model and then compress it using pruning or distillation. However, the study suggests that carving during the initial training phase is a superior strategy.

According to the authors, Model Carving outperforms both pruning and distillation when measured on the quality-efficiency frontier. The advantage of this method appears to grow as the scale of the model increases. Furthermore, the researchers found that the performance leads established by Model Carving are robust, persisting through downstream tasks like instruction tuning and even remaining effective after weight quantization.

Can the architecture be task-specific?

One of the most striking findings of the research is the ability of the method to learn highly specialized architectures for specific types of problems. On symbolic tasks, the Model Carving process was able to reduce the architecture down to a minimal state, in some instances leaving only an attention-only Transformer.

This suggests that the "one size fits all" approach to Transformer layers is unnecessary. Instead of forcing every task through a heavy, multi-layered pipeline, Model Carving identifies the specific structural requirements of the data, removing any computation that does not contribute meaningfully to the objective.

Applying these insights in research

For researchers and developers working with complex AI architectures, understanding the relationship between topology and compute is becoming increasingly critical. While Model Carving is a specialized training methodology, the ability to analyze and query the latest breakthroughs in neural architecture is essential for staying at the frontier of the field.

Readers interested in diving deeper into the mathematical foundations or the specific experimental setups of papers like this can use Reader to perform research over the full PDF. This allows for direct questioning of the methodology, such as asking for specific details on the gate behavior or the pressure calculation formulas used by the authors.

Frequently asked questions

Does Model Carving require a separate architecture search step?

No, Model Carving collapses architecture selection and weight optimization into a single process. Unlike Neural Architecture Search (NAS), which often uses a second optimization loop or a controller to find a structure, Model Carving allows the model to learn its own topology directly within the standard training run using learnable gates.

Is the resulting carved model smaller in terms of parameters?

Yes, the method results in a smaller, more efficient network. By identifying and removing sublayers that do not contribute enough to the loss to justify their compute cost, the process effectively reduces the number of active parameters and the total FLOPs required for inference, creating a heterogeneous structure optimized for the task.

Does Model Carving improve inference speed?

Yes, Model Carving improves inference speed because the removed sublayers are no longer part of the computation graph. According to the research, this reduction in active components allows carved models to decode up to 1.6 times faster than standard models while maintaining high levels of performance and quality.


Source: Grafy Research Lab — Model Carving: Training Transformers That Optimize Their Own Topology