IP Library › Granted Patent US 11,403,090
Granted Patent B2
US 11,403,090 · App. 17/115,139 · Granted Aug 2, 2022

Method and system for compiler optimization based on artificial intelligence

Inventors: Yuanwei Fang (Sunnyvale, CA); Yen-kuang Chen (Palo Alto, CA)
Assignee: ALIBABA GROUP HOLDING LIMITED
G06F8/65G06F8/44G06F8/443G06F9/45525G06F9/45529G06F11/3466G06N3/04G06N3/08
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 11,403,090
App. No.
17/115,139
Granted
Aug 2, 2022
Kind
B2
Abstract

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.

Claims (69)

1. A computer-implemented method, comprising:

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.

2. The method of claim 1 , wherein the compiler comprises a plurality of interfaces, and the updating the compiler comprises:

triggering one or more of the plurality of interfaces to apply the one or more optimization actions to the compiler.

3. The method of claim 1 , wherein the generating the embedding vector based on the intermediate code and the one or more traces comprises:

generating a graph representation of the intermediate code;

learning code dependencies based on the graph representation of the intermediate code by using a Graph Neural Network (GNN); and

generating the embedding vector based on the code dependencies and the one or more traces to represent the code execution states.

4. The method of claim 3 , wherein the generating the embedding vector based on the code dependencies and the one or more traces comprises:

generating one or more sequence vectors based on the code dependencies and the one or more traces;

inputting the one or more sequence vectors into a Sequence Model to generate the embedding vector.

5. The method of claim 1 , wherein the runtime system is implemented in at least one of the following: a computing device with an operating system, a virtual machine, a cloud-native compiler-as-a-service platform, or a feedback-driven optimization compiler framework.

6. The method of claim 1 , wherein the each of the one or more traces comprises one or more metrics including at least one of the following: cycles per instruction (CPI), execution time, or miss per accruing instruction.

7. The method of claim 1 , wherein the obtaining intermediate code and executable code comprises:

generating the intermediate code based on the computer program;

obtaining a tree representation of the intermediate code; and

generating the executable code by optimizing the tree representation.

8. The method of claim 1 , wherein:

the obtaining intermediate code and executable code comprises obtaining the intermediate code and the executable code after the compiler compiling the computer program, and

the method further comprises triggering the updated compiler to re-compile the computer program.

9. The method of claim 1 , wherein the computer program comprises a plurality of sections, and wherein:

the obtaining intermediate code and executable code comprises obtaining the intermediate code and the executable code by compiling a first section of the computer program by the compiler, and

the method further comprises compiling a second section of the computer program with the updated compiler.

10. The method of claim 1 , wherein the reinforcement learning agent trains an optimization policy for recommending optimization actions, and the method further comprises:

obtaining new executable code from the updated compiler;

obtaining one or more new traces and a new reward by running the new executable code in the runtime system; and

training the optimization policy based on the new reward and the one or more optimization actions.

11. A system comprising one or more processors and one or more non-transitory computer-readable memories coupled to the one or more processors, the one or more non-transitory computer-readable memories storing instructions that, when executed by the one or more processors, cause the system to perform operations comprising:

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.

12. The system of claim 11 , wherein the generating the embedding vector based on the intermediate code and the one or more traces comprises:

generating a graph representation of the intermediate code;

learning code dependencies based on the graph representation of the intermediate code by using a Graph Neural Network (GNN); and

generating the embedding vector based on the code dependencies and the one or more traces to represent the code execution states.

13. The system of claim 12 , wherein the generating the embedding vector based on the code dependencies and the one or more traces comprises:

generating one or more sequence vectors based on the code dependencies and the one or more traces;

inputting the one or more sequence vectors into a Sequence Model to generate the embedding vector.

14. The system of claim 11 , wherein:

the obtaining intermediate code and executable code comprises obtaining the intermediate code and the executable code after the compiler compiling the computer program, and

the operations further comprise triggering the updated compiler to re-compile the computer program.

15. The system of claim 11 , wherein the computer program comprises a plurality of sections, and wherein:

the obtaining intermediate code and executable code comprises obtaining the intermediate code and the executable code by compiling a first section of the computer program by the compiler, and

the operations further comprise compiling a second section of the computer program with the updated compiler.

16. A non-transitory computer-readable storage medium configured with instructions executable by one or more processors to cause the one or more processors to perform operations comprising:

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.

17. The non-transitory computer-readable storage medium of claim 16 , wherein the generating the embedding vector based on the intermediate code and the one or more traces comprises:

generating a graph representation of the intermediate code;

learning code dependencies based on the graph representation of the intermediate code by using a Graph Neural Network (GNN); and

generating the embedding vector based on the code dependencies and the one or more traces to represent the code execution states.

18. The non-transitory computer-readable storage medium of claim 17 , wherein the generating the embedding vector based on the code dependencies and the one or more traces comprises:

generating one or more sequence vectors based on the code dependencies and the one or more traces;

inputting the one or more sequence vectors into a Sequence Model to generate the embedding vector.

19. The non-transitory computer-readable storage medium of claim 16 , wherein:

the obtaining intermediate code and executable code comprises obtaining the intermediate code and the executable code after the compiler compiling the computer program, and

the operations further comprise triggering the updated compiler to re-compile the computer program.

20. The non-transitory computer-readable storage medium of claim 16 , wherein the computer program comprises a plurality of sections, and wherein:

the obtaining intermediate code and executable code comprises obtaining the intermediate code and the executable code by compiling a first section of the computer program by the compiler, and

the operations further comprise compiling a second section of the computer program with the updated compiler.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Dec 8, 2020
From: FANG, YUANWEI; CHEN, YEN-KUANG
To: ALIBABA GROUP HOLDING LIMITED
Reel/Frame 054579/0433 →
Continuity (1)
Related Publication 20220179635A1 · Jun 9, 2022