← Latest papers
💻 computer science

Tensor Seeks Layout: Formalizing Layout Selection for ML Compilers

This paper presents the first formal study of layout selection in machine learning compilers by formulating it as a combinatorial optimization problem, proving its computational hardness, and proposing both optimal algorithms for bounded treewidth graphs and a weighted MaxSAT encoding for general instances to demonstrate that simple heuristics can degrade performance by up to 5x compared to optimal solutions.

Original authors: Clemens Eisenhofer, Yuwen Jia, Daniel Kroening, Sergey Pupyrev

Published 2026-08-25
📖 5 min read🧠 Deep dive

Original authors: Clemens Eisenhofer, Yuwen Jia, Daniel Kroening, Sergey Pupyrev

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

Modern artificial intelligence relies on massive mathematical models that process vast amounts of data to recognize speech, translate languages, or generate images. To run these models quickly, engineers use specialized computer chips designed specifically for this heavy lifting. However, these chips do not simply execute instructions; they must also move data around efficiently. The speed at which a model runs often depends less on the raw power of the chip and more on how the data is arranged in its memory. Imagine a library where books are stored on shelves. If a reader needs to find a specific set of books, the time it takes depends entirely on whether those books are scattered across different aisles or neatly grouped together on a single shelf. In the world of computer chips, this arrangement is called a "layout." When a computer program performs a calculation, it expects data in one specific arrangement, but the previous step in the program might have left the data in a different one. If the two do not match, the computer must stop and rearrange the data before it can proceed, a process that wastes time and energy.

For years, the software that prepares these models for the chips has relied on a collection of rough guesses and rules of thumb to decide how to arrange this data. These rules work well enough for simple tasks, but as models have grown more complex, the guesses have started to fail, leading to significant slowdowns. A team of researchers from the Technical University of Vienna and Amazon set out to change this approach. Instead of relying on intuition, they treated the problem of arranging data as a formal mathematical puzzle. They built a precise model that calculates the exact cost of every possible arrangement, including the time it takes to move data between different formats. By doing this, they could determine the single best way to organize the data for any given model, rather than hoping a set of rules would get close enough.

The researchers discovered that finding this perfect arrangement is an incredibly difficult task. In the language of computer science, the problem is so complex that no computer can solve it quickly for every possible situation, especially as the models grow larger. They proved that even for a simplified version of the problem involving only basic matrix calculations, the number of possibilities is so vast that a standard computer would struggle to find the answer in a reasonable time. This finding ruled out the idea that a single, fast, universal algorithm could solve the problem for all future models. However, the team also found a way forward. They showed that while the problem is hard in general, it becomes manageable when the structure of the model resembles a tree with limited branching. For these specific structures, which are common in many real-world applications, they designed a method that finds the perfect solution quickly. For more complex structures that do not fit this pattern, they developed a way to translate the problem into a format that existing powerful solvers can handle, allowing them to find the best possible arrangement even when a perfect mathematical shortcut does not exist.

To test their ideas, the researchers implemented their new method inside a real-world compiler used for Amazon's Trainium chips, which are designed to run artificial intelligence models. They compared their new approach against the standard methods currently used in the industry, which rely on the older rules of thumb. The results were striking. On some complex models, particularly those used for image recognition, the old rules of thumb caused the models to run up to five times slower than necessary. This happened because the simple rules failed to see the big picture; they would arrange data perfectly for one step but create a mess for the next, forcing the computer to waste time rearranging data constantly. The new method, by looking at the entire sequence of steps at once, avoided these costly rearrangements and kept the data flowing smoothly.

However, the study also revealed a crucial limitation. While the new method could always find the mathematically best arrangement according to its own calculations, this did not always translate to the fastest speed on the actual hardware. In some cases, the new method produced a result that was theoretically perfect but performed worse than the older, simpler rules. The researchers traced this discrepancy to the cost model itself. The software used to predict how long a task would take was not perfectly accurate; it underestimated the time required for certain types of data movement. Because the new method was so good at finding the lowest cost according to its own flawed predictions, it sometimes chose an arrangement that looked cheap on paper but was actually expensive in reality. This finding suggests that the biggest hurdle for future improvements is not better search algorithms, but better ways to predict how long tasks will actually take.

The work provides a clear path forward for the field. It demonstrates that treating layout selection as a formal optimization problem is a viable and powerful strategy, capable of delivering massive speedups where simple rules fail. It also clarifies that the ultimate limit of performance is not the ability to find the best solution, but the accuracy of the predictions used to guide that search. For models with regular, predictable structures, the new solver-based approach is already a superior choice. For more chaotic and complex models, the focus must shift to refining the cost models so that the mathematical optimum aligns with the physical reality of the chip. By separating the problem of finding the best solution from the problem of predicting the cost, the researchers have given compiler developers a new tool to measure their progress and a clear target for where to focus their efforts next.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →