News for hackers. Stuff that matters.
Re:Large Language Models for Compiler Optimization by jebarker on Sunday September 17, 2023 @05:59PM (#37549739)
If there's a list of known optimizations that preserve correctness then it becomes an optimization problem based on output length (as a proxy for cycle count). So is the idea that an LLM is more efficient than a search or direct optimization?
Re:Large Language Models for Compiler Optimization by sagarm on Sunday September 17, 2023 @06:56PM (#37550168)
There tend to be a lot of heuristics involved when deciding which optimizations to apply and in which order, so there's plenty of room to apply some machine learning.

Whether LLMs are the right approach is a separate question.

In SQL optimization, the problem is a bit trickier (IMO) because compilation is in the query path. One successful approach I know of is Bao: https://arxiv.org/abs/2004.03814

Re:Large Language Models for Compiler Optimization by drug-freedom on Sunday September 17, 2023 @07:13PM (#37550280)
One example where a LLM might be better is which functions to inline.

Current compilers use a complex set of heuristics, a more holistic approach the kind neural networks do might outperform.

Re:Large Language Models for Compiler Optimization by boomanaiden154 on Sunday September 17, 2023 @07:21PM (#37550346)
For function inlining specifically, I'm not sure LLMs are necessarily the right choice. The original MLGO paper [1] demonstrated a big code-size improvement with a ML model for making inlining decisions (7-20% code size wins), but they used tens of engineered features. Maybe a LLM could squeeze some additional size wins out, but maybe not [2].

Additionally, there are other factors to consider when productionizing these systems. Compile time is important (which LLMs will almost certainly explode), and anyone concerned about code size will probably be doing (Thin)LTO which would require feeding a lot more context into a LLM making inlining decisions.

1. https://arxiv.org/abs/2101.04808 2. https://dl.acm.org/doi/10.1145/3503222.3507744

Re:Large Language Models for Compiler Optimization by BruceEel on Monday September 18, 2023 @01:08AM (#37552445)
I'm probably being very naive with this but, could mechanistic interpretability play a role here? Specifically, to experimentally short-list the LLM's most effective optimizations, then try to peek inside the LLM and perhaps fish out some novel optimization algorithm that could be efficiently implemented without the LLM?
Re:Large Language Models for Compiler Optimization by boomanaiden154 on Monday September 18, 2023 @01:17AM (#37552492)
I did a bit of work on this last summer on (much) smaller models [1] and it was briefly discussed towards the end of last year's MLGO panel [2]. For heuristic replacements specifically, you might be able to glean some things (or just use interpretable models like decision trees), but something like a neural network works fundamentally differently than the existing heuristics, so you probably wouldn't see most of the performance gains. For just tuning heuristics, the usual practice is to make most of the parameters configurable and then use something like bayesian optimization to try and find an optimal set, and this is sometimes done as a baseline in pieces of ML-in-compiler research.

1. https://github.com/google/ml-compiler-opt/pull/109 2. https://youtu.be/0uUKDQyn1Z4?si=PHrx9RICJIiA3E6C

Re:Large Language Models for Compiler Optimization by BruceEel on Monday September 18, 2023 @01:37AM (#37552590)
Ah interesting. Hadn't seen that presentation, thanks for sharing!
Re:Large Language Models for Compiler Optimization by namibj on Sunday September 17, 2023 @08:34PM (#37550843)
That's neither the only metric of relevance, nor is that a good proxy for modern superscalar vector processor architectures.
Re:Large Language Models for Compiler Optimization by Buttons840 on Monday September 18, 2023 @12:37AM (#37552294)
This is scooching into AlphaGo (or whatever the generic implementation is called) territory: mixing predictive AI with traditional optimization algorithms.
Re:Large Language Models for Compiler Optimization by kaba0 on Monday September 18, 2023 @03:40AM (#37553400)
Cycle count is not a proper benchmark for performance on “modern” processors.