Low-bit quantization for transformer-based machine learning models
Patent Information
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Filing Date
- 2025-03-05
- Publication Date
- 2026-08-13
Smart Images

Figure CN2025080691_13082026_PF_FP_ABST
Abstract
Description
LOW-BIT QUANTIZATION FOR TRANSFORMER-BASED MACHINE LEARNING MODELSCROSS-REFERENCE TO RELATED APPLICATION (S)
[0001] The present application for patent is related to International Application No. PCT / CN2025 / 075896, filed February 6, 2025, which is hereby incorporated by reference herein in its entirety for all applicable purposes. INTRODUCTION
[0002] Aspects of the present disclosure relate to machine learning.
[0003] A wide variety of machine learning model architectures have been trained to perform an assortment of diverse tasks, including computer vision tasks, language tasks, classification and regression tasks, and the like. Recently, research has yielded substantial success in using large language models (LLMs) , large vison models (LVMs) , and / or large multimodal models (LMMs) to process and generate output data. Often, machine learning models (especially LLMs, LVMs, and LMMs) have many parameters (e.g., millions or even billions) , resulting in significant model size, as well as substantial computational expense in training the model. Further, once trained, such models are often difficult (or impossible) to fine-tune, as the vast number of parameters makes overfitting a major challenge (e.g., potentially relying on tremendous amounts of fine-tuning data to prevent overfitting) .
[0004] One recent approach to enable fine-tuning or personalization of such generative models involves training relatively smaller model adapters for larger models. However, many conventional quantization approaches fail to provide adequate accuracy for such adapters. BRIEF SUMMARY
[0005] Certain aspects of the present disclosure provide a processor-implemented method, comprising: accessing a first set of adapter parameters for a first transformer block of a machine learning model, wherein the first set of adapter parameters comprises a first set of encoder parameters and a first set of decoder parameters; generating a first rotation matrix for the first set of adapter parameters; generating a first set of modified adapter parameters, comprising: generating a first rotated set of encoder parameters based on rotating the first set of encoder parameters according to the first rotation matrix; and generating a first rotated set of decoder parameters based on rotating the first set of decoder parameters according to an inverse of the first rotation matrix; generating a quantized machine learning model based on quantizing the first set of modified adapter parameters; and providing the quantized machine learning model for inferencing.
[0006] Certain aspects of the present disclosure provide a processor-implemented method of machine learning. The method generally includes accessing a first set of base model parameters for a first transformer block of a machine learning model; training at least one of: a first rotation matrix for a first subset of the first set of base model parameters, wherein the first subset corresponds to a query operation of the first transformer block, or a second rotation matrix for a second subset of the first set of base model parameters, wherein the second subset corresponds to a feed-forward operation of the first transformer block; generating a quantized machine learning model based on the first set of base model parameters and the first and second rotation matrices; and providing the quantized machine learning model for inferencing.
[0007] Other aspects provide processing systems configured to perform the aforementioned methods as well as those described herein; non-transitory, computer-readable media comprising instructions that, when executed by one or more processors of a processing system, cause the processing system to perform the aforementioned methods as well as those described herein; a computer program product embodied on a computer-readable storage medium comprising code for performing the aforementioned methods as well as those further described herein; and a processing system comprising means for performing the aforementioned methods as well as those further described herein.
[0008] The following description and the related drawings set forth in detail certain illustrative features of one or more aspects.BRIEF DESCRIPTION OF THE DRAWINGS
[0009] The appended figures depict example features of certain aspects of the present disclosure and are therefore not to be considered limiting of the scope of this disclosure.
[0010] FIGS. 1A, 1B, and 1C depict an example architecture for improved adapter quantization using base model rotation matrices, according to some aspects of the present disclosure.
[0011] FIGS. 2A, 2B, and 2C depict an example architecture for improved adapter quantization using base model rotation matrices and adapter rotation matrices, according to some aspects of the present disclosure.
[0012] FIGS. 3A, 3B, and 3C depict an example architecture for improved adapter quantization using adapter rotation matrices, according to some aspects of the present disclosure.
[0013] FIG. 4 depicts an example architecture for improved model quantization using learned base model rotation matrices, according to some aspects of the present disclosure.
[0014] FIG. 5 is a flow diagram depicting an example method for generating rotation matrices for improved quantization, according to some aspects of the present disclosure.
[0015] FIG. 6 is a flow diagram depicting an example method for machine learning model quantization, according to some aspects of the present disclosure.
[0016] FIG. 7 depicts an example processing system configured to perform various aspects of the present disclosure.
[0017] To facilitate understanding, identical reference numerals have been used, where possible, to designate identical elements that are common to the drawings. It is contemplated that elements and features of one aspect may be beneficially incorporated in other aspects without further recitation.DETAILED DESCRIPTION
[0018] Aspects of the present disclosure provide apparatuses, methods, processing systems, and non-transitory computer-readable mediums for providing improved machine learning. Specifically, in some aspects of the present disclosure, techniques are provided for more effective adapter and / or base model quantization via rotation matrices.
[0019] In many architectures, adapters have been used to modify to personalize machine learning model performance. For example, low rank adaptation (LoRA) may be used to generate adapters including an encoder portion (which transforms the input embedding to a relatively low rank tensor) and a decoder portion (which transforms the low-rank tensor back to the original size) . Such adapters are often trained to be deployed in parallel with base model operations, such as convolutions, attention operations, feed-forward layers, and the like (e.g., where the input to the base model component is also provided as input to the adapter, and the output of the adapter is summer or otherwise aggregated with the output of the base model component before being provided to the next downstream component) .
[0020] While effective techniques exist for quantization of the base model parameters, few (if any) quantization approaches exist for such adapters. For example, some approaches involve quantizing the adapter parameters to a bit-width of sixteen or eight bits per parameter, even while the base model parameters are quantized to a bit-width of four bits. This approach can result in accuracy reductions, as well as increased latency and / or higher memory usage. Similarly, though a variety of quantization techniques have been developed for the base model parameters, adapters often have unique quantization ranges that render existing approaches ineffective.
[0021] In some aspects of the present disclosure, rotation matrices can be generated for base model components to improve the efficacy of adapter quantization (e.g., by removing outliers in parameter tensors) . In some aspects, adapter-specific rotation matrices can be similarly generated to improve the quantizability of such adapters. In some aspects, techniques are provided to merge such rotation matrices into model adapters offline, reducing or eliminating any runtime impact (e.g., improving model accuracy without affecting runtime latency) .
[0022] For example, in some aspects, after a base model (e.g., an LLM) is trained, the parameters of the base model may be frozen and a set of one or more base model rotation matrices may be generated (e.g., using random rotations, or using trained rotation matrices learned during a calibration or subsequent training phase) . In some aspects, model adapter (s) may also be trained while the base model remains frozen. In some aspects, after the adapter (s) are trained, adapter rotation matrices may be generated (e.g., using random rotations, or learning trained rotation matrices during a subsequent training phase) for the adapter (s) . Further, as discussed below in more detail, the various rotation matrices may then be merged into the corresponding model components, and the resulting modified model may be quantized. As discussed above, the use of rotation matrices can significantly reduce the noise introduced by quantization, resulting in improved quantized model accuracy. Example Architecture for Improved Adapter Quantization Using Base Model Rotation Matrices
[0023] FIGS. 1A, 1B, and 1C depict an example architecture for improved adapter quantization using base model rotation matrices, according to some aspects of the present disclosure. Specifically, FIG. 1A depicts an example architecture of a transformer 100A of a machine learning model (sometimes referred to as a “transformer block” ) , where the transformer 100A includes an attention component 106A and a feed-forward component 110A. FIG. 1B provides additional detail for the architecture of the attention component 106A, while FIG. 1C provides additional detail for the architecture of the feed-forward component 110A. In some aspects, the depicted transformer 100A may be used by a machine learning system (e.g., a computing system configured to train and / or use machine learning models) .
[0024] Turning now to FIG. 1A, the transformer 100A receives an input 102 and generates a corresponding output 118. The transformer 100A may generally correspond to one component (e.g., one transformer block) of a machine learning model (e.g., a transformer-based model, such as an LLM) . That is, there may be zero or more machine learning model components (e.g., convolution operations, transformer blocks, and / or other model operations) prior to the transformer 100A (e.g., to generate the input 102) , as well as zero or more machine learning model components (e.g., convolution operations, transformer blocks, and / or other model operations) subsequent to the transformer 100A (e.g., to receive the output 118 as input) .
[0025] In the illustrated example, the input 102 (also referred to in some aspects as an embedding) generally corresponds to a tensor having features or information generated using one or more prior model components. In some aspects, the input 102 may correspond to the input to the model itself (e.g., if the transformer 100A is the first component of the model) . Similarly, the output 118 generally corresponds to a tensor having features or information generated based on processing the input 102 using the transformer 100A. The output 118 may be provided to a subsequent component, or may be used as the output of the model itself.
[0026] In the illustrated example, a rotation matrix 104A (denoted R1) is used to transform (e.g., rotate) the input 102. For example, the rotation matrix 104A may be a transformation matrix used to perform a rotation in Euclidean space. In some aspects, the rotation matrix 104A may be a random matrix (e.g., a rotation matrix comprising random values) or may have values learned during a training or calibration phase of the model architecture (e.g., after the parameters of the base model and / or adapter (s) are frozen) . In some aspects, the rotation matrix 104A is trained based on the base model parameters (without any adapters applied) .
[0027] In some aspects, the rotated input (e.g., generated by rotating the input 102 by the rotation matrix 104A) may generally exhibit fewer outliers, allowing the rotated input to be quantized more effectively (e.g., with reduced quantization loss) , as compared to directly quantizing the input 102 itself. That is, although not depicted in the illustrated example in some aspects, the rotated input may be quantized (e.g., for more efficient storage with reduced memory footprint) .
[0028] In the illustrated example, the first operation of the attention component 106A includes applying an inverse rotation matrix 104B (e.g., the inverse of the rotation matrix 104A, denoted in the illustrated example, where ) to rotate the rotated input 102 back to the original rotation. In some aspects, the rotation matrix 104A is a Hadamard matrix, such that That is, to maintain numerical invariance, the rotation matrix 104A applied to the input 102 is reversed by applying the inverse rotation matrix 104B prior to passing the data through the attention component 106A.
[0029] In the illustrated example, the unrotated input 102 is provided to a first component for multi-head self-attention 108, as well as an adapter (e.g., a LoRA adapter) . In the illustrated example, the adapter represents an additional set of parameters that has been decomposed into two low-rank matrices (often denoted A or WA and B or WB) . For example, A may have dimensionality d×r and B may have dimensionality r×d, where r is significantly smaller than d. In some aspects of the present disclosure, these low-rank parameter matrices A and B may be referred to as adapter “encoders” and “decoders, ” respectively, for conceptual clarity. In the illustrated example, the adapter comprises an encoder 110 (denoted to indicate that the encoder 110 is the “A” matrix for the adapter of the attention component t106A) and a decoder 112 (denoted to indicate that the decoder 112 is the “B” matrix for the adapter of the attention component 106A) .
[0030] The multi-head self-attention 108 generally applies a self-attention operation across one or more attention heads, as discussed in more detail below. In some aspects, the multi-head self-attention 108 may be referred to as a “base model” component or set of parameters to indicate that the multi-head self-attention 108 is part of the base model (e.g., the LLM) , as contrasted with components or parameters corresponding to model adapters (e.g., the encoder 110 and decoder 112) .
[0031] In the illustrated example, the input may similarly be processed using the adapter parameters (e.g., the encoder 110 and decoder 112) , such as by convolving or multiplying the input with the parameters of the encoder 110 ( ) and then convolving or multiplying the resulting tensor with the parameters of the decoder 112 ( ) .
[0032] In the illustrated example, the output of the multi-head self-attention 108 and the output of the decoder 112 may be combined (e.g., summer, averaged, or otherwise aggregated) , and the resulting tensor can be rotated using the rotation matrix 104A. As discussed above, this rotation may improve quantization (e.g., reduce quantization noise) of the tensor. In some aspects, therefore, the output of the attention component 106A may be defined as h=R1 (Wattentionx+BattentionAattentionx) (ignoring the internal use of R1 and ) , where h is the output of the attention component 106A, R1 is the rotation matrix 104A, Wattention represents the parameters of the multi-head self-attention 108, x is the input 102, Battention represents the parameters of the decoder 112, and Battention represents the parameters of the encoder 110. In some aspects, the parameters of the adapter and the multi-head self-attention 108 may be merged offline to reduce online latency (e.g., by summing, where h=R1x (Wattention+BattentionAattention) ) .
[0033] In the illustrated example, the rotated output of the attention component 106A is then provided as input to the feed-forward component 113A. As illustrated, the feed-forward component 113A may first apply the inverse rotation matrix 104B, as discussed above, to undo the rotation applied by the attention component 106A. The unrotated tensor is then provided to both a multilayer perceptron (MLP) 114 (e.g., one or more feed-forward layers of a neural network) and an adapter (e.g., a LoRA adapter) comprising an encoder 115 (denoted to indicate that the encoder 115 is the “A” matrix for the adapter of the feed-forward component 113A and a decoder 116 (denoted to indicate that the decoder 116 is the “B” matrix for the adapter of the feed-forward component 113A) . As discussed above, the input to the feed-forward component 113A may be processed by the adapter, such as by convolving or multiplying the input with the parameters of the encoder 115 and the decoder 116.
[0034] The MLP 114 generally performs feed-forward operations on the input, such as by multiplying and / or convolving the input with one or more sets of parameters (e.g., for one or more layers) . In some aspects, the MLP 114 may be referred to as a “base model” component or set of parameters to indicate that the MLP 114 is part of the base model (e.g., the LLM) , as contrasted with components or parameters corresponding to model adapters (e.g., the encoder 115 and decoder 116) .
[0035] In the illustrated example, the output of the MLP 114 and the output of the decoder 116 may be combined (e.g., summer, averaged, or otherwise aggregated) , and the resulting tensor can be rotated using the rotation matrix 104A. As discussed above, this rotation may improve quantization (e.g., reduce quantization noise) of the tensor. As illustrated, the tensor is then unrotated by applying the inverse rotation matrix 104B to generate the output 118 of the transformer 100A. In some aspects, therefore, the output of the feed-forward component 113A may be defined as o=WMLPh+BMLPAMLPh(ignoring the internal use of R1 and ) , where h is the output of the attention component 106A, WMLP represents the parameters of the MLP 114, o is the output of the feed-forward component 113A, BMLP represents the parameters of the decoder 116, and AMLP represents the parameters of the encoder 115. In some aspects, the parameters of the adapter and the MLP 114 may be merged offline to reduce online latency (e.g., by summing, where o=h (WMLP+BMLPAMLP) ) . The output 118 of the transformer 100A may therefore be represented as
[0036] Turning now to FIG. 1B, the architecture of the attention component 106A is discussed in more detail. Specifically, FIG. 1B depicts how some of the rotation operations used in the transformer 100A can be merged into corresponding model parameters, reducing or eliminating the overhead of such operations during runtime.
[0037] In the illustrated example, the attention operation includes four operations 120A, 124A, 130A, and 146A (with four corresponding sets of base model parameters) . Specifically, the multi-head attention (e.g., 108 of FIG. 1A) may include use of base model parameters including a set of query parameters (denoted Wq in the illustrated example) , a set of key parameters (denoted Wk in the illustrated example) , a set of value parameters (denoted Wv in the illustrated example) , and a set of output parameters (denoted Wo in the illustrated example) .
[0038] In the illustrated example, each of the operations 120A, 124A, 130A, and 146A also includes use of a corresponding set of parameters from the adapter. Specifically, the adapter parameters (e.g., the encoder 110 and decoder 112 of FIG. 1A) may include a set of adapter parameters for the query operation 120A (denoted and in the illustrated example) , a set of adapter parameters for the key operation 124A (denoted and in the illustrated example) , a set of adapter parameters for the value operation 130A (denoted and in the illustrated example) , and a set of adapter parameters for the output operation 146A (denoted and in the illustrated example) .
[0039] Further, the illustrated architecture includes use of several rotation matrices, including the rotation matrix R1 (e.g., 104A of FIG. 1A) and its inverse (e.g., 104B of FIG. 1B) , as well as a second rotation matrix R2, its inverse and a third rotation matrix R3. In some aspects, the rotation matrices R2 and R3 may be similar to the rotation matrix R1 in that each may be referred to as a “base model rotation matrix” to indicate that each of the rotation matrices R1, R2, and R3 may be generated (e.g., trained) using the (frozen) base model without the adapter (s) applied or activated. In some aspects, each of the rotation matrices R1, R2, and R3 is a Hadamard matrix.
[0040] In the illustrated example, the outputs of the query operation 120A and the key operation 124A may each be processed using corresponding positional embedding operations 138A and 138B (e.g., a rotary positional embedding (RoPE) operation) . These embeddings can then each be rotated using the third rotation matrix 140A (denoted R3) . In some aspects, the application of the rotation matrix 140A may be performed online, as there are no model parameters into which the rotation can be merged. However, in some aspects, the rotation may be performed efficiently using Hadamard transforms. In some aspects, the use of the rotation matrix 140 may be optionally disabled during training of one or more other components of the architecture (e.g., while training or fine-tuning adapter-specific rotation matrices) .
[0041] As illustrated, these rotated tensors are then aggregated using an operation 142 (e.g., multiplication) and processed using a softmax operation 144. Although not depicted in the illustrated example, in some aspects, the keys (e.g., the output of the key operation 124A) may be transposed prior to the multiplication. The output of the softmax operation 144 (referred to in some aspects as the attention score (s) ) are then used to compute the weighted sum of the values (e.g., the output of the value operation 130A) using the operation 142 (e.g., multiplication) . As illustrated, these weighted values are then processed using the output operation 146A to generate the output of the attention component 106A.
[0042] In the illustrated example, some of the rotation matrices can be merged with corresponding model parameters to reduce runtime overhead. For example, as illustrated, the inverse rotation matrix ( ) used to rotate input to the attention component 106A can be merged with each of the operations 120A, 124A, and 130A to reduce runtime overhead (by rotating the parameter matrix offline, rather than rotating the input online) . That is, during runtime, rather than first rotating the input and then applying the relevant parameters, the machine learning system may process the input using the rotated parameters (e.g., using multiplication or convolution) .
[0043] Specifically, with respect to the query operation 120A, the inverse rotation matrix can be used to rotate the query parameters Wq to generate a set of modified (e.g., rotated) parameters 122A. That is, the set of modified parameters 122A may be defined as Similarly, the query encoder parameters can be rotated by the inverse rotation matrix to generate a modified (e.g., rotated) set of parameters 123A. That is, the set of modified parameters 123A may be defined as As illustrated, the query decoder parameters are left as an unmodified set of parameters 112A.
[0044] Similarly, with respect to the key operation 124A, the inverse rotation matrix can be used to rotate the key parameters Wk to generate a set of modified (e.g., rotated) parameters 126A. That is, the set of modified parameters 126A may be defined as Similarly, the key encoder parameters can be rotated by the inverse rotation matrix to generate a modified (e.g., rotated) set of parameters 128A. That is, the set of modified parameters 128A may be defined as As illustrated, the key decoder parameters are left as an unmodified set of parameters 112B.
[0045] Further, with respect to the value operation 130A, the value parameters Wvmay be rotated by both the inverse rotation matrix as well as a second rotation matrix (denoted R2) to generate a set of modified (e.g., rotated) parameters 132A. That is, the set of modified parameters 132A may be defined as Similarly, the value encoder parameters can be rotated by the inverse rotation matrix to generate a modified (e.g., rotated) set of parameters 134A, and the value decoder parameters are rotated by the rotation matrix R2 to form a set of modified (e.g., rotated) parameters 136A. That is, the set of modified parameters 134A may be defined as and the set of modified parameters 136A may be defined as
[0046] Finally, with respect to the output operation 146A, the output parameters Womay be rotated by both the inverse rotation matrix as well as the rotation matrix R1 to generate a set of modified (e.g., rotated) parameters 148A. That is, the set of modified parameters 148A may be defined as Similarly, the output encoder parameters can be rotated by the inverse rotation matrix to generate a modified (e.g., rotated) set of parameters 150A, and the value decoder parameters are rotated by the rotation matrix R1 to form a set of modified (e.g., rotated) parameters 152A. That is, the set of modified parameters 150A may be defined as and the set of modified parameters 152A may be defined as
[0047] As discussed above, merging these rotation matrices by rotating the various sets of parameters (to generate modified or rotated parameters) offline may reduce the computational expense and latency of using the model during runtime to generate output predictions.
[0048] Turning now to FIG. 1C, the architecture of the feed-forward component 113A of FIG. 1A is discussed in more detail. Specifically, FIG. 1C depicts how some of the rotation operations used in the transformer 100A can be merged into corresponding model parameters, reducing or eliminating the overhead of such operations during runtime.
[0049] In the illustrated example, the feed-forward operation includes three operations 154A, 160A, and 172A (with three corresponding sets of base model parameters) . Specifically, the MLP (e.g., 114 of FIG. 1A) may include use of base model parameters including a set of up-projection parameters (denoted Wu in the illustrated example) , a set of gating parameters (denoted Wg in the illustrated example) , and a set of down-projection parameters (denoted Wd in the illustrated example) .
[0050] In the illustrated example, each of the operations 154A, 160A, and 172A also includes use of a corresponding set of parameters from the adapter. Specifically, the adapter parameters (e.g., the encoder 115 and decoder 116 of FIG. 1A) may include a set of adapter parameters for the up-projection operation 154A (denoted and in the illustrated example) , a set of adapter parameters for the gating operation 160A (denoted and in the illustrated example) , and a set of adapter parameters for the down-projection operation 172A (denoted and in the illustrated example) .
[0051] Further, the illustrated architecture includes use of several rotation matrices, including the rotation matrix R1 (e.g., 104A of FIG. 1A) and its inverse (e.g., 104B of FIG. 1B) , as well as a fourth rotation matrix R4 and its inverse . In some aspects, the fourth rotation matrix R4 may be similar to the rotation matrices R1, R2, and R3 in that each may be referred to as “base model rotation matrices” to indicate that each of the rotation matrices R1, R2, R3, and R4 may be generated (e.g., trained) using the (frozen) base model without the adapter (s) applied or activated. In some aspects, the rotation matrix R4 is a Hadamard matric.
[0052] In the illustrated example, the outputs of the gating operation 160A may be processed using an operation 166 (e.g., a swish operation) , and the resulting tensor can then be aggregated with the output of the up-projection operation 154A using the operation 168 (e.g., multiplication) to generate a gated up-projected tensor. The output of the operation 168 (e.g., the gated up-projected tensor) may then be rotated using the fourth rotation matrix 170A (denoted R4) . In some aspects, the application of the rotation matrix 170A may be performed online, as there are no model parameters into which the rotation can be merged. However, in some aspects, the rotation may be performed efficiently using Hadamard transforms. In some aspects, the use of the rotation matrix 170A (and its inverse) may be optionally disabled during training of one or more other components of the architecture (e.g., while training or fine-tuning adapter-specific rotation matrices) .
[0053] As illustrated, the rotated tensor is then processed using the down-projection operation 172A to generate the output of the feed-forward component 113A.
[0054] In the illustrated example, some of the rotation matrices can be merged with corresponding model parameters to reduce runtime overhead. Specifically, as illustrated, the inverse rotation matrix ( ) used to rotate input to the feed-forward component 113A can be merged with each of the operations 154A, and 160A to reduce runtime overhead (by rotating the parameter matrix offline, rather than rotating the input online) . That is, during runtime, rather than first rotating the input and then applying the relevant parameters, the machine learning system may process the input using the rotated parameters (e.g., using multiplication or convolution) .
[0055] Specifically, with respect to the up-projection operation 154A, the inverse rotation matrix can be used to rotate the up-projection parameters Wu to generate a set of modified (e.g., rotated) parameters 156A. That is, the set of modified parameters 156A may be defined as Similarly, the up-projection encoder parameters can be rotated by the inverse rotation matrix to generate a modified (e.g., rotated) set of parameters 158A. That is, the set of modified parameters 158A may be defined as As illustrated, the up-projection decoder parameters are left as an unmodified set of parameters 116A.
[0056] Similarly, with respect to the gating operation 160A, the inverse rotation matrix can be used to rotate the gating parameters Wg to generate a set of modified (e.g., rotated) parameters 162A. That is, the set of modified parameters 162A may be defined as Similarly, the gating encoder parameters can be rotated by the inverse rotation matrix to generate a modified (e.g., rotated) set of parameters 164A. That is, the set of modified parameters 164A may be defined as As illustrated, the gating decoder parameters are left as an unmodified set of parameters 116B.
[0057] Finally, with respect to the down-projection operation 172A, the down-projection parameters Wd can be rotated by the inverse rotation matrix and the rotation matrix R1 to generate a set of modified (e.g., rotated) parameters 174A. That is, the set of modified parameters 174A may be defined as Similarly, the down-projection encoder parameters can be rotated by the inverse rotation matrix to generate a modified (e.g., rotated) set of parameters 176A, and the down-projection decoder parameters can be rotated by the rotation matrix R1 to generate a modified (e.g., rotated) set of parameters 178A. That is, the set of modified parameters 176A may be defined as and the set of modified parameters 178A may be defined as
[0058] As discussed above, merging these rotation matrices by rotating the various sets of parameters (to generate modified or rotated parameters) offline may reduce the computational expense and latency of using the model during runtime to generate output predictions. Example Architecture for Improved Adapter Quantization Using Base Model Rotation Matrices and Adapter Rotation Matrices
[0059] FIGS. 2A, 2B, and 2C depict an example architecture for improved adapter quantization using base model rotation matrices and adapter rotation matrices, according to some aspects of the present disclosure. Specifically, FIG. 2A depicts an example architecture of a transformer 100B of a machine learning model, where the transformer 100B includes an attention component 106B and a feed-forward component 110B. FIG. 2B provides additional detail for the architecture of the attention component 106B, while FIG. 2C provides additional detail for the architecture of the feed-forward component 110B. In some aspects, the depicted transformer 100B may be used by a machine learning system, such as the machine learning system discussed above with reference to FIGS. 1A-1C.
[0060] Turning now to FIG. 2A, the transformer 100B shares a number of similarities from the architecture discussed above with respect to the transformer 100A of FIG. 1A. For example, the transformer 100B receives an input 102 and generates a corresponding output 118 using an attention component 106B and a feed-forward component 113B. However, in addition to the rotation matrix 104A discussed above, the transformer 100B further includes adapter-specific rotation matrices 205A and 207A (denoted RL1 and RL2 in the illustrated example) . Specifically, in the illustrated example, the adapter associated with attention component 106B uses an adapter-specific rotation matrix 205A (RL1) after the encoder 110, as well as the inverse of the rotation matrix 205B (denoted ) prior to the decoder 112. Similarly, in the feed-forward component 113B, the adapter uses an adapter-specific rotation matrix 207A (RL2) after the encoder 115, as well as the inverse of the rotation matrix 207B (denoted ) prior to the decoder 116.
[0061] In some aspects, the adapter rotation matrices 205 and 207 (and their inverses) may be Hadamard matrices. In some aspects, the adapter rotation matrices 205 and 207 (and their inverses) may each have a shape of (Drank, Drank) , where Drank is the rank of the corresponding set of adapter parameters (e.g., the rank of the LoRA adapter, such as the encoder 110 and / or 115) .
[0062] In some aspects, a unique adapter-specific rotation matrix 205 and / or 207 may be trained for each adapter in the model. That is, the attention component 106B and the feed-forward component 113B may have different rotation matrices. In some aspects, components within the same transformer 100B may use the same adapter rotation matrix. In some aspects, each transformer in the machine learning model may use one or more unique adapter rotation matrices. That is, a unique adapter rotation matrix may be generated for each adapter and / or for each transformer in the model.
[0063] In some aspects, the adapter rotation matrices 205 and 207 may be generated using calibration or other training data. That is, the values of the adapter rotation matrices 205 and 207 may be learned based on a training phase. In some aspects, the adapter rotation matrices 205 and 207 may be trained after the other portions of the model are trained. For example, after the base weights (e.g., the parameters of the multi-head self-attention 108 and / or MLP 114) , adapter weights (e.g., the parameters of the encoders 110 and / or 115 and / or the decoder 112 and / or 116) , and / or base model rotation matrices (e.g., R1, R2, R3, and / or R4) are trained, these parameters may be frozen to allow the adapter rotation matrices RL to be learned based on calibration data (e.g., by seeking to find parameters of each adapter rotation matrix that minimizes or at least reduces the quantization error and / or maximizes or at least improves the accuracy of the model) .
[0064] The remaining aspects of the transformer 100B largely mirror the architecture of the transformer 100A discussed above with reference to FIG. 1A. Turning now to FIG. 2B, the architecture of the attention component 106B is discussed in more detail. Specifically, FIG. 2B depicts how the adapter rotation matrices used in the transformer 100B can be merged into corresponding model parameters, reducing or eliminating the overhead of such operations during runtime.
[0065] Generally, most of the depicted architecture of the attention component 106B mirrors the architecture of the attention component 106A discussed above with reference to FIG. 1B. For example, the attention component 106B also includes four operations 120B, 124B, 130B, and 146B with four corresponding sets of base model parameters as well as four corresponding sets of adapter parameters.
[0066] Further, the various sets of base model parameters may have base model rotation matrices (e.g., R1, R2, and R3, and their inverses) merged into the base model parameters themselves (e.g., to form the modified sets of parameters 122A, 126A, 132A, and 148A) , as discussed above.
[0067] The illustrated architecture of FIG. 2B also includes use of the adapter specific rotation matrix 205A (RL1) and the inverse. Although the illustrated example depicts use of the same rotation matrix RL1 for each operation or component of the attention component 106B, in some aspects, a separate adapter rotation matrix may be trained for each depicted operation. In the illustrated example, these adapter rotation matrices can be merged with corresponding sets of adapter parameters to reduce runtime overhead. That is, during runtime, rather than first rotating a given tensor and then applying the relevant set of parameters, the machine learning system may rotate the parameters offline and then use the rotated parameters to process data during runtime (e.g., using multiplication or convolution) .
[0068] Specifically, with respect to the query operation 120B, the query encoder parameters can be rotated by the inverse rotation matrix (discussed above) as well as by the adapter rotation matrix RL1 (e.g., 205A of FIG. 2A) to generate a modified (e.g., rotated) set of parameters 123B, and the query decoder parameters are rotated by the inverse adapter rotation matrix (e.g., 205B from FIG. 2A) to form a set of modified (e.g., rotated) parameters 210. That is, the set of modified parameters 123B may be defined as and the set of modified parameters 210 may be defined as
[0069] Similarly, with respect to the key operation 124B, the key encoder parameters can be rotated by the inverse rotation matrix (discussed above) as well as by the adapter rotation matrix RL1 to generate a set of modified (e.g., rotated) parameters 128B. The key decoder parameters are rotated by the inverse adapter rotation matrix to form a set of modified (e.g., rotated) parameters 215. That is, the set of modified parameters 128B may be defined as and the set of modified parameters 215 may be defined as
[0070] Further, with respect to the value operation 130B, the value encoder parameters can be rotated by the inverse rotation matrix (discussed above) as well as by the adapter rotation matrix RL1 to generate a set of modified (e.g., rotated) parameters 134B. The value decoder parameters are rotated by the inverse adapter rotation matrix and further by the base model rotation matrix R2 to form a set of modified (e.g., rotated) parameters 136B. That is, the set of modified parameters 134B may be defined as and the set of modified parameters 136B may be defined as
[0071] Finally, with respect to the output operation 146B, the output encoder parameters can be rotated by the inverse rotation matrix and further by the adapter rotation matrix RL1 to generate a modified (e.g., rotated) set of parameters 150B, and the value decoder parameters are rotated by the inverse adapter rotation matrix and the rotation matrix R1 to form a set of modified (e.g., rotated) parameters 152B. That is, the set of modified parameters 150B may be defined as and the set of modified parameters 152B may be defined as
[0072] As discussed above, merging these rotation matrices by rotating the various sets of parameters (to generate modified or rotated parameters) offline may reduce the computational expense and latency of using the model during runtime to generate output predictions.
[0073] Turning now to FIG. 2C, the architecture of the feed-forward component 113B of FIG. 2A is discussed in more detail. Specifically, FIG. 2C depicts how some of the rotation operations used in the transformer 100B can be merged into corresponding model parameters, reducing or eliminating the overhead of such operations during runtime.
[0074] Generally, most of the depicted architecture of the feed-forward component 113B mirrors the architecture of the feed-forward component 113A discussed above with reference to FIG. 1C. For example, the feed-forward component 113B also includes three operations 154B, 160B, and 172B with three corresponding sets of base model parameters as well as three corresponding sets of adapter parameters.
[0075] Further, the various sets of base model parameters may have base model rotation matrices (e.g., R1 and its inverse) merged into the base model parameters themselves (e.g., to form the modified sets of parameters 156A, 162A, and 174A) , as discussed above.
[0076] The illustrated architecture of FIG. 2C also includes use of the adapter specific rotation matrix 207A (RL2) and the inverse. Although the illustrated example depicts use of the same rotation matrix RL2 for each operation or component of the feed-forward component 113B, in some aspects, a separate adapter rotation matrix may be trained for each depicted operation. In the illustrated example, these adapter rotation matrices can be merged with corresponding sets of adapter parameters to reduce runtime overhead. That is, during runtime, rather than first rotating a given tensor and then applying the relevant set of parameters, the machine learning system may rotate the parameters offline and then use the rotated parameters to process data during runtime (e.g., using multiplication or convolution) .
[0077] Specifically, with respect to the up-projection operation 154B, the up-projection encoder parameters can be rotated by the inverse rotation matrix (discussed above) as well as by the adapter rotation matrix RL2 (e.g., 207A of FIG. 2A) to generate a modified (e.g., rotated) set of parameters 158B, and the up-projection decoder parameters are rotated by the inverse adapter rotation matrix (e.g., 207B from FIG. 2A) to form a set of modified (e.g., rotated) parameters 220. That is, the set of modified parameters 158B may be defined as and the set of modified parameters 220 may be defined as
[0078] Similarly, with respect to the gating operation 160B, the gating encoder parameters can be rotated by the inverse rotation matrix (discussed above) as well as by the adapter rotation matrix RL2 to generate a set of modified (e.g., rotated) parameters 164B. The gating decoder parameters are rotated by the inverse adapter rotation matrix to form a set of modified (e.g., rotated) parameters 225. That is, the set of modified parameters 164B may be defined as and the set of modified parameters 225 may be defined as
[0079] Finally, with respect to the down-projection operation 172B, the down-projection encoder parameters can be rotated by the inverse rotation matrix and further by the adapter rotation matrix RL2 to generate a modified (e.g., rotated) set of parameters 176B, and the down-projection decoder parameters can be rotated by inverse adapter rotation matrix and further by the rotation matrix R1 to generate a modified (e.g., rotated) set of parameters 178B. That is, the set of modified parameters 176B may be defined as and the set of modified parameters 178B may be defined as
[0080] As discussed above, merging these rotation matrices by rotating the various sets of parameters (to generate modified or rotated parameters) offline may reduce the computational expense and latency of using the model during runtime to generate output predictions. Example Architecture for Improved Adapter Quantization Using Adapter Rotation Matrices
[0081] FIGS. 3A, 3B, and 3C depict an example architecture for improved adapter quantization using adapter rotation matrices, according to some aspects of the present disclosure. Specifically, FIG. 3A depicts an example architecture of a transformer 100C of a machine learning model, where the transformer 100C includes an attention component 106C and a feed-forward component 110C. FIG. 3B provides additional detail for the architecture of the attention component 106C, while FIG. 3C provides additional detail for the architecture of the feed-forward component 110C. In some aspects, the depicted transformer 100C may be used by a machine learning system, such as the machine learning system discussed above with reference to FIGS. 1A-1C and / or 2A-2C.
[0082] Turning now to FIG. 3A, the transformer 100C shares a number of similarities from the architectures discussed above with respect to the transformer 100A of FIG. 1A and the transformer 100B of FIG. 2A. For example, the transformer 100C receives an input 102 and generates a corresponding output 118 using an attention component 106C and a feed-forward component 113C. However, in the illustrated architecture, the base model rotation matrices (e.g., the rotation matrices R1, R2, R3, and R4) are not included. That is, the only rotation matrices used in the transformer 100C are the adapter specific rotation matrices 205A and 207A (and their inverses) .
[0083] The remaining aspects of the transformer 100C largely mirror the architecture of the transformer 100A discussed above with reference to FIG. 1A and / or the transformer 100B discussed above with reference to FIG. 2A. Turning now to FIG. 3B, the architecture of the attention component 106C is discussed in more detail. Specifically, FIG. 3B depicts how the adapter rotation matrices used in the transformer 100C can be merged into corresponding model parameters, reducing or eliminating the overhead of such operations during runtime.
[0084] Generally, most of the depicted architecture of the attention component 106C mirrors the architecture of the attention component 106A discussed above with reference to FIG. 1B and / or the attention component 106B discussed above with reference to FIG. 2B. For example, the attention component 106C also includes four operations 120C, 124C, 130C, and 146C with four corresponding sets of base model parameters as well as four corresponding sets of adapter parameters.
[0085] Of note, the various sets of base model parameters do not incorporate base model rotation matrices (e.g., R1 and R2) merged into the base model parameters themselves. Instead, the query operation 120C uses the (non-rotated or original) base model parameters 108A (denoted Wq) , the key operation 124C uses the (non-rotated or original) base model parameters 108B (denoted Wk) , the value operation 130C uses the (non-rotated or original) base model parameters 108C (denoted Wv) , and the output operation 146C uses the (non-rotated or original) base model parameters 108C (denoted Wo) . Additionally, rather than being rotated (e.g., by R3) during runtime, the outputs of the positional embedding operations 138 are provided directly to the operation 142 for aggregation.
[0086] The illustrated architecture of FIG. 3B retains use of the adapter specific rotation matrix 205A (RL1) and the inverse. Although the illustrated example depicts use of the same rotation matrix RL1 for each operation or component of the attention component 106C, in some aspects, a separate adapter rotation matrix may be trained for each depicted operation. In the illustrated example, these adapter rotation matrices can be merged with corresponding sets of adapter parameters to reduce runtime overhead. That is, during runtime, rather than first rotating a given tensor and then applying the relevant set of parameters, the machine learning system may rotate the parameters offline and then use the rotated parameters to process data during runtime (e.g., using multiplication or convolution) .
[0087] Specifically, with respect to the query operation 120C, the query encoder parameters can be rotated by the adapter rotation matrix RL1 (e.g., 205A of FIG. 3A) to generate a modified (e.g., rotated) set of parameters 123C, and the query decoder parameters are rotated by the inverse adapter rotation matrix (e.g., 205B from FIG. 3A) to form the set of modified (e.g., rotated) parameters 210. That is, the set of modified parameters 123C may be defined as and the set of modified parameters 210 may be defined as discussed above with reference to FIG. 2B.
[0088] Similarly, with respect to the key operation 124C, the key encoder parameters can be rotated by the adapter rotation matrix RL1 to generate a set of modified (e.g., rotated) parameters 128C. The key decoder parameters are rotated by the inverse adapter rotation matrix to form the set of modified (e.g., rotated) parameters 215. That is, the set of modified parameters 128C may be defined as and the set of modified parameters 215 may be defined as discussed above with reference to FIG. 2B.
[0089] Further, with respect to the value operation 130C, the value encoder parameters can be rotated by the adapter rotation matrix RL1 to generate a set of modified (e.g., rotated) parameters 134C. The value decoder parameters are rotated by the inverse adapter rotation matrix to form a set of modified (e.g., rotated) parameters 136C. That is, the set of modified parameters 134C may be defined as and the set of modified parameters 136C may be defined as
[0090] Finally, with respect to the output operation 146C, the output encoder parameters can be rotated by the adapter rotation matrix RL1 to generate a modified (e.g., rotated) set of parameters 150C, and the value decoder parameters are rotated by the inverse adapter rotation matrix to form a set of modified (e.g., rotated) parameters 152C. That is, the set of modified parameters 150C may be defined as and the set of modified parameters 152C may be defined as
[0091] As discussed above, merging these rotation matrices by rotating the various sets of parameters (to generate modified or rotated parameters) offline may reduce the computational expense and latency of using the model during runtime to generate output predictions.
[0092] Turning now to FIG. 3C, the architecture of the feed-forward component 113C of FIG. 3A is discussed in more detail. Specifically, FIG. 3C depicts how some of the rotation operations used in the transformer 100C can be merged into corresponding model parameters, reducing or eliminating the overhead of such operations during runtime.
[0093] Generally, most of the depicted architecture of the feed-forward component 113C mirrors the architecture of the feed-forward component 113A discussed above with reference to FIG. 1C and / or the feed-forward component 113B discussed above with reference to FIG. 2C. For example, the feed-forward component 113C also includes three operations 154C, 160C, and 172C with three corresponding sets of base model parameters as well as three corresponding sets of adapter parameters.
[0094] Of note, the various sets of base model parameters do not incorporate base model rotation matrices merged into the base model parameters themselves. Instead, the up-projection operation 154C uses the (non-rotated or original) base model parameters 114A (denoted Wu) , the gating operation 160C uses the (non-rotated or original) base model parameters 114B (denoted Wg) , and the down-projection operation 172C uses the (non-rotated or original) base model parameters 114C (denoted Wd) . Additionally, rather than being rotated (e.g., by R4) during runtime, the output of the operation 168 is provided directly to the operation 172C.
[0095] The illustrated architecture of FIG. 3C retains use of the adapter specific rotation matrix 207A (RL2) and the inverse. Although the illustrated example depicts use of the same rotation matrix RL2 for each operation or component of the feed-forward component 113C, in some aspects, a separate adapter rotation matrix may be trained for each depicted operation. In the illustrated example, these adapter rotation matrices can be merged with corresponding sets of adapter parameters to reduce runtime overhead. That is, during runtime, rather than first rotating a given tensor and then applying the relevant set of parameters, the machine learning system may rotate the parameters offline and then use the rotated parameters to process data during runtime (e.g., using multiplication or convolution) .
[0096] Specifically, with respect to the up-projection operation 154C, the up-projection encoder parameters can be rotated by the adapter rotation matrix RL2 (e.g., 207A of FIG. 3A) to generate a modified (e.g., rotated) set of parameters 158C, and the up-projection decoder parameters are rotated by the inverse adapter rotation matrix (e.g., 207B from FIG. 3A) to form the set of modified (e.g., rotated) parameters 220. That is, the set of modified parameters 158C may be defined as and the set of modified parameters 220 may be defined as discussed above with reference to FIG. 2C.
[0097] Similarly, with respect to the gating operation 160C, the gating encoder parameters can be rotated by the adapter rotation matrix RL2 to generate a set of modified (e.g., rotated) parameters 164C. The gating decoder parameters are rotated by the inverse adapter rotation matrix to form the set of modified (e.g., rotated) parameters 225. That is, the set of modified parameters 164C may be defined as and the set of modified parameters 225 may be defined as discussed above with reference to FIG. 2C.
[0098] Finally, with respect to the down-projection operation 172C, the down-projection encoder parameters can be rotated by the adapter rotation matrix RL2 to generate a modified (e.g., rotated) set of parameters 176C, and the down-projection decoder parameters can be rotated by inverse adapter rotation matrix to generate a modified (e.g., rotated) set of parameters 178C. That is, the set of modified parameters 176C may be defined as and the set of modified parameters 178C may be defined as
[0099] As discussed above, merging these rotation matrices by rotating the various sets of parameters (to generate modified or rotated parameters) offline may reduce the computational expense and latency of using the model during runtime to generate output predictions. Example Architecture for Improved Model Quantization Using Learned Base Model Rotation Matrices
[0100] FIG. 4 depicts an example architecture for improved model quantization using learned base model rotation matrices, according to some aspects of the present disclosure. Specifically, FIG. 4 depicts an example architecture of a transformer 100D of a machine learning model, where the transformer 100D includes an attention component 106D and a feed-forward component 113D. In some aspects, the depicted transformer 100D may be used by a machine learning system, such as the machine learning system discussed above with reference to FIGS. 1A-1C, 2A-2C, and / or 3A-3C.
[0101] The transformer 100D shares a number of similarities from the architectures discussed above with respect to the transformer 100A of FIG. 1A, the transformer 100B of FIG. 2A, and / or the transformer 100C of FIG. 3A. For example, the transformer 100D receives an input 102 and generates a corresponding output 118 using an attention component 106D and a feed-forward component 113D. However, in the illustrated architecture, the transformer 100D does not include an adapter (e.g., the encoder 110 and the decoder 112 and / or the encoder 115 and / or the decoder 116) . Although the illustrated example does not depict an adapter for conceptual clarity, in some aspects, an adapter could be used as discussed above.
[0102] Generally, most of the depicted architecture of the attention component 106D mirrors the architecture of the attention component 106A discussed above with reference to FIG. 1B. For example, the attention component 106D also includes four operations 120D, 124D, 130D, and 146D with four corresponding sets of base model parameters with corresponding rotation matrices merged, as discussed above (e.g., the modified parameters 122A, 126A, 132A, and 148A) .
[0103] In the illustrated attention component 106D, however, rotation matrices 440A (designated R3) may be trainable rotation matrices (e.g., having values learned during training of the architecture) rather than fixed or predefined rotations. That is, while some systems use fixed rotation matrices (e.g., the rotation matrices 1140A discussed above with reference to FIG. 1B) to enable fast computation, the illustrated example instead uses learned rotation matrices 440A to improve model performance.
[0104] For example, in some aspects, the rotation matrices 440A may each have dimensionality head_dim×head_dim, where head_dim is the dimensionality of each attention head of the attention component 106D, thereby enabling per-head quantization. In some aspects, by using learnable rotation matrices 440A (rather than fixed Hadamard parameters) , the depicted architecture can improve model quantization (e.g., reducing the quantization loss) and enable the model to perform with improved accuracy. Although using such learnable matrices (also referred to in some aspects as “learned” or “trainable” matrices) may introduce additional latency in some systems, many hardware systems cannot fully leverage such fixed matrices regardless, and using learnable matrices improves accuracy without actually affecting the latency of the model.
[0105] As illustrated, the output of the attention component 106D is used as input to the feed-forward component 113D, as discussed above. Generally, most of the depicted architecture of the feed-forward component 113D mirrors the architecture of the feed-forward component 113A discussed above with reference to FIG. 1C. For example, the feed-forward component 113D also includes three operations 154D, 160D, and 172D with three corresponding sets of base model parameters with corresponding rotation matrices merged.
[0106] However, in the illustrated example, the rotation matrix 470A (designated R4) and its inverse , merged into the parameters 174D discussed in more detail below) may be a trainable rotation matrix (e.g., having values learned during training of the architecture) rather than a fixed or predefined rotation matrix. That is, while some systems use fixed rotation matrices to enable fast computation, the illustrated example instead uses learnable rotation matrices 470A to improve model performance. In some aspects, by using learnable rotation matrices 470A (rather than fixed Hadamard parameters) , the depicted architecture can improve model quantization (e.g., reducing the quantization loss) and enable the model to perform with improved accuracy. As discussed above, many hardware systems cannot fully leverage such fixed matrices regardless, and using learnable matrices improves accuracy without actually affecting the latency of the model.
[0107] In some aspects, the rotation matrix 470A has relatively large dimensionality (e.g., n×n) , which may be too large for efficient processing using many hardware systems. In some aspects, to reduce processing latency, therefore, the rotation matrix 470A (and its inverse) can be decomposed to two smaller matrices (e.g., a first matrix having dimensionality n1×n1 and a second having dimensionality n2×n2. For example, if n=8192, n1 may have a value of 64, and n2 may have a value of 128. These smaller matrices can be readily processed in many hardware systems.
[0108] In some aspects, given an original size of n×n for the rotation matrix 470A, the training and / or quantization system may define n1 and n2 as (n1, n2) =argmin (n1, n2) where n1*n2=n and n1<n2. By using these decomposed rotation matrices, the system may be able to more efficiently apply the learned rotations during runtime, as compared to the rotation matrices 470A in their initial size.
[0109] Further, in the illustrated example, scaling vectors 450A and 450B (collectively referred to herein as “scaling vectors 450” ) are used to improve the quantization accuracy of the up-projection operation 154D and the down-projection operation 172D. In some aspects, at least these components of the feed-forward component 113D may have numerous parameters that make it challenging to find suitable quantization parameters, resulting in significant accuracy loss (e.g., due to quantization error) in some cases. In some aspects, using trainable scaling vectors 450A and / or 450B can improve the model accuracy.
[0110] In some aspects, the scaling vectors 450 include a vector 450A (designated V in some aspects) and an inverse vector 450B (designated V-1 in some aspects) . That is, the vector 450B may be the inverse of the vector 450A. In some aspects, VV-1=1. In some aspects, the scaling vectors 450 may have a size (e.g., length) of c, where c is the number of channels in the tensors being processed (which may match the number of channels of the set of parameters 156D and 174D) . That is, in some aspects, the scaling vectors 450 may be used to perform per-channel scaling.
[0111] As depicted in the illustrated example, in some aspects, the scaling vectors 450 may be merged with the corresponding set of parameters prior to runtime (e.g., after training and / or before quantization) . That is, the base model parameters Wu of the up-projection operation 154D may be merged with the inverse rotation matrix and the scaling vector 450B (e.g., V-1) , such that the modified set of parameters 156D for the up-projection operation 154D may be defined as WuV-1.
[0112] Similarly, as illustrated, the base model parameters Wd of the down-projection operation 172D may be merged with the inverse rotation matrix (or decomposed matrices thereof, as discussed above) , the scaling vector 450A (e.g., V) , and the rotation matrix R1 such that the modified set of parameters 156D for the up-projection operation 154D may be defined as VWdR1.
[0113] Although not depicted in the illustrated example, in some aspects, one or both of the scaling vectors 450 (or a similar per-channel scaling vector having the same size but with potentially different learned values) may be similarly merged with the parameters of one or more other depicted operations, including the query operation 120D, the key operation 124D, the value operation 130D, the output operation 146D, the gating operation 160D, and the like.
[0114] In some aspects, as discussed above, the use of learnable rotation matrices 440 and / or 470, as well as use of learnable scaling vectors 450, can significantly reduce the error introduced by model quantization, resulting in improved model accuracy in some implementations. Example Method for Generating Rotation Matrices for Improved Quantization
[0115] FIG. 5 is a flow diagram depicting an example method 500 for generating rotation matrices for improved quantization, according to some aspects of the present disclosure. In some aspects, the method 500 may be performed by a machine learning system (e.g., a computing system configured to train and / or use machine learning models) , such as the machine learning system discussed above with reference to FIGS. 1A-1C, 2A-2C, 3A-3C, and / or 4.
[0116] At block 505, the machine learning system may access a trained base model (e.g., an LLM) . For example, as discussed above, the base model may comprise a set or sequence of transformer blocks. In some aspects, the machine learning system accesses the model from another system (e.g., a dedicated training system) . In some aspects, the machine learning system may itself train the machine learning model. In some aspects, the machine learning model may generally include base model parameters for components such as attention components (e.g., the multi-head self-attention 108 of FIGS. 1A, 2A, and / or 3A) , feed-forward components (e.g., the MLPs 114 of FIGS. 1A, 2A, and / or 3A) , and the like.
[0117] At block 510, the machine learning system trains a set of base model rotation matrices (e.g., the rotation matrices R1, R2, R3, and / or R4 discussed above) based on the base model. In some aspects, as discussed above, the machine learning system may freeze the parameters of the base model while training the values of the base model rotation matrices. In some aspects, as discussed above, the machine learning system may train the base model rotation matrices by seeking to find values for each rotation matrix to minimize (or at least reduce) the quantization noise resulting from quantizing the corresponding rotated data, and / or to maximize (or at least increase) the accuracy of the (quantized) model. In some aspects, training the base model rotation matrices can be performed by processing test or calibration data using the model, and refining the parameters of the rotation matrices based on the resulting model output and / or intermediate tensors within the model. In some aspects, as discussed above, the machine learning system may refrain from training base model rotation matrices (e.g., as discussed above with reference to FIGS. 3A-3C) .
[0118] Further at block 510, the machine learning system trains a set of base model scaling vectors (e.g., the scaling vector 450A (V) of FIG. 4 discussed above) based on the base model. In some aspects, as discussed above, the machine learning system may freeze the parameters of the base model while training the values of the scaling vector (s) . In some aspects, as discussed above, the machine learning system may train the base model scaling vectors by seeking to find values for each scaling vector to minimize (or at least reduce) the quantization noise resulting from quantizing the corresponding scaled parameters, and / or to maximize (or at least increase) the accuracy of the (quantized) model. In some aspects, training the base model scaling vectors can be performed by processing test or calibration data using the model, and refining the parameters of the vectors based on the resulting model output and / or intermediate tensors within the model. In some aspects, as discussed above, the machine learning system may refrain from training or using scaling vectors.
[0119] At block 515, the machine learning system determines whether one or more termination criteria are met with respect to the training of the base model rotation matrices. For example, the machine learning system may determine whether to train base model rotation matrices at all, whether a defined amount of time or amount of resources have been spent training, whether the model has reached a desired accuracy, and the like. If the termination criteria are not met, the method 500 returns to block 510 to continue training the base model rotation matrices. If the criteria are met, the method 500 continues to block 520.
[0120] At block 520, the machine learning system accesses one or more adapters (e.g., LoRA adapters) for the base model. In some aspects, the machine learning system accesses the adapters from another system (e.g., a dedicated training system) . In some aspects, the machine learning system may itself train the adapters. In some aspects, the adapters may generally include adapter parameters for one or more components of the base model. For example, the adapters may include parameters for the encoders 110 and / or 115 of FIGS. 1A, 2A, and / or 3A and / or the decoders 112 and / or 116 of FIGS. 1A, 2A, and / or 3A.
[0121] At block 525, the machine learning system trains a set of adapter rotation matrices (e.g., the rotation matrices RL1 and / or RL2 discussed above) based on the base model with the adapter (s) active. In some aspects, as discussed above, the machine learning system may freeze the parameters of the base model and the adapter (s) while training the values of the adapter rotation matrices. In some aspects, as discussed above, the machine learning system may train the adapter rotation matrices by seeking to find values for each rotation matrix to minimize (or at least reduce) the quantization noise resulting from quantizing the corresponding rotated data, and / or to maximize (or at least increase) the accuracy of the (quantized) adapted model. In some aspects, as discussed above, the machine learning system may train a unique adapter rotation matrix for each adapter and / or each component of the base model (e.g., for each transformer) , as discussed above. In some aspects, training the adapter rotation matrices can be performed by processing test or calibration data using the model, and refining the parameters of the rotation matrices based on the resulting model output and / or intermediate tensors within the model.
[0122] At block 530, the machine learning system determines whether one or more termination criteria are met with respect to the training of the adapter rotation matrices. For example, the machine learning system may determine whether a defined amount of time or amount of resources have been spent training, whether the model has reached a desired accuracy, and the like. If the termination criteria are not met, the method 500 returns to block 525 to continue training the base model rotation matrices. If the criteria are met, the method 500 continues to block 532.
[0123] At block 532, the machine learning system can decompose one or more of the rotation matrices, as discussed above. For example, in some aspects, the machine learning system may decompose R4 (e.g., the rotation matrix 470A of FIG. 4) and / or the inverse (s) thereof in order to generate two smaller matrices. In some aspects, as discussed above, the machine learning system may decompose any rotation matrices that are larger than a defined size (e.g., such that the rotation matrix is too large to be efficiently processed using the hardware system (s) on which the model is intended to be deployed) . In some aspects, as discussed above, the machine learning system may decompose such large rotation matrices that are to be applied during runtime (e.g., the rotation matrices 440A and / or 470A of FIG. 4) , while matrices that are merged with corresponding parameters (e.g., the inverse rotation matrix ) may be left intact, as this merging may collapse any added latency into the latency of the parameters themselves.
[0124] At block 535, the machine learning system merges one or more of the rotation matrices and / or one or more of the scaling vectors with one or more corresponding sets of parameters, as discussed above. For example, the machine learning system may merge base model rotation matrices and scaling vectors with the corresponding base model parameters and / or the corresponding adapters. Similarly, the machine learning system may merge the adapter rotation matrices with the corresponding adapter parameters for which the rotation matrices were generated. In some aspects, as discussed above, merging the rotation matrix with the set of parameters may generally include multiplying the rotation matrix and parameter matrix (e.g., rotating the parameters by the rotation matrix) to generate a set of modified (e.g., rotated) parameters.
[0125] At block 540, the machine learning system quantizes the merged parameters (and, in some cases, any non-merged or original parameters of the model) . For example, as discussed above, using aspects of the present disclosure the machine learning system may quantize the rotated parameters to relatively small bit-widths (e.g., four bits) , significantly reducing the memory footprint of the machine learning model. Although not depicted in the illustrated example, the machine learning system may then provide the quantized model for inferencing or runtime use, and / or may itself generate output predictions or inferences using the quantized model. Example Method for Machine Learning Model Quantization
[0126] FIG. 6 is a flow diagram depicting an example method 600 for machine learning model quantization, according to some aspects of the present disclosure. In some aspects, the method 600 may be performed by a machine learning system (e.g., a computing system configured to train and / or use machine learning models) , such as the machine learning system discussed above with reference to FIGS. 1A-1C, 2A-2C, 3A-3C, 4, and / or 5.
[0127] At block 605, a first set of base model parameters (e.g., parameters of the attention component 106D and / or the feed-forward component 113D of FIG. 4) for a first transformer block (e.g., the transformer 100D of FIG. 4) of a machine learning model is accessed.
[0128] At block 610, at least one of a first rotation matrix (e.g., the rotation matrix 440A of FIG. 4) or a second rotation matrix (e.g., the rotation matrix 470A of FIG. 4) is trained, where the first rotation matrix is for a first subset of the first set of base model parameters (e.g., the set of parameters 122A of FIG. 4) corresponding to a query operation (e.g., the query operation 120D of FIG. 4) of the first transformer block, and the second rotation matrix is for a second subset of the first set of base model parameters (e.g., the set of parameters 174D of FIG. 4) corresponding to a feed-forward operation (e.g., the feed-forward component 113D of FIG. 4) of the first transformer block.
[0129] At block 615, a quantized machine learning model is generated based on the first set of base model parameters and the first and second rotation matrices.
[0130] At block 620, the quantized machine learning model is provided for inferencing.
[0131] In some aspects, training the first rotation matrix comprises learning values for the first rotation matrix using a set of calibration data, wherein the first set of base model parameters are frozen during training of the first rotation matrix.
[0132] In some aspects, the method 600 further includes generating a respective rotation matrix for each respective query operation of the machine learning model.
[0133] In some aspects, a shape of the first rotation matrix is defined as (head_dim, head_dim) , wherein head_dim is a dimensionality of each attention head of the first transformer block.
[0134] In some aspects, the method 600 further includes decomposing the second rotation matrix into a pair of rotation matrices having smaller sizes than the second rotation matrix.
[0135] In some aspects, the method 600 further includes training a scaling vector (e.g., the scaling vectors 450A and / or 450B of FIG. 4) for the feed-forward operation.
[0136] In some aspects, the method 600 further includes scaling one or more parameters of the second subset based on the scaling vector. In some aspects, the one or more parameters of the second subset comprise a set of up-projection parameters (e.g., the set of parameters 156D of FIG. 4) for the feed-forward operation.
[0137] In some aspects, the method 600 further includes scaling one or more parameters of the second subset based on an inverse of the scaling vector. In some aspects, the one or more parameters of the second subset comprise a set of down-projection parameters (e.g., the set of parameters 174D of FIG. 4) for the feed-forward operation. Example Processing System for Machine Learning
[0138] FIG. 7 depicts an example processing system 700 configured to perform various aspects of the present disclosure, including, for example, the techniques and methods described with respect to FIGS. 1A-6. In some aspects, the processing system 700 may correspond to one or more machine learning systems. For example, the processing system 700 may correspond to the machine learning systems discussed above with reference to FIGS. 1A-1C, 2A-2C, 3A-3C, 4, 5, and / or 6. Although depicted as a single system for conceptual clarity, in some aspects, as discussed above, the components described below with respect to the processing system 700 may be distributed across any number of devices or systems.
[0139] The processing system 700 includes a central processing unit (CPU) 702, which in some examples may be a multi-core CPU. Instructions executed at the CPU 702 may be loaded, for example, from a program memory associated with the CPU 702 or may be loaded from a memory partition (e.g., a partition of a memory 724) .
[0140] The processing system 700 also includes additional processing components tailored to specific functions, such as a graphics processing unit (GPU) 704, a digital signal processor (DSP) 706, a neural processing unit (NPU) 708, a multimedia component 710 (e.g., a multimedia processing unit) , and a wireless connectivity component 712.
[0141] An NPU, such as the NPU 708, is generally a specialized circuit configured for implementing the control and arithmetic logic for executing machine learning algorithms, such as algorithms for processing artificial neural networks (ANNs) , deep neural networks (DNNs) , random forests (RFs) , and the like. An NPU may sometimes alternatively be referred to as a neural signal processor (NSP) , tensor processing unit (TPU) , neural network processor (NNP) , intelligence processing unit (IPU) , vision processing unit (VPU) , or graph processing unit.
[0142] NPUs, such as the NPU 708, are configured to accelerate the performance of common machine learning tasks, such as image classification, machine translation, object detection, and various other predictive models. In some examples, a plurality of NPUs may be instantiated on a single chip, such as a system on a chip (SoC) , while in other examples the NPUs may be part of a dedicated neural-network accelerator.
[0143] NPUs may be optimized for training or inference, or in some cases configured to balance performance between both. For NPUs that are capable of performing both training and inference, the two tasks may still generally be performed independently.
[0144] NPUs designed to accelerate training are generally configured to accelerate the optimization of new models, which is a highly compute-intensive operation that involves inputting an existing dataset (often labeled or tagged) , iterating over the dataset, and then adjusting model parameters, such as weights and biases, in order to improve model performance. Generally, optimizing based on a wrong prediction involves propagating back through the layers of the model and determining gradients to reduce the prediction error.
[0145] NPUs designed to accelerate inference are generally configured to operate on complete models. Such NPUs may thus be configured to input a new piece of data and rapidly process this piece of data through an already trained model to generate a model output (e.g., an inference) .
[0146] In some implementations, the NPU 708 is a part of one or more of the CPU 702, the GPU 704, and / or the DSP 706.
[0147] In some examples, the wireless connectivity component 712 may include subcomponents, for example, for third generation (3G) connectivity, fourth generation (4G) connectivity (e.g., Long-Term Evolution (LTE) ) , fifth generation (5G) connectivity (e.g., New Radio (NR) ) , Wi-Fi connectivity, Bluetooth connectivity, and other wireless data transmission standards. The wireless connectivity component 712 is further coupled to one or more antennas 714.
[0148] The processing system 700 may also include one or more sensor processing units 716 associated with any manner of sensor, one or more image signal processors (ISPs) 718 associated with any manner of image sensor, and / or a navigation processor 720, which may include satellite-based positioning system components (e.g., GPS or GLONASS) as well as inertial positioning system components.
[0149] The processing system 700 may also include one or more input and / or output devices 722, such as screens, touch-sensitive surfaces (including touch-sensitive displays) , physical buttons, speakers, microphones, and the like.
[0150] In some examples, one or more of the processors of the processing system 700 may be based on an ARM or RISC-V instruction set.
[0151] The processing system 700 also includes a memory 724, which is representative of one or more static and / or dynamic memories, such as a dynamic random access memory, a flash-based static memory, and the like. In this example, the memory 724 includes computer-executable components, which may be executed by one or more of the aforementioned processors of the processing system 700.
[0152] In particular, in this example, the memory 724 includes a training component 724A, a merging component 724B, a quantization component 724C, and an inferencing component 724D. Although not depicted in the illustrated example, the memory 724 may also include other components. Though depicted as discrete components for conceptual clarity in FIG. 7, the illustrated components (and others not depicted) may be collectively or individually implemented in various aspects.
[0153] Further, as illustrated, the memory 724 may also include various data, such as a set of model parameters 724E (e.g., parameters of one or more machine learning models and / or model adapters) , training and / or calibration data, and the like.
[0154] The processing system 700 further comprises a training circuit 726, a merging circuit 727, a quantization circuit 728, and an inferencing circuit 729. The depicted circuits, and others not depicted (such as an inferencing circuit) , may be configured to perform various aspects of the techniques described herein.
[0155] The training component 724A and / or the training circuit 726 may be used to train machine learning models and / or adapters (e.g., the model parameters 724E) , and / or to generate trained rotation matrices and / or scaling vectors, as discussed above. For example, the training component 724A and / or the training circuit 726 may train the parameters of the multi-head self-attention 108 of FIGS. 1A, 2A, 3A, and / or the attention component 106D of FIG. 4 and / or the parameters of the MLPs 114 of FIGS. 1A, 2A, 3A, and / or the feed-forward component 113D of FIG. 4, and / or may be used to train the base model rotation matrices, scaling vector (s) , and / or adapter rotation matrices, as discussed above.
[0156] The merging component 724B and / or the merging circuit 727 may be used to merge rotation matrices and / or scaling vectors with corresponding model parameters, as discussed above. For example, the merging component 724B and / or the merging circuit 727 may rotate model parameter matrices based on corresponding rotation matrices in order to merge these rotations offline, reducing the online latency and computational expense of the model. Similarly, the merging component 724B and / or the merging circuit 727 may scale the (potentially rotated) parameters by multiplying the corresponding scaling vector with the parameters. In some aspects, the merging component 724B and / or the merging circuit 727 may also decompose one or more rotation matrices (e.g., matrices larger than a defined size) , as discussed above.
[0157] The quantization component 724C and / or the quantization circuit 728 may be used to quantize the machine learning model (which may include any number of modified, scaled, and / or rotated parameter sets) , as discussed above. For example, the quantization component 724C and / or the quantization circuit 728 may quantize the (rotated, scaled, and / or modified) model parameters to a relatively small bit-width, such as four bits, because the rotations and / or per-channel scaling can significantly reduce the quantization noise in some cases.
[0158] The inferencing component 724D and / or the inferencing circuit 729 may be used to perform inferencing (e.g., generating model outputs during runtime) , as discussed above. For example, the inferencing component 724D and / or the inferencing circuit 729 may use the quantized modified (e.g., rotated) model parameters during runtime to process data and generate corresponding output predictions.
[0159] Though depicted as separate components and circuits for clarity in FIG. 7, the training circuit 726, the merging circuit 727, the quantization circuit 728, and the inferencing circuit 729 may collectively or individually be implemented in other processing devices of the processing system 700, such as within the CPU 702, the GPU 704, the DSP 706, the NPU 708, and the like.
[0160] Generally, the processing system 700 and / or components thereof may be configured to perform the methods described herein.
[0161] Notably, in other aspects, elements of the processing system 700 may be omitted, such as where the processing system 700 is a server computer or the like. For example, the multimedia component 710, the wireless connectivity component 712, the sensor processing units 716, the ISPs 718, and / or the navigation processor 720 may be omitted in other aspects. Further, elements of the processing system 700 may be distributed between multiple devices. Example Clauses
[0162] Implementation examples are described in the following numbered clauses:
[0163] Clause 1: A method, comprising: accessing a first set of adapter parameters for a first transformer block of a machine learning model, wherein the first set of adapter parameters comprises a first set of encoder parameters and a first set of decoder parameters; generating a first rotation matrix for the first set of adapter parameters; generating a first set of modified adapter parameters, comprising: generating a first rotated set of encoder parameters based on rotating the first set of encoder parameters according to the first rotation matrix; and generating a first rotated set of decoder parameters based on rotating the first set of decoder parameters according to an inverse of the first rotation matrix; generating a quantized machine learning model based on quantizing the first set of modified adapter parameters; and providing the quantized machine learning model for inferencing.
[0164] Clause 2: A method according to Clause 1, wherein generating the first rotation matrix comprises training the first rotation matrix using a set of calibration data, wherein the first set of adapter parameters and parameters of the machine learning model are frozen during training of the first rotation matrix.
[0165] Clause 3: A method according to any of Clauses 1-2, further comprising generating a respective rotation matrix for each respective transformer block, with a corresponding adapter, of the machine learning model.
[0166] Clause 4: A method according to any of Clauses 1-3, further comprising: accessing a second set of adapter parameters corresponding to a feed-forward component of the first transformer block, wherein the first set of adapter parameters corresponds to an attention component of the first transformer block; generating a second rotation matrix for the second set of adapter parameters; and generating a second set of modified adapter parameters using the second rotation matrix, wherein generating the quantized machine learning model comprises generating the quantized machine learning model based on quantizing the first set of modified adapter parameters and the second set of modified adapter parameters.
[0167] Clause 5: A method according to any of Clauses 1-4, wherein a shape of the first rotation matrix is defined as (D_rank, D_rank) , wherein Drank is a rank of an adapter with which the first set of adapter parameters is associated.
[0168] Clause 6: A method according to any of Clauses 1-5, further comprising generating a second rotation matrix for the first transformer block; and generating the first set of modified adapter parameters based further on the second rotation matrix, wherein: generating the first rotated set of encoder parameters comprises rotating the first set of encoder parameters according to an inverse of the second rotation matrix and then according to the first rotation matrix; and generating the first rotated set of decoder parameters further comprises rotating the first rotated set of decoder parameters according to the second rotation matrix.
[0169] Clause 7: A method according to any of Clauses 1-6, wherein the first rotation matrix comprises a Hadamard matrix.
[0170] Clause 8: A method according to any of Clauses 1-7, wherein quantizing the first set of modified adapter parameters comprises quantizing each respective modified adapter parameter of the first set of modified adapter parameters to a bit-width of four bits.
[0171] Clause 9: A method, comprising: accessing a first set of base model parameters for a first transformer block of a machine learning model; training at least one of: a first rotation matrix for a first subset of the first set of base model parameters, wherein the first subset corresponds to a query operation of the first transformer block, or a second rotation matrix for a second subset of the first set of base model parameters, wherein the second subset corresponds to a feed-forward operation of the first transformer block; generating a quantized machine learning model based on the first set of base model parameters and the first and second rotation matrices; and providing the quantized machine learning model for inferencing.
[0172] Clause 10: A method according to Clause 9, wherein training the first rotation matrix comprises learning values for the first rotation matrix using a set of calibration data, wherein the first set of base model parameters is frozen during training of the first rotation matrix.
[0173] Clause 11: A method according to any of Clauses 9-10, further comprising generating a respective rotation matrix for each respective query operation of the machine learning model.
[0174] Clause 12: A method according to any of Clauses 9-11, wherein a shape of the first rotation matrix is defined as (head_dim, head_dim) , wherein head_dim is a dimensionality of each attention head of the first transformer block.
[0175] Clause 13: A method according to any of Clauses 9-12, further comprising decomposing the second rotation matrix into a pair of rotation matrices having smaller sizes than the second rotation matrix.
[0176] Clause 14: A method according to any of Clauses 9-13, further comprising training a scaling vector for the feed-forward operation.
[0177] Clause 15: A method according to Clause 14, further comprising scaling one or more parameters of the second subset based on the scaling vector.
[0178] Clause 16: A method according to Clause 15, wherein the one or more parameters of the second subset comprise a set of up-projection parameters for the feed-forward operation.
[0179] Clause 17: A method according to Clause 14, further comprising scaling one or more parameters of the second subset based on an inverse of the scaling vector.
[0180] Clause 18: A method according to Clause 17, wherein the one or more parameters of the second subset comprise a set of down-projection parameters for the feed-forward operation.
[0181] Clause 19: A processing system comprising: one or more memories comprising processor-executable instructions; and one or more processors coupled to the one or more memories and configured to execute the processor-executable instructions and cause the processing system to perform a method in accordance with any of Clauses 1-18.
[0182] Clause 20: A mobile device comprising the processing system of Clause 19.
[0183] Clause 21: A processing system comprising means for performing a method in accordance with any of Clauses 1-18.
[0184] Clause 22: A non-transitory computer-readable medium comprising computer-executable instructions that, when executed by one or more processors of a processing system, cause the processing system to perform a method in accordance with any of Clauses 1-18.
[0185] Clause 23: A computer program product embodied on a computer-readable storage medium comprising code for performing a method in accordance with any of Clauses 1-18. Additional Considerations
[0186] The preceding description is provided to enable any person skilled in the art to practice the various aspects described herein. The examples discussed herein are not limiting of the scope, applicability, or aspects set forth in the claims. Various modifications to these aspects will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other aspects. For example, changes may be made in the function and arrangement of elements discussed without departing from the scope of the disclosure. Various examples may omit, substitute, or add various procedures or components as appropriate. For instance, the methods described may be performed in an order different from that described, and various steps may be added, omitted, or combined. Also, features described with respect to some examples may be combined in some other examples. For example, an apparatus may be implemented or a method may be practiced using any number of the aspects set forth herein. In addition, the scope of the disclosure is intended to cover such an apparatus or method that is practiced using other structure, functionality, or structure and functionality in addition to, or other than, the various aspects of the disclosure set forth herein. It should be understood that any aspect of the disclosure disclosed herein may be embodied by one or more elements of a claim.
[0187] As used herein, the word “exemplary” means “serving as an example, instance, or illustration. ” Any aspect described herein as “exemplary” is not necessarily to be construed as preferred or advantageous over other aspects.
[0188] As used herein, a phrase referring to “at least one of” a list of items refers to any combination of those items, including single members. As an example, “at least one of: a, b, or c” is intended to cover a, b, c, a-b, a-c, b-c, and a-b-c, as well as any combination with multiples of the same element (e.g., a-a, a-a-a, a-a-b, a-a-c, a-b-b, a-c-c, b-b, b-b-b, b-b-c, c-c, and c-c-c or any other ordering of a, b, and c) .
[0189] As used herein, the term “determining” encompasses a wide variety of actions. For example, “determining” may include calculating, computing, processing, deriving, investigating, looking up (e.g., looking up in a table, a database or another data structure) , ascertaining, and the like. Also, “determining” may include receiving (e.g., receiving information) , accessing (e.g., accessing data in a memory) , and the like. Also, “determining” may include resolving, selecting, choosing, establishing, and the like.
[0190] The methods disclosed herein comprise one or more steps or actions for achieving the methods. The method steps and / or actions may be interchanged with one another without departing from the scope of the claims. In other words, unless a specific order of steps or actions is specified, the order and / or use of specific steps and / or actions may be modified without departing from the scope of the claims. Further, the various operations of methods described above may be performed by any suitable means capable of performing the corresponding functions. The means may include various hardware and / or software component (s) and / or module (s) , including, but not limited to a circuit, an application specific integrated circuit (ASIC) , or processor. Generally, where there are operations illustrated in figures, those operations may have corresponding counterpart means-plus-function components with similar numbering.
[0191] The following claims are not intended to be limited to the aspects shown herein, but are to be accorded the full scope consistent with the language of the claims. Within a claim, reference to an element in the singular is not intended to mean “one and only one” unless specifically so stated, but rather “one or more. ” Unless specifically stated otherwise, the term “some” refers to one or more. No claim element is to be construed under the provisions of 35 U.S.C. § 112 (f) unless the element is expressly recited using the phrase “means for” or, in the case of a method claim, the element is recited using the phrase “step for. ” All structural and functional equivalents to the elements of the various aspects described throughout this disclosure that are known or later come to be known to those of ordinary skill in the art are expressly incorporated herein by reference and are intended to be encompassed by the claims. Moreover, nothing disclosed herein is intended to be dedicated to the public regardless of whether such disclosure is explicitly recited in the claims.
Claims
1.A processing system for machine learning, comprising:one or more memories comprising processor-executable instructions; andone or more processors coupled to the one or more memories and configured to execute the processor-executable instructions and cause the processing system to:access a first set of base model parameters for a first transformer block of a machine learning model;train at least one of:a first rotation matrix for a first subset of the first set of base model parameters, wherein the first subset corresponds to a query operation of the first transformer block, ora second rotation matrix for a second subset of the first set of base model parameters, wherein the second subset corresponds to a feed-forward operation of the first transformer block;generate a quantized machine learning model based on the first set of base model parameters and the first and second rotation matrices; andprovide the quantized machine learning model for inferencing.2.The processing system of claim 1, wherein, to train the first rotation matrix, the one or more processors are configured to execute the processor-executable instructions and cause the processing system to learn values for the first rotation matrix using a set of calibration data, wherein the first set of base model parameters is frozen during training of the first rotation matrix.3.The processing system of claim 1, wherein the one or more processors are configured to execute the processor-executable instructions and further cause the processing system to generate a respective rotation matrix for each respective query operation of the machine learning model.4.The processing system of claim 1, wherein a shape of the first rotation matrix is defined as (head_dim, head_dim) , wherein head_dim is a dimensionality of each attention head of the first transformer block.5.The processing system of claim 1, wherein the one or more processors are configured to execute the processor-executable instructions and further cause the processing system to decompose the second rotation matrix into a pair of rotation matrices having smaller sizes than the second rotation matrix.6.The processing system of claim 1, wherein the one or more processors are configured to execute the processor-executable instructions and cause the processing system to train a scaling vector for the feed-forward operation.7.The processing system of claim 6, wherein the one or more processors are configured to execute the processor-executable instructions and further cause the processing system to scale one or more parameters of the second subset based on an inverse of the scaling vector.8.The processing system of claim 7, wherein the one or more parameters of the second subset comprise a set of up-projection parameters for the feed-forward operation.9.The processing system of claim 6, the one or more processors are configured to execute the processor-executable instructions and further cause the processing system to scale one or more parameters of the second subset based on the scaling vector.10.The processing system of claim 9, wherein the one or more parameters of the second subset comprise a set of down-projection parameters for the feed-forward operation.11.A mobile device comprising the processing system of claim 1.12.A processor-implemented method of machine learning, comprising:accessing a first set of base model parameters for a first transformer block of a machine learning model;training at least one of:a first rotation matrix for a first subset of the first set of base model parameters, wherein the first subset corresponds to a query operation of the first transformer block, ora second rotation matrix for a second subset of the first set of base model parameters, wherein the second subset corresponds to a feed-forward operation of the first transformer block;generating a quantized machine learning model based on the first set of base model parameters and the first and second rotation matrices; andproviding the quantized machine learning model for inferencing.13.The processor-implemented method of claim 12, wherein training the first rotation matrix comprises learning values for the first rotation matrix using a set of calibration data, wherein the first set of base model parameters is frozen during training of the first rotation matrix.14.The processor-implemented method of claim 12, wherein a shape of the first rotation matrix is defined as (head_dim, head_dim) , wherein head_dim is a dimensionality of each attention head of the first transformer block.15.The processor-implemented method of claim 12, further comprising decomposing the second rotation matrix into a pair of rotation matrices having smaller sizes than the second rotation matrix.16.The processor-implemented method of claim 12, further comprising training a scaling vector for the feed-forward operation.17.The processor-implemented method of claim 16, further comprising scaling one or more parameters of the second subset based on an inverse of the scaling vector.18.The processor-implemented method of claim 17, wherein the one or more parameters of the second subset comprise a set of up-projection parameters for the feed-forward operation.19.The processor-implemented method of claim 16, further comprising scaling one or more parameters of the second subset based on the scaling vector.20.A processing system, comprising:means for accessing a set of base model parameters for a transformer block of a machine learning model;means for training at least one of:a first rotation matrix for a first subset of the set of base model parameters, wherein the first subset corresponds to a query operation of the transformer block, ora second rotation matrix for a second subset of the set of base model parameters, wherein the second subset corresponds to a feed-forward operation of the transformer block;means for generating a quantized machine learning model based on the set of base model parameters and the first and second rotation matrices; andmeans for providing the quantized machine learning model for inferencing.