IP Library › Granted Patent US 12,632,693
Granted Patent B1
US 12,632,693 · App. 17/657,276 · Granted May 19, 2026

Matrix multiplication packing with instruction reordering

Inventors: Jiading Gai (Seattle, WA); Tobias Joseph Kastulus Edler von Koch (Austin, TX); Robert Geva (Cupertino, CA); Paul Gilbert Meyer (Jericho, VT); Donald John Kretsch (Cupertino, CA); Ron Diamant (San Jose, CA)
Assignee: Amazon Technologies, Inc.
G06N3/02G06F8/443G06F9/3838G06F17/16
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 12,632,693
App. No.
17/657,276
Granted
May 19, 2026
Kind
B1
Abstract

A technique for packing matrix multiplications for concurrent execution in an integrated circuit device may include obtaining a description of a neural network model, and generating an intermediate representation of the neural network model. Matrix multiplication instructions in the intermediate representation of the neural network model can then be vectorized for concurrent execution on an integrated circuit device, and machine instructions can be generated for the integrated circuit device based on the vectorized matrix multiplication instructions.

Claims (53)

1 . A computer-implemented method for compiling a neural network model, the method comprising:

obtaining a description of the neural network model;

generating a representation of a data dependency graph of the neural network model;

identifying accumulation groups (AGs) having one or more matrix multiplication instructions in the data dependency graph;

initializing an AG pack from each AG, the AG pack being a data structure representing AGs to be reordered into a consecutive sequence of matrix multiplication instructions;

identifying AG pack pairs that are within a search window distance in the data dependency graph;

forming a set of packing candidates from AG pack pairs that fits in a tile arrangement of a processing engine array, each packing candidate containing an AG pack pair;

selecting packing candidates based on a similarity metric;

combining the AG packs in each of the selected packing candidates to form new AG packs;

reordering the data dependency graph to place the AGs in each new AG pack together for concurrent execution on an integrated circuit device; and

generating machine instructions based on the reordered data dependency graph for execution on the integrated circuit device to implement the neural network model.

2 . The computer-implemented method of claim 1 , wherein the AG packs of each packing candidate are unreachable to each other in the data dependency graph, and have an identical weight tensor shape.

3 . The computer-implemented method of claim 1 , wherein the similarity metric is a prioritized list of attributes of the AG packs of the packing candidate in which an instruction proximity measurement in the data dependency graph has a highest priority.

4 . The computer-implemented method of claim 1 , wherein the tile arrangement of the processing engine array includes at least 4 row groups in a tile arrangement.

5 . A computer-implemented method comprising:

obtaining a representation of a data dependency graph of a neural network model;

identifying accumulation groups (AGs) having one or more matrix multiplication instructions in the data dependency graph;

initializing AG packs each including one of the AGs;

combining the AG packs in the data dependency graph to form new AG packs;

reordering the data dependency graph to place the AGs in each new AG pack together for concurrent execution on an integrated circuit device; and

generating machine instructions based on the reordered data dependency graph for execution on the integrated circuit device.

6 . The computer-implemented method of claim 5 , further comprising:

combining AG packs in the reordered data dependency graph based on a set of packing criteria and similarity metric.

7 . The computer-implemented method of claim 5 , wherein combining the AG packs in the data dependency graph includes:

identifying AG pack pairs that are within a search window distance in the data dependency graph;

forming a set of packing candidates from AG pack pairs that satisfy a set of packing criteria, each packing candidate containing an AG pack pair; and

iteratively performing operations on the packing candidates until all packing candidates are pruned from the set of packing candidates, the operations including:

selecting a packing candidate having an AG pack pair whose members are most similar to each other;

forming a new AG pack by grouping the AG packs in the selected packing candidate together; and

pruning packing candidates from the set of packing candidates having at least one of the AG packs in the selected packing candidate.

8 . The computer-implemented method of claim 5 , wherein the AG packs are combined based on a criterion of the AG packs of a packing candidate being unreachable in the data dependency graph.

9 . The computer-implemented method of claim 5 , wherein the AG packs are combined based on a criterion of the AG packs of a packing candidate being able to fit in a tile arrangement of a processing engine array.

10 . The computer-implemented method of claim 5 , wherein the AG packs are combined based on a criterion of the AG packs of a packing candidate having a tensor size that is larger than an instruction fetch latency threshold.

11 . The computer-implemented method of claim 5 , wherein the AG packs are combined based on a criterion of the AG packs of a packing candidate having an identical weight tensor shape.

12 . The computer-implemented method of claim 5 , wherein the AG packs are combined based on a prioritized list of attributes of the AG packs of a packing candidate.

13 . The computer-implemented method of claim 5 , wherein the AG packs are combined based on an instruction proximity measurement between the AG packs of a packing candidate in an intermediate representation of the neural network model.

14 . The computer-implemented method of claim 13 , wherein the instruction proximity measurement is a Hausdorff distance.

15 . The computer-implemented method of claim 5 , wherein the AG packs are combined based on a comparison of feature map sizes of the AG packs of a packing candidate.

16 . The computer-implemented method of claim 5 , wherein the AG packs are combined based on a comparison of a number of matrix multiplications in the AG packs of a packing candidate.

17 . The computer-implemented method of claim 5 , wherein the AG packs are combined based on a comparison of an innermost loop identifiers of the AG packs of a packing candidate.

18 . A non-transitory computer-readable medium having stored therein instructions that, when executed by one or more processors, cause the one or more processors to execute a compiler, the compiler performing operations including:

obtaining a representation of a data dependency graph of a neural network model;

identifying accumulation groups (AGs) having one or more matrix multiplication instructions in the data dependency graph;

initializing AG packs each including one of the AGs;

combining the AG packs in the data dependency graph to form new AG packs;

reordering the data dependency graph according to the new AG packs to place the AGs in each new AG pack together for concurrent execution on an integrated circuit device; and

generating machine instructions based on the reordered data dependency graph for execution on the integrated circuit device.

19 . The non-transitory computer-readable medium of claim 18 , wherein the AG packs are combined based on a set of packing criteria that includes:

a first criterion of the AG packs of a packing candidate being able to fit in a tile arrangement of a processing engine array; and

a second criterion of the AG packs of the packing candidate being unreachable in the data dependency graph.

20 . The non-transitory computer-readable medium of claim 18 , wherein the AG packs are combined based on prioritizing an instruction proximity measurement in the data dependency graph of the AG packs of a packing candidate.

21 . The non-transitory computer-readable medium of claim 18 , assigning the AGs in each new AG pack to a tile arrangement of a processing engine array.

22 . The non-transitory computer-readable medium of claim 18 , wherein the AG packs are combined based on a comparison of feature map sizes or a number of matrix multiplications in the AG packs of a packing candidate.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Mar 30, 2022
From: GAI, JIADING; EDLER VON KOCH, TOBIAS JOSEPH KASTULUS; GEVA, ROBERT; MEYER, PAUL GILBERT; KRETSCH, DONALD JOHN; DIAMANT, RON
To: AMAZON TECHNOLOGIES, INC.
Reel/Frame 059449/0380 →
References Cited (25)
US 11782706B1 · Diamant · 2023 [cited by examiner]
US 20150106596A1 · Vorbach · 2015 [cited by examiner]
US 20190278593A1 · Elango · 2019 [cited by examiner]
US 20190391796A1 · Brady · 2019 [cited by examiner]
US 20200409717A1 · Huynh · 2020 [cited by examiner]
US 20210312320A1 · Shah · 2021 [cited by examiner]
US 20220156322A1 · Singh · 2022 [cited by examiner]
US 20220229641A1 · Meister · 2022 [cited by examiner]
US 20220309027A1 · Nama · 2022 [cited by examiner]
US 20220343145A1 · Xue et al. · 2022 [cited by applicant]
US 20220414455A1 · Collins et al. · 2022 [cited by applicant]
Arslan, Mehmet Ali, et al. “Code generation for a SIMD architecture with custom memory organisation.” 2016 Conference on Design and Architectures for Signal and Image Processing (DASIP). IEEE, 2016. (Year: 2016). [cited by examiner]
Lakhotia, Kartik, et al. “Recall: Reordered cache aware locality based graph processing.” 2017 IEEE 24th International Conference on High Performance Computing (HiPC). IEEE, 2017. (Year: 2017). [cited by examiner]
Chen, Peng, et al. “A versatile software systolic execution model for GPU memory-bound kernels.” Proceedings of the International Conference for High Performance Computing, Networking, Storage and Analysis. 2019. (Year:… [cited by examiner]
Rotem, Nadav, et al. “Glow: Graph lowering compiler techniques for neural networks.” arXiv preprint arXiv:1805.00907v3 (2019). (Year: 2019). [cited by examiner]
Vasilache, Nicolas, et al. “Composable and modular code generation in MLIR: A structured and retargetable approach to tensor compiler construction.” arXiv preprint arXiv:2202.03293 (2022). (Year: 2022). [cited by examiner]
D. Nuzman, I. Rosen, and A. Zaks, “Auto-Vectorization of Interleaved Data for SIMD”, [cited by applicant]
G. Goff, K. Kennedy, and C.-W. Tseng, “Practical Dependence Testing”. [cited by applicant]
J. Llosa, et al., “Swing Modulo Scheduling: A Lifetime-Sensitive Approach” in [cited by applicant]
R. Allen, K. Kennedy, “Automatic Translation of FORTRAN Programs to Vector Form”, [cited by applicant]
I. Rosen, D. Nuzman, and A. Zaks, “Loop-Aware SLP in GCC” in [cited by applicant]
S. Larsen and S. Amarasinghe, “Exploiting Superword Level Parallelism with Multimedia Instruction Sets”, [cited by applicant]
T. Kohonen, “The self-organizing map” in [cited by applicant]
U.S. Appl. No. 17/657,279, Gai et al., filed Mar. 30, 2022. [cited by applicant]
U.S. Notice of Allowance dated Aug. 21, 2025 in U.S. Appl. No. 17/657,279. [cited by applicant]