IP Library Granted Patent US 12,699,899
Granted Patent B1
US 12,699,899 · App. 18/797,892 · Granted Aug 4, 2026

Systems and methods for generation of sparse-dense matrix multiplication code for neural network and other applications

Inventor: Aleksander Zleteski (Somerville, MA)
Assignee: Red Hat, Inc.
G06N3/08G06F9/3001G06F9/3012G06F17/16G06N3/04
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,699,899
App. No.
18/797,892
Filed
Aug 8, 2024
Granted
Aug 4, 2026
Kind
B1
Art Unit
2184
USPC
706/25
Abstract

Generating computer code to perform a matrix-multiply operation, for use in neural network compute or other applications may include determining parameters R r (number of rows for a plurality of partitioned matrices A′), Rc (number of registers used for each column of a target matrix C′), and R L (number of processor registers used as a source for targets for vector broadcast instructions. For each row r in A′, having R r rows, operations may be performed such that for each column i, if the element at row r and column i is non-zero: a vector broadcast instruction may be generate to a register for the element at row r and column i; and a set of fused multiply-add (FMA) instructions may be generated having as parameters the register, a set of registers for a target matrix, and a memory location for input data.

Claims (60)

1 . A method comprising, prior to an inference phase of a neural network:

generating computer instruction code for execution in relation to a matrix-multiply operation of the neural network, wherein generating the computer instruction code involves:

for each row r and each column i in a sparse neural network parameter matrix associated with the neural network:

analyzing an element at row r and column i to determine whether the element is a zero element or a non-zero element; and

if the element at row r and column i is a non-zero element:

generating, in the computer instruction code, a vector broadcast instruction to a register for the element at row r and column i; and

generating, in the computer instruction code, a set of fused multiply-add (FMA) instructions having as parameters the register, a set of registers for a target matrix, and a memory location for input data; or

if the element at row r and column i is a zero element, omitting corresponding instructions for the element from the computer instruction code; and

compiling the computer instruction code into compiled code, wherein the compiled code is configured to be subsequently executed during the inference phase of the neural network to perform the matrix-multiply operation using the vector broadcast instruction and set of FMA instructions generated for each non-zero element.

2 . The method of claim 1 , wherein generating a vector broadcast instruction to a register comprises:

selecting a next available register from a circular queue of registers for use as the register.

3 . The method of claim 1 , further comprising incorporating, into the computer instruction code, an additional set of instructions to combine more than one produced target matrix into a final matrix.

4 . The method of claim 1 , further comprising determining R r , R c and R L , where R r is the number of rows for the sparse neural network parameter matrix, R c is the number of registers used for each row of the target matrix, and R L is the number of registers in a queue of registers used as a source for the register for which the vector broadcast instruction is generated.

5 . The method of claim 1 , wherein the input data is represented as an input data matrix, the method further comprising determining R r and R c , where R r is the number of rows for the target matrix, and Rc is the number of registers used for each row of the input data matrix.

6 . A method comprising, prior to an inference phase of a neural network:

generating computer instruction code for execution in relation to a matrix-multiply operation of the neural network, wherein generating the computing instruction code involves:

for each row r and each column i in a first matrix associated with the neural network:

analyzing an element at row r and column i to determine whether the element is a zero element or a non-zero element; and

if the element at row r and column i is a non-zero element:

selecting a next available register from a circular queue of registers;

generating, in the computer instruction code, a vector broadcast instruction to the selected register for the element at row r and column i; and

generating, in the computer instruction code, a set of fused multiply-add (FMA) instructions having as parameters the selected register, a set of registers for a target matrix, and a memory location for input data; or

if the element at row r and column i is a zero element, omitting corresponding instructions for the element from the computer instruction code; and

compiling the computer instruction code into compiled code, wherein the compiled code is configured to be subsequently executed during the inference phase of the neural network to perform the matrix-multiply operation using the vector broadcast instruction and set of FMA instructions generated for each non-zero element.

7 . The method of claim 6 , further comprising incorporating, into the computer instruction code, an additional set of instructions to combine more than one produced target matrix into a final matrix.

8 . The method of claim 6 , further comprising determining R r , R c and R L , where R r is the number of rows for the first matrix, R c is the number of registers used for each row of the target matrix, and R L is the number of registers in the circular queue of registers used as a source for the register for which the vector broadcast instruction is generated.

9 . The method of claim 6 , wherein the input data is represented as an input data matrix, the method further comprising determining R r and R c , where R r is the number of rows for the target matrix, and Rc is the number of registers used for each row of the input data matrix.

10 . The method of claim 6 , where the first matrix represents neural network parameters.

11 . A system comprising:

a processor; and

a memory storing instructions that are executable by the processor for causing the processor to perform operations including, prior to an inference phase of a neural network:

generating computer instruction code for execution in relation to a matrix-multiply operation of the neural network, wherein generating the computer instruction code involves:

for each row r and each column i in a sparse neural network parameter matrix associated with the neural network:

analyzing an element at row r and column i to determine whether the element is a zero element or a non-zero element; and

if the element at row r and column i is a non-zero element:

 generating, in the computer instruction code, a vector broadcast instruction to a register for the element at row r and column i; and

 generating, in the computer instruction code, a set of fused multiply-add (FMA) instructions having as parameters the register, a set of registers for a target matrix, and a memory location for input data; or

if the element at row r and column i is a zero element, omitting corresponding instructions for the element from the computer instruction code; and

compiling the computer instruction code into compiled code, wherein the compiled code is configured to be subsequently executed during the inference phase of the neural network to perform the matrix-multiply operation using the vector broadcast instruction and set of FMA instructions generated for each non-zero element.

12 . The system of claim 11 , wherein generating a vector broadcast instruction to a register comprises:

selecting a next available register from a circular queue of registers for use as the register.

13 . The system of claim 11 , wherein the operations further comprise:

incorporating, into the computer instruction code, an additional set of instructions to combine more than one produced target matrix into a final matrix.

14 . The system of claim 11 , wherein the operations further comprise:

determining R r , R c and R L , where R r is the number of rows for the sparse neural network parameter matrix, R c is the number of registers used for each row of the target matrix, and R L is the number of registers in a queue of registers used as a source for the register for which the vector broadcast instruction is generated.

15 . The system of claim 11 , wherein the input data is represented as an input data matrix, and wherein the operations further comprise determining R r and R c , where R r is the number of rows for the target matrix, and Rc is the number of registers used for each row of the input data matrix.

16 . A system comprising:

a processor; and

a memory storing instructions that are executable by the processor for causing the processor to perform operations including, prior to an inference phase of a neural network:

generating computer instruction code for execution in relation to a matrix-multiply operation of the neural network, wherein generating the computer instruction code involves:

for each row r and each column i in a first matrix associated with the neural network:

analyzing an element at row r and column i to determine whether the element is a zero element or a non-zero element; and

if the element at row r and column i is a non-zero element:

 selecting a next available register from a circular queue of registers;

 generating, in the computer instruction code, a vector broadcast instruction to the selected register for the element at row r and column i; and

 generating, in the computer instruction code, a set of fused multiply-add (FMA) instructions having as parameters the selected register, a set of registers for a target matrix, and a memory location for input data; or

if the element at row r and column i is a zero element, omitting corresponding instructions for the element from the computer instruction code; and

compiling the computer instruction code into compiled code, wherein the compiled code is configured to be subsequently executed during the inference phase of the neural network to perform the matrix-multiply operation using the vector broadcast instruction and set of FMA instructions generated for each non-zero element.

17 . The system of claim 16 , wherein the operations further comprise:

incorporating, into the computer instruction code, an additional set of instructions to combine more than one produced target matrix into a final matrix.

Assignments (2)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Jul 30, 2025
From: NEURALMAGIC, INC.
To: RED HAT, INC.
Reel/Frame 072278/0309 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded May 23, 2025
From: ZLATESKI, ALEKSANDAR
To: NEURALMAGIC INC.
Reel/Frame 071209/0607 →
Continuity (6)
Continuation 18472360 · Sep 22, 2023
Continuation 18075770 · Dec 6, 2022
Continuation 16832954 · Mar 27, 2020
Continuation 16751940 · Jan 24, 2020
Continuation PCTUS2019040537 · Jul 3, 2019
Provisional Application 62746117 · Oct 16, 2018
References Cited (110)
US 5577166A · Mizuno · 1996 [cited by examiner]
US 9558156B1 · Bekas · 2017 [cited by examiner]
US 9811775B2 · Krizhevsky · 2017 [cited by examiner]
US 9818059B1 · Woo · 2017 [cited by examiner]
US 10157045B2 · Venkataramani · 2018 [cited by examiner]
US 10223333B2 · Chetlur · 2019 [cited by examiner]
US 10719323B2 · Baum · 2020 [cited by examiner]
US 10990650B1 · Vantrease · 2021 [cited by examiner]
US 11132423B2 · Chatterjee · 2021 [cited by examiner]
US 11500962B1 · Meyer · 2022 [cited by examiner]
US 11620818B2 · Pillai · 2023 [cited by examiner]
US 11803736B1 · Meyer · 2023 [cited by examiner]
US 11842423B2 · Appu · 2023 [cited by examiner]
US 11899614B2 · Ray · 2024 [cited by examiner]
US 11960566B1 · Vantrease · 2024 [cited by examiner]
US 12086205B2 · Mei · 2024 [cited by examiner]
US 12399685B2 · Parra · 2025 [cited by examiner]
US 20070172148A1 · Hawley · 2007 [cited by examiner]
US 20100076915A1 · Xu · 2010 [cited by examiner]
US 20110119467A1 · Cadambi · 2011 [cited by examiner]
US 20110296146A1 · Anand · 2011 [cited by examiner]
US 20120311299A1 · Blumrich · 2012 [cited by examiner]
US 20130138589A1 · Yu · 2013 [cited by examiner]
US 20160224465A1 · Morad · 2016 [cited by examiner]
US 20160239706A1 · Dijkman · 2016 [cited by examiner]
US 20160321031A1 · Hancock · 2016 [cited by examiner]
US 20160328643A1 · Liu · 2016 [cited by examiner]
US 20160358070A1 · Brothers · 2016 [cited by examiner]
US 20160379109A1 · Chung · 2016 [cited by examiner]
US 20170032487A1 · Ashari · 2017 [cited by examiner]
US 20170103313A1 · Ross · 2017 [cited by examiner]
US 20170103317A1 · Young · 2017 [cited by examiner]
US 20170132496A1 · Shoaib · 2017 [cited by examiner]
US 20170169567A1 · Chefd'hotel · 2017 [cited by examiner]
US 20170193361A1 · Chilimbi · 2017 [cited by examiner]
US 20170200094A1 · Bruestle · 2017 [cited by examiner]
US 20170220524A1 · Herrero Abellanas · 2017 [cited by examiner]
US 20170316311A1 · Pilly · 2017 [cited by examiner]
US 20170316312A1 · Goyal · 2017 [cited by examiner]
US 20170372202A1 · Ginsburg · 2017 [cited by examiner]
US 20180004515A1 · Yamamura · 2018 [cited by examiner]
US 20180046900A1 · Dally · 2018 [cited by examiner]
US 20180096226A1 · Aliabadi · 2018 [cited by examiner]
US 20180173571A1 · Huang · 2018 [cited by examiner]
US 20180253402A1 · Redfern · 2018 [cited by examiner]
US 20180315159A1 · Ould-Ahmed-Vall · 2018 [cited by examiner]
US 20180322390A1 · Das · 2018 [cited by examiner]
US 20180336468A1 · Kadav · 2018 [cited by examiner]
US 20190042250A1 · Anders · 2019 [cited by examiner]
US 20190042542A1 · Narayanamoorthy · 2019 [cited by examiner]
US 20190056916A1 · Varma · 2019 [cited by examiner]
US 20190138902A1 · Matveev · 2019 [cited by examiner]
US 20190156206A1 · Graham · 2019 [cited by examiner]
US 20190156215A1 · Matveev · 2019 [cited by examiner]
US 20190179818A1 · Lee · 2019 [cited by examiner]
US 20190212982A1 · Yoda · 2019 [cited by examiner]
US 20190303743A1 · Venkataramani · 2019 [cited by examiner]
US 20190354894A1 · Lazovich · 2019 [cited by examiner]
US 20190370071A1 · Matveev · 2019 [cited by examiner]
US 20190370644A1 · Kenney · 2019 [cited by examiner]
US 20200034710A1 · Sidhu · 2020 [cited by examiner]
US 20200097826A1 · Du · 2020 [cited by examiner]
US 20200104717A1 · Alistarh · 2020 [cited by examiner]
US 20200160181A1 · Zlateski · 2020 [cited by examiner]
US 20200160182A1 · Matveev · 2020 [cited by examiner]
US 20200193274A1 · Darvish Rouhani · 2020 [cited by examiner]
US 20200218978A1 · Kopinsky · 2020 [cited by examiner]
US 20200342301A1 · Miao · 2020 [cited by examiner]
US 20230064381A1 · Yinger · 2023 [cited by examiner]
US 20240045685A1 · Adelman · 2024 [cited by examiner]
EP 3547115A2 · 2019 [cited by examiner]
EP 3789893A1 · 2021 [cited by examiner]
WO WO2021054990A1 · 2021 [cited by examiner]
'Bit-Tactical: Exploiting Ineffectual Computations in Convolutional Neural Networks: Which, Why, and How' by Lascorz et al., 2018. (Year: 2018). [cited by examiner]
‘Designing Vector-Friendly Compact BLAS and LAPACK Kernels’ by Kim et al., 2017. (Year: 2017). [cited by examiner]
Machine Translation of Chinese Patent Application CN 111767079 A, published 2020. (Year: 2020). [cited by examiner]
‘How to Multiply Matrices’ from Math is Fun, archived on Oct. 5, 2017. (Year: 2017). [cited by examiner]
Yang, Huanrui, Wei Wen, and Hai Li. “Deephoyer: Learning sparser neural network with differentiable scale-invariant sparsity measures.” (2019). (Year: 2019). [cited by examiner]
Yuster, Raphael, and Uri Zwick. “Fast sparse matrix multiplication.” ACM Transactions On Algorithms (TALG) 1.1 (2005): 2-13. ( Year: 2005). [cited by examiner]
Park, Jongsoo, et al. “Faster cnns with direct sparse convolutions and guided pruning.” (2016). (Year: 2016). [cited by examiner]
Paixao, Crysttian A., and Flavio Codeco Coelho. Matrix compression methods. No. 1049. PeerJ PrePrints, 2015. (Year: 2015). [cited by examiner]
https://www.kinematicsoup.com/news/2016/9/6/data-compression-bit-packing-101, published Sep. 6, 2016. (Year: 2016). [cited by examiner]
Robert Lim; “Methods for Accelerating Machine Learning in High Performance Computing”; University of Oregon—AREA-2019-01. (Year: 2019). [cited by examiner]
Zhizhou Li et al.; “A CPU-based Algorithm for Traffic Optimization Based on Sparse Convolutional Neural Networks”; 2017 IEEE 30th Canadian Conference on Electrical and Computer (CCECE). (Year: 2017). [cited by examiner]
Baoyuan Liu et al.; “Sparse Convolutional Neural Networks”; CVPR 2015—Computer Vision Foundation—IEEE. (Year: 2015). [cited by examiner]
Hesham Mostafa et al.; “Parameter Efficient Training of Deep Convolutional Neural Networks by Dynamic Sparse Reparameterization”; Proceedings of the 36 the International Conference on Machine Learning, Long Beach, Calif… [cited by examiner]
Israt Nisa et al.; “Sampled Dense Matrix Multiplication for High-Performance Machine Learning”; 2018 IEEE 25th International Conference on High Performance Computing (Hi PC). (Year: 2018). [cited by examiner]
Yu, Dong, Li Deng, and Frank Seide. “The deep tensor neural network with applications to large vocabulary speech recognition”. IEEE Transactions on Audio Speech, and Language Processing 21.2 (2012): 388-396. (Year: 2012… [cited by examiner]
Zhangxiaowen Gong et al. “Sparse Train: Leveraging Dynamic Sparsity in Training DNNs on General-Purpose SIMD Processors”; Nov. 2019. (Year: 2019). [cited by examiner]
Kurtz, Mark et al. “Inducing and Exploiting Activation Sparsity for Fast Neural Network Inference.” Proceedings of the International Conference on Machine Learning. Jul. 2020. (Year: 2020). [cited by examiner]
Kaya et al., “Scalable sparse tensor decompositions in distributed memory systems”, SC'15: Proceedings of the International Conference for High Performance Computing, Networking, Storage and Analysis, IEEE, 2015. (Year:… [cited by examiner]
Liu et al., “Sparse convolutional neural networks”, Proceedings of the IEEE conference on computer vision and pattern recognition, 2015. (Year: 2015). [cited by examiner]
Smith et al., “SPLATT: Efficient and parallel sparse tensor-matrix multiplication”, 2015 IEEE International Parallel and Distributed Processing Symposium, IEEE, 2015. (Year: 2015). [cited by examiner]
Alwani et al., “Fused-layer CNN accelerators”, 49th Annual IEEE/ACM International Symposium on Microarchitecture (MICRO), 2016, pp. 1-12. (Year: 2016). [cited by examiner]
Budden et al., “Deep tensor convolution on multicores”, In Proceedings of the 34th International Conference on Machine Learning, 2017, vol. 70, pp. 615-624. (Year: 2017). [cited by examiner]
Chen, Xuhao, “Escoin: Efficient Sparse Convolutional Neural Network Inference on GPUs” from Jul. 2017 “Conference '17”, Apr. 3, 2019. (Year: 2019). [cited by examiner]
Despande, Adit, “A beginner's guide to understanding convolutional neural networks”, Jul. 20, 2016. (Year: 2016). [cited by examiner]
Du et al., “Width Provably Matters in Optimization for Deep Linear Neural Networks”, May 27, 2019. (Year: 2019). [cited by examiner]
Gale et al., “The State of Sparsity in Deep Neural Networks”, Feb. 25, 2019. (Year: 2019). [cited by examiner]
Georganas et al., “Anatomy Of High-Performance Deep Learning Convolutions On SIMD Architectures.” In: SC18: International Conference for High Performance Computing, Networking, Storage and Analysis. Aug. 20, 2018. (Year… [cited by examiner]
Han et al., “Learning both Weights and Connections for Efficient Neural Networks”, 2015, Advances in Neural Information Processing Systems, vol. 28. (Year: 2015). [cited by examiner]
Hinton et al., “Distilling the Knowledge in a Neural Network”, Mar. 9, 2015. (Year: 2015). [cited by examiner]
Lavin et al., “Fast Algorithms for Convolutional Neural Networks”, Nov. 10, 2015. (Year: 2015). [cited by examiner]
Lecun et al., “Optimal brain damage”, Advances in neural information processing systems, 1990, pp. 598-605. (Year: 1990). [cited by examiner]
Liu et al., “Sparse convolutional neural networks.” In: Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition. Jun. 12, 2015. (Year: 2015). [cited by examiner]
Mishra et al., “Apprentice: Using Knowledge Distillation Techniques to Improve Low-Precision Network Accuracy”, Nov. 15, 2017. (Year: 2017). [cited by examiner]
Papyan et al., “Convolutional neural networks analyzed via convolutional sparse coding.” In: The Journal of Machine Learning Research. Jul. 17, 2017. (Year: 2017). [cited by examiner]
Rusu et al., “Progressive Neural Networks”, Sep. 7, 2016. (Year: 2016). [cited by examiner]
Scardapane et al. “Group sparse regularization for deep neural networks.” In: Neurocomputing. Jul. 2, 2016. (Year: 2016). [cited by examiner]
Wozniak et al., “GiMMiK—Generating bespoke matrix multiplication kernels for accelerators: Application to high-order Computational Fluid Dynamics”, Computer Physics Communications, vol. 202, 2016, pp. 12-22. (Year: 2016… [cited by examiner]