Method and apparatus for machine learning model

EP4771542A1Pending Publication Date: 2026-07-08ROBERT BOSCH GMBH +1

Patent Information

Authority / Receiving Office
EP · EP
Patent Type
Applications
Current Assignee / Owner
ROBERT BOSCH GMBH
Filing Date
2023-08-29
Publication Date
2026-07-08

AI Technical Summary

Technical Problem

Training large-scale machine learning models is challenging due to significant memory overheads caused by stateful optimizers, which restrict the model size and mini-batch size, affecting accuracy.

Method used

A method for memory-efficient optimization that involves providing a machine learning model with inputs, obtaining gradients, updating and compressing optimizer states separately using different compression processes tailored to the characteristics of each optimizer state.

Benefits of technology

This approach improves memory efficiency while maintaining comparable accuracy to full-precision optimizers, allowing for larger model sizes and batch sizes during training.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2023115412_06032025_PF_FP_ABST
    Figure CN2023115412_06032025_PF_FP_ABST
Patent Text Reader

Abstract

The present disclosure provides a computer-implemented method for a machine learning model, comprising providing the machine learning model with a set of inputs; obtaining a gradient based on the set of inputs; retrieving a first optimizer state and a second optimizer state; updating the first optimizer state and the second optimizer state based on the gradient; and compressing the updated first and second optimizer states in separate ways.
Need to check novelty before this filing date? Find Prior Art

Description

METHOD AND APPARATUS FOR MACHINE LEARNING MODELFIELD

[0001] Aspects of the present disclosure relate generally to artificial intelligence (AI) , and more particularly, to a method and an apparatus for memory efficient optimizer used for training a machine learning model.BACKGROUND

[0002] Recently, large-scale models with a massive amount of parameters have shown impressive few-shot learning abilities on general tasks, such as natural language processing, image classification, and the like. Despite being powerful, training these large models is challenging. Memory capacity is one of the main bottlenecks of training large-scale models. Modern machine learning models (such as, neural networks) are typically trained with stateful optimizers, such as Adam, which need to maintain one or two optimizer states per each parameter, thus introducing significant memory overheads that restrict the size of model being used as well as the number of examples in a mini-batch, both of which have dramatic effect on the accuracy of the model.

[0003] Therefore, it may be desirable to provide a method or a technique for improving memory usage by the stateful optimizer.SUMMARY

[0004] The following presents a simplified summary of one or more aspects according to the present disclosure in order to provide a basic understanding of such aspects. This summary is not an extensive overview of all contemplated aspects, and is intended to neither identify key or critical elements of all aspects nor delineate the scope of any or all aspects. Its sole purpose is to present some concepts of one or more aspects in a simplified form as a prelude to the more detailed description that is presented later.

[0005] In an aspect of the disclosure, a computer-implemented method for a machine learning model is provided, comprising providing the machine learning  model with a set of inputs; obtaining a gradient based on the set of inputs; retrieving a first optimizer state and a second optimizer state; updating the first optimizer state and the second optimizer state based on the gradient; and compressing the updated first and second optimizer states in separate ways.

[0006] In another aspect of the disclosure, a computer-implemented method for a machine learning model is provided, comprising providing the machine learning model with a set of inputs, wherein the set of inputs comprises images or texts of natural language; obtaining a gradient based on the set of inputs; retrieving a first optimizer state and a second optimizer state from a memory; updating the first optimizer state and the second optimizer state based on the gradient; and compressing the updated first and second optimizer states in separate ways, and storing the compressed updated first and second optimizer states into the memory, wherein parameters of the machine learning model are updated based on the updated first and second optimizer states.

[0007] In another aspect of the disclosure, apparatus for a machine learning model is provided, comprising a memory and at least one processor coupled to the memory. The at least one processor is configured to provide the machine learning model with a set of inputs; obtain a gradient based on the set of inputs; retrieve a first optimizer state and a second optimizer state; update the first optimizer state and the second optimizer state based on the gradient; and compress the updated first and second optimizer states in separate ways.

[0008] In another aspect of the disclosure, a computer program product for a machine learning model is provided, comprising processor executable computer code for providing the machine learning model with a set of inputs; obtaining a gradient based on the set of inputs; retrieving a first optimizer state and a second optimizer state; updating the first optimizer state and the second optimizer state based on the gradient; and compressing the updated first and second optimizer states in separate ways.

[0009] In another aspect of the disclosure, a computer readable medium stores computer code for a machine learning model. The computer code when executed by a processor causes the processor to provide the machine learning model with a set of inputs; obtain a gradient based on the set of inputs; retrieve a first optimizer state and a second optimizer state; update the first optimizer state and the second optimizer  state based on the gradient; and compress the updated first and second optimizer states in separate ways.

[0010] The proposed methods for memory efficient optimization of machine learning models according to one or more aspects of the present disclosure may be used for various applications and / or fields, such as image classification, nature language processing or generation, question answering, machine translation, and the like. Although the following disclosure may be described with reference to language and vision tasks for some part only for illustration, the present disclosure may be applicable to many other application fields beyond these specific application fields, such as graph learning tasks, audio tasks, reinforcement learning, etc.

[0011] By using separate compression processes for different optimizer states in consideration of respective characteristics of the different optimizer states, the memory efficiency can be further improved while maintaining comparable accuracy compared with full-precision counterparts.

[0012] Other aspects or variations of the disclosure, as well as other advantages thereof will become apparent by consideration of the following detailed description and accompanying drawings.BRIEF DESCRIPTION OF THE DRAWINGS

[0013] The disclosed aspects will hereinafter be described in connection with the appended drawings that are provided to illustrate and not to limit the disclosed aspects.

[0014] FIG. 1A and 1B illustrate schematic diagrams for optimizer state tensors according to one or more aspects of the present disclosure.

[0015] FIGs. 2A and 2B illustrate schematic diagrams for magnitudes of two first order momentum tensors in two layers of a Swin-T model during training.

[0016] FIG. 3 illustrates a schematic diagram for distribution of first order momentum.

[0017] FIGs. 4A and 4B illustrate schematic diagrams for distribution of approximations of first order momentum that was quantized by a block size of 2048 and a block size of 128, respectively.

[0018] FIGs. 5A, 5B and 5C illustrate schematic diagrams for density of inverse square root of second order momentum.

[0019] FIG. 6 illustrates an exemplary workflow of a method for compression of optimizer states according to one or more aspects of the present disclosure.

[0020] FIG. 7 illustrates an exemplary framework for compression of optimizer states according to one or more aspects of the present disclosure.

[0021] FIG. 8 illustrates an example of a hardware implementation for an apparatus according to one or more aspects of the present disclosure.DETAILED DESCRIPTION

[0022] The present disclosure will now be discussed with reference to several example implementations. It is to be understood that these implementations are discussed only for enabling those skilled in the art to better understand and thus implement the embodiments of the present disclosure, rather than suggesting any limitations on the scope of the present disclosure.

[0023] Stochastic gradient-based optimization is of core practical importance in many fields of science and engineering. Many problems in these fields can be cast as the optimization of some scalar parameterized objective function requiring maximization or minimization with respect to its parameters. Often, objective functions are stochastic. For example, many objective functions are composed of a sum of sub-functions evaluated at different subsamples of data; in this case optimization can be made more efficient by taking gradient steps with respect to individual sub-functions, i.e., stochastic gradient descent (SGD) or ascent. SGD proved itself as an efficient and effective optimization method that was central in many machine learning success histories, such as recent advances in deep learning.

[0024] Stateful optimizers maintain gradient statistics over time, for example, the exponentially smoothed sum (e.g., SGD with momentum) or squared sum (e.g., Adam) of past gradient values. This state can be used to accelerate optimization compared to plain SGD. However, this state also occupies memory that might otherwise be allocated to model parameters, thereby limiting the size of models.

[0025] There are several approaches to reduce optimizers’ memory consumption. In general, factorization applies low-rank approximation to optimizer states, delta tuning avoids maintaining optimizer states for most parameters by only tuning a small subset, and low-precision optimizers represent their states with low-precision numerical formats, which consume less memory.

[0026] For further illustration, a general updated rule of the Adam optimizer may be formulated as below:

[0027] During the training process, the model parameters wt and the optimizer states (e.g., a first order momentum and a second order momentum) mt, vt need to be stored persistently in a memory (e.g., caches of GPU) . As the model grows large, optimizer states are a main source of training memory consumption. For example, each parameter dimension may take two 32-bit optimizer states, making the memory consumption of Adam-style optimizers three times larger than stateless optimizers, such as SGD.

[0028] In order to mitigate the significant increased memory consumption by the stateful optimizers, a compression-based memory efficient optimization framework may be used, which is described in Algorithm 1.

[0029] The algorithm can be any gradient-based optimizer, such as SGDM, Adam, AdamW, etc. For example, the precise state st are only temporal, and only the compressed states are stored persistently in the memory. Memory footprint reduction can be achieved since in neural networks, the state vectors mt and vt are usually concatenation of state vectors of each parameterized layer. Therefore, the  optimizer steps of line 3 to line 5 can be performed separately for each layer, such that only one single layer’s precise states are presented in the memory at a time. The states for all other layers may be kept compressed.

[0030] Recent studies have presented various methods for the compression, for example, Dettmer et al. ( “8-bit optimizer via block-wise quantization” in International Conference on learning Representations, 2022b) propose an 8-bit optimizer with reparameterized embedding layers ( “stable embedding layers” ) and a block-wise 8-bit dynamic exponential numerical format for optimizer states; Shazeer et al. ( “Adafactor: Adaptive Learning Rates with Sublinear Memory Cost” in International Conference on Machine learning, 2018) propose a factorization method for the second optimizer state by tracking moving averages of the row and column sums of the squared gradients for matrix-valued variables, and reconstructing a low-rank approximation of the exponentially smoothed accumulator at each training step.

[0031] Quantizing the optimizer states to lower precision is an effective way to compression optimizer states. In this case, the optimizer states are compressed with a quantizer and decompressed with a dequantizer. The low-precision numerical format may significantly impact the accuracy of quantization methods. Here, a general framework for numerical formats are given as below.

[0032] A quantizer may convert full-precision tensors to low-precision formats. Based on the formulation proposed by recent studies, the quantizer Q (·) may be disentangled into two parts: normalization N (·) and mapping M (·) , which applies sequentially and element-wise to a tensor to be quantized. Formally, the quantizer for a tensor may be given by:

[0033] The normalization operator N scales each element of x into the unit interval. Normalization may have different granularities, such as per-tensor, per-token (row) , per-channel (column) , group-wise, and block-wise. As an example, the per-tensor and block-wise normalization operators may be given as below:

[0034] Where the involved scaling factors may be referred to as quantization scales, which are persistently stored along with the quantized tensor until dequantization. The granularity of normalization presents a trade-off of quantization error and memory overhead. Normalization method with low quantization error and acceptable memory overhead may be preferred. In this example, the coarsest per-tensor normalization operator has negligible memory overhead, i.e., only one scaling factor regardless of tensor size, but suffers from largest error. Block-wise normalization views the tensor as an one-dimensional array, divides the array into blocks of size B (e.g., as called block) , and assigns a quantization scale within each block, which leads to quantization scales totally.

[0035] A mapping M converts normalized quantities to low-bitwidth integers. Formally, the mapping operator M=MT, b is equipped with a bitwidth b and a predefined increasing mapping, named quantization mapping T:  Then M may be defined as below:

[0036] A current mapping may include dynamic exponent (DE) mapping. The DE mapping can approximate small values well, similar to floating point numbers. DE splits a binary representation of a low-precision integer i into three parts: a leading sequence of E zeros, followed by an indicator bit one, and remaining F fraction bits. DE may define: T (i) =10-E (i) fraction (i) , where fraction (i) ∈ [0.1, 1]                        Eq. (5)

[0037] The dequantizer may be just the inverse of the quantizer, which may be simply as:

[0038] Although stateful optimizers with current compression methods may achieve similar convergence as full-precision optimizers on language modeling, image classification, machine translation, and language understanding tasks, the present disclosure aims to further improve the memory efficiency while maintaining good convergence.

[0039] In one or more aspects of the present disclosure, dedicated compression styles or processes (e.g., various quantization methods and / or factorization, and the like) may be designed for each of the optimizer states by considering respective characteristics of the two optimizer states. By accommodating to the individual characteristics of each order momentums, the memory efficiency can be further improved while maintaining good convergence.

[0040] For example, one of important characteristics of the second order momentum may be that since the update direction is usually inversely proportional to the square root of the second order momentum as shown in Eq. (1) , quantizing non-zero quantities to zero would cause significant deviation during the training. On the other hand, the quantization of the first order momentum may be relatively simple. For example, the first order momentum may be compressed by a lower-precision quantizer (e.g., 4-bit or lower) , while the second order momentum may be compressed by factorization or a higher-precision quantizer (e.g., 8-bit or higher) , which may avoid or facilitate to mitigate the zero-point problem.

[0041] Specifically, one remedy for the zero-point problem is to simply remove zero from DE quantization map, which may be referred to as DE-0. The smallest value representable by DE-0 is 0.0033. By using the DE-0, the zero-point problem may be avoided, but as zero being removed, DE-0 wastes one of the quantization points, which may degrade the quantization precision. Therefore, a higher-precision quantizer with more quantization points may be used to compensate the wasted point, e.g., 8-bit DE-0 quantizer with 255 (i.e., 256-1) effective quantization points may be used for the second order momentum.

[0042] To further improve the performance, the patterns of the first and second order momentums are investigated, and various improvements are presented herein to lead to even better memory efficiency. For example, there are some outliers in the momentums. Outliers can significantly affect quantization scale due to their large magnitude. We find that the outlier patterns in the first and second order momentums are quite complicated.

[0043] FIGs. 1A and 1B illustrate schematic diagrams for optimizer state tensors according to one or more aspects of the present disclosure. FIG. 1A illustrates a two-dimension tensor, where a value (e.g., the box 101) is defined based on two coordinate axes (x, y) . FIG. 1B illustrates a three-dimension tensor, a value (e.g., the  box 102) is defined based on three coordinate axes (x, y, z) . In other aspects of the present disclosure, the optimizer state tensors may be of higher-dimension (e.g., more than three-dimension) or one-dimension (e.g., a vector) .

[0044] FIGs. 2A and 2B illustrate schematic diagrams for magnitudes of two first order momentum tensors in two layers of a Swin-T model during training. As shown in FIG. 2A, outliers of a first layer lie in a fixed row, and as shown in FIG. 2B, outliers of a second layer lie in fixed columns, where the tensors are of two-dimension.

[0045] The complicated outliers pattern may make the optimizer states harder to quantize. For example, there may exist some momentum tensors in which the outliers persist roughly in certain columns, as shown in FIG. 2B. Block-wise normalization treats this tensor as the one-dimensional sequence, row-by-row. Therefore, any block may include an entry in the outlier column when the block size is relatively large, resulting in a large quantization scale within each block. In this case, the block-wise normalization may not be better than per-tensor normalization.

[0046] FIG. 3 illustrates a schematic diagram for distribution of first order momentum. It can be seen from FIG. 3, the distribution of magnitudes of the first order momentum may be similar as a normal distribution, and most quantities of the first order momentum are concentrated around zero, and the number of outliers is much less.

[0047] In one or more aspects of the present disclosure, a smaller block size (e.g., 128) is presented, as it can provide an enhanced performance while incurring only a litter memory overhead.

[0048] FIGs. 4A and 4B illustrate schematic diagrams for distribution of approximations of first order momentum that was quantized by a block size of 2048 and a block size of 128, respectively. It can be seen from the comparison between FIG. 4A and FIG. 4B that, quantizing with a smaller block size, such as, 128, can approximate the first order momentum (e.g., as shown in FIG. 3) better than a large block size, such as, 2048.

[0049] It will be appreciated that other smaller block sizes (e.g., a block size of 64 or even smaller, or a block size of 256, 512, 1024, etc. ) may be adopted depending on specific application cases (e.g., memory budget, the distribution of the outliers, the model size, and the like) without causing a departure from the scope of the present  disclosure.

[0050] FIGs. 5A, 5B and 5C illustrate schematic diagrams for density of inverse square root of second order momentum (e.g., transformed with ) , where FIG. 5A represents the full-precision of the second order momentum, FIG. 5B represents an approximation of the second order momentum that was quantized by a block size of 128 and a DE mapping, and FIG. 5C represents an approximation of the second order momentum that was quantized by a block size of 128 and a DE-0 mapping, and all figures are at log10 scale. It can be seen from FIG. 5B that even with a block size of 128 by which the performance of the first order momentum can be improved significantly (e.g., as shown in FIG. 4B) , the approximation of the second order momentum may not be good enough.

[0051] This is because compared to the first order momentum, quantizing the second order momentum may be more difficult and incur training instability. For example, the zero-point problem may be a main bottleneck of quantizing the second order momentum. As shown in FIG. 5B, the quantizer pushes most of entries of the tensor to zero, so the inverse square root of most points fall into 10-6 due to zero-point problem, resulting in a complete degradation in approximation. It can be shown that, excluding zero from the mapping is indeed the key factor for second order momentum quantization, which cannot be replaced by a smaller block size. Furthermore, the second order momentum may have a sharper outlier pattern and ill-conditioned distribution compared with the first order momentum.

[0052] While the DE-0 mapping may solve the zero-point problem as shown in FIG. 5C, but it is at the expense of reducing quantization precision due to wasting one of quantization bits. In this case, we propose to use a linear mapping (e.g., T (i) = (i+1)  / 2b) , whose smallest representable value is 0.0625. The linear mapping can perform better than DE-0 for quantizing second order momentums, since it can solve the zero-point problem without wasting quantization bitwidth. For example, a linear mapping with bitwidth b=4 may be used for the second order momentum.

[0053] Alternatively, in order to solve the zero-point problem, the factorization method may be applied to the second order momentum, while quantization method being used for the first order momentum, as the factorization method may be only applicable to the second order momentum.

[0054] Furthermore, in order to meet the challenge of more complicated outlier  pattern of the second order momentum, rank-1 normalization is proposed herein. Formally, for a matrix-shaped non-negative tensor its one dimensional statistics and may be defined asri=max1≤j≤mxi, j and cj = max1≤i≤nxi, j, which are exactly the quantization scales of per-row and per-column normalization. The proposed rank-1 normalization can utilize the two quantization scales jointly and produce a tighter bound for the entry, which may be defined as:

[0055] Compared with per-tensor, per-token (row) , and per-channel (column) normalization, rank-1 normalization may utilize the one dimensional information in a more fine-grained manner and can provide element-specific quantization scales. The element-specific quantization scales may be wisely determined based on the one dimensional information associated with each element. Therefore, the outliers may be treated more smartly and effectively by using the rank-1 normalization when the outlier patterns are more complicated, such as with unknown and / or varied distributions.

[0056] FIG. 6 illustrates an exemplary workflow of a method for compression of optimizer states according to one or more aspects of the present disclosure. The method 600 may be used in training and / or fine-tuning of machine learning models for various tasks, such as, image classification with Swin-T, natural language understanding by fine-tuning RoBERTa-L, question answering by fine-tuning RoBERTa-L, natural language generation by fine-tuning GPT-2 Medium, machine translation by training Transformer-Base, and the like.

[0057] At step 610, a machine learning model may be provided with a set of inputs. The set of inputs may comprise a mini-batch of samples, which may be obtained from a dataset of images, text data, or the like.

[0058] At step 620, a gradient may be obtained based on the set of inputs, for example, as shown in Algorithm 1.

[0059] At step 630, a first optimizer state and a second optimizer state may be retrieved. For example, the first and second optimizer states may be compressed previously and stored into a memory. During a current iteration, the compressed first and second optimizer states may be fetched from the memory and decompressed. For  another example, the first and second optimizer states may be initial states.

[0060] At step 640, the retrieved decompressed first and second optimizer states may be updated based on the gradient obtained at step 620, for example, as shown in Algorithm 1, to obtain the updated first and second optimizer states, which may be used to update parameters of the machine learning model.

[0061] At step 650, the updated first and second optimizer states may be compressed in separate ways. For example, one or more of 4-bit quantizer, higher bitwidth quantizer (such as, 8-bit or higher) , a block-wise normalization with a smaller block size (e.g., 64, 128, 256, or 512) , rank-1 normalization, a block-wise normalization with a large block size (e.g., 2048) , a per-tensor normalization, a per-row normalization, a per-column normalization, linear mapping, DE mapping, DE-0 mapping, or factorization may be determined respectively for compression of the first and second optimizer states. The determination may be made based on the characteristics of the first and second optimizer states, for example, exhibited in optimization algorithms and / or models. By using separate compression processes for different optimizer states, individual characteristics of each of different optimizer states may be accommodated, and thus memory efficiency can be further improved while maintaining good convergence. For applicable tasks, the hybrid compression for the optimizer can benefit from both sides: good convergence and memory efficiency.

[0062] In an embodiment, the first optimizer state (i.e., first order momentum) may be compressed using a 4-bit quantizer, for example, with a DE mapping having a bitwidth of 4 and a large block size (e.g., 2048) or small block size (e.g., 128, 256, 512, or the like) normalization.

[0063] In an embodiment, the second optimizer state (i.e., second order momentum) may be compressed using an 8-bit quantizer, for example, with a DE-0 mapping with a bitwidth of 8 and rank-1 normalization or a large block size (e.g., 2048) normalization.

[0064] In an embodiment, the second optimizer state (i.e., second order momentum) may be compressed using a 4-bit quantizer, for example, with a linear mapping with a bitwidth of 4 and rank-1 normalization.

[0065] In an embodiment, the second optimizer state (i.e., second order momentum) may be compressed by factorizing tensors of the second optimizer state having a dimension higher than one, and quantizing the remaining tensors of the  second optimizer state having a dimension of one. In the case of one dimensional tensors, rank-1 normalization may fall back to per-tensor normalization, so a block-wise normalization (e.g., with a small block size of 128, etc. ) may be used.

[0066] In one or more aspects of the present disclosure, parameters of the machine learning model may be updated based on the updated first and second optimizer states, as shown in Eq. (1) for example. Generally, the above steps may be repeated with more mini-batches of samples until convergence. Once the machine learning model is converged, it can be deployed in various environments to make a prediction to control or direct corresponding operations under specific environments. For example, the updated machine learning model may be provided with data from a sensor as an input (e.g., image captured by a visual sensor) , and output data or signal to control an actuator or executor to perform corresponding actions (such as, slow down in an environment of automatic driving. )

[0067] It will be appreciated that the above example is described just for illustration, and the methods presented herein may be applied to other specific application fields without causing a departure of the present disclosure.

[0068] FIG. 7 illustrates an exemplary framework for compression of optimizer states according to one or more aspects of the present disclosure. The framework 700 may comprise a logic unit 710 to hold an optimization algorithm used for a model and a memory 720. For example, the method 600 may be performed in the framework 700. The logic unit 710 may comprise software, hardware, firmware, data structure, or any combination thereof, and the memory 720 may include one or more storage units, depending on specific design preferences. A set of inputs 701 may be provided to the logic unit 710, and gradient may be obtained by the logic unit 710 according to the optimization algorithm. The current optimizer states may be compressed and stored in the memory 720. In order to update parameters of the model based on the gradient, the logic unit 710 may access the memory 720 for the current optimizer states. After updating of the parameters and the current optimizer states, the logic unit 710 may compress the updated optimizer states according to one or more aspects of the proposed methods, and store the compressed updated optimizer states into the memory 720 for subsequent use.

[0069] For example, the updating may be performed layer-by-layer. Thus, a part of compressed current optimizer states associated with only one single layer may be  decompressed once, and used for updating corresponding parameters associated with that layer, during which the part of current optimizer states associated with that layer is first updated based on the gradient (e.g., as shown in Eq. (1) ) . After the updating, the updated part of current optimizer states associated with that layer may be compressed and stored into the memory 720 for use in a next iteration.

[0070] To further demonstrate the advantages of the present disclosure, experimental results are given in the following tables.

[0071] Table 1: Performance on language and vision tasks (Metric: NLU=Mean Accuracy or Correlation; CLS=Accuracy; NLG=BLEU (Bilingual Evaluation Understudy) ; QA=F1; MT=SacreBleu)

[0072] In the Table 1, we compare our 4-bit optimizers with their full-precision counterparts, as well as other memory efficient optimizers including 8-bit AdamW+(Dettmer et al. “8-bit optimizer via block-wise quantization” in International Conference on learning Representations, 2022b, where+ indicates that optimizer states for stable embedding layers are not quantized) , Adafactor (Shazeer et al. “Adafactor: Adaptive Learning Rates with Sublinear Memory Cost” in International Conference on Machine learning, 2018, where++ indicates β1=0) and SM3 (Anil et al. “Memory efficient adaptive optimization” in Advances in Neural Information Processing Systems, 2019) . For our 4-bit optimizer, there are two versions based on 32-bit AdamW: our proposed method 1 quantizes a first order momentum by using a block-wise normalization with a block size of 128 and a DE mapping, and quantizes a second order momentum by using a rank-1 normalization and a linear mapping; our  proposed method 2 quantizes a first order momentum by using a block-wise normalization with a block size of 128 and a DE mapping, and factorizes tensors of a second order momentum having a dimension greater than one and quantizes tensors of the second order momentum having a dimension of one by using a rank-1 normalization and a linear mapping.

[0073] To further evaluate the memory and computation efficiency of the proposed 4-bit optimizer, we compare our proposed methods 1 and 2 with 32-bit AdamW and 8-bit AdamW as shown in Table 2.

[0074] Table 2

[0075] As shown in Table 1 and Table 2, by adopting one or more improvements presented herein, the proposed methods can provide significantly improved memory saving compared with current compression methods while maintaining comparable accuracy compared with full-precision counterparts.

[0076] FIG. 8 illustrates an example of a hardware implementation for an apparatus 800 according to one or more aspects of the present disclosure. The apparatus 800 for memory efficient optimization of models may comprise a memory  810 and at least one processor 820. The processor 820 may be coupled to the memory 810 and configured to implement the method and / or framework 600 and 700 described above with reference to FIGs. 6 and 7. The processor 820 may be a general-purpose processor, or may also be implemented as a combination of computing devices, e.g., a combination of a DSP and a microprocessor, multiple microprocessors, one or more microprocessors in conjunction with a DSP core, or any other such configuration. The memory 810 may store the input data, output data, data generated and / or processed (e.g., compressed and / or decompressed) by processor 820, and / or instructions executed by processor 820.

[0077] The various operations, models, and networks described in connection with the disclosure herein may be implemented in hardware, software executed by a processor, firmware, or any combination thereof. According an embodiment of the disclosure, a computer program product for memory efficient optimization of models may comprise processor executable computer code for implementation of the method and / or the framework 600 and 700 described above with reference to FIGs. 6 and 7. According to another embodiment of the disclosure, a computer readable medium may store computer code for memory efficient optimization of models, the computer code when executed by a processor may cause the processor to implement the method and / or the framework 600 and 700 described above with reference to FIGs. 6 and 7. Computer-readable media includes both non-transitory computer storage media and communication media including any medium that facilitates transfer of a computer program from one place to another. Any connection may be properly termed as a computer-readable medium. Other embodiments and implementations are within the scope of the disclosure.

[0078] The preceding description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the various embodiments. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the scope of the various embodiments. Thus, the claims are not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the following claims and the principles and novel features disclosed herein.

Claims

1.A computer-implemented method for a machine learning model, comprising:providing the machine learning model with a set of inputs;obtaining a gradient based on the set of inputs;retrieving a first optimizer state and a second optimizer state;updating the first optimizer state and the second optimizer state based on the gradient; andcompressing the updated first and second optimizer states in separate ways.2.The computer-implemented method of claim 1, wherein the compressing the updated first and second optimizer states in separate ways comprises:compressing the updated first optimizer state by quantization with 4-bit; andcompressing the updated second optimizer state by quantization with 8-bit.3.The computer-implemented method of claim 1, wherein the compressing the updated first and second optimizer states in separate ways comprises:compressing the updated first optimizer state by block-wise normalization with a block size of 128; andcompressing the updated second optimizer state by rank-1 normalization.4.The computer-implemented method of claim 1, wherein the compressing the updated first and second optimizer states in separate ways comprises:compressing the updated first optimizer state by quantization; andcompressing the updated second optimizer state by factorization.5.The computer-implemented method of claim 4, wherein compressing the updated second optimizer state by factorization further comprises:factorizing tensors of the updated second optimizer state having a dimension greater than one; andquantizing tensors of the updated second optimizer state having a dimension of one.6.The computer-implemented method of claim 1, wherein the compressing the updated first and second optimizer states in separate ways comprises:compressing the updated first optimizer state by quantization with a dynamic exponent (DE) mapping; andcompressing the updated second optimizer state by quantization with a linear mapping.7.The computer-implemented method of claim 1, wherein parameters of the machine learning model are updated based on the updated first and second optimizer states.8.The computer-implemented method of claim 7, further comprising:providing the updated machine learning model with an input; andobtaining an output by the updated machine learning model to control an actuator to perform operations according to the output.9.A computer-implemented method for a machine learning model, comprising:providing the machine learning model with a set of inputs, wherein the set of inputs comprises images or texts of natural language;obtaining a gradient based on the set of inputs;retrieving a first optimizer state and a second optimizer state from a memory;updating the first optimizer state and the second optimizer state based on the gradient; andcompressing the updated first and second optimizer states in separate ways, and storing the compressed updated first and second optimizer states into the memory,wherein parameters of the machine learning model are updated based on the updated first and second optimizer states.10.An apparatus for a machine learning model, comprising:a memory; andat least one processor coupled to the memory and configured to perform the method of one of claims 1-7, and to store the updated first and second optimizer states compressed according to the method of one of claims 1-7 into the memory.11.A computer program product for a machine learning model, comprising: processor executable computer code for performing the method of one of claims 1-7.12.A computer readable medium, storing computer code for a machine learning model, the computer code when executed by a processor, causing the processor to perform the method of one of claims 1-7.