AI Compiler Optimization via Reinforcement Learning

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing compiler optimization techniques are inflexible and inefficient, relying on rule-based methods that do not effectively adapt to optimize computer program compilation for improved execution efficiency and code quality.

Innovation Solution

An AI-assisted compiler that employs a reinforcement learning framework to learn patterns in computer program compilation, generating embedding vectors from intermediate code and execution traces to determine optimization actions, which are then applied to improve the compilation process, allowing for dynamic and platform-agnostic optimization.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Productivity

If rule-based optimization techniques are used in compilers, then the compilation process is simple and predictable, but the optimization efficiency and code quality are insufficient

Engineering Contradiction:
Improvecompilation efficiencyVSAvoidcompiler complexity
Core Design Contradiction:
ProductivityVSDevice complexity

Solution Approach 1:

The patent implements feedback mechanisms where the compiler analyzes execution traces and performance metrics from previously compiled code, uses this feedback to learn optimization patterns through machine learning, and applies learned optimizations to subsequent compilation tasks. This creates a closed-loop system that continuously improves compilation efficiency while managing complexity through automated learning.

Inventive Principle:
Principle #23Feedback

Solution Approach 2:

The patent replaces traditional rule-based mechanical optimization systems with machine learning-based optimization. Instead of relying on hand-crafted rules and heuristics, the system uses trained models that automatically learn optimization strategies from execution data, thereby improving compilation efficiency while the model handles the complexity internally.

Inventive Principle:
Principle #28Mechanics substitution (Replace mechanical system)

2Reliability

If traditional compiler optimization methods are used, then the compilation process is fast, but the code execution performance and quality are limited

Engineering Contradiction:
Improvecode execution performanceVSAvoidcompilation time
Core Design Contradiction:
ReliabilityVSLoss of time

Solution Approach 1:

The patent performs preliminary analysis of execution traces and performance metrics during the compilation process, using this pre-computed information to guide optimization decisions. By preparing optimization strategies in advance based on learned patterns, the system improves code execution performance without excessive compilation time penalty.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The patent dynamically changes compilation parameters and optimization strategies based on learned patterns from execution traces. The system adjusts optimization levels, instruction selection, and code transformation parameters adaptively, improving execution performance while managing compilation time through intelligent parameter selection rather than exhaustive exploration.

Inventive Principle:
Principle #35Parameter changes

Data Source

PatentUS11403090B2Method and system for compiler optimization based on artificial intelligence
Publication Date: 2022.08.02 ALIBABA GROUP HOLDING LTD
  • US11403090B2 patent drawing
  • US11403090B2 patent drawing
  • US11403090B2 patent drawing

AI summary

This application describes methods, systems, and apparatus, including computer programs encoded on computer storage media, of an AI-assisted compiler. An example method includes obtaining intermediate code and executable code generated by compiling a computer program with a compiler; determining a reward based on one or more traces obtained by executing the executable code in a runtime system; generating an embedding vector based on the intermediate code and the one or more traces to represent code execution states; determining, using a reinforcement learning agent, one or more optimization actions based on the embedding vector and the reward; and updating the compiler by applying the one or more optimization actions.