Quantization error compensation for vector computing
A method for performing a computing task includes: extracting one or more features from a user content; converting the features to a floating point query vector; quantizing the floating point query vector; obtaining a database vector including one or more floating point feature vectors; determining a compensation vector based on a data distribution of the floating point query vector; quantizing the floating point feature vectors; determining an error function based on a difference between data distributions of i) the quantized query vector compensated with the compensation vector, and ii) the floating point query vector; determining, based on the error function, values of the compensation vector corresponding to the quantized feature vectors; combining the quantized query vectors and the values of the compensation vector to obtain one or more compensated query vectors; and performing the computing task using the compensated query vectors and the quantized feature vectors to obtain an output.
1 . A method for performing a computing task based on a user content, the method comprising:
extracting one or more features from the user content, the one or more features corresponding to a search request indicated in the user content;
converting the one or more features to a floating point query vector;
quantizing the floating point query vector to obtain a quantized query vector;
obtaining a database vector based on the one or more features, the database vector comprising one or more floating point feature vectors;
determining a compensation vector based on a data distribution of the floating point query vector;
quantizing the one or more floating point feature vectors to obtain one or more quantized feature vectors;
determining an error function based on a difference between data distributions of i) the quantized query vector compensated with the compensation vector, and ii) the floating point query vector;
determining, based on the error function, one or more values of the compensation vector corresponding to the one or more quantized feature vectors, wherein the one or more values of the compensation vector are determined such that a difference in magnitude between the quantized query vector compensated with the compensation vector and each of the one or more quantized feature vectors is below a known threshold value;
combining the one or more quantized query vectors and the one or more values of the compensation vector to obtain one or more compensated query vectors; and
performing the computing task using the one or more compensated query vectors and the one or more quantized feature vectors to obtain an output.
2 . The method of claim 1 , wherein the computing task comprises performing at least one of a multiply-and-accumulate operation, general matrix multiplication (GeMM), fully connected layer computing, or k-nearest neighbors computing.
3 . The method of claim 1 , wherein the computing task comprises computing a plurality of vector distances.
4 . The method of claim 3 , wherein the plurality of vector distances comprises at least one of: a plurality of cosine similarity distances, a plurality of Euclidean distances, or a plurality of Hamming distances.
5 . The method of claim 3 , further comprising generating a response to the user content based on the output, wherein generating the response comprises sorting the plurality of vector distances in a descending order or an ascending order.
6 . The method of claim 1 , wherein the user content comprises at least one of:
graphical information, textual information, geographical information, or temporal information.
7 . The method of claim 1 , further comprising receiving the user content from at least one of: a text-based search engine, a graph-based search engine, a brute force search engine, or a behavior-based content recommendation system.
8 . The method of claim 1 , wherein performing the computing task comprises performing the computing task using an in-memory computing (IMC) circuit, and wherein the IMC circuit comprises a plurality of memory cells comprising at least one of NAND flash cells, NOR flash cells, phase change memory (PCM), Magnetoresistive random-access memory (MRAM), Ferroelectirc random-access memory (FeRAM), or Spin-Transfer-Torque random-access memory (STT-RAM).
9 . A computing system comprising:
one or more processors; and a computing circuit coupled to the one or more processors, wherein the one or more processors are configured to execute instructions to perform operations comprising:
extracting one or more features from user content, the one or more features corresponding to a search request indicated in the user content;
converting the one or more features to a floating point query vector;
quantizing the floating point query vector to obtain a quantized query vector;
obtaining a database vector based on the one or more features, the database vector comprising one or more floating point feature vectors;
determining a compensation vector based on a data distribution of the floating point query vector;
quantizing the one or more floating point feature vectors to obtain one or more quantized feature vectors;
determining an error function based on a difference between data distributions of i) the quantized query vector compensated with the compensation vector, and ii) the floating point query vector;
determining, based on the error function, one or more values of the compensation vector corresponding to the one or more quantized feature vectors, wherein the one or more values of the compensation vector are determined such that a difference in magnitude between the quantized query vector compensated with the compensation vector and each of the one or more quantized feature vectors is below a known threshold value;
combining the one or more quantized query vectors and the one or more values of the compensation vector to obtain one or more compensated query vectors; and
performing, by the computing circuit, a computing task using the one or more compensated query vectors and the one or more quantized feature vectors to obtain an output.
10 . The computing system of claim 9 , wherein the computing task comprises performing at least one of: a multiply-and-accumulate operation, general matrix multiplication (GeMM), fully connected layer computing, or k-nearest neighbors computing.
11 . The computing system of claim 10 , wherein the computing task comprises computing a plurality of vector distances, and wherein the plurality of vector distances comprises at least one of: a plurality of cosine similarity distances, a plurality of Euclidean distances, or a plurality of Hamming distances.
12 . The computing system of claim 10 , the operations further comprising generating a response to the user content based on the output, wherein generating the response comprises sorting the plurality of vector distances in a descending order or an ascending order.
13 . The computing system of claim 9 , wherein the user content comprises at least one of: graphical information, textual information, geographical information, or temporal information.
14 . The computing system of claim 9 , the operations further comprising receiving the user content from at least one of: a text-based search engine, a graph-based search engine, a brute force search engine, or a recommendation system.
15 . The computing system of claim 9 , wherein the computing circuit comprises an in-memory computing (IMC) circuit, wherein the IMC circuit comprises a plurality of memory cells comprising at least one of: NAND flash cells, NOR flash cells, phase change memory (PCM), Magnetoresistive random-access memory (MRAM), Ferroelectirc random-access memory (FeRAM), or Spin-Transfer-Torque random-access memory (STT-RAM).
16 . A non-transitory computer-readable medium storing program instructions that, when executed, cause one or more processors to perform operations comprising:
extracting one or more features from user content, the one or more features corresponding to a search request indicated in the user content;
converting the one or more features to a floating point query vector;
quantizing the floating point query vector to obtain a quantized query vector;
obtaining a database vector based on the one or more features, the database vector comprising one or more floating point feature vectors;
determining a compensation vector based on a data distribution of the floating point query vector;
quantizing the one or more floating point feature vectors to obtain one or more quantized feature vectors;
determining an error function based on a difference between data distributions of i) the quantized query vector compensated with the compensation vector, and ii) the floating point query vector;
determining, based on the error function, one or more values of the compensation vector corresponding to the one or more quantized feature vectors, wherein the one or more values of the compensation vector are determined such that a difference in magnitude between the quantized query vector compensated with the compensation vector and each of the one or more quantized feature vectors is below a known threshold value;
combining the one or more quantized query vectors and the one or more values of the compensation vector to obtain one or more compensated query vectors; and
performing a computing task using the one or more compensated query vectors and the one or more quantized feature vectors to obtain an output.
17 . The non-transitory computer-readable medium of claim 16 , wherein the computing task comprises computing a plurality of vector distances.