# US 2024/0005133 A1 · Hardware acceleration framework for graph neural network quantization

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2024/0005133 A1
- Document ID: US20240005133A1
- Status: Published application
- Kind: A1
- Application number: 17/899,557
- Filed: 2022-08-30
- Published: 2024-01-04
- Earliest claimed: 2022-07-01
- Assignees: Alibaba (China) Co., Ltd.
- Applicants: Alibaba (China) Co., Ltd.
- Inventors: Linyong HUANG; Zhe ZHANG; Shuangchen LI; Hongzhong ZHENG
- Web page: https://patentgrep.com/patent/US20240005133A1

## CPC

- G06N 3/0495: Quantised networks; Sparse networks; Compressed networks
- G06N 3/063: using electronic means
- G06F 16/9014: {hash tables}
- G06N 3/04: Architecture, e.g. interconnection topology
- G06N 3/08: Learning methods
- G06N 20/10: using kernel methods, e.g. support vector machines [SVM]
- G06N: COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

This application describes an hardware and a software design for quantization in GNN computation. An exemplary method may include: receiving a graph comprising a plurality of nodes respectively represented by a plurality of feature vectors; segmenting the plurality of feature vectors into a plurality of sub-vectors and grouping the plurality of sub-vectors into a plurality of groups of sub-vectors; performing vector clustering on each of the plurality of groups of sub-vectors to generate a plurality of centroids as a codebook; encoding each of the plurality of feature vectors to obtain a plurality of index maps by quantizing sub-vectors within the each feature vector based on the codebook, wherein each index map occupies a smaller storage space than the each feature vector does; and storing the plurality of index maps as an assignment table instead of the plurality of feature vectors to represent the plurality of nodes for GNN computation.

## Claims

### Claim 1

A computer-implemented method for accelerating graph neural network (GNN) computation using product quantization, comprising:
receiving, by a graph neural network (GNN) accelerator, a graph comprising a plurality of nodes as an input for the GNN computation, wherein the plurality of nodes are respectively represented by a plurality of feature vectors;
segmenting, by the GNN accelerator, the plurality of feature vectors into a plurality of sub-vectors;
grouping, by the GNN accelerator, the plurality of sub-vectors into a plurality of groups of sub-vectors;
performing, by the GNN accelerator, vector clustering on each of the plurality of groups of sub-vectors to generate a plurality of centroids;
storing, by the GNN accelerator, the plurality of centroids as a codebook;
encoding, by the GNN accelerator, each of the plurality of feature vectors into an index map to obtain a plurality of index maps by quantizing sub-vectors within the each feature vector based on the codebook, wherein the index map occupies a smaller memory space than the each feature vector does; and
storing, by the GNN accelerator, the plurality of index maps as an assignment table and the codebook to represent the plurality of nodes for the GNN computation, wherein the GNN computation comprises decoding the plurality of index maps based on the assignment table and the codebook, storing the assignment table and the codebook saves memory space than directly storing the plurality of feature vectors, and storing the assignment table and the codebook comprises storing at least a portion of the codebook on an on-chip memory of the GNN accelerator.

### Claim 2 (depends on 1)

The method of claim 1, wherein the segmenting the plurality of feature vectors into the plurality of sub-vectors and grouping the plurality of sub-vectors into a plurality of groups of sub-vectors comprises:
segmenting the plurality of feature vectors into the plurality of sub-vectors of a predetermined sub-vector size; and
grouping the sub-vectors into the plurality of groups of sub-vectors based on an offset of each sub-vector within a corresponding feature vector.

### Claim 3 (depends on 1)

The method of claim 1, prior to the segmenting the plurality of feature vectors into a plurality of sub-vectors, further comprising:
quantifying a sparsity level of the plurality of feature vectors;
determining a sub-vector size based on the sparsity level, wherein the sparsity level is inversely proportional to the sub-vector size; and
segmenting the plurality of feature vectors into the plurality of sub-vectors with the determined sub-vector size.

### Claim 4 (depends on 1)

The method of claim 1, wherein each of the plurality of sub-vectors comprises one sub-vector from each of the plurality of feature vectors at a same offset.

### Claim 5 (depends on 1)

The method of claim 1, wherein the vector clustering comprises K-means or Support Vector Clustering (SVC).

### Claim 6 (depends on 1)

The method of claim 1, wherein the performing vector clustering on each of the plurality of groups of sub-vectors to generate the plurality of centroids comprises:
within each of the plurality of groups of sub-vectors, determining multiple centroids by executing a vector clustering algorithm, wherein each of the multiple centroids comprises a vector of a same size as each of the plurality of sub-vectors.

### Claim 7 (depends on 1)

The method of claim 1, wherein the storing the plurality of centroids in the codebook comprises:
indexing the plurality of centroids with a plurality of indices; and
storing mappings between the plurality of indices and the plurality of centroids.

### Claim 8 (depends on 1)

The method of claim 1, wherein the quantizing the sub-vectors within the each feature vector based on the codebook comprises:
for each of the sub-vectors that belongs to one of the plurality of groups of sub-vectors, determining one or more of the plurality of centroids that correspond to the one group of sub-vectors;
determining a vector distance between the sub-vector and each of the one or more centroids;
identifying one of the one or more centroids having a shortest vector distance to the sub-vector; and
encoding the sub-vector using an index of the one identified centroid, wherein storing the index uses less number of bytes than storing the sub-vector.

### Claim 9 (depends on 1)

The method of claim 1, wherein the decoding comprises:
receiving a request for a feature vector representing a graph node;
obtaining the index map corresponding to the requested feature vector, wherein the index map comprises one or more indices corresponding to one or more of the plurality of centroids;
obtaining the one or more centroids based on the one or more indices and the codebook; and
aggregating the one or more centroids as the requested feature vector of the graph node.

### Claim 10 (depends on 1)

The method of claim 1, wherein the performing vector clustering on each of the plurality of groups of sub-vectors comprises:
filtering out sub-vectors comprising all zeros from the plurality of sub-vectors;
excluding the sub-vectors comprising all zeros from the vector clustering;
assigning a special centroid to represent all of the sub-vectors comprising all zeros; and
performing the vector clustering on the sub-vectors comprising non-zero data.

### Claim 11 (depends on 1)

The method of claim 1, wherein the method further comprises:
assigning a higher priority for storing the codebook and a lower priority for storing the assignment table, and
wherein the storing the codebook and the assignment table comprises:
in response to an on-chip memory being sufficient to store both the codebook and the assignment table, storing both codebook and the assignment table in the on-chip memory; and
in response to the on-chip memory being insufficient to store both the code book and the assignment table, storing the codebook in the on-chip memory and storing the assignment table in an off-chip memory.

### Claim 12 (depends on 1)

The method of claim 1, further comprising:
batching the plurality of nodes into a plurality of batches and assigning the plurality of batches into a plurality of processing units for parallel encoding, wherein the parallel encoding comprises:
generating a codebook and an assignment table for each of the plurality of batches.

### Claim 13 (depends on 12)

The method of claim 12, wherein the batching comprises:
batching the plurality of nodes into the plurality of batches by applying a hash function to node indices of the plurality of nodes.

### Claim 14 (depends on 12)

The method of claim 12, wherein the batching comprises:
batching the plurality of nodes into the plurality of batches based on locality of each node within the graph.

### Claim 15

A hardware accelerator for accelerating graph neural network (GNN) computation based on product quantization, comprising:
an on-chip memory;
a graph node feature vector segmenting circuitry configured to:
receive a graph comprising a plurality of nodes as an input for the GNN computation, wherein the plurality of nodes are respectively represented by a plurality of feature vectors;
segment the plurality of feature vectors into a plurality of sub-vectors;
group the plurality of sub-vectors into a plurality of groups of sub-vectors;
a feature vector clustering circuitry configured to:
perform vector clustering on each of the plurality of groups of sub-vectors to generate a plurality of centroids;
store the plurality of centroids as a codebook;
an encoding circuitry configured to:
encode each of the plurality of feature vectors into an index map to obtain a plurality of index maps by quantizing sub-vectors within the each feature vector based on the codebook, wherein the index map occupies a smaller memory space than the each feature vector does; and
store the plurality of index maps as an assignment table and the codebook to represent the plurality of nodes for the GNN computation, wherein the GNN computation comprises decoding the plurality of index maps based on the assignment table and the codebook, storing the assignment table and the codebook saves memory space than directly storing the plurality of feature vectors, and storing the assignment table and the codebook comprises storing at least a portion of the codebook on the on-chip memory of the accelerator.

### Claim 16 (depends on 15)

The hardware accelerator of claim 15, wherein the quantizing the sub-vectors within the each feature vector based on the codebook comprises:
for each of the sub-vectors that belongs to one of the plurality of groups of sub-vectors, determining one or more of the plurality of centroids that correspond to the one group of sub-vectors;
determining a vector distance between the sub-vector and each of the one or more centroids;
identifying one of the one or more centroids having a shortest vector distance to the sub-vector; and
encoding the sub-vector using an index of the one identified centroid, wherein storing the index uses less number of bytes than storing the sub-vector.

### Claim 17 (depends on 15)

The hardware accelerator of claim 15, wherein the decoding comprises:
receiving a request for a feature vector representing a graph node;
obtaining the index map corresponding to the requested feature vector, wherein the index map comprises one or more indices corresponding to one or more of the plurality of centroids;
obtaining the one or more centroids based on the one or more indices and the codebook; and
aggregating the one or more centroids as the requested feature vector of the graph node.

### Claim 18 (depends on 15)

The hardware accelerator of claim 15, wherein to perform vector clustering on each of the plurality of groups of sub-vectors, the feature vector clustering circuitry is further configured to:
filter out sub-vectors comprising all zeros from the plurality of sub-vectors;
exclude the sub-vectors comprising all zeros from the vector clustering;
assign a special centroid to represent all of the sub-vectors comprising all zeros; and
perform the vector clustering on the sub-vectors comprising non-zero data.

### Claim 19 (depends on 15)

The hardware accelerator of claim 15, wherein the codebook has a higher priority for storage in the on-chip memory of the accelerator than the assignment table does, and the encoding circuitry is further configured to:
in response to an on-chip memory being sufficient to store both the codebook and the assignment table, store both codebook and the assignment table in the on-chip memory; and
in response to the on-chip memory being insufficient to store both the code book and the assignment table, store the codebook in the on-chip memory and storing the assignment table in an off-chip memory.

### Claim 20 (depends on 15)

The hardware accelerator of claim 15, wherein the encoding circuitry is further configured to:
batch the plurality of nodes into a plurality of batches and assigning the plurality of batches into a plurality of processing units for parallel encoding, wherein the parallel encoding comprises:
generating a codebook and an assignment table for each of the plurality of batches.
