IP Library Granted Patent US 12,475,355
Granted Patent B2
US 12,475,355 · App. 17/289,227 · Granted Nov 18, 2025

Quantizing trained long short-term memory neural networks

Inventor: Raziel Alvarez Guevara (Menlo Park, CA)
Assignee: Google LLC
G06N3/044G06N3/045
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,475,355
App. No.
17/289,227
Granted
Nov 18, 2025
Kind
B2
Abstract

Method for quantizing a trained long short-term memory (LSTM) neural network having a plurality of weights, the method comprising: obtaining data specifying trained floating-point values for each of the weights of the trained LSTM neural network, the trained LSTM neural network comprising one or more LSTM layers, each LSTM layer having a plurality of gates and each of the plurality of gates being associated with an input weight matrix and a recurrent weight matrix; quantizing the trained LSTM neural network, comprising: for each gate, quantizing the elements of the input weight matrix to a target fixed bit-width; for each gate, quantizing the elements of the recurrent weight matrix to the target fixed bit-width; and providing data specifying a quantized LSTM neural network for use in performing quantized inference.

Claims (108)

1 . A method for quantizing a trained long short-term memory (LSTM) neural network having a plurality of weights, the method comprising:

obtaining data specifying trained floating-point values for each of the weights of the trained LSTM neural network, the trained LSTM neural network comprising one or more LSTM layers, each LSTM layer having a plurality of gates, each gate of the plurality of gates comprising a corresponding gate bias and is associated with an input weight matrix and a recurrent weight matrix;

determining, from first elements of the input weight matrix, that a first ratio between a minimum value and a maximum value of the first elements fails to satisfy a threshold;

determining, from second elements of the recurrent weight matrix, that a second ratio between a minimum value and a maximum value of the second elements fails to satisfy the threshold;

determining that the first elements of the input weight matrix or the second elements of the recurrent weight matrix are represented as floating-point values;

in response that the first elements of the input weight matrix or the second elements of the recurrent weight matrix are represented as floating-point values, determining a rounding error;

quantizing the trained LSTM neural network by:

for at least one of the plurality of gates, determining that the corresponding gate bias of the at least one of the plurality of gates is represented as a floating-point value;

based on determining that the corresponding gate bias of the at least one of the plurality of gates is represented as the floating-point value, quantizing the corresponding gate bias of the at least one of the plurality of gates to a target bias bit-width;

based on determining that the first ratio between the minimum value and the maximum value of the first elements fails to satisfy the threshold, for each gate, quantizing the first elements of the input weight matrix to a target fixed bit-width using asymmetric quantization with an offset value;

based on determining that the second ratio between the minimum value and the maximum value of the second elements fails to satisfy the threshold, for each gate, quantizing the second elements of the recurrent weight matrix to the target fixed bit-width using asymmetric quantization with the offset value; and

for each LSTM layer, quantizing the first elements of the input weight matrix or the second elements of the recurrent weight matrix to the target fixed bit-width using the rounding error; and

providing data specifying a quantized LSTM neural network for use in performing quantized inference.

2 . The method of claim 1 , wherein quantizing the trained LSTM neural network further comprises:

for each gate, determining a scale factor, wherein the scale factor is:

scale

factor

=

2

target

fixed

bit

-

width

-

1

maximum

value

-

minimum

value

for each gate, applying the scale factor to the first elements of the input weight matrix; and

for each gate, applying the scale factor to the second elements of the recurrent weight matrix.

3 . The method of claim 1 , wherein quantizing the LSTM network further comprises quantizing, for each gate, a respective gate output for the gate obtained by processing a respective input through the gate.

4 . The method of claim 1 , wherein the target fixed bit-width is 8 bits.

5 . The method of claim 1 , wherein each LSTM layer receives an input vector and a recurrent vector, and wherein the method further comprises:

for each gate, determining a minimum and a maximum of products of the trained floating-point values of the input weight matrix and input vectors for a set of test inputs to the trained LSTM neural network;

for each gate, determining a minimum and a maximum of products of the trained floating-point values of the recurrent weight matrix and recurrent vectors for the set of test inputs;

for each gate, determining a minimum and a maximum of respective gate outputs for the gate; and

providing data specifying the quantized LSTM neural network for use in performing quantized inference, the data comprising:

the minimum and the maximum of the products of the trained floating-point values of the input weight matrix and the input vectors for the set of test inputs,

the minimum and the maximum of the products of the trained floating-point values of the recurrent weight matrix and the recurrent vectors for the set of test inputs, and

the minimum and the maximum of the respective gate outputs for each gate in the LSTM neural network.

6 . The method of claim 5 , wherein the trained LSTM neural network is configured to receive speech utterances and the set of test inputs is data representing a speech utterance.

7 . The method of claim 1 , wherein quantizing the corresponding gate bias of the at least one of the plurality of gates to the target bias bit-width comprises quantizing the corresponding gate bias using asymmetric quantization.

8 . The method of claim 1 , wherein the target bias bit-width is different than the target fixed bit-width.

9 . The method of claim 1 , wherein the target bias bit-width is 32 bits.

10 . The method of claim 1 , wherein providing data specifying the quantized LSTM neural network for use in performing quantized inference comprises for each LSTM layer, providing the quantized corresponding gate bias for the at least one of the plurality of gates.

11 . The method of claim 1 , further comprising:

determining that a floating-point co-processor is not available to a target computing device used to implement the trained LSTM neural network,

wherein quantizing the corresponding gate bias of the at least one of the plurality of gates is further based on determining that a floating-point co-processor is not available to a target computing device used to implement the trained LSTM neural network.

12 . A method of performing an inference task of generating output data based on input data, the method comprising:

obtaining data specifying trained floating-point values for each of a plurality of weights of a trained long short-term memory (LSTM) neural network, the trained LSTM neural network comprising one or more LSTM layers, each LSTM layer having a plurality of gates, each gate of the plurality of gates comprising a corresponding gate bias and is associated with an input weight matrix and a recurrent weight matrix;

determining, from first elements of the input weight matrix, that a first ratio between a minimum value and a maximum value of the first elements fails to satisfy a threshold;

determining, from second elements of the recurrent weight matrix, that a second ratio between a minimum value and a maximum value of the second elements fails to satisfy the threshold;

determining that the first elements of the input weight matrix or the second elements of the recurrent weight matrix are represented as floating-point values;

in response that the first elements of the input weight matrix or the second elements of the recurrent weight matrix are represented as floating-point values, determining a rounding error;

quantizing the trained LSTM neural network by:

for at least one of the plurality of gates, determining that the corresponding gate bias of the at least one of the plurality of gates is represented as a floating-point value;

based on determining that the corresponding gate bias of the at least one of the plurality of gates is represented as the floating-point value, quantizing the corresponding gate bias of the at least one of the plurality of gates to a target bias bit-width;

based on determining that the first ratio between the minimum value and the maximum value of the first elements fails to satisfy the threshold, for each gate, quantizing the first elements of the input weight matrix to a target fixed bit-width using asymmetric quantization with an offset value;

based on determining that the second ratio between the minimum value and the maximum value of the second elements fails to satisfy the threshold, for each gate, quantizing the second elements of the recurrent weight matrix to the target fixed bit-width using asymmetric quantization with the offset value; and

for each LSTM layer, quantizing the first elements of the input weight matrix or the second elements of the recurrent weight matrix to the target fixed bit-width using the rounding error;

obtaining data specifying a quantized LSTM neural network having a plurality of weights;

generating the quantized LSTM neural network based on the obtained data; and

processing the input data through the quantized LSTM neural network to generate the output data.

13 . The method of claim 12 , wherein:

the input data comprises real-world data obtained by at least one sensor and is representative of the real world; and

the output data comprises control data for controlling a device arranged to operate on the input data.

14 . One or more non-transitory computer-readable storage media storing instructions that when executed by one or more computers cause the one or more computers to perform operations for quantizing a trained long short-term memory (LSTM) neural network having a plurality of weights, the operations comprising:

obtaining data specifying trained floating-point values for each of the weights of the trained LSTM neural network, the trained LSTM neural network comprising one or more LSTM layers, each LSTM layer having a plurality of gates, each gate of the plurality of gates comprising a corresponding gate bias and is associated with an input weight matrix and a recurrent weight matrix;

determining, from first elements of the input weight matrix, that a first ratio between a minimum value and a maximum value of the first elements fails to satisfy a threshold;

determining, from second elements of the recurrent weight matrix, that a second ratio between a minimum value and a maximum value of the second elements fails to satisfy the threshold;

determining that the first elements of the input weight matrix or the second elements of the recurrent weight matrix are represented as floating-point values;

in response that the first elements of the input weight matrix or the second elements of the recurrent weight matrix are represented as floating-point values, determining a rounding error;

quantizing the trained LSTM neural network by:

for at least one of the plurality of gates, determining that the corresponding gate bias of the at least one of the plurality of gates is represented as a floating-point value;

based on determining that the corresponding gate bias of the at least one of the plurality of gates is represented as the floating-point value, quantizing the corresponding gate bias of the at least one of the plurality of gates to a target bias bit-width;

based on determining that the first ratio between the minimum value and the maximum value of the first elements fails to satisfy the threshold, for each gate, quantizing the first elements of the input weight matrix to a target fixed bit-width using asymmetric quantization with an offset value;

based on determining that the second ratio between the minimum value and the maximum value of the second elements fails to satisfy the threshold, for each gate, quantizing the second elements of the recurrent weight matrix to the target fixed bit-width using asymmetric quantization with the offset value; and

for each LSTM layer, quantizing the first elements of the input weight matrix or the second elements of the recurrent weight matrix to the target fixed bit-width using the rounding error; and

providing data specifying a quantized LSTM neural network for use in performing quantized inference.

15 . A system comprising one or more computers and one or more storage devices storing instructions that when executed by one or more computers cause the one or more computers to perform operations for quantizing a trained long short-term memory (LSTM) neural network having a plurality of weights, the operations comprising:

obtaining data specifying trained floating-point values for each of the weights of the trained LSTM neural network, the trained LSTM neural network comprising one or more LSTM layers, each LSTM layer having a plurality of gates, each gate of the plurality of gates comprising a corresponding gate bias and is associated with an input weight matrix and a recurrent weight matrix;

determining, from first elements of the input weight matrix, that a first ratio between a minimum value and a maximum value of the first elements fails to satisfy a threshold;

determining, from second elements of the recurrent weight matrix, that a second ratio between a minimum value and a maximum value of the second elements fails to satisfy the threshold;

determining that the first elements of the input weight matrix or the second elements of the recurrent weight matrix are represented as floating-point values;

in response that the first elements of the input weight matrix or the second elements of the recurrent weight matrix are represented as floating-point values, determining a rounding error;

quantizing the trained LSTM neural network by:

for at least one of the plurality of gates, determining that the corresponding gate bias of the at least one of the plurality of gates is represented as a floating-point value;

based on determining that the corresponding gate bias of the at least one of the plurality of gates is represented as the floating-point value, quantizing the corresponding gate bias of the at least one of the plurality of gates to a target bias bit-width;

based on determining that the first ratio between the minimum value and the maximum value of the first elements fails to satisfy the threshold, for each gate, quantizing the first elements of the input weight matrix to a target fixed bit-width using asymmetric quantization with an offset value;

based on determining that the second ratio between the minimum value and the maximum value of the second elements fails to satisfy the threshold, for each gate, quantizing the second elements of the recurrent weight matrix to the target fixed bit-width using asymmetric quantization with the offset value; and

for each LSTM layer, quantizing the first elements of the input weight matrix or the second elements of the recurrent weight matrix to the target fixed bit-width using the rounding error; and

providing data specifying a quantized LSTM neural network for use in performing quantized inference.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Apr 28, 2021
From: GUEVARA, RAZIEL ALVAREZ
To: GOOGLE LLC
Reel/Frame 056064/0310 →
Continuity (2)
Provisional Application 62752914 · Oct 30, 2018
Related Publication 20220036155A1 · Feb 3, 2022
References Cited (24)
US 10579383B1 · Rotem · 2020 [cited by examiner]
US 20070180434A1 · Forin · 2007 [cited by examiner]
US 20150347819A1 · Yin · 2015 [cited by examiner]
US 20180121796A1 · Deisher · 2018 [cited by examiner]
US 20190012559A1 · Desappan · 2019 [cited by examiner]
US 20190042935A1 · Deisher · 2019 [cited by examiner]
US 20190171927A1 · Diril · 2019 [cited by examiner]
US 20190243610A1 · Lin · 2019 [cited by examiner]
US 20190294413A1 · Vantrease · 2019 [cited by examiner]
US 20220019915A1 · Bryan · 2022 [cited by examiner]
US 20220366238A1 · Liu · 2022 [cited by examiner]
He, Qinyao, et al. “Effective quantization methods for recurrent neural networks.” arXiv preprint arXiv:1611.10176 (2016), pp. 1-20 (Year: 2016). [cited by examiner]
Alvarez, Raziel, et al. “On the efficient representation and execution of deep acoustic models.” arXiv preprint arXiv:1607.04683 (Dec. 17, 2016) (Year: 2016). [cited by examiner]
Lu, Yuzhen, et al. “Simplified gating in long short-term memory (lstm) recurrent neural networks.” 2017 IEEE 60th international midwest symposium on circuits and systems (MWSCAS) (2017), pp. 1601-1604 (Year: 2017). [cited by examiner]
Ott, Joachim, et al. “Recurrent neural networks with limited numerical precision.” arXiv preprint arXiv:1608.06902 (2017), pp. 1-11 (Year: 2017). [cited by examiner]
Wang, Zhisheng, et al. “Accelerating recurrent neural networks: A memory-efficient approach.” IEEE Transactions on Very Large Scale Integration (VLSI) Systems 25.10 (2017): pp. 2763-2775 (Year: 2017). [cited by examiner]
Zhou, Shu-Chang, et al. “Balanced quantization: An effective and efficient approach to quantized neural networks.” Journal of Computer Science and Technology 32 (2017): pp. 667-682 (Year: 2017). [cited by examiner]
Lai, Liangzhen, et al. “Rethinking machine learning development and deployment for edge devices.” arXiv preprint arXiv: 1806.07846 (Jun. 20, 2018). (Year: 2018). [cited by examiner]
Krishnamoorthi, Raghuraman. “Quantizing deep convolutional networks for efficient inference: A whitepaper.” arXiv preprint arXiv: 1806.08342 (Jun. 21, 2018), pp. 1-36 (Year: 2018). [cited by examiner]
International Search Report and Written Opinion for the related International Application No. PCT/US2019/058821 dated Apr. 20, 2020, 83 pages. [cited by applicant]
Raghuraman Krishnamoorthi: “Quantizing deep convolutional networks for efficient inference: A white paper”, arxiv.org, Cornell University Library, 201 Olin Library Cornell University Ithaca, NY 14853, Jun. 21, 2018 (Jun… [cited by applicant]
Benoit Jacob et al: “Quantization and Training of Neural Networks for Efficient Integer-Arithmetic-Only Inference”, arxiv.org, Cornell University Library, 201 Olin Library Cornell University Ithaca, NY 14853, Dec. 16, 2… [cited by applicant]
Li-Wen Chang et al: “Accelerating Recurrent Neural Networks through Compiler Techniques and Quantizaton”, Conference on Neural Information Processing Systems (NI PS), Dec. 3, 2018 (Dec. 3, 2018), XP055681357, Sections 4… [cited by applicant]
Alom Md Zahangir et al: “Effective Quantization Approaches for Recurrent Neural Networks”, 2018 International Joint Conference on Neural Networks (IJCNN), IEEE, Jul. 8, 2018 (Jul. 8, 2018), pp. 1-8, XP033419197, DOI: 10… [cited by applicant]