Low-bit quantization for adapters of transformer-based machine learning models

WO2026165734A1PCT designated stage Publication Date: 2026-08-13QUALCOMM INC +3
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Filing Date
2025-02-06
Publication Date
2026-08-13

Smart Images

  • Figure CN2025075896_13082026_PF_FP_ABST
    Figure CN2025075896_13082026_PF_FP_ABST
Patent Text Reader

Abstract

Certain aspects of the present disclosure provide techniques and apparatus for machine learning. In an example method, a set of adapter parameters for a transformer block of a machine learning model is accessed, where the set of adapter parameters comprises a set of encoder parameters and a set of decoder parameters. A rotation matrix for the set of adapter parameters is generated. A set of modified adapter parameters is generated, comprising: generating a rotated set of encoder parameters based on rotating the set of encoder parameters according to the rotation matrix, and generating a rotated set of decoder parameters based on rotating the set of decoder parameters according to an inverse of the rotation matrix. A quantized machine learning model is generated based on quantizing the set of modified adapter parameters, and the quantized machine learning model is provided for inferencing.
Need to check novelty before this filing date? Find Prior Art

Description

LOW-BIT QUANTIZATION FOR ADAPTERS OF TRANSFORMER-BASED MACHINE LEARNING MODELSINTRODUCTION

[0001] Aspects of the present disclosure relate to machine learning.

[0002] 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) .

[0003] 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

[0004] 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.

[0005] 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.

[0006] The following description and the related drawings set forth in detail certain illustrative features of one or more aspects.BRIEF DESCRIPTION OF THE DRAWINGS

[0007] 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.

[0008] 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.

[0009] 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.

[0010] 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.

[0011] FIG. 4 is a flow diagram depicting an example method for generating rotation matrices for improved quantization, according to some aspects of the present disclosure.

[0012] FIG. 5 is a flow diagram depicting an example method for machine learning model quantization, according to some aspects of the present disclosure.

[0013] FIG. 6 depicts an example processing system configured to perform various aspects of the present disclosure.

[0014] 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

[0015] 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 quantization via rotation matrices.

[0016] 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) .

[0017] 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.

[0018] 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) .

[0019] 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 mode 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

[0020] 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) .

[0021] 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) .

[0022] 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.

[0023] 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) .

[0024] 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) .

[0025] 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.

[0026] 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) .

[0027] 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) .

[0028] 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

[0029] 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) ) .

[0030] 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.

[0031] 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) .

[0032] 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

[0033] 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.

[0034] 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) .

[0035] 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) .

[0036] 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.

[0037] 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) .

[0038] 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.

[0039] 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) .

[0040] 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.

[0041] 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.

[0042] 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

[0043] 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

[0044] 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.

[0045] 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.

[0046] 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) .

[0047] 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) .

[0048] 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.

[0049] 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) . The output of the operation 168 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) .

[0050] As illustrated, the rotated tensor is then processed using the down-projection operation 172A to generate the output of the feed-forward component 113A.

[0051] 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) .

[0052] 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.

[0053] 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.

[0054] 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

[0055] 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

[0056] 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.

[0057] 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.

[0058] 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) .

[0059] 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.

[0060] 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) .

[0061] 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.

[0062] 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.

[0063] 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.

[0064] 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) .

[0065] 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

[0066] 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

[0067] 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

[0068] 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

[0069] 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.

[0070] 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.

[0071] 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.

[0072] Further, the various sets of base model parameters may have base model rotation matrices (e.g., R1 and its inverses) merged into the base model parameters themselves (e.g., to form the modified sets of parameters 156A, 162A, and 174A) , as discussed above.

[0073] 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) .

[0074] 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

[0075] 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

[0076] 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

[0077] 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

[0078] 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.

[0079] 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) .

[0080] 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.

[0081] 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.

[0082] 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.

[0083] 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) .

[0084] 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.

[0085] 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.

[0086] 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

[0087] 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

[0088] 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.

[0089] 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.

[0090] 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.

[0091] 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.

[0092] 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) .

[0093] 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.

[0094] 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.

[0095] 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

[0096] 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 Method for Generating Rotation Matrices for Improved Quantization

[0097] FIG. 4 is a flow diagram depicting an example method 400 for generating rotation matrices for improved quantization, according to some aspects of the present disclosure. In some aspects, the method 400 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, and / or 3A-3C.

[0098] At block 405, 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.

[0099] At block 410, the machine learning system trains a set of base model rotation matrices (e.g., the rotation matrices R1, R2, R3, and 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) .

[0100] At block 415, 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 400 returns to block 410 to continue training the base model rotation matrices. If the criteria are met, the method 400 continues to block 420.

[0101] At block 420, 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.

[0102] At block 425, 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.

[0103] At block 430, 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 400 returns to block 425 to continue training the base model rotation matrices. If the criteria are met, the method 400 continues to block 435.

[0104] At block 435, the machine learning system merges one or more of the rotation matrices with one or more corresponding sets of parameters, as discussed above. For example, the machine learning system may merge base model rotation matrices 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.

[0105] At block 440, 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

[0106] FIG. 5 is a flow diagram depicting an example method 500 for machine learning model 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.

[0107] At block 505, a first set of adapter parameters (e.g., the encoder 110 and / or 115 and / or the decoder 112 and / or 116 of FIGS. 1A-1C, 2A-2C, and / or 3A-3C) for a first transformer block (e.g., the transformer 100A of FIG. 1A, 100B of FIG. 1B, and / or 100C of FIG. 1C) of a machine learning model is accessed, wherein the first set of adapter parameters comprises a first set of encoder parameters and a first set of decoder parameters.

[0108] At block 510, a first rotation matrix (e.g., the rotation matrix 205A and / or 207A of FIGS. 2A and / or 3A) for the first set of adapter parameters is generated.

[0109] At block 515, a first modified set of adapter parameters comprising a first rotated set of encoder parameters (e.g., the modified parameters 123B, 128B. 134B, and / or 150B of FIG. 2B, the modified parameters 158B, 164B, and / or 176B of FIG. 2C, the modified parameters 123C, 128C, 134C, and / or 150C of FIG. 3B, and / or the modified parameters 158C, 164C, and / or 176C of FIG. 3C) is generated based on rotating the first set of encoder parameters according to the first rotation matrix.

[0110] At block 520, the first modified set of adapter parameters further comprising a first rotated set of decoder parameters (e.g., (e.g., the modified parameters 210, 215. 136B, and / or 152B of FIG. 2B, the modified parameters 220, 225, and / or 178B of FIG. 2C, the modified parameters 210, 215, 136C, and / or 152C of FIG. 3B, and / or the modified parameters 220, 225, and / or 178C of FIG. 3C) is generated based on rotating the first set of decoder parameters according to an inverse of the first rotation matrix (e.g., the inverse rotation matrix 205B and / or 207B of FIGS. 2A and / or 3A) .

[0111] At block 525, a quantized machine learning model is generated based on quantizing the first set of modified adapter parameters.

[0112] At block 530, the quantized machine learning model is provided for inferencing.

[0113] In some aspects, 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 (e.g., of the multi-head self-attention 108 and / or LMP 114 of FIGS. 1A-1C, 2A-2C, and / or 3A-3C) are frozen during training of the first rotation matrix.

[0114] In some aspects, the method 500 further includes generating a respective rotation matrix for each respective transformer block, with a corresponding adapter, of the machine learning model.

[0115] In some aspects, the method 500 further includes accessing a second set of adapter parameters corresponding to a feed-forward component (e.g., the feed-forward component 113A-C of FIGS. 1A, 1C, 2A, 2C, 3A, and / or 3C) of the first transformer block, wherein the first set of adapter parameters corresponds to an attention component (e.g., the attention component 106A-C of FIGS. 1A, 1C, 2A, 2C, 3A, and / or 3C) of the first transformer block, generating a second rotation matrix (e.g., the rotation matrix 207A of FIGS. 2A and / or 3A) 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.

[0116] In some aspects, 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.

[0117] In some aspects, the method 500 further includes generating a second rotation matrix (e.g., the rotation matrix 104A of FIGS. 1A and / or 2A) 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.

[0118] In some aspects, the first rotation matrix comprises a Hadamard matrix.

[0119] In some aspects, 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. Example Processing System for Machine Learning

[0120] FIG. 6 depicts an example processing system 600 configured to perform various aspects of the present disclosure, including, for example, the techniques and methods described with respect to FIGS. 1-5. In some aspects, the processing system 600 may correspond to one or more machine learning systems. For example, the processing system 600 may correspond to the machine learning systems discussed above with reference to FIGS. 1A-1C, 2A-2C, 3A-3C, 4, and / or 5. 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 600 may be distributed across any number of devices or systems.

[0121] The processing system 600 includes a central processing unit (CPU) 602, which in some examples may be a multi-core CPU. Instructions executed at the CPU 602 may be loaded, for example, from a program memory associated with the CPU 602 or may be loaded from a memory partition (e.g., a partition of a memory 624) .

[0122] The processing system 600 also includes additional processing components tailored to specific functions, such as a graphics processing unit (GPU) 604, a digital signal processor (DSP) 606, a neural processing unit (NPU) 608, a multimedia component 610 (e.g., a multimedia processing unit) , and a wireless connectivity component 612.

[0123] An NPU, such as the NPU 608, 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.

[0124] NPUs, such as the NPU 608, 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.

[0125] 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.

[0126] 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.

[0127] 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) .

[0128] In some implementations, the NPU 608 is a part of one or more of the CPU 602, the GPU 604, and / or the DSP 606.

[0129] In some examples, the wireless connectivity component 612 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 612 is further coupled to one or more antennas 614.

[0130] The processing system 600 may also include one or more sensor processing units 616 associated with any manner of sensor, one or more image signal processors (ISPs) 618 associated with any manner of image sensor, and / or a navigation processor 620, which may include satellite-based positioning system components (e.g., GPS or GLONASS) as well as inertial positioning system components.

[0131] The processing system 600 may also include one or more input and / or output devices 622, such as screens, touch-sensitive surfaces (including touch-sensitive displays) , physical buttons, speakers, microphones, and the like.

[0132] In some examples, one or more of the processors of the processing system 600 may be based on an ARM or RISC-V instruction set.

[0133] The processing system 600 also includes a memory 624, 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 624 includes computer-executable components, which may be executed by one or more of the aforementioned processors of the processing system 600.

[0134] In particular, in this example, the memory 624 includes a training component 624A, a merging component 624B, a quantization component 624C, and an inferencing component 624D. Although not depicted in the illustrated example, the memory 624 may also include other components. Though depicted as discrete components for conceptual clarity in FIG. 6, the illustrated components (and others not depicted) may be collectively or individually implemented in various aspects.

[0135] Further, as illustrated, the memory 624 may also include various data, such as a set of model parameters 624E (e.g., parameters of one or more machine learning models and / or model adapters) , training and / or calibration data, and the like.

[0136] The processing system 600 further comprises a training circuit 626, a merging circuit 627, a quantization circuit 628, and an inferencing circuit 629. The depicted circuits, and others not depicted (such as an inferencing circuit) , may be configured to perform various aspects of the techniques described herein.

[0137] The training component 624A and / or the training circuit 626 may be used to train machine learning models and / or adapters (e.g., the model parameters 624E) , and / or to generate trained rotation matrices, as discussed above. For example, the training component 624A and / or the training circuit 626 may train the parameters of the multi-head self-attention 108 of FIGS. 1A, 2A, and / or 3A and / or the parameters of the MLPs 114 of FIGS. 1A, 2A, and / or 3A, and / or may be used to train the base model rotation matrices and / or adapter rotation matrices, as discussed above.

[0138] The merging component 624B and / or the merging circuit 627 may be used to merge rotation matrices with corresponding model parameters, as discussed above. For example, the merging component 624B and / or the merging circuit 627 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.

[0139] The quantization component 624C and / or the quantization circuit 628 may be used to quantize the machine learning model (which may include any number of modified or rotated parameter sets) , as discussed above. For example, the quantization component 624C and / or the quantization circuit 628 may quantize the (rotated or modified) model parameters to a relatively small bit-width, such as four bits, because the rotations can significantly reduce the quantization noise in some cases.

[0140] The inferencing component 624D and / or the inferencing circuit 629 may be used to perform inferencing (e.g., generating model outputs during runtime) , as discussed above. For example, the inferencing component 624D and / or the inferencing circuit 629 may use the quantized modified (e.g., rotated) model parameters during runtime to process data and generate corresponding output predictions.

[0141] Though depicted as separate components and circuits for clarity in FIG. 6, the training circuit 626, the merging circuit 627, the quantization circuit 628, and the inferencing circuit 629 may collectively or individually be implemented in other processing devices of the processing system 600, such as within the CPU 602, the GPU 604, the DSP 606, the NPU 608, and the like.

[0142] Generally, the processing system 600 and / or components thereof may be configured to perform the methods described herein.

[0143] Notably, in other aspects, elements of the processing system 600 may be omitted, such as where the processing system 600 is a server computer or the like. For example, the multimedia component 610, the wireless connectivity component 612, the sensor processing units 616, the ISPs 618, and / or the navigation processor 620 may be omitted in other aspects. Further, elements of the processing system 600 may be distributed between multiple devices. Example Clauses

[0144] Implementation examples are described in the following numbered clauses:

[0145] 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.

[0146] 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.

[0147] 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.

[0148] 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.

[0149] 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.

[0150] 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.

[0151] Clause 7: A method according to any of Clauses 1-6, wherein the first rotation matrix comprises a Hadamard matrix.

[0152] 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.

[0153] Clause 9: 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-8.

[0154] Clause 10: A processing system comprising means for performing a method in accordance with any of Clauses 1-8.

[0155] Clause 11: 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-8.

[0156] Clause 12: A computer program product embodied on a computer-readable storage medium comprising code for performing a method in accordance with any of Clauses 1-8. Additional Considerations

[0157] 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.

[0158] 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.

[0159] 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) .

[0160] 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.

[0161] 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.

[0162] 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 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;generate a first rotation matrix for the first set of adapter parameters;generate a first set of modified adapter parameters, wherein, the generate the first set of modified adapter parameters, the one or more processors are configured to execute the processor-executable instructions and cause the processing system to:generate a first rotated set of encoder parameters based on rotating the first set of encoder parameters according to the first rotation matrix; andgenerate 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;generate a quantized machine learning model based on quantizing the first set of modified adapter parameters; andprovide the quantized machine learning model for inferencing.2.The processing system of claim 1, wherein, to generate the first rotation matrix, the one or more processors are configured to execute the processor-executable instructions and cause the processing system to train 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.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 transformer block, with a corresponding adapter, of the machine learning model.4.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:access 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;generate a second rotation matrix for the second set of adapter parameters; andgenerate 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.5.The processing system of claim 1, 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.6.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 second rotation matrix for the first transformer block; andgenerate the first set of modified adapter parameters based further on the second rotation matrix, wherein:generate 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; andgenerate the first rotated set of decoder parameters further comprises rotating the first rotated set of decoder parameters according to the second rotation matrix.7.The processing system of claim 1, wherein the first rotation matrix comprises a Hadamard matrix.8.The processing system of claim 1, wherein, to quantize the first set of modified adapter parameters, the one or more processors are configured to execute the processor-executable instructions and cause the processing system to quantize each respective modified adapter parameter of the first set of modified adapter parameters to a bit-width of four bits.9.A processor-implemented method of machine learning, 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; andgenerating 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; andproviding the quantized machine learning model for inferencing.10.The processor-implemented method of claim 9, 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.11.The processor-implemented method of claim 9, further comprising generating a respective rotation matrix for each respective transformer block, with a corresponding adapter, of the machine learning model.12.The processor-implemented method of claim 9, 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; andgenerating 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.13.The processor-implemented method of claim 9, 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.14.The processor-implemented method of claim 9, further comprising:generating a second rotation matrix for the first transformer block; andgenerating 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; andgenerating the first rotated set of decoder parameters further comprises rotating the first rotated set of decoder parameters according to the second rotation matrix.15.The processor-implemented method of claim 9, wherein the first rotation matrix comprises a Hadamard matrix.16.The processor-implemented method of claim 9, 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.17.A processing system, comprising:means for 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;means for generating a first rotation matrix for the first set of adapter parameters;means for generating a first set of modified adapter parameters, comprising:means for generating a first rotated set of encoder parameters based on rotating the first set of encoder parameters according to the first rotation matrix; andmeans for 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;means for generating a quantized machine learning model based on quantizing the first set of modified adapter parameters; andmeans for providing the quantized machine learning model for inferencing.18.The processing system of claim 17, wherein the means for generating the first rotation matrix comprise means for 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.19.The processing system of claim 17, further comprising:means for 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;means for generating a second rotation matrix for the second set of adapter parameters; andmeans for 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.20.The processing system of claim 17, further comprising:means for generating a second rotation matrix for the first transformer block; andmeans for generating the first set of modified adapter parameters based further on the second rotation matrix, wherein:the means for generating the first rotated set of encoder parameters comprise means for rotating the first set of encoder parameters according to an inverse of the second rotation matrix and then according to the first rotation matrix; andthe means for generating the first rotated set of decoder parameters further comprise means for rotating the first rotated set of decoder parameters according to the second rotation matrix.