Incremental quantizer enabling for machine learning models with adapters

WO2026218149A1PCT designated stage Publication Date: 2026-10-22QUALCOMM INC +8
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2025/088929
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Filing Date
2025-04-15
Publication Date
2026-10-22

Smart Images

  • Figure CN2025088929_22102026_PF_FP_ABST
    Figure CN2025088929_22102026_PF_FP_ABST
Patent Text Reader

Abstract

Systems and techniques are described for incremental quantization. For instance, a process can include determining a quantization ratio for a set of layers in a pretrained machine learning model; selecting a first layer, of the set of layers, based on the quantization ratio; and predicting, using an adapter and the pretrained machine learning model, an output value using the selected first layer, wherein the selected first layer uses at least one of a set of quantized weights or a set of quantized activations.
Need to check novelty before this filing date? Find Prior Art

Description

INCREMENTAL QUANTIZER ENABLING FOR MACHINE LEARNING MODELS WITH ADAPTERSTECHNICAL FIELD

[0001] The disclosure relates generally to machine learning models. For example, aspects of the present disclosure include systems and techniques for enabling incremental quantization in machine learning models with adapters.BACKGROUND

[0002] Machine learning systems (or models) , such as neural networks (e.g., deep neural networks) are widely used for numerous applications, such as generative operations (e.g., to generate images, language / text outputs, etc. ) , object detection, object classification, object tracking, big data analysis, among others. For example, convolutional neural networks (CNNs) are able to extract high-level features, such as facial shapes, from an input image, and use these high-level features to output a probability that, for example, an input image includes a particular object.

[0003] A generative machine learning system can process data to generate desired output content from an input (e.g., a natural language input, input image (s) or video (s) , a noise input such as for diffusion models, etc. ) . For instance, a language-based generative machine learning model (e.g., a large language model (LLM) ) can generate natural language responses from natural language inputs and can incorporate various forms of data, such as audio, images and text. In some cases, a generative machine learning system can include an encoder that processes input features to generate output features (also referred to as embeddings or encodings) and can use the output features to generate relevant output content in a given form (e.g., in a natural language form, as generated images and / or video, as audio, explanation of the content, etc. ) .

[0004] A generative ML system can perform a wide range of tasks such as answering questions, providing explanations, generating creative content, assisting with coding, and offering recommendations. Various tools may be connected to the generative ML system to allow interaction with external systems, such as browsing the Internet, generating images, executing code, etc. Generative ML systems are designed to assist users in solving problems, learning new information, and enhancing productivity.SUMMARY

[0005] The following presents a simplified summary relating to one or more aspects disclosed herein. Thus, the following summary should not be considered an extensive overview relating to all contemplated aspects, nor should the following summary be considered to identify key or critical elements relating to all contemplated aspects or to delineate the scope associated with any particular aspect. Accordingly, the following summary presents certain concepts relating to one or more aspects relating to the mechanisms disclosed herein in a simplified form to precede the detailed description presented below.

[0006] In one illustrative example, an apparatus for incremental quantization is provided. The apparatus includes at least one memory and at least one processor coupled to the at least one memory. The at least one processor is configured to: determine a quantization ratio for a set of layers in a pretrained machine learning model; select a first layer, of the set of layers, based on the quantization ratio; and predict, using an adapter and the pretrained machine learning model, an output value using the selected first layer, wherein the selected first layer uses at least one of a set of quantized weights or a set of quantized activations.

[0007] As another example, a method for incremental quantization is provided. The method includes: determining a quantization ratio for a set of layers in a pretrained machine learning model; selecting a first layer, of the set of layers, based on the quantization ratio; and predicting, using an adapter and the pretrained machine learning model, an output value using the selected first layer, wherein the selected first layer uses at least one of a set of quantized weights or a set of quantized activations.

[0008] In another example, a non-transitory computer-readable medium having stored thereon instructions is provided. The instructions, when executed by one or more processors, cause the at one or more processors to: determine a quantization ratio for a set of layers in a pretrained machine learning model; select a first layer, of the set of layers, based on the quantization ratio; and predict, using an adapter and the pretrained machine learning model, an output value using the selected first layer, wherein the selected first layer uses at least one of a set of quantized weights or a set of quantized activations.

[0009] For another example, apparatus for incremental quantization is provided. The apparatus includes means for determining a quantization ratio for a set of layers in a pretrained machine learning model; means for selecting a first layer, of the set of layers, based on the quantization ratio; and means for predicting, using an adapter and the pretrained machine learning model, an output value using the selected first layer, wherein the selected first layer uses at least one of a set of quantized weights or a set of quantized activations.

[0010] In some aspects, one or more of the apparatuses described herein is, is part of, and / or includes a mobile device (e.g., a mobile telephone or other mobile devices) or other wireless communication device, a vehicle or a computing device or component of a vehicle, an extended reality (XR) device or system (e.g., a virtual reality (VR) device, an augmented reality (AR) device, or a mixed reality (MR) device) , a wearable device, a camera, a personal computer, a laptop computer, a server computer or server device (e.g., an edge or cloud-based server, a personal computer acting as a server device, a mobile device such as a mobile phone acting as a server device, an XR device acting as a server device, a vehicle acting as a server device, a network router, or other device acting as a server device) , another device, or a combination thereof. In some aspects, each apparatus can include a camera or multiple cameras for capturing one or more images. In some aspects, each apparatus can include a display or multiple displays for displaying one or more images, notifications, and / or other displayable data. In some aspects, each apparatus can include one or more sensors (e.g., one or more inertial measurement units (IMUs) , such as one or more gyroscopes, one or more gyrometers, one or more accelerometers, or any combination thereof, and / or other sensor.

[0011] This summary is not intended to identify key or essential features of the claimed subject matter, nor is it intended to be used in isolation to determine the scope of the claimed subject matter. The subject matter should be understood by reference to appropriate portions of the entire specification of this patent, any or all drawings, and each claim.

[0012] The foregoing, together with other features and aspects, will become more apparent upon referring to the following specification, claims, and accompanying drawings.BRIEF DESCRIPTION OF THE DRAWINGS

[0013] Illustrative aspects of the present application are described in detail below with reference to the following drawing figures:

[0014] FIG. 1 illustrates an example implementation of a system, which may include a central processing unit (CPU) , configured to perform one or more of the functions described herein;

[0015] FIG. 2 is a block diagram illustrating a multimodal generative machine learning system for generating natural language responses based on natural language input from a prompt and any additional information, in accordance with aspects of the disclosure;

[0016] FIG. 3 is a block diagram illustrating a generative response engine, in accordance with aspects of the disclosure;

[0017] FIG. 4 is a block diagram illustrating an example of a system including a base model and various adapters, in accordance with aspects of the disclosure;

[0018] FIG. 5 is a block diagram of a process for providing a base model weight activation quantization aware Low Rank Adapter (LoRA) , in accordance with aspects of the disclosure;

[0019] FIG. 6 illustrates a technique for incremental quantization of a machine learning model, in accordance with aspects of the present disclosure;

[0020] FIG. 7 is a block diagram of a process for providing incremental quantization of a machine learning model, in accordance with aspects of the present disclosure;

[0021] FIG. 8A is a timeline illustrating multi-stage incremental quantization adapter training, in accordance with aspects of the present disclosure;

[0022] FIG. 8B is a timeline illustrating single-stage incremental quantization adapter training, in accordance with aspects of the present disclosure;

[0023] FIG. 9A illustrates a randomly determined quantizer enabled / disabled pattern, in accordance with aspects of the present disclosure;

[0024] FIG. 9B illustrates a deterministically determined quantizer enabled / disabled pattern, in accordance with aspects of the present disclosure;

[0025] FIG. 10 is a flow diagram illustrating a process for incremental quantization, in accordance with aspects of the present disclosure;

[0026] FIG. 11 is a block diagram of an example transformer in accordance with some aspects of the disclosure; and

[0027] FIG. 12 shows an example of a computing system, which may be for example any computing device that may implement components of the system.DESCRIPTION

[0028] Certain aspects of this disclosure are provided below. Some of these aspects may be applied independently and some of them may be applied in combination as would be apparent to those of skill in the art. In the following description, for the purposes of explanation, specific details are set forth in order to provide a thorough understanding of aspects of the application. However, it will be apparent that various aspects may be practiced without these specific details. The figures and description are not intended to be restrictive.

[0029] The ensuing description provides example aspects only, and is not intended to limit the scope, applicability, or configuration of the disclosure. Rather, the ensuing description of the example aspects will provide those skilled in the art with an enabling description for implementing an example aspect. It should be understood that various changes may be made in the function and arrangement of elements without departing from the spirit and scope of the application as set forth in the appended claims.

[0030] Machine learning models can be trained to perform various functions and / or provide various types of outputs. For instance, some generative machine learning models can provide a conversational interface that uses natural language prompts as inputs, such as text or voice. In some examples, a user can provide an input prompt in natural language to the generative machine learning model, and the generative machine learning model can provide a response in natural language form. The input prompt and the output response can optionally be combined with one or more other types of information or data, such as images or files.

[0031] Previously trained machine learning models, such as generative machine learning models, can be fine-tuned to improve performance of the machine learning models for specific tasks. Fine-tuning can involve adapting a pre-trained machine learning model (e.g., a pre-trained generative machine learning model or other type of machine learning model) to a specific task by updating parameters (e.g., weights and / or other parameters) of the machine learning model using task-specific training data. The fine-tuning process allows the machine learning model to leverage its pre-existing knowledge while specializing in new tasks. Fine-tuning typically requires less data and computing than fully training a previously untrained machine learning model. Fine-tuning can thus be useful for improving performance of machine learning models on domain-specific tasks without sacrificing the benefits of large-scale pretraining.

[0032] One technique for fine tuning machine learning models is to use an adapter, such as a Low-Rank Adapter (LoRA) . An adapter is a lightweight trainable model that connects to different layers (or blocks) of a machine learning model. Adapters can be used to efficiently adapt large pre-trained models to specific tasks with minimal computational cost and resource usage. Adapters (e.g., a LoRA) can be trained to generalize task-specific information to a frozen (e.g., immutable) pre-trained machine learning model.

[0033] For instance, LoRA introduces lightweight trainable modules parameterized as low-rank matrices into an original (e.g., pre-trained) machine learning model to capture task-specific information while the original machine learning model parameters remain frozen, preserving the pre-trained knowledge of the machine learning model. Training a LoRA can include injecting low-rank layers into certain layers of the base model (e.g., attention layers in a transformer model, feedforward layers in the transformer model, convolutional layers in a transformer and / or convolutional model, etc. ) to optimize the layers during training and reduce the number of overall parameters that need to be updated. Such a technique can be performed to overcome the computational challenges of fine-tuning large machine learning models, such as when working with a smaller dataset.

[0034] While machine learning models (e.g., neural networks) are powerful architectures capable of a wide range of useful tasks, such as recognizing objects in image data, they are likewise highly resource dependent. For example, neural networks may require significant compute, memory, power, and / or time resources for training and / or for inferencing. These resource requirements may significantly limit the ability to train and deploy neural networks to certain types of devices and for certain use cases. For instance, training of machine learning models may be a computationally intensive process that can take a relatively long time, a large quantity of training data, and many operations.

[0035] Quantization is a method of mapping continuous values to a smaller set of discrete finite values. For example, quantization approximates real-world values (e.g., floating point values) with representative values (e.g., integer values) that limit the precision and range of the original input. When applied to machine learning, such as to a neural network, quantization may significantly reduce resource usage for both training and inferencing. For example, performing massive numbers of integer operations during training of or inferencing with a quantized (e.g., reduced-precision) neural network may be significantly more efficient in terms of resource usage as compared to performing floating point operations with an unquantized (e.g., full-precision) neural network processing the same input data.

[0036] Quantization of trained machine learning models allows quantized trained machine learning models to be efficiently deployed on various devices. Quantization may allow a quantized trained machine learning model to perform operations (e.g., at the inference phase of operation) on a device relatively quickly. Quantization may include changing a format of parameters (e.g., weights and activations) of a machine learning model from the format in which the machine learning model was trained to a different format.

[0037] Post-Training Quantization (PTQ) is a process by which a trained machine learning model is quantized. For example, during training, a machine learning model may store parameters (e.g., weights) according to a first format that may allow a high degree of precision. For example, during training, the model may store parameters as floating-point numbers, such as 16-bit floating point numbers, which may be referred to as float16 or FP16, or 32-bit floating point numbers, which may be referred to as float32 or FP32. According to PTQ, after training is performed to generate the trained machine learning model and before the trained machine learning model is deployed onto a device for use by a device, the model may be quantized by, in part, changing the format used to store the parameters of the model from the first format to a second format (e.g., an integer format where the parameters are represented as integer numbers instead of floating point numbers) . The second format may use less memory and / or be less computational expensive to use. For example, after quantization, the model may store parameters as integer numbers such as 16-bit integer numbers (which may be referred to as Int16) , 8-bit integer numbers (which may be referred to as Int8) , 4-bit integer numbers (which may be referred to as Int4) , etc. It may be less computationally expensive to store and / or operate using integer numbers than floating point numbers. Thus, a device may conserve power and / or processing time when using a quantized trained machine learning model as compared with using an unquantized trained machine learning model. Accordingly, it may be advantageous to quantize machine learning models.

[0038] Quantized Aware Training (QAT) is another quantization technique that allows a machine learning model to adapt to quantization during training, resulting in better performance after actual quantization is performed as compared to quantizing a fully trained model (e.g., using PTQ) . For example, using QAT, a machine learning model can be trained while simulating effects of actual quantization of weights and / or activations of the machine learning model during training. QAT can minimize accuracy loss when the machine learning model is eventually quantized to a different format, such as from floating point to an integer format, such as INT8.

[0039] In various aspects of the present disclosure, the term “quantize, ” “quantizing, ” and like terms may be used as a verb and may be applied to machine learning models, and / or layers of a trained machine learning model. In such cases the term “quantize, ” “quantizing, ” and like terms may refer to quantizing parameters (e.g., weights and / or activations) as stored in the of the respective machine learning models and / or layers. For example, a trained machine learning model may include weights (e.g., numerical values) . During training, and after training, the weights may be stored in the trained machine learning model in a first format (e.g., float8, float16, float32, float16) . Quantizing the trained machine learning model may include changing the weights from the first format to a second format (e.g., Int8) .

[0040] Further, machine learning models may include activations. Activations can refer to values used as inputs and / or outputs of various functions, operations, and / or layers (or blocks or modules) of the machine learning model. The activations may have a certain format. For example, a function (of a particular layer) may expect to receive values formatted according to the certain format. For instance, the function may read the values from memory according to the certain format. Further, the function may output other values (e.g., based on processing the values read from memory by the function) according to a particular format (which may or may not be the same as the certain format) . For instance, the function may write the other values to memory in the particular format. For example, an unquantized trained machine learning model may use FP16 to pass values between functions (e.g., outputting values from one function and reading the values by another function) . The activations of the machine learning model can also be quantized. For example, quantizing activations may refer to obtaining floating point (or continuous) values calculated by a layer (e.g., an output of an activation function of the layer) and converting the values into a smaller set of discrete values. For instance, the values may be represented with fewer bits, such as 8-bit integer numbers instead of 32-bit floating point numbers. After quantization of the activations the machine learning model is configured to process and / or output, the quantized trained machine learning model may use Int8 to pass the values between functions. The term “quantize, ” “quantizing, ” and like terms may refer to changing how activations are stored and / or used in a quantized machine learning model.

[0041] As mentioned, adapters such as LoRA can be used to efficiently adapt large pre-trained models to perform specific tasks with minimal computational cost and resource usage. As indicated above, an adapter may be trained in conjunction with a frozen base model to adapt the frozen base model to perform the specific tasks. In some cases where the frozen base model includes quantized weights and / or activations, the quantization loss may dominate over the task loss, making training of the adapter difficult. The quantization loss may be differences as between a prediction of the base model and a ground truth due to quantization and the task loss may be a difference between a prediction of the base model and adapter with respect to the specific task to be performed. In some cases, improved techniques for training adapters may be useful.

[0042] Systems, apparatuses, processes (also referred to as methods) , and computer-readable media (collectively referred to as “systems and techniques” ) are described herein for incremental quantizer enabling for machine learning models with adapters. For instance, an adapter may be trained for a pretrained machine learning model (e.g., machine learning model with frozen weights / activations) . As a part of training the adapter, a quantization ratio for a set of layers of the pretrained machine learning model may be determined. For example, the pretrained machine learning model may include a set of layers. In some cases, a subset layers, of the set of layers, may be quantized while the other layers of the set of layers may not be quantized. A layer that is quantized may be a layer which uses a set of quantized weights and / or quantized activations in place of, for example floating point weights and / or floating point activations. The non-quantized layers may use floating point weights and / or floating point activations. The quantization ratio (e.g., percentage) may be a ratio of quantized layers to non-quantized layers of the pretrained machine learning model.

[0043] The adapter may be trained over a number of stages. In some cases, the quantization ratio may be determined based on a number of stages (e.g., training stages) and a current stage. The quantization ratio increases from a first stage in the number of stages to a next stage in the number of stages. For example, the first stage may have a quantization ratio of 0%where none of the layers are quantized. A next stage may include a larger quantization ratio and some of the layers are quantized. The quantization ratio may increase for each additional stage and the last stage of the number of stages may have a quantization ratio of 100%where all of the layers of the predetermined machine learning model are quantized.

[0044] A first layer, of the set of layers of the pretrained machine learning model, may be selected based on the quantization ratio. For example, in some cases, layers, of the set of layers, may be selected randomly and the quantization ratio may indicate the number of layers that may be selected. As another example, layers, of the set of layers may be selected in a deterministic manner, such as in cascaded pattern where the layers are quantized starting from the first layer of the pretrained machine learning model and adding additional layers in an order in which the layers occur in the pretrained machine learning model in later stages.

[0045] The selected layer may use at least one of a set of quantized weights or a set of quantized activations (e.g., activation energies) . In some cases, another layer (e.g., second layer) that was not selected may use floating point weights and / or floating point activations. An output value of the adapter and pretrained machine learning model may be predicted using the first layer with quantized values and possibly the other layer. The output value may be used to determine a loss for updating a wight and / or activation of the adapter.

[0046] In some cases, the adapter may be trained over a number of training steps (e.g., training rounds, repetitions, passes etc. ) . A training step may include using an adapter and pretrained machine learning model to predict an output value (e.g., a prediction) for input training data, determining a loss (e.g., loss value) based on the output value (e.g., comparing the output value to a ground truth to determine the loss) , and back-propagate and / or forward-propagate the loss through the adapter to update the weights and / or activations of the adapter. In some cases, the quantization ratio may be determined (e.g., increased) based on how many training steps have been performed.

[0047] In some cases, a learning rate may also be adjusted based on the number of stages and the current stage and / or the how many training steps have been performed. The learning rate may be a hyperparameter which may control how much weights of the adapter are adjusted during training. In some cases, the learning rate may decrease as the current stage increases or as the number of training steps that have been performed increases.

[0048] Various aspects of the disclosure are discussed in detail below. While specific implementations are discussed, it should be understood that this is done for illustration purposes only. A person skilled in the relevant art will recognize that other components and configurations may be used without parting from the spirit and scope of the disclosure.

[0049] FIG. 1 illustrates an example implementation of a system 100, which may include a central processing unit (CPU) , configured to perform one or more of the functions described herein. System 100, which may include a central processing unit (CPU 102) (which may be a multi-core CPU) . Parameters or variables (e.g., neural signals and synaptic weights) , system parameters associated with a computational device (e.g., neural network with weights) , task information, among other information may be stored in a memory block associated with a neural processing unit (NPU 108) , in a memory block associated with a CPU 102, in a memory block associated with a graphics processing unit (GPU 104) , in a memory block associated with a digital signal processor (DSP 106) , in a memory 116, and / or may be distributed across multiple blocks. Instructions executed at the CPU 102 may be loaded from a program memory associated with the CPU 102 or may be loaded from memory 116.

[0050] The system 100 may also include additional processing blocks tailored to specific functions, such as the GPU 104, the DSP 106, a connectivity engine 118, which may include fifth generation (5G) connectivity, fourth generation long term evolution (4G LTE) connectivity, Wi-Fi connectivity, USB connectivity, Bluetooth connectivity, and the like, and a multimedia processor 112 that may, for example, detect and recognize gestures. In one implementation, the NPU is implemented in the CPU 102, the DSP 106, and / or the GPU 104. The system 100 may also include one or more sensor processor (s) 114, one or more image signal processors (ISP (s) 110) , and / or navigation engine 120, which may include a global positioning system. In some examples, the sensor processor (s) 114 can be associated with or connected to one or more sensors for providing sensor input (s) to the sensor processor (s) 114. For example, the one or more sensors and sensor processor (s) 114 can be provided in, coupled to, or otherwise associated with a same computing device.

[0051] The system 100 may be implemented as a system on a chip (SoC) . The system 100 may be based on an Advanced Reduced Instruction Set Computer (RISC) Machine (ARM) instruction set. The system 100 and / or components thereof may be configured to perform machine learning techniques according to aspects of the present disclosure discussed herein. For example, the system 100 and / or components thereof may be configured to implement a machine learning model (e.g., a quantized trained machine learning model) as described herein and / or according to aspects of the present disclosure.

[0052] Machine learning (ML) can be considered a subset of artificial intelligence (AI) . ML systems can include algorithms and statistical models that computer systems can use to perform various tasks by relying on patterns and inference, without the use of explicit instructions. In some examples, an ML system can be a neural network (also referred to as an artificial neural network) , which may include an interconnected group of artificial neurons (e.g., neuron models) . Neural networks may be used for various applications and / or devices, such as image and / or video coding, image analysis and / or computer vision applications, Internet Protocol (IP) cameras, Internet of Things (IoT) devices, autonomous vehicles, service robots, among others.

[0053] Individual nodes in a neural network may emulate biological neurons by taking input data and performing simple operations on the data. The results of the simple operations performed on the input data are selectively passed on to other neurons. Weight values are associated with each vector and node in the network, and these values constrain how input data is related to output data. For example, the input data of each node may be multiplied by a corresponding weight value, and the products may be summed. The sum of the products may be adjusted by an optional bias, and an activation function may be applied to the result, yielding the node’s output signal or “output activation” (sometimes referred to as a feature map or an activation map) . The weight values may initially be determined by an iterative flow of training data through the network (e.g., weight values are established during a training phase in which the network learns how to identify particular classes by their typical input data characteristics) .

[0054] Different types of neural networks exist, such as convolutional neural networks (CNNs) , recurrent neural networks (RNNs) , generative adversarial networks (GANs) , multilayer perceptron (MLP) neural networks, transformer neural networks, diffusion-based neural networks, among others. For instance, convolutional neural networks (CNNs) are a type of feed-forward artificial neural network. Convolutional neural networks may include collections of artificial neurons that each have a receptive field (e.g., a spatially localized region of an input space) and that collectively tile an input space. RNNs work on the principle of saving the output of a layer and feeding this output back to the input to help in predicting an outcome of the layer. A GAN is a form of generative neural network that can learn patterns in input data so that the neural network model can generate new synthetic outputs that reasonably could have been from the original dataset. A GAN can include two neural networks that operate together, including a generative neural network that generates a synthesized output and a discriminative neural network that evaluates the output for authenticity. In MLP neural networks, data may be fed into an input layer, and one or more hidden layers provide levels of abstraction to the data. Predictions may then be made on an output layer based on the abstracted data.

[0055] Deep learning (DL) is an example of a machine learning technique and can be considered a subset of ML. Many DL approaches are based on a neural network, such as an RNN or a CNN, and utilize multiple layers. The use of multiple layers in deep neural networks can permit progressively higher-level features to be extracted from a given input of raw data. For example, the output of a first layer of artificial neurons becomes an input to a second layer of artificial neurons, the output of a second layer of artificial neurons becomes an input to a third layer of artificial neurons, and so on. Layers that are located between the input and output of the overall deep neural network are often referred to as hidden layers. The hidden layers learn (e.g., are trained) to transform an intermediate input from a preceding layer into a slightly more abstract and composite representation that can be provided to a subsequent layer, until a final or desired representation is obtained as the final output of the deep neural network.

[0056] As noted above, a neural network is an example of a machine learning system, and can include an input layer, one or more hidden layers, and an output layer. Data is provided from input nodes of the input layer, processing is performed by hidden nodes of the one or more hidden layers, and an output is produced through output nodes of the output layer. Deep learning networks typically include multiple hidden layers. Each layer of the neural network can include feature maps or activation maps that can include artificial neurons (or nodes) . A feature map can include a filter, a kernel, or the like. The nodes can include one or more weights used to indicate an importance of the nodes of one or more of the layers. In some cases, a deep learning network can have a series of many hidden layers, with early layers being used to determine simple and low-level characteristics of an input, and later layers building up a hierarchy of more complex and abstract characteristics.

[0057] A deep learning architecture may learn a hierarchy of features. If presented with visual data, for example, the first layer may learn to recognize relatively simple features, such as edges, in the input stream. In another example, if presented with auditory data, the first layer may learn to recognize spectral power in specific frequencies. The second layer, taking the output of the first layer as input, may learn to recognize combinations of features, such as simple shapes for visual data or combinations of sounds for auditory data. For instance, higher layers may learn to represent complex shapes in visual data or words in auditory data. Still higher layers may learn to recognize common visual objects or spoken phrases.

[0058] Deep learning architectures may perform especially well when applied to problems that have a natural hierarchical structure. For example, the classification of motorized vehicles may benefit from first learning to recognize wheels, windshields, and other features. These features may be combined at higher layers in different ways to recognize cars, trucks, and airplanes.

[0059] Neural networks may be designed with a variety of connectivity patterns. In feed-forward networks, information is passed from lower to higher layers, with each neuron in a given layer communicating to neurons in higher layers. A hierarchical representation may be built up in successive layers of a feed-forward network, as described above. Neural networks may also have recurrent or feedback (also called top-down) connections. In a recurrent connection, the output from a neuron in a given layer may be communicated to another neuron in the same layer. A recurrent architecture may be helpful in recognizing patterns that span more than one of the input data chunks that are delivered to the neural network in a sequence. A connection from a neuron in a given layer to a neuron in a lower layer is called a feedback (or top-down) connection. A network with many feedback connections may be helpful when the recognition of a high-level concept may aid in discriminating the particular low-level features of an input.

[0060] FIG. 2 is a block diagram illustrating a multimodal generative ML system 200 for generating natural language responses based on natural language input from a prompt 202, in accordance with aspects of the disclosure. A multimodal machine learning system is a machine learning model that receives, processes, and outputs data in multiple forms. For example, the input prompt may include text, images, and audio.

[0061] For example, the multimodal generative ML system 200 includes a plurality of encoders 204 that are each configured to encode different modes of content (e.g., text, images, audio, etc. ) into different tokens within a common embedding space. For example, a text input may be segmented based on different techniques (e.g., paragraph, sentence, etc. ) and encoded by a text encoder (from the encoders 204) into tokens. In another example, one or more images can be provided to an image encoder (from the encoders 204) that extracts features associated with the image and generates tokens representing the visual features. In another example, audio can be provided to an audio encoder (from the encoders 204) that extracts features associated with the image and generates tokens representing the audio features. In the case of audio, the audio encoder can identify features that can include formants that characterize resonant frequencies in speech, rhythmic features related to timing and tempo, and harmonic features that describe the relationship between fundamental frequencies and their harmonics.

[0062] The different tokens from the plurality of encoders are provided to combiner 206. The combiner 206 can combine the tokens based on the order in which they are presented. For example, the input into the encoder may be an array of primitive values. A primitive value is an immutable data type provided by a programming language and includes values that represent a single piece of data (e.g., number, string, Boolean, etc. ) rather than a complex object or reference. A non-limiting example prompt may include a byte array (e.g., an unsigned 8-byte integer array or uint8array) , and another string. The byte array may be audio, images, or other content that can be processed by the encoders 204. In some aspects, the combiner 206 is configured to concatenate the different tokens in order based on the array to preserve the semantic order of features and provide the tokens to the generative machine learning model 208.

[0063] The generative machine learning model 208 is configured to receive the tokens and generate a natural language response 212 based on the tokens and the prompt 202. Generative machine learning model 208 may include one or more models 210 (e.g., transformer neural network (s) , diffusion model (s) , fully connected layer (s) , multilayer perceptrons (MLPs) , any combination thereof, and / or other models) . The one or more models 210 of the generative machine learning model 208 are configured to process the tokens and extract different types of features that are relevant to the prompt 202. For example, the prompt 202 can be a query for a particular type of information. The one or more models of the generative machine learning model 208 can perform different tasks related to the query, such as writing code to perform a particular function, generating an image based on an input image with expressed modifications, generate an image without any input image, and so forth.

[0064] The generative machine learning model 208 may include different components, such as a featurization engine to identify different types of features, an inference engine to identify inferences within the text (e.g., pronoun usage and corresponding disambiguation functions) , data retrieval engines (e.g., to identify features related to a particular concept observed by the generative machine learning model 208) , and so forth. The generative machine learning model 208 may also include different types of models and engines to synthesize a coherent contextual output, such as to synthesize the input content and information that is responsive to tasks embedded within the text. For example, the generative machine learning model 208 may include a predictive output engine (not shown) that is configured to generate a sequence of words that is most likely contextually correct and to provide a coherent and contextually relevant answer. For instance, the predictive output generation engine can generate responses by sampling from the probability distribution of possible words and sequences based on patterns observed during training. The generative machine learning model 208 may also include a predictive output generation engine to generate multiple responses that are potentially relevant and coherent with respect to the prompt 202. The generative machine learning model 208 may also include an output validation engine configured to evaluate the generated responses based on certain criteria. Non-limiting examples of criteria to evaluate generated responses include relevance to the prompt, coherence, fluency, and adherence to specific guidelines or rules. Based on the evaluation, the output validation engine may select and output the most appropriate response.

[0065] As noted above, the generative machine learning model 208 may include various types of models (e.g., machine learning models) , such as a transformer. A transformer is a neural network architecture that can be trained to perform one or more natural language processing (NLP) tasks, such as language translation, sentiment analysis, and text summarization. Conventional traditional recurrent neural networks (RNNs) process data in sequence. A transformer or transformer network can process input in parallel and can thus be faster and more efficient than sequential training and processing. In some aspects, a transformer can use a self-attention mechanism (e.g., one or more self-attention layers) , which allows the transformer to identify the most relevant parts of the input text or content (e.g., audio or video) . In some cases, a transformer can also use a cross-attention mechanism (e.g., one or more cross-attention layers) which uses other content or data to determine the most relevant parts of the input. For example, cross-attention mechanisms are useful in sequential content such as a stream of data, such as optical flow, and other computer vision techniques.

[0066] A transformer neural network can include a multi-layer encoder-decoder architecture. For instance, an encoder of the encoder-decoder architecture can receive text as input, convert the input text into a sequence of hidden representations, and capture the meaning of the text at different levels of abstraction. A decoder of the encoder-decoder architecture can then process the representations output from the decoder to generate an output sequence, such as a text translation or a summary. The encoder and decoder can be trained together using supervised learning, unsupervised learning, or a combination of supervised and unsupervised learning techniques, such as maximum likelihood estimation and self-supervised pretraining. Illustrative examples of transformer engines include a BERT model, a Text-to-Text Transfer Transformer (T5) , biomedical BERT (BioBERT) , scientific BERT (SciBERT) , and the SPECTER model for document-level representation learning. In some aspects, multiple transformer engines may be used to generate different tokens.

[0067] In some aspects, the generative machine learning model 208 may be executed using a neural engine (or multiple neural engines) for on-device execution, such as a neural processing unit (NPU) , a neural signal processor (NSP) , a digital signal processor (DSP) , any combination thereof, and / or other neural engine. The neural engine can include a plurality of neural processing cores that are configured to parallelize operations associated with neural networks. A neural processing core can include arrays of multiply-accumulate (MAC) units and specialized instructions that are optimized for matrix operations, such as convolution and matrix multiplication. The neural processing core can receive input data and perform matrix transformations and nonlinear activation functions to break down and parallelize matrix operations. The neural processing core can perform tasks such as inference (e.g., runtime operation of a machine learning model) or training of deep learning models. The neural processing core can accelerate tasks by parallelization of larger computations that can be performed in parallel (e.g., matrix operations associated with neural networks) . For instance, the neural engine may perform computer vision tasks such as object recognition. In some cases, the neural engine can be implemented based on various ML libraries such as PyTorch, which interfaces with the compute unified device architecture (CUDA) to parallelize operations.

[0068] In some aspects, the generative machine learning model 208 may be a small generative model that has fewer parameters, fewer layers, fewer neurons, or a simpler architecture compared to larger models. A small generative model may not capture the full complexity of the underlying data distribution as effectively as larger models but can still be useful in scenarios where computational resources are limited or where a simpler model is sufficient for the task. Small generative models can also be easier to train and interpret, making them suitable for certain applications. For example, ChatGPT-3.5 has 175 billion parameters that results in a size of 1.4 Terabytes (TB) for a model implemented with double-precision floating point numbers. A smaller model may have a simpler architecture, use fewer parameters (e.g., 10 million) , and use less precise numbers (e.g., single-precision floating point numbers) resulting in a size of 38 Megabytes (MB) .

[0069] In addition, small models benefit from increased training based on local execution and data specific to a local device and a user of that local device. An additional benefit to small models is increased privacy because the information is not transmitted over the network and only relies on information requested by the user or usage at the local device.

[0070] FIG. 3 is a conceptual block diagram of a generative response engine 300 that is configured for multimodal input and output in accordance with some aspects of the disclosure. In some aspects, the generative response engine 300 is configured to receive a prompt 302 (e.g., from a user, an application programming interface (API) request, etc. ) and perform various processing to generate a response 304 that is responsive to the prompt 302 that is contextually accurate. In some aspects, the prompt 302 may be an array of primitive values, such as text, binary data (byte arrays, etc. For example, the prompt may be a union type that combines different types of primitive data (e.g., string uint8array in JavaScript) .

[0071] The generative response engine 300 includes a generative machine learning model 318. In some aspects, the generative response engine 300 includes a plurality of adapters (e.g., LoRA) that are trained to improve performance of a base machine learning model (also referred to as a base model) of the generative response engine 300 during inference. The plurality of adapters can be trained to perform different tasks. For example, a first adapter may be trained to perform a first task, and a second adapter a second task and so forth. In this manner, the independently trained adapters are configured to prevent the generative response engine 300 from defaulting to the application of the base model’s weights (which can be referred to as base weights) and allow the combination of the base model and the adapters to accurately provide specialized responses that correspond to the fine tuning.

[0072] The generative response engine 300 includes various components, such as a segmenter 310, a classifier 312, a plurality of encoders 314, a combiner 316, and the generative machine learning model 318. The segmenter 310 is configured to segment different content into different portions based on various limitations, such as text size, image size, and so forth. In some cases, the segmenter 310 may also reduce the scope of content (e.g., by reducing a size of an input image) based on limitations of one or more machine learning models of the generative response engine 300. For example, the machine learning model (s) may be trained on a particular size input to extract important features. The segmenter 310 may also segment text into different chunks, such as into individual sentences or paragraphs.

[0073] In some aspects, the classifier 312 may be configured to classify the input. For example, the classifier 312 may be configured to generate embeddings that represent features associated with the input (e.g., segmented text, images, etc. ) in a vector space. An embedding is a representation of a discrete object, such as a word, a document, or an image, as a continuous vector in a multi-dimensional space. An embedding captures the semantic or structural relationships between the objects, such that similar objects are mapped to nearby vectors, and dissimilar objects are mapped to distant vectors. Embeddings are commonly used in machine learning, computer vision, and natural language processing tasks, such as language modeling, sentiment analysis, and machine translation. Embeddings can be learned from large corpora of data using unsupervised learning algorithms, such as word2vec, GloVe, or fastText, which optimize the embeddings based on the co-occurrence or context of the objects in the data. Once learned, embeddings can be used to improve the performance of downstream tasks by providing a more meaningful and compact representation of the objects. In some aspects, the classifications are provided to the generative machine learning model 318 to activate specific learned domains.

[0074] In some cases, the classifier 312 may be configured to classify the input based on a plurality of clusters. The plurality of clusters may represent different semantic spaces for the operation of the generative response engine 300. The plurality of clusters may be related to different specialized tasks, data, or other operations and represent different domains of the generative response engine 300. For example, a generative model trained for customer service may need to learn different domains of knowledge, such as identification of products or services, accounting and billing information, a corpus of documents to help diagnose problems or provide information, and so forth. The plurality of clusters can be determined based on the input and output from the generative response engine 300.

[0075] In some cases, the classifier 312 may generate a probability for the prompt 302 (e.g., for each cluster) based on the output from the segmenter 310. The probability represents a likelihood that the prompt 302 is associated with features (e.g., features in a corresponding cluster) . In some aspects, the classifier 312 provides the probabilities associated with each cluster and the embeddings to the generative machine learning model 318.

[0076] The segmented portions of the prompt 302 can then be provided as input to a plurality of encoders 314 (e.g., the encoders 204 in FIG. 2) to extract various features and generate tokens associated with those features. In some aspects, each encoder 314 is configured for a different modality or different type of input. For example, the generative response engine 300 may include an encoder 314 for encoding text, an encoder 314 for encoding images, an encoder 314 for encoding audio, etc. There may be additional encoders based on the different modalities. For example, there may be an encoder 314 for handling different types of documents (e.g., PDF, etc. ) .

[0077] The combiner 316 (e.g., the combiner 206 in FIG. 2) receives the tokens from the encoders 314 and synthesizes tokens that represent the prompt 302. For example, the combiner 316 can be configured to concatenate the tokens from the encoders 314 in the correct order to preserve the semantic context of the content. In some cases, the encoders 314 may be configured to execute the encoding operations in parallel and because different content may be encoded at different rates, the tokens may be received out of order. The combiner 316 may receive information (e.g., from the segmenter 310 and / or from the encoders 314) to identify how to sequence the embeddings into an input suitable for the generative machine learning model 318 (e.g., an array of tokens) .

[0078] In some aspects, the generative machine learning model 318 is configured to use the embeddings during inference to begin inference operation based on the prompt 302. In some aspects, the probabilities from the classifier 312 can be used by the generative machine learning model 318 to activate at least one adapter based on the probability associated with that adapter. In some aspects, because the adapters are tuned independently based on clustered data, the adapters provide a stronger response based on the identification of features that more accurately represent that different classification.

[0079] The generative machine learning model 318 may be configured to synthesize the response 304 based on the probabilities provided by the classifier 312 and the generative machine learning model 318.

[0080] In some cases, a pre-trained machine learning model may be adapted to perform tasks that the original machine learning model may not have been capable of. For example, a machine learning model that has been pre-trained on general data may support adapters, such as a low rank adaptation (LoRA) . To support adapters, a pre-trained, frozen, model (e.g., machine learning model with frozen weights) may include trainable matrices in layers of the machine learning model that allow the machine learning model to be adapted to different tasks. As an example, a machine learning model trained to generate images of objects generally may be adapted with one or more LoRAs to generate images in different styles, different backgrounds, etc.

[0081] FIG. 4 is a block diagram illustrating an example of a system 400 including a base model 410 and various adapters 420a-420n, in accordance with aspects of the disclosure. In some aspects, the adapters 420a-420n can include Low-Rank Adapters (LoRAs) or other types of adapters.

[0082] The base model 410 and / or the adapters 420a-n may be adjusted or calibrated (e.g., quantized) to generate one or more activation encodings, which represent how parameters of the model (e.g., tensors) are quantized. For instance, an activation encoding refers to the quantization level for a particular activation (e.g., the quantization step size or grid used for the activation) . As described herein, quantization refers to a reduction in precision of values or numbers representing parameters (e.g., weights) or activations. For example, the values or numbers can be quantized by converting the values or numbers from floating point values to integer values, or first floating-point values with a first precision to second floating point values with a second precision.

[0083] Activation encodings may be categorized as base activation encodings (applicable to layers of the base model 410) or adapter activation encodings (applicable to one or more of the adapters 420a-n) . Examples of base activation encodings include 417, 415, and 412. Examples of adapter activation encodings include 431a-431n, 429a-429n, 427a-427n, 414, 425a-425n, 423a-423n, 421a-421n, and 411.

[0084] In some aspects, one or more of the adapters 420a-n can include a LoRA. A LoRA can include trainable rank decomposition matrices. Use of LoRAs to fine-tune the base model 410 can involve freezing the base model weights (also referred to as base weights) and combining outputs of the trainable rank decomposition matrices with outputs of one or more layers of the base model 410 to then tune parameters of the LoRA. When the base model weights are frozen, the base model weights are not changed. Freezing the base model weights allows training of the adapters without influencing and / or adjusting the weights of the base model. A LoRA can include two matrices, referred to as matrix A and matrix B. As shown, each adapter 420a-n includes matrix A (with dimensions d x r) , a scalar value denoted as alpha (α) , and matrix B (with dimensions r x m) . Rank (r) is proportional to a number of trainable parameters in the adapter. Therefore, a higher rank implies a greater number of trainable parameters in the adapter model, whereas lower rank implies fewer trainable parameters. In general, the low rank matrices A and B include a rank (r) having a size that is much smaller than the size of d and m (r<<d, m) . Alpha (α) is a scaling factor that can control how much influence the adapter will have on a combined output resulting from combining an output of a layer of the base model 410 (e.g., the linear layer 416 and / or the linear layer 413) with an output of the adapter. For instance, a higher alpha (α) value can result in the adapter having more influence on the combined output, while a lower alpha (α) value can result in the adapter having less influence on the combined output. Adjustment of “alpha” can balance fitting the data against overfitting. The dimension of the original weight is represented by d.

[0085] The base model 410 in FIG. 4 is shown to include two linear layers 413 and 416 for illustration purposes. In practice, the base model 410 can include many layers in addition to those shown in FIG. 4. Each adapter 420a-n includes a capability of scaling and / or adjusting parameters or weights based on training, such as parameters of the matrices A, B and alpha (α) . Various inputs and outputs of the linear layers 413 and 416 are shared between the base model 410 and adapters 420a-n. Similarly, outputs from each of the adapters 420a-n are shared with the base model 410 and ultimately combined into inputs to various linear layers.

[0086] In the example depicted in FIG. 4, base activation encoding 417 is provided as input to linear layer 416, and to adapter 420a. Linear layer 416 processes base activation encoding 417, outputting base activation encoding 415. The adapter multiplies the base activation encoding 417 with matrix A 432a, resulting in the adapter outputting adapter activation encoding 431a. Adapter activation encoding 431a is scaled by scaling block 430a, which generates adapter activation encoding 429a. The adapter then multiplies the adapter activation encoding 429a by matrix B 428a to generate and output adapter activation encoding 427a. Adapter activation encoding 429a is passed back to base model 410, where adapter activation encoding 429a is combined with (e.g., added to, concatenated with, etc. ) the base activation encoding 415, resulting in adapter activation encoding 414.

[0087] Similarly, adapter activation encoding 414 is passed both as an input to linear layer 413 and to adapter 420a. Linear layer 413 processes the input, outputting base activation encoding 412. Separately, matrix A 426a is multiplied with adapter activation encoding 414, resulting in adapter activation encoding 425a. Adapter activation encoding 425a is scaled by scaling 424a, which results in adapter activation encoding 423a. Adapter activation encoding 423a is multiplied with matrix B 422a, creating adapter activation encoding 421a. Adapter activation encoding 421a is passed back to base model 410, where adapter activation encoding 421a is added to base encoding 412, resulting in adapter activation encoding 411. Different activation encodings may be generated using the techniques described herein.

[0088] In some cases, adapters may be attached to a frozen base model (e.g., base part) and individually trained to generate different contents, styles, backgrounds, etc. to extend functionality of the frozen base model. In some cases, an adapter may be used alone, or used along with other adapters to generate a composite output. In frozen base encoding, the frozen base model can be common to multiple adapters. The base model may be initialized and loaded once initially and the base model may switch among the different adapters without having to reload the base model. In cases where the base model is quantized, the quantized values of the base model is also common to the multiple adapters. In some cases, it can be challenging to determine a suitable quantized frozen base model for all of the adapters.

[0089] In some cases, a floating point base model may be quantized (e.g., quantized weights and activation energies) . An adapter may be trained using the quantized base model and then the trained adapter may be quantized.

[0090] FIG. 5 is a block diagram of a process 500 for providing a base model weight activation quantization aware LoRA, in accordance with aspects of the disclosure. The process 500 includes performing weight quantization 520, activation quantization 530, LoRA training / tuning 540, and a post-training quantization (PTQ) 550.

[0091] A machine learning model 510 (abase model) includes parameters, including weights and in some cases other parameters (e.g., biases, etc. ) . The machine learning model can be similar to or the same as the base model 410 of FIG. 4. The weights (and in some cases the other parameters) of the machine learning model 510 may be represented as floating point numbers or values (e.g., as 16-bit floating point numbers, float16 or FP16, 32-bit floating point numbers, float32 or FP32, or other floating-point representation) . Weight quantization 520 can be performed on the weights (and in some cases the other parameters) to convert the floating-point representations to integer numbers or values (e.g., converted to Int4, Int8, Int16, etc. ) . For example, the weight quantization 520 can quantize the parameters (including weights) of the machine learning model 510 in order to generate (e.g., determine, calculate, etc. ) quantized base model weights 525 for the machine learning model 510. Examples of quantized base model weights 525 are those associated with layer 413 and / or layer 416 of the base model 410 of FIG. 4.

[0092] The machine learning model 510 can process data using the quantized base model weights 525 to generate activation data at each layer of the machine learning model 510. Activation quantization 530 can be used to quantize the activation data output from each layer to generate one or more base activation encodings 535. Examples of base model activation encodings 535 include base activation encodings 412, 414, and 417 of FIG. 4.

[0093] After the base model activation encodings 535 are generated, the base model parameters and activations are frozen (are no longer updated or adjusted) . The LoRA can then be trained / fine-tuned conditioned on the quantized base model weights and activation encodings. For instance, as shown in FIG. 5, the quantized base model weights 525 and the quantized base model activation encodings 535 are used for LoRA training / tuning 540 to generate adapter weights 545 (e.g., weights for the matrices A and B, the scalar value alpha (α) , and / or other parameters of the LoRA) . For example, the base model 510 (with the frozen quantized base model weights 525 and the frozen quantized base model activation encodings 535) and the LoRA together can process a set of training data to generate output data. The training data can be used to fine-tune the LoRA for a specific task, such as image segmentation, answering questions specific to a particular document or subject, for generating images of a particular dog, etc. The output data can be compared to ground truth data to determine a loss. Based on the loss, backpropagation can be performed to update or fine-tune the weights of the LoRA. Such a process can be performed a number of times (e.g., until the loss is minimized) , resulting in the adapter weights 545.

[0094] PTQ 550 can then be performed on the adapter weights 545 and on activations resulting from processing data using the adapter weights 545. Examples of adapter activations include, but are not limited to, adapter activations 431a-n, 429a-n, 427a-n, etc. of FIG. 4. For instance, the adapter weights 545 and the activations are represented as floating point numbers or values (e.g., as float16, float32, etc. ) . The PTQ 550 can change the format of the adapter weights 545 and activations by converting the floating-point representations to integer numbers or values (e.g., to Int4, Int8, Int16, etc. ) . The PTQ 550 can output quantized adapter weights and quantized activation encodings 555. Once the process 500 is completed, all parameters and activations of the base machine learning model 510 and all parameters and activations of the LoRA are quantized (shown as quantized weights / activation encodings 560) , in which case a system or device deploying the machine learning model 510 and LoRA (for inference) can store the parameters and activations as integer numbers (e.g., 4-bit integer numbers in Int4 format, 8-bit integer numbers in Int8 format, 16-bit integer numbers in Int16 format, etc. ) . The machine learning model 510 and LoRA may be deployed in a resource-constrained device (e.g., an edge device) . The operations discussed with respect to process 500 may be repeated as necessary for different adapters (e.g., LoRAs) that are used with machine learning model 510 (e.g., adapters for different downstream inference tasks or functionality) .

[0095] In process 500, as the base model is frozen after parameters and activations are quantized, the quantization loss can dominate, making LoRA training / tuning 540 to generate adapter weights 545 challenging. In some cases, it may be useful to modify process 500 to enable incremental quantization (e.g., multi-stage quantization) .

[0096] FIG. 6 illustrates a technique for incremental quantization of a machine learning model 600, in accordance with aspects of the present disclosure. FIG 6 plots, on the Y-axis 620, a learning rate, and a number of training steps 630 (e.g., training rounds, repetitions, passes etc. ) on the X-axis. As shown in FIG. 6, training of an adapter may be divided into a number of stages K+1. As discussed above, the weights and / or activations of a frozen base model may be quantized on a per layer basis. In each stage, a certain ratio of the weights and / or activations of the base model may be quantized and an adapter may be trained a certain number of times at a specific learning rate. For example, in a stage 0 602, none of the weights and / or activations may be quantized for the base model and the adapter may be trained on essentially a full floating point base model. At stage 1 604, 10%of the layers may have their weights and / or activations quantized as a partially quantized base model with 10%quantization and the other 90%of the layers may use their original floating point weights and / or activations. The adapter may continue to be trained based on the partially quantized base model with 10%quantization. The percentage of quantized layers (e.g., quantization ratio) of the partially quantized based model may be increased for each stage until at stage K 606 where all of the layers of the base model are quantized (e.g., 100%of the layer weights and / or activations are quantized) .

[0097] Of note, in some cases, the weights and / or activations of the base layer may be quantized together (e.g., as a part of weight quantization 720 and activation quantization 730 of FIG. 7) and quantized versions of the weights and / or activations used (e.g., enabled) for a set of layers in the partially quantized base model. The original floating point weights and / or activations (e.g., of base model) may be used in the layers that are not quantized. In some cases, there may be multiple ways to determine which layers may be quantized (e.g., use quantized values) for each stage.

[0098] In some cases, the learning rate may also be decreased (e.g., reduced) based on the stage the training is in. The learning rate may be a hyperparameter which may control how much weights of the adapter are adjusted during training. Generally, a higher learning rate can result in a faster convergence to an optimal solution as compared to a lower learning rate, but the higher training rate may have a higher likelihood of overshooting. For example, the learning rate may start at a highest rate at stage 0 602 at 1e-3 and the learning rate may be reduced stage by stage to 1e-5 at stage K 606. In some cases, the learning rate may be set based on a stage index. The stage index may track a current stage of adapter training (e.g., 0, …K) . In some cases, as more quantizers are active, a quantization loss (e.g., differences as between a prediction of the base model and a ground truth due to quantization) may increase with respect to task loss and the reduced learning rate may help the adapter avoid learning based on the quantization loss.

[0099] FIG. 7 is a block diagram of a process 700 for providing incremental quantization of a machine learning model, in accordance with aspects of the present disclosure. The process 700 is similar to process 500 of FIG. 5 and process 700 includes performing weight quantization 720, activation quantization 730, LoRA training / tuning 740, quantization adjustment 770 and a post-training quantization (PTQ) 750.

[0100] In FIG. 7, the machine learning model 710 may be substantially similar to machine learning model 510 of FIG. 5 and the machine learning model 710 may have a frozen set of weights represented as floating point numbers (e.g., floating point weights) . Weight quantization 720 can be performed on the weights (and in some cases the other parameters) to convert floating-point weights to integer numbers or values as quantized weights. Of note, the quantized weights may be stored along with the original floating-point representations to allow the machine learning model 710 to be switched between the quantized weights and floating-point weights.

[0101] The machine learning model 710 can process data using the quantized base model weights 725 to generate activation data at each layer of the machine learning model 710. Activation quantization 730 can be used to quantize the activation data output from each layer to generate one or more base activation encodings 735. This quantized activation data may be saved along with the original non-quantized (e.g., floating point) activation data.

[0102] The LoRA can then be trained / fine-tuned 740 using a ratio of quantized weights and activation data to floating point weights and activation data (e.g., quantization ratio) . For example, during an initial training stage (e.g., stage 0 602 of FIG. 6) none of the quantized weights and activation data may be used (e.g., 0%quantized weights / activation data) and the LoRA may be trained / fine-tuned 740 based on the floating point weights and activation data. After a number of steps of training, a quantization adjustment 770 may be performed. A training step may include using an adapter to make a prediction based on input training data, determine a loss value for the predication, and back-propagate and / or forward-propagate the loss through the adapter to adjust the weights / activations of the adapter.

[0103] The quantization adjustment 770 may adjust which quantizers are enabled (e.g., which layers of the machine learning model 710 are using quantized weights / activation data) for the machine learning model 710. For example, in a second stage of the training (e.g., stage 1 604 of FIG. 6) , quantized weights and activation data may be used for 10%of the layers of the machine learning model 710 as a partially quantized base model. The remaining 90%of the layers of the machine learning model 710 (e.g., partially quantized base model) may continue to use the floating point weights and activation data. The LoRA may be trained / fine-tuned 740 on the partially quantized base model in a manner substantially similar to described above. Of note, as used herein, quantizer may refer to whether a layer uses quantized weights and / or activations such that when a quantizer is enabled (or a layer is quantized) , the layer uses quantized weights and / or activations and when the quantizer is disabled (or when a layer is not quantized) , the layer uses floating point weights and / or activations. The actual quantization of the weight and / or activation values may be performed once and stored for use when the quantizer is enabled or the actual quantization of the weights and / or activation values may be performed on an as used basis.

[0104] After a number of steps of training, another quantization adjustment 770 may be performed to increase the percentage of the layers that used quantized weights / activation data until all of the layers of the machine learning model 710 are used quantized weights / activation data. This loop of where the LoRA may be trained / fine-tuned 740 and then quantization adjustment 770 performed may be repeated with an increasing percentage of the layers using quantized weights / activation data until all of the weights / activation data are quantized. PTQ 750 can then be performed on the adapter weights 745 and activations in a manner substantially similar to that described above with respect to PTQ 550 of FIG. 5 to generate quantized adapter weights and quantized activation encodings 755 for output along with quantized parameters and activations of the based model (shown collectively as quantized weights / activation encodings 760) .

[0105] In some cases, incremental quantization may be performed using different training patterns. The training pattern may refer to how the overall training of the adapter may be set up. For example, the training pattern may be a multi-stage training or a single stage training.

[0106] FIG. 8A is a timeline illustrating multi-stage incremental quantization adapter training 800, in accordance with aspects of the present disclosure. In FIG. 8A, the adapter 802 may be trained in K+1 stages where each stage includes a separate input and output. Each stage may include a fixed quantizer enabled / disabled pattern. In some cases, the K+1 stages in FIG. 8A may correspond to the K+1 stages discussed above with respect to FIG. 6. For example, in a 0th stage 804, the adapter 802 may be loaded along with a training configuration 806 for 0th stage 804. The adapter 802 may be initiated with random and / or invalid weights / activations (e.g., all 0s) . The training configuration 806 may include hyperparameters for training the adapter 802 for the stage, such as a number of training steps 808 (steps0) , the learning rate 810 (L0) for the 0th stage 804, and a quantization ratio 812 (α0) . The number of training steps 808 may correspond to the number of training steps 630 of FIG. 6. The quantization ratio (e.g., ratio of enabled quantizers to disabled quantizers) may be reflected in a fixed quantizer enabled / disabled pattern indicating which layers of the base model should use quantized values (e.g., weights / activations) or floating point values. After the training configuration is loaded, the adapter may be trained for the number of training steps 808 based on the learning rate 810 and the enabled and disabled quantizers of the base model. After being trained a checkpoint 814 of the partially trained adapter 802 is saved. The checkpoint 814 may be a copy (e.g., version, image, etc. ) of the adapter at a particular point in time, such as after a stage in training.

[0107] In a next training stage, such as the 1st stage 816, a previous checkpoint (e.g., checkpoint 814) from a previous stage may be loaded 818 and trained using a training configuration 820 for that stage. In some cases, the previous checkpoint may be loaded to initialize the adapter weights. The training configuration 820 for each stage may have a different learning rate, quantization ratio (e.g., quantizer enabled / disabled pattern) , and / or number of training steps. In some cases, the quantization ratio may be increased from the 0th stage to the Kth stage. Similarly, the learning rate may be decreased from the 0th stage to the Kth stage. After training another checkpoint 822 may be saved. This process may be repeated for the K+1 stages. At the Kth stage 824, the saved checkpoint 826 may be the trained adapter.

[0108] In some cases, the multi-stage incremental quantization adapter training 800 may be advantages as the quantizer disabling / enabling pattern can be predefined prior to training for each stage of the multi-stage training. This allows existing training loops to be easily adapted for the multi-stage incremental quantization adapter training 800. For example, an existing training loop may include loading an adapter, loading training configuration information, performing a number of training steps, and saving a checkpoint. Such a training loop can be adapted to loop through the stages of the multi-stage training by adjusting the training configuration information and enabling / disabling the quantizers (e.g., setting whether to use the quantized or floating point weights / activations for a layer of the base model) .

[0109] In some cases, loading and saving checkpoints for each stage can be time consuming. To avoid repeated loading and saving checkpoints, single stage adapter training may be used.

[0110] FIG. 8B is a timeline illustrating single-stage incremental quantization adapter training 850, in accordance with aspects of the present disclosure. In some cases, the ingle-stage incremental quantization adapter training 850 may be a modified version of the multi-stage incremental quantization adapter training 800 using a modified version of the training loop discussed above. In FIG. 8B, the adapter 852 may be trained in a single stage with a single set of inputs and outputs. Initially, the adapter 852 may be loaded for training. The adapter 852 may be initiated with random and / or invalid weights / activations (e.g., all 0s) . A training configuration 854 may also be loaded. The training configuration 854 may include hyperparameters for training the adapter 852, such as a number of training steps 856 (steps0) , and a learning rate 858 (L0) . An initial quantization ratio 860 (ε0) may also be loaded. In some cases, the quantization ratio may be a quantizer enabled / disabled pattern indicating which layers of the base model should use quantized values (e.g., weights / activations) or floating point values.

[0111] In single-stage incremental quantization adapter training 850, the quantization ratio may be defined for different training steps (e.g., passes, rounds, etc. ) . For example, a first number of training steps may be performed with a first quantization ratio in the base model. A next number of training steps may be performed with a second quantization ratio in the base model, and so forth. Initially, training for the adapter may be performed by, for example, making a prediction based on input training data, determining a loss value for the predication, and back-propagating / forward-propagating 862 the loss through the adapter to adjust the weights / activations of the adapter for a first number of steps. The quantization ratio 864 (ε1) may then be adjusted after the first number of steps and additional training for the adapter may be performed with the losses back-propagated / forward-propagated 866 through the adapter for a second number of steps. The quantization ratio may then be adjusted again, and so forth until a total number of steps have been performed and the quantization ratio is 100% (e.g., only quantized values are used for the base layer weights / activations) to obtain a trained adapter. A checkpoint 868 of the trained adapter may be generated and the trained adapter output.

[0112] In some cases, the quantization ratio may be adjusted after each training step. In some cases, the number of training steps to perform with the different ratios of enabled quantizers to disabled quantizers may be provided in the number of training steps 856. In some cases, the learning rate 858 (L0) may also be adjusted when the quantization ratio is adjusted.

[0113] As indicated above, the multi-stage incremental quantization adapter training 800 and single-stage incremental quantization adapter training 850 may use a quantizer enabled / disabled pattern indicating which layers of the base model should use quantized values and a different quantizer enabled / disabled pattern may be used for each stage or number of steps. The quantizer enabled / disabled pattern may be a vector (e.g., array) corresponding to the layers of the base model indicating which layers may use quantized values and which layers may use non-quantized (e.g., floating point) values. For example, a base model may have a set of layers (e.g., modules) such as {input, conv, norm, adding, linear, linear, . . ., output} . The layers may be associated with a 0 or 1 (or other binary / Boolean) , such as {0, 1, 0, 1, 1, 0, 1,... } , where a value (e.g., 1) may indicate that the weights / activations of the layer may use quantized values (e.g., quantizer is enabled) , and another value (e.g., 0) may indicate that the weights / activations of the layer may use floating point values (e.g., quantizer is disabled) . In some cases, a single layer (e.g., module) may include quantized weights and activations, or either quantized activations or quantized weights. Whether both weights and activations are quantized for a layer or either activations or weights are quantized for a layer may be predetermined for all of the layers of a base model.

[0114] In some cases, the quantizer enabled / disabled pattern may be predetermined while the specific quantizers to enable / disable in the pattern may be either randomly determined or determined in a deterministic manner.

[0115] FIG. 9A illustrates a randomly determined quantizer enabled / disabled pattern, in accordance with aspects of the present disclosure. In some cases, the specific quantizers to enable / disable in a quantizer enabled / disabled pattern may be randomly determined based on the quantization ratio (e.g., percentage, probability, etc. of enabled quantizers to disabled quantizers) . For example, layers of the base model may be randomly set to use quantized values using a Bernoulli distribution defined as P (X=1) =α, where P represents a sign of the probability, where X represents a pattern of a specific layer, such as each number in {0, 1, 0, 1, 1, 0, 1, ... } , and where the probability of X to be 1 is α . As a more specific, for a 9 layer base model 902 at a kth stage, a ratio (e.g., percentage, probability, etc. ) of enabled quantizers to disabled quantizers may be 2: 9 such that two of the 9 layers may use quantized weights / activations. These quantized layers 904 may be randomly selected from among the 9 layers.

[0116] In some cases, the pattern may be independent as between stages, so each stage may have randomly enabled quantizers. Thus, at a kth + 1 stage 906, the ratio (e.g., percentage, probability, etc. ) of enabled quantizers to disabled quantizers may be 4: 9 and the quantized layers 908 may not include the quantized layers 904 from the kth stage.

[0117] FIG. 9B illustrates a deterministically determined quantizer enabled / disabled pattern, in accordance with aspects of the present disclosure. In some cases, which quantizers of the base model to enable / disable may be deterministically determined. As an example, the quantizers may be determined in a cascaded pattern where the layers are quantized layer-by-layer starting from the first layer and adding additional layers at each stage / step (in an order in which the layers occur in the base model) . For example, for a 9 layer base model 952 at a kth stage, with a ratio (e.g., percentage, probability, etc. ) of 2: 9 for enabled quantizers to disabled quantizers, the first two layers may be quantized 954. For a kth + 1 stage 956 with a ratio of 4: 9 for enabled quantizers to disabled quantizers, two additional layers may be quantized so that the first four layers are quantized 958. Thus, the quantizer layers may be incrementally added in an accumulative manner.

[0118] As indicated above, the learning rate may be decreased based on a stage the training is in. In cases where the learning rate is decreased based on a stage, given K+1 number of total stages, where k is a stage index representing a current stage, the learning rate (LRk) may be defined as where LRFP, adapter may be the initial learning rate, and β is an offset to finalize the learning rate when all quantizers are enabled. In some cases, the initial learning rate may be a value that may be used for adapter training with floating point values. In some cases, the above technique for decreasing the learning rate may be applied to both multi-stage incremental quantization adapter training and single-stage incremental quantization adapter training. For single-stage incremental quantization adapter training, the training steps with a particular quantization ratio may be considered a stage and the total number of different ratios of enabled quantizers to disabled quantizers may be considered as the number of total stages. Of note, the above technique for decreasing the learning rate is an example and other techniques for decreasing the learning rate may be used.

[0119] In some cases, the quantization ratio may be set based on a stage the training is in. For example, the quantization ratio may be defined as where k is a stage index ranging from 0 to K. Of note, in the first stage where k=0, α = 0, and in the final stage, k=K, α = 1. The above technique for setting the quantization ratio is an example and other techniques for setting the quantization ratio may be used.

[0120] In some cases, incremental quantization may be used to finetune trained adapters. For example, an adapter may be trained using a floating point version of the base model. The pretrained adapter may be used as starting point for incremental quantization adapter training (e.g., as the adapter 802 of FIG. 8A or adapter 852 of FIG. 8B) . In some cases, finetuning a pretrained adapter may use fewer stages (e.g., training steps) to converge as compared to training from scratch.

[0121] FIG. 10 is a flow diagram illustrating a process 1000 for incremental quantization, in accordance with aspects of the present disclosure. The process 1000 may be performed by a computing device (or apparatus) (e.g., system 100 of FIG. 1, computing device architecture 1200 of FIG. 12) or a component (e.g., a chipset, codec, CPU 102, GPU 104, DSP 106, NPU 108, ISP 110, multimedia processor 112, sensor processor 114 of FIG. 1, processor 1210 of FIG. 12, etc. ) of the computing device. The computing device may be a mobile device (e.g., a mobile phone) , a network-connected wearable such as a watch, an extended reality (XR) device such as a virtual reality (VR) device or augmented reality (AR) device, a vehicle or component or system of a vehicle, or other type of computing device. The operations of the process 1000 may be implemented as software components that are executed and run on one or more processors.

[0122] At block 1002, the computing device (or component thereof) may determine a quantization ratio (e.g., quantization ratio 812 (α0) of FIG. 8A, initial quantization ratio 860 (ε0) of FIG. 8B, quantization ratio 864 (ε1) of FIG. 8B, etc. ) for a set of layers (e.g., as shown in FIG. 9A for base model 902 of FIG. 9A, base model 952 of FIG. 9B, etc. ) in a pretrained machine learning model (e.g., base model 410 of FIG. 4, machine learning model 510 of FIG. 5, machine learning model 710 of FIG. 7, base model 902 of FIG. 9A, base model 952 of FIG. 9B, etc. ) . In some cases, the quantization ratio is determined based on the number of stages and a current stage and the quantization ratio may be set based on a stage the training is in. In some examples, the quantization ratio increases from a first stage in the number of stages to a next stage in the number of stages. For example, the quantization ratio may be increased from the 0th stage to the Kth stage. In some cases, the quantization ratio may be defined as As another example, the quantization ratio may be defined for different training steps. In some cases, the quantization ratio may be adjusted after each training step. In some cases, at a last stage of the number of stages, all layers of the pretrained machine learning model use at least one of a set of quantized weights or a set of quantized activations. For example, at stage K 606 of FIG. 6, all of the layers of the base model may be quantized (e.g., 100%of the layer weights and / or activations are quantized) . In some examples, the quantization ratio is adjusted based on number of training steps performed.

[0123] At block 1004, the computing device (or component thereof) may select a first layer, of the set of layers, (e.g., a layer of the quantized layers 904 of FIG. 9A, quantized layers 908 of FIG. 9A, quantized layers 954 of FIG. 9B, quantized layers 958 of FIG. 9B, etc. ) based on the quantization ratio. In some cases, the first layer is selected based on a deterministic pattern. In some examples, each layer is selected layer-by-layer starting from the first layer. For example, layers may be selected for quantization by quantizers and the quantizers may be determined in a cascaded pattern where the layers are quantized layer-by-layer starting from the first layer and adding additional layers at each stage / step. In some examples, layers (including the first layer) are selected from the set of layers randomly.

[0124] At block 1006, the computing device (or component thereof) may predict, using an adapter (e.g., adapters 420a-420n of FIG. 4, adapter 802 of FIG. 8A, adapter 852 of FIG. 8B, etc. ) and the pretrained machine learning model, an output value using the selected first layer. In some cases, the selected first layer uses at least one of a set of quantized weights or a set of quantized activations (e.g., from weight quantization 520 of FIG. 5 or activation quantization 530 of FIG. 5, weight quantization 720 of FIG. 7 or activation quantization 730 of FIG. 7) . In some cases, the output value is predicted based on a second layer of the set of layers. In some examples, the second layer uses a set of non-quantized weights and non-quantized activations (e.g., layers of the ML models base model 902 of FIG. 9A and base model 952 of FIG. 9B other than quantized layers 904 of FIG. 9A, quantized layers 908 of FIG. 9A, quantized layers 954 of FIG. 9B, quantized layers 958 of FIG. 9B, etc. ) . In some cases, the output value is predicted as a part of a first training stage (e.g., any of stage 0 602, stage 1 604, …, stage K 606 of FIG. 6, any of 0th stage 804, 1st stage 816, …, Kth stage 824 of FIG. 8A) , and wherein the adapter is trained over a number of stages (e.g., K+1 stages) . In some examples, the computing device (or component thereof) may determine a loss based on the predicted output value and update at least one of a weight or activation of the adapter based on the loss and a learning rate. For example, a training step and / or stage may include using an adapter to make a prediction based on input training data, determine a loss value for the predication, and back-propagate and / or forward-propagate the loss through the adapter to adjust the weights / activations of the adapter. In some cases, the learning rate is determined based on the number of stages and a current stage. For example, the learning rate may be decreased from the 0th stage to the Kth stage. In some cases, the adapter is trained from a pre-trained checkpoint (e.g., checkpoint 814, 822, …826 of FIG. 8A) .

[0125] In some examples, the techniques or processes described herein may be performed by a computing device, an apparatus, and / or any other computing device. In some cases, the computing device or apparatus may include a processor, microprocessor, microcomputer, or other component of a device that is configured to carry out the steps of processes described herein. In some examples, the computing device or apparatus may include a camera configured to capture video data (e.g., a video sequence) including video frames. For example, the computing device may include a camera device, which may or may not include a video codec. As another example, the computing device may include a mobile device with a camera (e.g., a camera device such as a digital camera, an IP camera or the like, a mobile phone or tablet including a camera, or other type of device with a camera) . In some cases, the computing device may include a display for displaying images. In some examples, a camera or other capture device that captures the video data is separate from the computing device, in which case the computing device receives the captured video data. The computing device may further include a network interface, transceiver, and / or transmitter configured to communicate the video data. The network interface, transceiver, and / or transmitter may be configured to communicate Internet Protocol (IP) based data or other network data.

[0126] The processes described herein can be implemented in hardware, computer instructions, or a combination thereof. In the context of computer instructions, the operations represent computer-executable instructions stored on one or more computer-readable storage media that, when executed by one or more processors, perform the recited operations. Generally, computer-executable instructions include routines, programs, objects, components, data structures, and the like that perform particular functions or implement particular data types. The order in which the operations are described is not intended to be construed as a limitation, and any number of the described operations can be combined in any order and / or in parallel to implement the processes.

[0127] In some cases, the devices or apparatuses configured to perform the operations of the process 1000 and / or other processes described herein may include a processor, microprocessor, micro-computer, or other component of a device that is configured to carry out the steps of the process 1000 and / or other process. In some examples, such devices or apparatuses may include one or more sensors configured to capture image data and / or other sensor measurements. In some examples, such computing device or apparatus may include one or more sensors and / or a camera configured to capture one or more images or videos. In some cases, such device or apparatus may include a display for displaying images. In some examples, the one or more sensors and / or camera are separate from the device or apparatus, in which case the device or apparatus receives the sensed data. Such device or apparatus may further include a network interface configured to communicate data.

[0128] The components of the device or apparatus configured to carry out one or more operations of the process 1000 and / or other processes described herein can be implemented in circuitry. For example, the components can include and / or can be implemented using electronic circuits or other electronic hardware, which can include one or more programmable electronic circuits (e.g., microprocessors, graphics processing units (GPUs) , digital signal processors (DSPs) , central processing units (CPUs) , and / or other suitable electronic circuits) , and / or can include and / or be implemented using computer software, firmware, or any combination thereof, to perform the various operations described herein. The computing device may further include a display (as an example of the output device or in addition to the output device) , a network interface configured to communicate and / or receive the data, any combination thereof, and / or other component (s) . The network interface may be configured to communicate and / or receive Internet Protocol (IP) based data or other type of data.

[0129] The process 1000 is illustrated as a logical flow diagram, the operations of which represent sequences of operations that can be implemented in hardware, computer instructions, or a combination thereof. In the context of computer instructions, the operations represent computer-executable instructions stored on one or more computer-readable storage media that, when executed by one or more processors, perform the recited operations. Generally, computer-executable instructions include routines, programs, objects, components, data structures, and the like that perform particular functions or implement particular data types. The order in which the operations are described is not intended to be construed as a limitation, and any number of the described operations can be combined in any order and / or in parallel to implement the processes.

[0130] Additionally, the processes described herein (e.g., the process 1000 and / or other processes) may be performed under the control of one or more computer systems configured with executable instructions and may be implemented as code (e.g., executable instructions, one or more computer programs, or one or more applications) executing collectively on one or more processors, by hardware, or combinations thereof. As noted above, the code may be stored on a computer-readable or machine-readable storage medium, for example, in the form of a computer program including a plurality of instructions executable by one or more processors. The computer-readable or machine-readable storage medium may be non-transitory. Additionally, the processes described herein may be performed under the control of one  or more computer systems configured with executable instructions and may be implemented as code (e.g., executable instructions, one or more computer programs, or one or more applications) executing collectively on one or more processors, by hardware, or combinations thereof. As noted above, the code may be stored on a computer-readable or machine-readable storage medium, for example, in the form of a computer program comprising a plurality of instructions executable by one or more processors. The computer-readable or machine-readable storage medium may be non-transitory.

[0131] FIG. 11 is a block diagram of an example transformer in accordance with some aspects of the disclosure. In a convolutional neural network (CNN) model, the number of operations required to relate signals from two arbitrary input or output positions grows in the distance between positions, which makes learning dependencies at different distant positions challenging for a CNN model. The transformer 1100 reduces the operations of learning dependencies by using an encoder 1110 and a decoder 1130 that implements an attention mechanism at different positions of a single sequence to compute a representation of that sequence. An attention function can be described as mapping a query and a set of key-value pairs to an output, where the query, keys, values, and output are all vectors. The output is computed as a weighted sum of the values, where the weight assigned to each value is computed by a compatibility function of the query with the corresponding key.

[0132] In some examples of a transformer, the encoder 1110 is composed of a stack of six identical layers and each layer has two sub-layers. The first sub-layer is a multi-head self-attention engine 1112, and the second sub-layer is a fully connected feed-forward network 1114. A residual connection (not shown) connects around each of the sub-layers followed by normalization.

[0133] In this example of a transformer 1100, the decoder 1130 is also composed of a stack of six identical layers. The decoder also includes a masked multi-head self-attention engine 1132, a multi-head attention engine 1134 over the output of encoder 1110, and a fully connected feed-forward network 1126. Each layer includes a residual connection (not shown) around the layer, which is followed by layer normalization. The masked multi-head self-attention engine 1132 is masked to prevent positions from attending to subsequent positions and ensures that the predictions at position i can depend only on the known outputs at positions less than i (e.g., auto-regression) .

[0134] In the transformer 1100, the queries, keys, and values are linearly projected by a multi-head attention engine into learned linear projects, and then attention is performed in parallel on each of the learned linear projects, which are concatenated and then projected into final values.

[0135] The transformer also includes a positional encoder 1140 to encode positions because the model does not contain recurrence and convolution and relative or absolute position of the tokens is needed. For example, the positional encodings are added to the input embeddings at the bottom layer of the encoder 1110 and the decoder 1130. The positional encodings are summed with the embeddings because the positional encodings and embeddings have the same dimensions. A corresponding position decoder 1150 is configured to decode the positions of the embeddings for the decoder 1130.

[0136] In some aspects, the transformer 1100 uses self-attention mechanisms to selectively weigh the importance of different parts of an input sequence during processing and allows the model to attend to different parts of the input sequence while generating the output. The input sequence is first embedded into vectors and then passed through multiple layers of self-attention and feed-forward networks. The transformer 1100 can process input sequences of variable length, making it well-suited for natural language processing tasks where input lengths can vary greatly. Additionally, the self-attention mechanism allows the transformer 1100 to capture long-range dependencies between words in the input sequence, which is difficult for RNNs and CNNs. The transformer with self-attention has achieved results in several natural language processing tasks that are beyond the capabilities of other neural networks and has become a popular choice for language and text applications. For example, the various large language models, such as a generative pretrained transformer (e.g., ChatGPT, etc. ) and other current models are types of transformer networks.

[0137] FIG. 12 illustrates an example computing device architecture 1200 of an example computing device which can implement the various techniques described herein. In some examples, the computing device can include a mobile device, a wearable device, an extended reality device (e.g., a virtual reality (VR) device, an augmented reality (AR) device, or a mixed reality (MR) device) , a personal computer, a laptop computer, a video server, a vehicle (or computing device of a vehicle) , or other device. The components of computing device architecture 1200 are shown in electrical communication with each other using connection 1205, such as a bus. The example computing device architecture 1200 includes a processing unit (CPU or processor) 1210 and computing device connection 1205 that couples various computing device components including computing device memory 1215, such as read only memory (ROM) 1220 and random access memory (RAM) 1225, to processor 1210.

[0138] Computing device architecture 1200 can include a cache of high-speed memory connected directly with, in close proximity to, or integrated as part of processor 1210. Computing device architecture 1200 can copy data from memory 1215 and / or the storage device 1230 to cache 1212 for quick access by processor 1210. In this way, the cache can provide a performance boost that avoids processor 1210 delays while waiting for data. These and other modules can control or be configured to control processor 1210 to perform various actions. Other computing device memory 1215 may be available for use as well. Memory 1215 can include multiple different types of memory with different performance characteristics. Processor 1210 can include any general purpose processor and a hardware or software service, such as service 1 1232, service 2 1234, and service 3 1236 stored in storage device 1230, configured to control processor 1210 as well as a special-purpose processor where software instructions are incorporated into the processor design. Processor 1210 may be a self-contained system, containing multiple cores or processors, a bus, memory controller, cache, etc. A multi-core processor may be symmetric or asymmetric.

[0139] To enable user interaction with the computing device architecture 1200, input device 1245 can represent any number of input mechanisms, such as a microphone for speech, a touch-sensitive screen for gesture or graphical input, keyboard, mouse, motion input, speech and so forth. Output device 1235 can also be one or more of a number of output mechanisms known to those of skill in the art, such as a display, projector, television, speaker device, etc. In some instances, multimodal computing devices can enable a user to provide multiple types of input to communicate with computing device architecture 1200. Communication interface 1240 can generally govern and manage the user input and computing device output. There is no restriction on operating on any particular hardware arrangement and therefore the basic features here may easily be substituted for improved hardware or firmware arrangements as they are developed.

[0140] Storage device 1230 is a non-volatile memory and can be a hard disk or other types of computer readable media which can store data that are accessible by a computer, such as magnetic cassettes, flash memory cards, solid state memory devices, digital versatile disks, cartridges, random access memories (RAMs) 1225, read only memory (ROM) 1220, and hybrids thereof. Storage device 1230 can include services 1232, 1234, 1236 for controlling processor 1210. Other hardware or software modules are contemplated. Storage device 1230 can be connected to the computing device connection 1205. In one aspect, a hardware module that performs a particular function can include the software component stored in a computer-readable medium in connection with the necessary hardware components, such as processor 1210, connection 1205, output device 1235, and so forth, to carry out the function.

[0141] In some examples, the processes described herein (e.g., process 700, and / or other process described herein) may be performed by a computing device or apparatus. In some examples, the process 1000 can be performed by a computing device having a computing architecture of the computing device architecture 1200 shown in FIG. 12.

[0142] Specific details are provided in the description above to provide a thorough understanding of the aspects and examples provided herein, but those skilled in the art will recognize that the application is not limited thereto. Thus, while illustrative aspects of the application have been described in detail herein, it is to be understood that the inventive concepts may be otherwise variously embodied and employed, and that the appended claims are intended to be construed to include such variations, except as limited by the prior art. Various features and aspects of the above-described application may be used individually or jointly. Further, aspects may be utilized in any number of environments and applications beyond those described herein without departing from the broader scope of the specification. The specification and drawings are, accordingly, to be regarded as illustrative rather than restrictive. For the purposes of illustration, methods were described in a particular order. It should be appreciated that in alternate aspects, the methods may be performed in a different order than that described.

[0143] For clarity of explanation, in some instances the present technology may be presented as including individual functional blocks including devices, device components, steps or routines in a method embodied in software, or combinations of hardware and software. Additional components may be used other than those shown in the figures and / or described herein. For example, circuits, systems, networks, processes, and other components may be shown as components in block diagram form in order not to obscure the aspects in unnecessary detail. In other instances, well-known circuits, processes, algorithms, structures, and techniques may be shown without unnecessary detail in order to avoid obscuring the aspects.

[0144] Further, those of skill in the art will appreciate that the various illustrative logical blocks, modules, engines, circuits, and algorithm steps described in connection with the aspects disclosed herein may be implemented as electronic hardware, computer software, or combinations of both. To clearly illustrate this interchangeability of hardware and software, various illustrative components, blocks, modules, engines, circuits, and steps have been described above generally in terms of their functionality. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the overall system. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present disclosure.

[0145] Individual aspects may be described above as a process or method which is depicted as a flowchart, a flow diagram, a data flow diagram, a structure diagram, or a block diagram. Although a flowchart may describe the operations as a sequential process, many of the operations may be performed in parallel or concurrently. In addition, the order of the operations may be re-arranged. A process is terminated when its operations are completed but could have additional steps not included in a figure. A process may correspond to a method, a function, a procedure, a subroutine, a subprogram, etc. When a process corresponds to a function, its termination may correspond to a return of the function to the calling function or the main function.

[0146] Processes and methods according to the above-described examples may be implemented using computer-executable instructions that are stored or otherwise available from computer-readable media. Such instructions may include, for example, instructions and data which cause or otherwise configure a general purpose computer, special purpose computer, or a processing device to perform a certain function or group of functions. Portions of computer resources used may be accessible over a network. The computer executable instructions may be, for example, binaries, intermediate format instructions such as assembly language, firmware, source code. Examples of computer-readable media that may be used to store instructions, information used, and / or information created during methods according to described examples include magnetic or optical disks, flash memory, USB devices provided with non-volatile memory, networked storage devices, and so on.

[0147] In some aspects the computer-readable storage devices, mediums, and memories may include a cable or wireless signal containing a bitstream and the like. However, when mentioned, non-transitory computer-readable storage media expressly exclude media such as energy, carrier signals, electromagnetic waves, and signals per se.

[0148] Those of skill in the art will appreciate that information and signals may be represented using any of a variety of different technologies and techniques. For example, data, instructions, commands, information, signals, bits, symbols, and chips that may be referenced throughout the above description may be represented by voltages, currents, electromagnetic waves, magnetic fields or particles, optical fields or particles, or any combination thereof, in some cases depending in part on the particular application, in part on the desired design, in part on the corresponding technology, etc.

[0149] The various illustrative logical blocks, modules, engines, and circuits described in connection with the aspects disclosed herein may be implemented or performed using hardware, software, firmware, middleware, microcode, hardware description languages, or any combination thereof, and may take any of a variety of form factors. When implemented in software, firmware, middleware, or microcode, the program code or code segments to perform the necessary tasks (e.g., a computer-program product) may be stored in a computer-readable or machine-readable medium. A processor (s) may perform the necessary tasks. Examples of form factors include laptops, smart phones, mobile phones, tablet devices or other small form factor personal computers, personal digital assistants, rackmount devices, standalone devices, and so on. Functionality described herein also may be embodied in peripherals or add-in cards. Such functionality may also be implemented on a circuit board among different chips or different processes executing in a single device, by way of further example.

[0150] The instructions, media for conveying such instructions, computing resources for executing them, and other structures for supporting such computing resources are example means for providing the functions described in the disclosure.

[0151] The techniques described herein may also be implemented in electronic hardware, computer software, firmware, or any combination thereof. Such techniques may be implemented in any of a variety of devices such as general purposes computers, wireless communication device handsets, or integrated circuit devices having multiple uses including application in wireless communication device handsets and other devices. Any features described as modules, engines, or components may be implemented together in an integrated logic device or separately as discrete but interoperable logic devices. If implemented in software, the techniques may be realized at least in part by a computer-readable data storage medium including program code including instructions that, when executed, performs one or more of the methods, algorithms, and / or operations described above. The computer-readable data storage medium may form part of a computer program product, which may include packaging materials. The computer-readable medium may include memory or data storage media, such as random access memory (RAM) such as synchronous dynamic random access memory (SDRAM) , read-only memory (ROM) , non-volatile random access memory (NVRAM) , electrically erasable programmable read-only memory (EEPROM) , FLASH memory, magnetic or optical data storage media, and the like. The techniques additionally, or alternatively, may be realized at least in part by a computer-readable communication medium that carries or communicates program code in the form of instructions or data structures and that may be accessed, read, and / or executed by a computer, such as propagated signals or waves.

[0152] The program code may be executed by a processor, which may include one or more processors, such as one or more digital signal processors (DSPs) , general purpose microprocessors, an application specific integrated circuits (ASICs) , field programmable logic arrays (FPGAs) , or other equivalent integrated or discrete logic circuitry. Such a processor may be configured to perform any of the techniques described in this disclosure. A general-purpose processor may be a microprocessor; but in the alternative, the processor may be any conventional processor, controller, microcontroller, or state machine. A processor may also be implemented as a combination of computing devices, e.g., a combination of a DSP and a microprocessor, a plurality of microprocessors, one or more microprocessors in conjunction with a DSP core, or any other such configuration. Accordingly, the term “processor, ” as used herein may refer to any of the foregoing structure, any combination of the foregoing structure, or any other structure or apparatus suitable for implementation of the techniques described herein.

[0153] One of ordinary skill will appreciate that the less than ( “<” ) and greater than (“>” ) symbols or terminology used herein may be replaced with less than or equal to ( “≤” ) and greater than or equal to ( “≥” ) symbols, respectively, without departing from the scope of this description.

[0154] Where components are described as being “configured to” perform certain operations, such configuration may be accomplished, for example, by designing electronic circuits or other hardware to perform the operation, by programming programmable electronic circuits (e.g., microprocessors, or other suitable electronic circuits) to perform the operation, or any combination thereof.

[0155] The phrase “coupled to” or “communicatively coupled to” refers to any component that is physically connected to another component either directly or indirectly, and / or any component that is in communication with another component (e.g., connected to the other component over a wired or wireless connection, and / or other suitable communication interface) either directly or indirectly.

[0156] Claim language or other language reciting “at least one of” a set and / or “one or more” of a set indicates that one member of the set or multiple members of the set (in any combination) satisfy the claim. For example, claim language reciting “at least one of A and B” or “at least one of A or B” means A, B, or A and B. In another example, claim language reciting “at least one of A, B, and C” or “at least one of A, B, or C” means A, B, C, or A and B, or A and C, or B and C, A and B and C, or any duplicate information or data (e.g., A and A, B and B, C and C, A and A and B, and so on) , or any other ordering, duplication, or combination of A, B, and C. The language “at least one of” a set and / or “one or more” of a set does not limit the set to the items listed in the set. For example, claim language reciting “at least one of A and B” or “at least one of A or B” may mean A, B, or A and B, and may additionally include items not listed in the set of A and B. The phrases “at least one” and “one or more” are used interchangeably herein.

[0157] Claim language or other language reciting “at least one processor configured to,” “at least one processor being configured to, ” “one or more processors configured to, ” “one or more processors being configured to, ” or the like indicates that one processor or multiple processors (in any combination) can perform the associated operation (s) . For example, claim language reciting “at least one processor configured to: X, Y, and Z” means a single processor can be used to perform operations X, Y, and Z; or that multiple processors are each tasked with a certain subset of operations X, Y, and Z such that together the multiple processors perform X, Y, and Z; or that a group of multiple processors work together to perform operations X, Y, and Z. In another example, claim language reciting “at least one processor configured to: X, Y, and Z” can mean that any single processor may only perform at least a subset of operations X, Y, and Z.

[0158] Where reference is made to one or more elements performing functions (e.g., steps of a method) , one element may perform all functions, or more than one element may collectively perform the functions. When more than one element collectively performs the functions, each function need not be performed by each of those elements (e.g., different functions may be performed by different elements) and / or each function need not be performed in whole by only one element (e.g., different elements may perform different sub-functions of a function) . Similarly, where reference is made to one or more elements configured to cause another element (e.g., an apparatus) to perform functions, one element may be configured to cause the other element to perform all functions, or more than one element may collectively be configured to cause the other element to perform the functions.

[0159] Where reference is made to an entity (e.g., any entity or device described herein) performing functions or being configured to perform functions (e.g., steps of a method) , the entity may be configured to cause one or more elements (individually or collectively) to perform the functions. The one or more components of the entity may include at least one memory, at least one processor, at least one communication interface, another component configured to perform one or more (or all) of the functions, and / or any combination thereof. Where reference to the entity performing functions, the entity may be configured to cause one component to perform all functions, or to cause more than one component to collectively perform the functions. When the entity is configured to cause more than one component to collectively perform the functions, each function need not be performed by each of those components (e.g., different functions may be performed by different components) and / or each function need not be performed in whole by only one component (e.g., different components may perform different sub-functions of a function) .

[0160] Illustrative aspects of the disclosure include:

[0161] Aspect 1. An apparatus for incremental quantization, comprising: at least one memory; and at least one processor coupled to the at least one memory and configured to: determine a quantization ratio for a set of layers in a pretrained machine learning model; select a first layer, of the set of layers, based on the quantization ratio; and predict, using an adapter and the pretrained machine learning model, an output value using the selected first layer, wherein the selected first layer uses at least one of a set of quantized weights or a set of quantized activations.

[0162] Aspect 2. The apparatus of Aspect 1, wherein the output value is predicted based on a second layer of the set of layers, and wherein the second layer uses a set of non-quantized weights and non-quantized activations.

[0163] Aspect 3. The apparatus of any of Aspects 1-2, wherein the output value is predicted as a part of a first training stage, and wherein the adapter is trained over a number of stages.

[0164] Aspect 4. The apparatus of Aspect 3, wherein the quantization ratio is determined based on the number of stages and a current stage.

[0165] Aspect 5. The apparatus of Aspect 4, wherein the quantization ratio increases from a first stage in the number of stages to a next stage in the number of stages.

[0166] Aspect 6. The apparatus of Aspect 5, wherein, at a last stage of the number of stages, all layers of the pretrained machine learning model use at least one of a set of quantized weights or a set of quantized activations.

[0167] Aspect 7. The apparatus of any of Aspects 3-6, wherein the at least one processor is further configured to: determine a loss based on the predicted output value; and update at least one of a weight or activation of the adapter based on the loss and a learning rate.

[0168] Aspect 8. The apparatus of Aspect 7, wherein the learning rate is determined based on the number of stages and a current stage.

[0169] Aspect 9. The apparatus of any of Aspects 1-8, wherein the first layer is selected from the set of layers randomly.

[0170] Aspect 10. The apparatus of any of Aspects 1-9, wherein the first layer is selected based on a deterministic pattern.

[0171] Aspect 11. The apparatus of Aspect 10, wherein each layer is selected layer-by-layer starting from the first layer.

[0172] Aspect 12. The apparatus of any of Aspects 1-11, wherein the quantization ratio is adjusted based on number of training steps performed.

[0173] Aspect 13. The apparatus of any of Aspects 1-12, wherein the adapter is trained from a pre-trained checkpoint.

[0174] Aspect 14. A method for incremental quantization, comprising: determining a quantization ratio for a set of layers in a pretrained machine learning model; selecting a first layer, of the set of layers, based on the quantization ratio; and predicting, using an adapter and the pretrained machine learning model, an output value using the selected first layer, wherein the selected first layer uses at least one of a set of quantized weights or a set of quantized activations.

[0175] Aspect 15. The method of Aspect 14, wherein the output value is predicted based on a second layer of the set of layers, and wherein the second layer uses a set of non-quantized weights and non-quantized activations.

[0176] Aspect 16. The method of any of Aspects 14-15, wherein the output value is predicted as a part of a first training stage, and wherein the adapter is trained over a number of stages.

[0177] Aspect 17. The method of Aspect 16, wherein the quantization ratio is determined based on the number of stages and a current stage.

[0178] Aspect 18. The method of Aspect 17, wherein the quantization ratio increases from a first stage in the number of stages to a next stage in the number of stages.

[0179] Aspect 19. The method of Aspect 18, wherein, at a last stage of the number of stages, all layers of the pretrained machine learning model use at least one of a set of quantized weights or a set of quantized activations.

[0180] Aspect 20. The method of any of Aspects 16-19, further comprising: determining a loss based on the predicted output value; and updating at least one of a weight or activation of the adapter based on the loss and a learning rate.

[0181] Aspect 21. The method of Aspect 20, wherein the learning rate is determined based on the number of stages and a current stage.

[0182] Aspect 22. The method of any of Aspects 14-21, wherein the first layer is selected from the set of layers randomly.

[0183] Aspect 23. The method of any of Aspects 14-22, wherein the first layer is selected based on a deterministic pattern.

[0184] Aspect 24. The method of Aspect 23, wherein each layer is selected layer-by-layer starting from the first layer.

[0185] Aspect 25. The method of any of Aspects 14-24, wherein the quantization ratio is adjusted based on number of training steps performed.

[0186] Aspect 26. The method of any of Aspects 14-25, wherein the adapter is trained from a pre-trained checkpoint.

[0187] Aspect 27. A non-transitory computer-readable medium having stored thereon instructions that, when executed by one or more processors, cause the at one or more processors to perform operations according to any of Aspects 14-26.

[0188] Aspect 28. An apparatus for incremental quantization, the apparatus comprising one or more means for performing operations according to any of Aspects 14-26.

Claims

1.An apparatus for incremental quantization, comprising:at least one memory; andat least one processor coupled to the at least one memory and configured to:determine a quantization ratio for a set of layers in a pretrained machine learning model;select a first layer, of the set of layers, based on the quantization ratio; andpredict, using an adapter and the pretrained machine learning model, an output value using the selected first layer, wherein the selected first layer uses at least one of a set of quantized weights or a set of quantized activations.2.The apparatus of claim 1, wherein the output value is predicted based on a second layer of the set of layers, and wherein the second layer uses a set of non-quantized weights and non-quantized activations.3.The apparatus of claim 1, wherein the output value is predicted as a part of a first training stage, and wherein the adapter is trained over a number of stages.4.The apparatus of claim 3, wherein the quantization ratio is determined based on the number of stages and a current stage.5.The apparatus of claim 4, wherein the quantization ratio increases from a first stage in the number of stages to a next stage in the number of stages.6.The apparatus of claim 5, wherein, at a last stage of the number of stages, all layers of the pretrained machine learning model use at least one of a set of quantized weights or a set of quantized activations.7.The apparatus of claim 3, wherein the at least one processor is further configured to:determine a loss based on the predicted output value; andupdate at least one of a weight or activation of the adapter based on the loss and a learning rate.8.The apparatus of claim 7, wherein the learning rate is determined based on the number of stages and a current stage.9.The apparatus of claim 1, wherein the first layer is selected from the set of layers randomly.10.The apparatus of claim 1, wherein the first layer is selected based on a deterministic pattern.11.The apparatus of claim 10, wherein each layer is selected layer-by-layer starting from the first layer.12.The apparatus of claim 1, wherein the quantization ratio is adjusted based on number of training steps performed.13.The apparatus of claim 1, wherein the adapter is trained from a pre-trained checkpoint.14.A method for incremental quantization, comprising:determining a quantization ratio for a set of layers in a pretrained machine learning model;selecting a first layer, of the set of layers, based on the quantization ratio; andpredicting, using an adapter and the pretrained machine learning model, an output value using the selected first layer, wherein the selected first layer uses at least one of a set of quantized weights or a set of quantized activations.15.The method of claim 14, wherein the output value is predicted based on a second layer of the set of layers, and wherein the second layer uses a set of non-quantized weights and non-quantized activations.16.The method of claim 14, wherein the output value is predicted as a part of a first training stage, and wherein the adapter is trained over a number of stages.17.The method of claim 16, wherein the quantization ratio is determined based on the number of stages and a current stage.18.The method of claim 17, wherein the quantization ratio increases from a first stage in the number of stages to a next stage in the number of stages.19.The method of claim 18, wherein, at a last stage of the number of stages, all layers of the pretrained machine learning model use at least one of a set of quantized weights or a set of quantized activations.20.The method of claim 16, further comprising:determining a loss based on the predicted output value; andupdating at least one of a weight or activation of the adapter based on the loss and a learning rate.21.The method of claim 20, wherein the learning rate is determined based on the number of stages and a current stage.22.The method of claim 14, wherein the first layer is selected from the set of layers randomly.23.The method of claim 14, wherein the first layer is selected based on a deterministic pattern.24.The method of claim 23, wherein each layer is selected layer-by-layer starting from the first layer.25.The method of claim 14, wherein the quantization ratio is adjusted based on number of training steps performed.26.The method of claim 14, wherein the adapter is trained from a pre-trained checkpoint.