Diffusion refactoring for lossless acceleration of diffusion models
Diffusion refactoring through fast-skip sampling and adaptive residual feedback enhances the speed and quality of pre-trained diffusion models, addressing computational overheads and quality degradation, enabling efficient deployment on resource-constrained devices.
Patent Information
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- INTEL CORP
- Filing Date
- 2025-08-29
- Publication Date
- 2026-07-30
AI Technical Summary
Current diffusion models, such as Stable Diffusion and variants, face significant computational overheads during inference due to slow sampling efficiency, making them challenging for deployment on resource-constrained devices, while existing acceleration techniques suffer from generation quality degradation or high training costs.
The diffusion refactoring technique employs fast-skip sampling and adaptive residual feedback to accelerate pre-trained diffusion models, reformulating the iterative generation process for improved runtime speed and quality, using a lightweight residual feedback model trained via efficient fine-tuning.
This approach achieves lossless acceleration of diffusion models, significantly improving runtime speed and generation quality without compromising on performance, and can be combined with other DNN acceleration techniques for enhanced efficiency.
Smart Images

Figure CN2025117753_30072026_PF_FP_ABST
Abstract
Description
DIFFUSION REFACTORING FOR LOSSLESS ACCELERATION OF DIFFUSION MODELSCross-Reference to Related Application
[0001] This application claims the benefit of International Application No. PCT / CN2025 / 073574, filed January 21, 2025, and titled “DIFFUSION REFACTORING FOR LOSSLESS ACCELERATION OF PRE-TRAINED DIFFUSION MODELS, ” which is incorporated by reference in its entirety for all purposes.Technical Field
[0002] This disclosure relates generally to artificial intelligence (AI) , and more specifically, lossless acceleration of diffusion models, such as pre-trained diffusion models.Background
[0003] Neural networks (also referred to as “deep neural networks” or “DNN” ) are used extensively for a variety of artificial intelligence (AI) applications ranging from computer vision to speech recognition and natural language processing due to their ability to achieve high accuracy. However, the high accuracy comes at the expense of significant computation cost. DNNs have extremely high computing demands as there can be a large number of operations as well as a large amount of data to read and write. Therefore, techniques to improve efficiency of DNNs are needed.Brief Description of the Drawings
[0004] Embodiments can be readily understood by the following detailed description in conjunction with the accompanying drawings. To facilitate this description, like reference numerals designate like structural elements. Embodiments are illustrated by way of example, and not by way of limitation, in the figures of the accompanying drawings.
[0005] Figure (FIG. ) 1 is a block diagram of an AI system, in accordance with various embodiments.
[0006] FIG. 2 illustrates an image generation process based on consecutive sampling, in accordance with various embodiments.
[0007] FIG. 3 illustrates an image generation process based on diffusion refactoring, in accordance with various embodiments.
[0008] FIG. 4 illustrates an example transformer model, in accordance with various embodiments.
[0009] FIG. 5 illustrates an example convolutional neural network (CNN) , in accordance with various embodiments.
[0010] FIG. 6 is a flowchart of a method of accelerating a diffusion model to perform an AI task, in accordance with various embodiments.
[0011] FIG. 7 is a block diagram of an example computing device, in accordance with various embodiments.Detailed Description
[0012] The last decade has witnessed a rapid rise in AI based data processing, particularly based on DNNs. DNNs are widely used in the domains of computer vision, speech recognition, image, and video processing mainly due to their ability to achieve beyond human-level accuracy. A DNN typically includes a sequence of layers. A DNN layer may include one or more operations, such as matrix multiplication, convolution, activation function, interpolation, layer normalization, batch normalization, SoftMax operation, pooling, elementwise operation, linear operation, nonlinear operation, and so on. These operations are referred to as deep learning operations or neural network operations.
[0013] Neural network operations may be tensor operations. Input or output data of neural network operations may be arranged in data structures called tensors. Taking a convolutional layer for example, the input tensors include an activation tensor (also referred to as “input feature map (IFM) ” or “input activation tensor” ) including one or more activations (also referred to as “input elements” ) and a weight tensor. The weight tensor may be a kernel (a 2D weight tensor) , afilter (a 3D weight tensor) , or a group of filters (a 4D weight tensor) . Aconvolution may be performed on the input activation tensor and weight tensor to compute an output activation tensor in the convolutional layer.
[0014] A tensor is a data structure having multiple elements across one or more dimensions. Examples of tensors include vector (which is one-dimensional (1D) tensor) , matrix (which is two-dimensional (2D) tensor) , three-dimensional (3D) tensors, four-dimensional (4D) tensors, and even higher dimensional tensors. Adimension of a tensor may correspond to an axis, e.g., an axis in a coordinate system. Adimension may be measured by the number of data points along the axis. The dimensions of a tensor may define the shape of the tensor. A DNN layer may receive one or more input tensors and compute an output tensor from the one or more input tensors. In some embodiments, a 3D tensor may have an X-dimension, aY-dimension, and Z-dimension. The X-dimension of a tensor may be the horizontal dimension, the length of which may be the width of the tensor; the Y-dimension may be the vertical dimension, the length of which may be the height of the tensor; and the Z-dimension may be the channel dimension, the length of which may be the number of channels. The coordinates of the elements along a dimension may be integers in an inclusive range from 0 to (L-1) , where L is the length of the tensor in the dimension. For instance, the x coordinate of the first element in a row may be 0, the x coordinate of the second element in a row may be 1, and so on. Similarly, the y coordinate of the first element in a column may be 0, the y coordinate of the second element in a column may be 1, and so on. A4D tensor may have a fourth dimension, which may indicate the number of batches in the operation.
[0015] Diffusion models can have remarkable performance on a variety of generative modeling tasks, such as image denoising, text-to-image generation, and text-to-video creation. However, currently available top performing diffusion models, such as Stable Diffusion and other variants typically have approximately 0.9~12 billion parameters. To generate high-quality samples, they usually require at least tens of sampling steps (e.g., 50) , and each sampling step needs to run the diffusion model once. As a result, the slow sampling efficiency of mainstream diffusion models incurs heavy computational overheads at inference, posing a great challenge for the deployment of them on resource-constrained client and edge devices.
[0016] There have been efforts to design effective solutions to speed up diffusion models. Some solutions use low-bit quantization, model parameter pruning, and carefully handcrafted model architectures. However, they typically suffer from the degeneration in generation quality. Some other solutions use knowledge distillation, by which a student diffusion model with a reduced number of sampling steps is trained from scratch by forcing it to mimic the output of a pre-trained teacher model with the original number of sampling steps. However, these solutions suffer from the heavy training cost in time and expense, and are also lossy in terms of generation quality compared to the teacher model.
[0017] Embodiments of this disclosure may improve on at least some of the challenges and issues described above by introducing diffusion refactoring, a novel lossless acceleration technique based on two coupled mechanisms: fast-skip sampling and adaptive residual feedback. In an example, apre-trained diffusion model may operate with the fast-skip sampling instead of the consecutive sampling (i.e., step-by-step sampling) , by which a sufficient large room can be created for improving runtime sampling efficiency. The adaptive residual feedback may be predicted by a significantly lightweight model constructed via an efficient fine-tuning process and may be added after each skip-step sampling, making the current skip-step noise estimate of the pre-trained diffusion model to be as close as possible to the non-skip noise estimate. By chaining the outputs of the fast-skip sampling and the adaptive residual feedback in a time-interleaved fashion, this approach can significantly improve the runtime speedup of any pre-trained diffusion models built upon different types of network architectures, meanwhile getting improved generation quality.
[0018] In various embodiments of the present disclosure, AI tasks may be performed through lossless acceleration of diffusion models. An AI system may receive a prompt for performing a task using an input sample. The input sample may include image, text, audio, video, or other types of data. The task may be to generate an output that includes image, text, audio, video, or other types of data. The task may have a sampling-step length that indicates a total number of steps to be carried out for performing the task. Each step may include an execution of a pre-trained diffusion model for generating a new sample. The steps may be iterative, sequential executions of a diffusion model for generating a sequence of samples from the input sample. Each execution of the diffusion model may use the sample generated in the previous step ( “previous sample” ) as an input to the diffusion model and may generate a sample ( “current sample” ) that has less noise than the previous sample. These samples may be referred to as non-skip samples. The iterative process may be accelerated using fast-skip sampling and adaptable residual feedback mechanisms. Askip-step length may be determined for the task. The skip-step length may indicate the number of sequential executions of the diffusion model to be skipped and may also indicate the number of samples whose generation is to be bypassed. An intermediate sample may be generated by executing the diffusion model once based on the input sample and the sample step length. The diffusion model may estimate a noise of the input sample, and the intermediate sample may be generated by removing the noise from the input sample. The input sample corresponds to a non-skip sample. The position of the non-skip sample in the sequence of non-skip samples depends on the skip-step length. Aresidual feedback model is executed to estimate a residual feedback based on the input sample, the sampling-step length, the first sample, and the skip-step length. The residual feedback may indicate a difference between a noise of the intermediate sample and a noise of the non-skip sample. The intermediate sample may be refined based on the residual feedback. The refined sample may be the output of the first iteration in the accelerated process. The total number of such iterations in the accelerated process may equal the sampling-step length divided by the skip-step length.
[0019] Different from currently available solutions, the diffusion refactoring approach in this disclosure is a low-cost lossless acceleration solution to any pre-trained diffusion models. Given a pre-trained diffusion model of any network architecture (e.g., U-Net or Transformer) , the core insight of the diffusion refactoring approach is to reformulate the iterative generation process of the pre-trained diffusion model to be much faster in terms of sampling efficiency and be better in terms of generation quality. The diffusion refactoring approach is orthogonal to these existing methods, and thus can be readily used to further improve acceleration performance. For instance, the diffusion refactoring technique can be combined with other DNN acceleration techniques, such as weight pruning, weight quantization, and so on. This approach has the great ability to flexibly attain the desired image generation performance with a significantly improved runtime speed under different sampling step budgets.
[0020] For purposes of explanation, specific numbers, materials and configurations are set forth in order to provide a thorough understanding of the illustrative implementations. However, it can be apparent to one skilled in the art that the present disclosure may be practiced without the specific details or / and that the present disclosure may be practiced with only some of the described aspects. In other instances, well known features are omitted or simplified in order not to obscure the illustrative implementations.
[0021] Further, references are made to the accompanying drawings that form a part hereof, and in which is shown, by way of illustration, embodiments that may be practiced. It is to be understood that other embodiments may be utilized, and structural or logical changes may be made without departing from the scope of the present disclosure. Therefore, the following detailed description is not to be taken in a limiting sense.
[0022] Various operations may be described as multiple discrete actions or operations in turn, in a manner that is most helpful in understanding the claimed subject matter. However, the order of description should not be construed as to imply that these operations are necessarily order dependent. In particular, these operations may not be performed in the order of presentation. Operations described may be performed in a different order from the described embodiment. Various additional operations may be performed or described operations may be omitted in additional embodiments.
[0023] For the purposes of the present disclosure, the phrase “A or B” or the phrase "A and / or B" means (A) , (B) , or (A and B) . For the purposes of the present disclosure, the phr ase “A, B, or C” or the phrase "A, B, and / or C" means (A) , (B) , (C) , (A and B) , (A and C) , (B and C) , or (A, B, and C) .The term "between, " when used with reference to measurement ranges, is inclusive of the ends of the measurement ranges.
[0024] The description uses the phrases "in an embodiment" or "in embodiments, " which may each refer to one or more of the same or different embodiments. The terms "comprising, " "including, " "having, " and the like, as used with respect to embodiments of the present disclosure, are synonymous. The disclosure may use perspective-based descriptions such as "above, " "below, " "top, " "bottom, " and "side" to explain various features of the drawings, but these terms are simply for ease of discussion, and do not imply a desired or required orientation. The accompanying drawings are not necessarily drawn to scale. Unless otherwise specified, the use of the ordinal adjectives “first, ” “second, ” and “third, ” etc., to describe a common object, merely indicates that different instances of like objects are being referred to and are not intended to imply that the objects so described must be in a given sequence, either temporally, spatially, in ranking or in any other manner.
[0025] In the following detailed description, various aspects of the illustrative implementations are described using terms commonly employed by those skilled in the art to convey the substance of their work to others skilled in the art.
[0026] The terms “substantially, ” “close, ” “approximately, ” “near, ” and “about, ” generally refer to being within+ / -20%of a target value as described herein or as known in the art. Similarly, terms indicating orientation of various elements, e.g., “coplanar, ” “perpendicular, ” “orthogonal, ” “parallel, ” or any other angle between the elements, generally refer to being within+ / -5-20%of a target value as described herein or as known in the art.
[0027] In addition, the terms “comprise, ” “comprising, ” “include, ” “including, ” “have, ” “having” or any other variation thereof, are intended to cover a non-exclusive inclusion. For example, amethod, process, device, or DNN accelerator that comprises a list of elements is not necessarily limited to only those elements but may include other elements not expressly listed or inherent to such method, process, device, or DNN accelerators. Also, the term “or” refers to an inclusive “or” and not to an exclusive “or. ”
[0028] The systems, methods and devices of this disclosure each have several innovative aspects, no single one of which is solely responsible for all desirable attributes disclosed herein. Details of one or more implementations of the subject matter described in this specification are set forth in the description below and the accompanying drawings.
[0029] FIG. 1 is a block diagram of an AI system 100, in accordance with various embodiments. The AI system 100 may use DNNs to perform AI tasks, including image generating, language processing, speech recognition, other types of AI tasks, or some combinations thereof. In some embodiments, the AI system 100 uses pre-trained diffusion models to perform AI tasks. The AI system 100 may conduct lossless acceleration of pre-trained diffusion models to improve efficiency while not compromising accuracy. In the embodiments of FIG. 1, the AI system 100 includes an interface module 110, a diffusion model 120, afast-skip sampling module 130, a residual feedback model 140, a refining module 150, a training module 160, a compression module 170, and a datastore 180. In other embodiments, alternative configurations, different or additional components may be included in the AI system 100. Further, functionality attributed to a component of the AI system 100 may be accomplished by a different component included in the AI system 100 or a different module or system. For example, functionality attributed to the refining module 150 may be accomplished by the residual feedback model 140. As another example, functionality attributed to the diffusion model 120 and fast-skip sampling module 130 may be accomplished by a fast-skip diffusion model.
[0030] The interface module 110 facilitates communications of the AI system 100 with other modules or systems. For example, the interface module 110 establishes communications for the AI system 100 to receive data that can be used to train the diffusion model 120 or residual feedback model 140. As another example, the interface module 110 establishes communications for the AI system 100 to receive prompts for performing AI tasks. A prompt may be a request from a user for the AI system 100 to perform a desired task to generate a specific output. The prompt may include one or more questions or instructions from the user. In some embodiments, aprompt may include image, text, audio, video, other types of data, or some combination thereof. The interface module 110 may also facilitate transmission of data (such as images, text, audio, video, or other types of data) generated by the AI system 100 to another system or device.
[0031] The diffusion model 120 is a DNN model that has been trained to generate content, such as high-quality images or other types of content. In some embodiments, the diffusion model 120 receives an input sample and works by gradually removing noise from the input sample to generate a high-quality sample. The diffusion model 120 may learn through a reversed process, in which the diffusion model 120 may receive a high-quality sample and iteratively adds noise to the high-quality sample. In some embodiments, the diffusion model 120 has CNN-based architecture. For instance, the diffusion model 120 is a U-Net model. In other embodiments, the diffusion model 120 has transformer-based architecture. For instance, the diffusion model 120 is a diffusion transformer.
[0032] An AI task to be performed by the diffusion model 120 may have a sampling step budget. The sampling step budget may be a sampling-step length t that indicates the total number of iterative executions of the diffusion model 120 to perform the task. t may be an integer that is greater than 1. In some embodiments, t may be a small number, such as a number less than 10. In other embodiments, t may be a larger number, such as 20, 50, 80, 100, and so on. The final output sample may be denoted as x0, and the input sample may be xt. The diffusion model 120 is run t times with a time schedule of (t, t-1, t-2…0) . The diffusion model 120 generates a sequence of t samples, i.e., xt-1 through x0. Each sample is generated from the previous sample. For instance, the diffusion model 120 generates xt-1 from xt, generates xt-2 from xt-1, generates xt-3 from xt-2, …, and generates x0 from x1. Each sample in the sequence has less noise and better quality than the previous sample. This process is a step-by-step sampling process, also referred to as consecutive sampling process. Performing AI tasks using such consecutive sampling processes can incur slow runtime speed due to the huge size of mainstream diffusion models.
[0033] The fast-skip sampling module 130 determines a skip-step length to accelerate performance of AI tasks. The skip-step length indicates the number of sampling steps to be skipped for generating a new sample, which is also the number of executions of the diffusion model 120 to be skipped for generating a new sample. In some embodiments, the fast-skip sampling module 130 determines the skip-step length based on one or more attributes of a hardware device that executes the diffusion model 120 or residual feedback model 140. Examples of the hardware attributes may include types of processing units available for executing the model (e.g., graphics processing unit, central processing unit, neural processing unit, etc. ) , number of work threads or compute units available for executing the model, memory capacity, memory bandwidth, and so on. The fast-skip sampling module 130 may determine a relatively large skip-step length when hardware resources are limited. The fast-skip sampling module 130 may also use other factors to determine the skip-step length. For instance, the fast-skip sampling module 130 may evaluate the requirement of the AI task. In an example where the user desires high-quality content, the fast-skip sampling module 130 may determine a relatively small skip-step length. In an example when the user desires fast result, the fast-skip sampling module 130 may determine a relatively large skip-step length.
[0034] In some embodiment, the skip-step length is denoted as s, sis an integerthat is smaller than t but greater than 1. t may be a multiple of s. The time schedule of running the diffusion model 120 may be changed from (t, t-1, t-2, t-3, …0) to (t-s, t-2s, t-3s, …0) . This process is a diffusion refactoring process as opposed to a consecutive sampling process.
[0035] For the diffusion refactoring process, the diffusion model 120 may estimate a noise (εt) of the input sample based on the input sample and the sampling-step length (t) . The estimated noise (εt) may indicate estimation of the noise when there is no skip in sampling. The fast-skip sampling module 130 may then generate a skip-step sample (xt-s) based on the estimated noise (εt) . For instance, the fast-skip sampling module 130 may remove the estimated noise from the input sample to generate the skip-step sample. The skip-step sample may be denoted as xt-s=xt-∈t.
[0036] The residual feedback model 140 determines residual feedback to address the information loss over unvisited sampling steps. In some embodiments, the residual feedback model 140 determines residual feedback (Δ∈t, t-s) , which indicates the difference between the current skip-step noise estimate (∈t-s) and the non-skip noise estimate (∈t) . εt-smay be an estimated noise of the skip-step sample (xt-s) . In some embodiments, the residual feedback may be denoted asΔ∈t, t-s=φarf (xt, t, ∈t, xt-s, t-s) , whereφarf is the residual feedback model 140. In some embodiments, the residual feedback model 140 estimates the current skip-step noise and then determines residual feedback based on the current skip-step noise and the non-skip noise estimated by the diffusion model 120.
[0037] The refining module 150 refines the skip-step sample, which is generated by the fast-skip sampling module 130 as described above, based on the residual feedback determined by the residual feedback model 140. The refining module 150 generates a refined skip-step sample (xt-s') . The residual feedback model may refine the skip-step sample (xt-s) by removingΔ∈t, t-sfrom the skip-step sample (xt-s) . The refined skip-step sample may be denoted as xt-s'=xt-s-Δ∈t, t-s. The generation of the refined skip-step sample may conclude the first iteration in the diffusion refactoring process.
[0038] For the second iteration in the diffusion refactoring process, the diffusion model 120 may be executed one more time to estimate noise ofxt-s'. The noise may be denoted as∈t-s= Next, the fast-skip sampling module 130 may remove the estimated noise from xt-s' and generate a new skip-step sample xt-2s. The residual feedback model 140 may predict residual feedback associated with the new skip-step sample. The residual feedback may 'beΔεt-s, t-2s=φarf(xt-s, t-s, εt-s, xt-2s, t-2s) . Further, the refining module 150 may refine the new skip-step sample based on the residual feedback and generate xt-2s'=xt-2s-Δεt-s, t-2s.
[0039] Similarly, for the third iteration, the diffusion model 120 may be executed to estimate noise Next, the fast-skip sampling module 130 may generate a skip-step sample xt-3s. The residual feedback model 140 may predict residual feedbackΔ∈t-2s, t-3s=φarf(x′t-2s, t-2s, ∈t-2s, xt-3s, t-3s) . Further, the refining module 150 may generate xt-3s'=xt-3s-Δ∈t-2s, t-3s. The diffusion refactoring process continues till x0' is generated. x0' may be the final output for the AI task.
[0040] With the diffusion refactoring technique, the total number of executions of the diffusion model 120 (or the total number ofsampling) for performing the same AI task may be reduced from t to t / s. The distance between two adjacent samples in the sequence is the skip-step length, rather than 1. The diffusion refactoring technique can resolve the performance degeneration issue via smartly coupling fast-skip sampling and adaptive residual feedback, attaining the universal lossless acceleration of pre-trained diffusion models. With the fast-skip sampling, the pre-trained diffusion model uniformly skips s sampling steps at each evaluation time, no longer operates with the consecutive sampling (i.e., step-by-step sampling) , by which a sufficient large room is created for improving runtime sampling efficiency. Also, the adaptive residual feedback is added after each skip-step sampling, making the current skip-step noise estimate to be as close as possible to the non-skip noise estimate of the pre-trained diffusion model. Furthermore, by chainingthe outputs of the fast-skip sampling and the adaptive residual feedback in a time-interleaved fashion, the diffusion refactoring technique has a great ability to flexibly attain the desired image generation performance with a significantly improved runtime speed under different sampling step budgets. Given a pre-trained diffusion model of any network architecture (either U-Net or Transformer) , the diffusion refactoring technique can reformulate its iterative generation process to be much faster in terms of sampling efficiency and be better in terms of generation quality, under a wide range of sampling step budgets such as tens of sampling steps for Stable Diffusion and few-step sampling for the most powerful distilled Stable Diffusion model (such as latent consistency models, Stable Diffusion XL, etc. ) .
[0041] The training module 160 trains the residual feedback model 140. In some embodiments, the training module 160 may generate the residual feedback model 140 from the diffusion model 120. In an example, the training module 160 may determine the structure of the residual feedback model 140 based on the structure of the diffusion model 120. For instance, one or more layers of the residual feedback model 140 may be the same as one or more layers in the diffusion model 120. The residual feedback model 140 may even have the same structure as the diffusion model 120, meaning the residual feedback model 140 may have the same layers as the diffusion model 120 and the layers may be arranged in the same way.
[0042] The training module 160 may make the residual feedback model 140 lightweight compared to the diffusion model 120. In some embodiments, the training module 160 may select one or more layers and reduce the number of input channels or output channels of each selected layer. For instance, the number of input / output channel number for a layer may be typically reduced to approximately 25%to 50%. Additionally or alternatively, the training module 160 may select one or more layers and reduce the resolution of each selected layer. The training module 160 may reduce the height or width of the input tensor or output tensor of each selected layer. The residual feedback model 140 is therefore a smaller model than the diffusion model 120. In some embodiments, the residual feedback model 140 is significantly smaller than the diffusion model 120, which can further improve the efficiency of the diffusion refactoring process. In an example, the residual feedback model 140 may be approximately 8 times to 16 times faster / smaller than the diffusion model 120.
[0043] The training module 160 may also train the residual feedback model 140 and modify one or more internal parameters of the residual feedback model 140. The training process may be an efficient fine-tuning process. In some embodiments, the training module 160 may determine the parameters of the residual feedback model 140 by a low-cost fine-tuning regime. For instance, the training module 160 may fine tune the residual feedback model 140 to minimize a difference between noise estimate of the residual feedback model 140 for one or more samples generated by skipping one or more steps and noise estimate of the diffusion model 120 for one or more samples generated without skipping any steps. The residual feedback is learnt via optimizing the current skip-step noise estimate to be as close as possible to the non-skip noise estimate of the pre-trained diffusion model. In some embodiments, the fine-tuning cost may be approximately 0.3%of the cost for pretraining the diffusion model 120.
[0044] The compression module 170 compress DNNs, such as the diffusion model 120 or residual feedback model 140. The compressing module 170 may compress the diffusion model 120 or fast-skip sampling module 130 after the model is trained. In some embodiments, the compressing module 170 may add pruning operations to DNN layers to reduce computational complexity or memory usage. A pruning operation may prune weight tensors of a DNN layer by changing one or more nonzero valued weights of the layer to zeros. The modification may be done before, during, or after training. Weights may be pruned during training, during inference, or a combination of both. The compressing module 170 may determine a sparsity ratio for a DNN layer. The sparsity ratio may be a ratio of the number of zero-valued weights to the total number of weights in the layer. The compressing module 170 may perform the pruning operation till the sparsity ratio of the DNN layer meets a target sparsity ration, such as 10%, 20%, 30%, 40%, 50%, and so on.
[0045] In some embodiments, the compressing module 170 may select one or more layers in a DNN and modify each selected layer with a pruning operation. For instance, the compressing module 170 may select computationally complex layers, such as layers with large filters. For a pruning operation of a layer or of a type of layer, the compressing module 170 may determine a weight threshold that would not cause a loss of the accuracy of the DNN to exceed an accuracy loss constraint. A pruning operation may modify weights having absolute values above the weight threshold to zeros and leave the other weights unchanged. The weight pruning can reduce memory storage as zero-valued weights may not be stored. Also, the number of operations in the layer can be reduced as computations on zero-valued weights can be skipped without impacting the output of the layer. In some embodiments, the compressing module 170 may also measure energy saving, final DNN accuracy, or layer-wise sparsity caused by pruning operations.
[0046] After compressing a DNN, the compressing module 170 may fine-tune the DNN, e.g., through a retraining process. The compressing module 170 may fine tunes DNNs after weights are pruned. In some embodiments, the fine-tuning process is a retraining or further training process. For instance, after weights in a DNN are pruned, the compressing module 170 may further train the DNN by inputting a training dataset into the DNN. The values of the unpruned weights in the DNN may be modified based on outputs of the DNN and ground-truth labels of the training samples in the training dataset. In some embodiments, the values of the pruned weights (i.e., zero) are not changed during the fine-tuning process. For instance, the compressing module 170 may place a mask over a pruned weight block and the mask can prevent values in the pruned weight blocks from being changed during the fine-tuning process. In other embodiments, the values of all weights, including the pruned weights, may be changed during the fine-tuning process. After one or more cycles of retraining and weight changing by the compressing module 170, the compressing module 170 may perform a new pruning process, e.g., by selecting weight blocks and pruning the selected weight blocks. In some embodiments, the weight pruning process may be repeated multiple times before the fine-tuning process is done. In some embodiments, the number of epochs in the fine-tuning process may be different from the number of epochs in the training process in which the pre-pruning values of the weights are determined. For instance, the fine-tuning process may have less epochs than the training process. In an example, the number of epochs in the fine-tuning process may be relatively small, such as 2, 3, 4, 5, and so on.
[0047] The datastore 180 stores data received, generated, used, or otherwise associated with the AI system 100. For example, the datastore 180 stores prompts received by the AI system 100 and AI task results generated by the AI system 100. The datastore 180 may also store samples generated by the diffusion model 120, fast-skip sampling module 130, residual feedback model 140, and refining module 150. The datastore 180 may further store noise estimates made by the diffusion model 120 and residual feedback model 140. In some embodiments, the datastore 180 stores internal parameters of the diffusion model 120 and residual feedback model 140, which may be determined by the training module 160 or compressing module 170. The datastore 180 may include one or more memories. In the embodiment of FIG. 1, the datastore 180 is a component of the AI system 100. In other embodiments, the datastore 180 may be external to the AI system 100 and communicate with the AI system 100 through a network.
[0048] FIG. 2 illustrates an image generation process 200 based on consecutive sampling, in accordance with various embodiments. For the purpose of illustration, the image generation process 200 is a process for performing an AI task of generating a better quality image using a diffusion model 210. The diffusion model 210 has been generated and trained to remove noise from images. In some embodiments, the diffusion model 210 may be a DNN having a CNN architecture. For instance, the diffusion model 210 is a U-Net. In other embodiments, the diffusion model 210 may be a DNN with a transformer architecture. The diffusion model 210 is an example of the diffusion model 120 in FIG. 1.
[0049] In the embodiments of FIG. 2, the image generation process 200 includes iteratively deploying the diffusion model 210 to remove noise from an input image 201. The input image 201 may be a prompt received from a user. The user prompt may also include a request to improve the quality of the input image 201. The input image 201 is represented by x10 in FIG. 2, where 10 indicates the sampling step size, which is also referred to as sampling-step length. The sampling-step length is denoted as t, and in the example shown in FIG. 2, t=10. The diffusion model 210 is deployed t=10 times to produce t=10 new samples, which may be denoted as x9 through x0. The time schedule of inference processes of the diffusion model 210 may be denoted as 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0. As shown in FIG. 2, the diffusion model 210 generates x9 from x10 through the first inference process, generates x8 from x9 through the second inference process, generates x7 from x8 through the third inference process, and generates x6 from x7 through the fourth inference process. This continues till the diffusion model 210 generates x0 from x1 through the last inference process, which is the tenth inference process, in the image generation process 200. x9 through x1 are also referred to as intermediate samples. x0 denotes an output image 202 of the image generation process 200. The output image 202 has less noise than the input image 201. In some embodiments, the output image 202 has a better quality (e.g., higher resolution) than the input image 201.
[0050] The image generation process 200 is based on step-by-step sampling, i.e., consecutive sampling. All the ten inference processes are performed and all the ten new samples (i.e., x9 through x0) are generated without skipping any step. Step-by-step sampling can incur slow runtime speed due to the huge size of the diffusion model 210.
[0051] FIG. 3 illustrates an image generation process 300 based on diffusion refactoring, in accordance with various embodiments. For the purpose of illustration, the image generation process 300 is a process for performing the same AI task as the image generation process 200 in FIG. 2. Different from the image generation process 200 in FIG. 2, the image generation process 300 in FIG. 3 is not based on consecutive sampling. Rather, it is based on diffusion refactoring, which can address the performance degeneration issue by coupling fast-skip sampling and adaptive residual feedback. As shown in FIG. 3, the image generation process 300 involves a fast-skip sampling module 310, aresidual feedback model 320, and a refining module 330, in addition to the diffusion model 210 that is used for the image generation process 200 in FIG. 2. An example of the fast-skip sampling module 310 is the fast-skip sampling module 130 in FIG. 1. An example of the residual feedback model 320 is the residual feedback model 140 in FIG. 1. An example of the refining module 330 is the refining module 150 in FIG. 1.
[0052] For the purpose of illustration, the image generation process 300 is used to perform the same AI tasks as the image generation process 200, which is to improve the quality of the input image 201, and the sampling-step length is also t=10. For the image generation process 300, a new parameter, skip-step length s, is determined for fast-skip sampling. The skip-step length indicates the number of steps to be skipped for generating every new sample. In some embodiments, the fast-skip sampling module 310 may determine the skip-step length based on the sampling-step length (which is 10 in this example) and hardware resources available to perform the image generation process 300. FIG. 3 shows an example in which s=5. The time schedule of deploying the diffusion model 210 is changed to 10, 5, 0. The image generation process 300 includes 2 iterations, as opposed to 10.
[0053] In the first iteration, the diffusion model 210 may predict a noise based on the input image 201 and the sampling-step length. The noise may be denoted as where denotes the diffusion model 210 with the fast-skip sampling module 310, x10 is the input image 201, and t is the sampling-step length. The fast-skip sampling module 310 generates an intermediate sample 301, which is also referred to as a skip-step sample, based on the noise predicted by the diffusion model 210. For instance, the fast-skip sampling module 310 may remove the predicted noise from the input image 201 to generate the intermediate sample 301. The intermediate sample 301 may be denoted as x5=x10-∈10. x5 in FIG. 3 may have worse quality than x5 in FIG. 2, due to the information loss over unvisited sampling steps. The information loss can be addressed using the residual feedback model 320 and refining module 330. In some embodiments, the fast-skip sampling module 310 and the diffusion model 210 may be combined into a fast-skip diffusion model.
[0054] As shown in FIG. 3, the intermediate sample 301 is provided to the residual feedback model 320. The residual feedback model 320 predicts a residual feedback based on the intermediate sample 301, input image 201, sampling-step length, and skip-step length. In some embodiments, the residual feedback indicates a difference between an estimated noise in the intermediate sample 301 and estimated noise in the intermediate sample generated by performing all the s steps. For instance, the residual feedback may indicate a difference between the noise associated with x5 in FIG. 3 and the noise associated with x5 in FIG. 2. In some embodiments, the residual feedback is denoted asΔ∈10, 5=φarf(x10, 10, ∈10, x5, 5) , whereφarf denotes the residual feedback model 320. The residual feedback can facilitate makingthe current skip-step noise estimate to be as close as possible to the non-skip noise estimate of the pre-trained diffusion model. The refining module 330 refines the intermediate sample 301 based on the residual feedback and generates a refined intermediate sample 302. In some embodiments, the refining module 330 may be part of the residual feedback model 320, and the residual feedback model 320 may refine the intermediate sample 301 after it estimates the residual feedback. The refined intermediate sample 302 may be denoted as x5'=x5-Δ∈10, 5.. This completes the first iteration in the image generation process 300.
[0055] In the second iteration, the refined intermediate sample 302 is processed by the diffusion model 210 and fast-skip sampling module 310 to generate another sample 303. Similar to the first iteration, the diffusion model 210 predicts a noise associated with the refined intermediate sample 302. The noise may be denoted as The fast-skip sampling module 310 generates the sample 303 by removing the predicted noise from the refined intermediate sample 302. The sample 303 may be denoted as x0=x5'-ε5. Then the sample 303 is provided to the residual feedback model 320 to predict a residual feedbackΔ∈5, 0 =φarf(x′5, 5, ∈5, x0, 0) . The refining module 330 refines the sample 303 based on the residual feedback, e.g., by removing the residual feedback from the sample 303, and generates an output image 304. The output image 304 may be denoted as x0'=x0-Δ∈5, 0. The output image 304 is the output of the image generation process 300.
[0056] As described above, the image generation process 200 includes t=10 iterations, meaning the diffusion model 210 is deployed 10 times; while the image generation process 300 includes t / s=2 iterations, meaning the diffusion model 210 is deployed 2 times plus that the residual feedback model 320 (which may be significantly more lightweight compared to the diffusion model 210) is deployed 2 times for predicting residual feedback. Therefore, the image generation process 300 can be significantly more efficient than the image generation process200. As adaptive residual feedback is added after each skip-step sampling, the quality of the output image 304 in FIG. 3 is comparable to or even the same as the quality of the output image 202 in FIG. 2. The adaptive residual feedback mechanism can also facilitate even better generation quality by making the current skip-step noise estimate to be as close as possible to the non-skip noise estimate for a later step.
[0057] FIG. 4 illustrates an example transformer model 400, in accordance with various embodiments. The transformer model 400 may be used for image generation or other types of AI tasks. The transformer model 400 includes an encoder block 410, a decoder block 420, and a head block 430. In other embodiment, different or additional components may be included in the transformer model 400. Further, functionality attributed to a component of the transformer model 400 may be accomplished by a different component included in the transformer model 400 or a different model or module.
[0058] The encoder block 410 receives input sequences and generates matrix representations of the input sequences. In the embodiments of FIG. 4, the encoder block 410 receives an input 401 and generates an encoder output 402. The input 401 may be an input prompt. In some embodiments, the input 401 may include one or more input tokens, such as words, phrases, sentences, images, audio signals, other types of input tokens, or some combination thereof. In an example, the input 401 may include a prompt received from a user of the transformer model 400. The prompt may include a question or request made by the user. Aword in the prompt may be an input token. The encoder output 402 may include one or more vectors that are contextualized representations of the input 401. Each vector in the encoder output 402 may represent a token in the input 401 with contextual understanding.
[0059] The encoder block 410 includes an embedding layer 413, a positional encoding layer 415, and a plurality of layers 440 (individually referred to as “layer 440” ) . In other embodiments, the encoder block 410 may have different, fewer, or more components. Also, the arrangement of the components in the encoder block 410 may be different from the arrangement shown in FIG. 4. For the purpose of illustration, the encoder block 410 has N layers in FIG. 4, where N is an integer. Each layer 440 may include one or more neural network operations. The layers 440 may transform a sequence of embeddings into a representation that encapsulates the learnt information from the input 401. Different layers 440 may have different internal parameters, e.g., different weights, bias, or other types of internal parameters. In some embodiments, the layers 440 have identical components. The components in a layer 440 may be layers and may also be referred to as sub-layers of the layer 440. As shown in FIG. 4, a layer 440 includes four sub-layers: an MHA layer 441, an add&norm layer 442, a feed forward layer 443, and another add&norm layer 444.
[0060] The decoder block 420 iteratively generates outputs 403 using encoded representations generated by the encoder block 410. The decoder block 420 includes an embedding layer 423, a positional encoding layer 425, and a plurality of layers 450 (individually referred to as “layer 450” ) . For the purpose of illustration, the decoder block 420 has N layers in FIG. 4, where N is an integer. In the embodiments of FIG. 4, the number of layers 450 in the decoder block 420 is the same as the number of layers 440 in the encoder block 410. In other embodiments, the number of layers 450 in the decoder block 420 may be different from the number of layers 440 in the encoder block 410. Each layer 450 may include one or more neural network operations. Different layers 450 may have different internal parameters. In some embodiments, the layers 450 may have identical components. The components in a layer 450 may be layers and may also be referred to as sub-layers of the layer 450. As shown in FIG. 4, a layer 450 includes six sub-layers: an MHA layer 451, an add&norm layer 452, another MHA layer 453, another add&norm layer 454, a feed forward layer 455, and another add&norm layer 456.
[0061] In some embodiments, a sequence of inference stages is performed in the decoder block 420 using encoder outputs, e.g., the encoder output 402. A matrix may be predicted through each inference stage. The outputs 403 may include a plurality of matrices. Each matrix may be further processed in the head block 430 to predict a token. The plurality of matrices may be used to predict a sequence of tokens. For the first inference stage, the decoder block 420 may receive one or more start tokens as input tokens and compute a first matrix from the input tokens and the output of the encoder block 410. The first matrix may be used by the head block 430 to predict a first token. The predicted token may be used as a new input token, in addition to the start token (s) , in the second inference stage. Similarly, a second token may be predicted through the second inference stage and may be used in the third inference stage. This iteration may continue till all the inference stages are complete.
[0062] The head block 430 receives the output of the decoder block 420 and processes it in a linear layer 433 and a SoftMax layer 435. A linear operation may be performed on the output of the decoder block 420 in the linear layer 433. The linear operation may include a multiplication of the output of the decoder block 420 with a weight matrix. The output of the linear layer 433 may be a vector. In some embodiments, the head block 430 may function as a classifier. The number of data elements in the vector computed in the linear layer 433 may depend on the number of classes involved. In an example where there are M classes, where M is an integer, the vector computed in the linear layer 433 may have M data elements representing the prediction for the M classes, respectively.
[0063] The output of the linear layer 433 may be input into the SoftMax layer 435. A SoftMax function may be applied on the output of the linear layer 433 to compute probability scores. A probability score may have a value in the range from 0 to 4. In some embodiments, a probability value is computed for each data element in the vector computed in the linear layer 433. The highest one of the probability scores may be the key. The corresponding index of the key may point to the token that the transformer model 400 predicts as the next in the sequence. The final output of the transformer model 400 may be the sequence of predicted tokens. In some embodiments, the head block 430 may be a language modeling head.
[0064] An embedding layer (e.g., the embedding layer 413 or the embedding layer 423) converts an input of the embedding layer (e.g., the input 401 or the outputs 403) into one or more embeddings. An embedding may be a vector, which is also referred to as an embedding vector or a vector embedding. The vector embedding may include a sequence of data elements. In some embodiments, the embedding layer 413 may generate a plurality of embeddings, each of which may be converted from a different input token in the input 401. The embeddings may capture the semantic meaning of the tokens in the input 401. The embeddings may be numerical representations that capture the relationships or meanings of words, phrases, or other data types. In an example where the input 401 is a prompt including a sequence of words, the embedding layer 413 may generate an embedding from each word in the input 401. The embedding layer 423 in the decoder block 420 may generate a plurality of embeddings from tokens received by the decoder block 420 in a similar manner as the embedding layer 413.
[0065] A positional encoding layer (e.g., the positional encoding layer 415 or the positional encoding layer 425) performs positional encoding on embeddings generated in the corresponding embedding layer. In some embodiments, the positional encoding layer may apply one or more positional encoding vectors (e.g., a positional encoding vector 404 or positional encoding vector 405) on vector embeddings from the corresponding embedding layer to generate new vector embeddings that represent the embeddings with positional context. The positional encoding vector may encode information about the position of the embedding in a sequence of embeddings. In some embodiments, the positional encoding layer performs an addition operation on a positional encoding vector and a vector embedding. The addition operation may be elementwise addition. The positional encoding layer may output an embedding matrix that includes the vector embeddings computed in the positional encoding layer.
[0066] An MHA layer (e.g., the MHA layer 441, the MHA layer 451, or the MHA layer 453) may implement a multi-head attention mechanism, which may be a multi-head self-attention mechanism or a multi-head cross-attention mechanism. In some embodiments, the MHA layer 441 or the MHA layer 451 may implement a self-attention mechanism. For self-attention, the queries, keys, and values may come from the same place. For instance, for the MHA layer 441, the queries, keys, and values may all come from the positional encoding layer 415. For the MHA layer 451, the queries, keys, and values may all come from the positional encoding layer 425. The self-attention mechanism may enable the transformer model 400 to relate each token with other tokens. The MHA layer may compute attention scores from embeddings generated in the corresponding positional encoding layer. In some embodiments, the MHA layer may receive one or more queries, one or more keys, and one or more values. In some embodiments, the MHA layer has a number of heads that receive different linearly projected versions of the queries, keys, and values and produce outputs in parallel that are then used to generate the final result.
[0067] In some embodiments, the queries, keys, and values input into the MHA layer 441 may be computed from vector embeddings generated by the positional encoding layer 415. The queries, keys, and values input into the MHA layer 451 may be computed from vector embeddings generated by the positional encoding layer 425. A query, key, or value may be a vector the represents a token in a sequence. In some embodiments, a query matrix may be computed by multiply an embedding matrix (e.g., an embedding matrix computed in a positional encoding layer) with a weight matrix where d is the dimension of a vector embedding, N is the number of vector embeddings in the embedding matrix, and h is the number of attention heads. Each row in the query matrix may be a query. A key matrix may be computed by multiple an embedding matrix (e.g., an embedding matrix computed in a positional encoding layer) with a weight matrix Each row in the key matrix may be a key. Avalue matrix may be computed by multiple an embedding matrix (e.g., an embedding matrix computed in a positional encoding layer) with a weight matrix Each row in the value matrix may be a value.
[0068] In some embodiments, the MHA layer 451 may implement masked multi-head self-attention. The MHA layer 451 may prevent positions from attending to subsequent positions. For instance, each token in the sequence may not be influenced by future tokens. This masking can ensure that the predictions of a particular position can depend on known outputs at positions before it and not depend on unknown outputs at positions after it.
[0069] In some embodiments, the MHA layer 453 may implement a cross-attention mechanism, such as encoder-decoder cross-attention. The MHA layer 453 may use outputs from the previous layer (i.e., the add&norm layer 452) as queries and use outputs from the encoder block 410 as keys and values. The cross-attention can align the encoder’s input with the decoder’s , empowering the decoder block 420 to identify and emphasize the most relevant parts of the encoder’s input.
[0070] In some embodiments, an MHA layer includes linear layers, a MatMul layer, a scale layer, a SoftMax layer, another MatMul layer, a concatenation layer, and another linear layer. These layers may be arranged in a sequence. The MHA layer may receive three input matrices: a query matrix, a key matrix, and a value matrix, which are inputs of three linear layers, respectively. The linear layers may include matrix multiplication (MatMul) operations. For instance, a first linear layer may perform a multiplication of the query matrix with a weight matrix to compute a first parameter matrix. The first parameter matrix may be denoted as where Q is the query matrix and is the weight matrix. A second linear layer may perform a multiplication of the key matrix with a weight matrix to compute a second parameter matrix. The second parameter matrix may be denoted as where K is the key matrix and is the weight matrix. A third linear layer may perform a multiplication of the value matrix with a weight matrix to compute a third parameter matrix. The third parameter matrix may be denoted as where V is the value matrix and is the weight matrix. i may indicate the index of the head. dq is the dimension of a query vector. dk is the dimension of a key vector. dv is the dimension of a value vector. In some embodiments, dq=dk=dv=dmodel / h. In some embodiments, the linear layers may be in a linear block of the MHA layer. In some embodiments, the MHA layer may include multiple linear blocks. For instance, the MHA layer includes h linear blocks. The linear blocks may have the same layers as each other. Each linear block may compute three parameter matrices from the query matrix, key matrix, and value matrix, respectively.
[0071] The MatMul layer, scale layer, mask layer, SoftMax layer, and MatMul layer may be in an attention block of the MHA layer. The attention block may implement a scaled dot-product attention mechanism. In some embodiments, the MHA layer includes a plurality of attention blocks that includes the attention block. For the purpose of illustration, the MHA layer includes h attention blocks. The attention blocks may have the same layers as each other. A linear block and an attention block may constitute a head of the MHA layer. When the MHA layer has h linear blocks and h attention blocks, the MHA layer has h heads. A head may be denoted as
[0072] A matrix multiplication operation may be performed on parameter matrices in the MatMul layer, which computes a score matrix. In some embodiments, the score matrix may establish the degree of emphasis each token should place on other tokens. The score matrix may include a plurality of scores. Each token may be assigned a score in relation to other tokens within the same time step. A higher score may indicate a higher focus or emphasis. The score matrix may be scaled in the scale layer. In some embodiments, the score matrix is scaled down in the scale layer by dividing the scores in the score matrix by the square root of the dimension of the query vector and the key vector, which may be denoted as The output of the scale layer may be a scaled matrix, which includes adjusted scores. The mask layer may be optional in some embodiments. The mask layer may add an attention mask (which may be an input to the attention block) to the output of the scale layer to mask out some elements in the output of the scale layer. The positions of the masked-out elements may be defined by the attention mask. A SoftMax function may be applied on the scaled matrix in the SoftMax layer to compute an attention weight matrix. The attention weight matrix includes attention weights. The attention weights may be probability values ranging from 0 to 1. The SoftMax function may emphasize high scores while diminishing low scores, which can enhance the model’s ability to determine which tokens should get more attention.
[0073] In the MatMul layer, amatrix multiplication operation is performed on the attention weight matrix computed in the SoftMax layer and the parameter matrix computed from value matrix in the corresponding linear layer. The result of the matrix multiplication operation is a single-head output matrix, which is an output of the attention block.
[0074] When the MHA layer has h attention blocks, there may be h single-head output matrices. The single-head output matrices are concatenated in the concatenation layer to form a concatenated matrix. A linear operation (also referred to as “linear transformation” ) is performed on the concatenated matrix using a weight matrix in the linear layer. In some embodiments, the MHA may be denoted as MultiHead(Q, K, V) =Concat (head1, head2, …, headh) WO, where Concat denotes concatenation, and is the weight matrix in the corresponding linear layer.
[0075] An add&norm layer in the transformer model 400, such as the add&norm layer 442, 444, 452, 454, and 456, has an addition operation followed by a layer normalization operation. The addition operation may be an addition of the output of the preceding layer and the input of the preceding layer. The preceding layer is a layer that is arranged right before the add&norm layer. For example, the preceding layer of the add&norm layer 442 is the MHA layer 441. As another example, the preceding layer of the add&norm layer 454 is the MHA layer 453.
[0076] Then the layer normalization operation is applied on the result of the addition operation, which may be denoted as LayerNorm (x+sublayer(x) ) , where LayerNorm denotes layer normalization, x is the input of the preceding layer, and sublayer (x) denotes the output of the preceding layer. In some embodiments, the layer normalization operation may include a sequence of computations. In an example, the layer normalization operation may include a mean computation, which may be denoted as where Axyz denotes a data element in the input tensor, x may be the positional index of the data element in one of the spatial dimensions, y may be the positional index of the data element in the other one of the spatial dimensions, z may be the positional index of the data element in the channel dimension, andμxy denotes the output of the mean computation, which may be a 2D matrix. The mean computation may be channel-wise reduction operation. The layer normalization operation may convertμxy to a 3D tensorμxyz, e.g., by replicating every data element over z output points.
[0077] The layer normalization operation may also include an elementwise subtraction, which may be denoted as Dxyz=Axyz-μxyz. The layer normalization operation may further include a variance computation denoted as and a division computation denoted as may be a 2D tensor. The layer normalization operation may also convert Mxy to a 3D tensor Mxyz, e.g., by replicating every data element over z output points. Further, the layer normalization operation may have an element multiplication denoted as The layer normalization operation may further compute and LNxyz=A” xyz×γz. LNxyz may be the output of the layer normalization operation.
[0078] A feed forward layer (e.g., the feed forward layer 443 and the feed forward layer 455) may be a position-wise fully-connected feed forward network. In an example, the feed forward layer may include two linear layers with an activation function in between. An example of the activation function is Rectified Linear Unit (ReLU) .
[0079] FIG. 5 illustrates an example CNN 500, in accordance with various embodiments. The CNN 500 may be at least part of a DNN that can be used for image generation or other types of AI tasks. For the purpose of illustration, the CNN 500 includes a sequence of layers comprising a plurality of convolutional layers 510 (individually referred to as “convolutional layer 510” ) , a plurality of pooling layers 520 (individually referred to as “pooling layer 520” ) , and a plurality of fully-connected layers 530 (individually referred to as “fully-connected layer 530” ) . In other embodiments, the CNN 500 may include fewer, more, or different layers. In an execution of the CNN 500, the layers of the CNN 500 execute tensor computation that includes many tensor operations, such as convolutions, interpolations, pooling operations, elementwise operations (e.g., elementwise addition, elementwise multiplication, etc. ) , other types of tensor operations, or some combination thereof.
[0080] The convolutional layers 510 summarize the presence of features in inputs to the CNN 500. The convolutional layers 510 function as feature extractors. The first layer of the CNN 500 is a convolutional layer 510. In an example, aconvolutional layer 510 performs a convolution on an input tensor 540 (also referred to as IFM 540) and a filter 550. As shown in FIG. 5, the IFM 540 is represented by a 7×7×3 three-dimensional (3D) matrix. The IFM 540 includes 3 input channels, each of which is represented by a 7×7 two-dimensional (2D) matrix. The 7×7 2D matrix includes 7 input elements (also referred to as input points) in each row and 7 input elements in each column. The filter 550 is represented by a 3×3×3 3D matrix. The filter 550 includes 3 kernels, each of which may correspond to a different input channel of the IFM 540. A kernel is a 2D matrix of weights, where the weights are arranged in columns and rows. A kernel can be smaller than the IFM. In the embodiments of FIG. 5, each kernel is represented by a 3×3 2D matrix. The 3×3 kernel includes 3 weights in each row and 3 weights in each column. Weights can be initialized and updated by backpropagation using gradient descent. The magnitudes of the weights can indicate importance of the filter 550 in extracting features from the IFM 540.
[0081] The convolution includes multiply-accumulate (MAC) operations with the input elements in the IFM 540 and the weights in the filter 550. The convolution may be a standard convolution 563 or a depthwise convolution 583. In the standard convolution 563, the whole filter 550 slides across the IFM 540. All the input channels are combined to produce an output tensor 560 (also referred to as output feature map (OFM) 560) . The OFM 560 is represented by a 5×5 2D matrix. The 5×5 2D matrix includes 5 output elements (also referred to as output points) in each row and 5 output elements in each column. For the purpose of illustration, the standard convolution includes one filter in the embodiments of FIG. 5. In embodiments where there are multiple filters, the standard convolution may produce multiple output channels in the OFM 560.
[0082] The multiplication applied between a kernel-sized patch of the IFM 540 and a kernel may be a dot product. Adot product is the elementwise multiplication between the kernel-sized patch of the IFM 540 and the corresponding kernel, which is then summed, always resulting in a single value. Because it results in a single value, the operation is often referred to as the “scalar product. ” Using a kernel smaller than the IFM 540 is intentional as it allows the same kernel (set of weights) to be multiplied by the IFM 540 multiple times at different points on the IFM 540. Specifically, the kernel is applied systematically to each overlapping part or kernel-sized patch of the IFM 540, left to right, top to bottom. The result from multiplying the kernel with the IFM 540 one time is a single value. As the kernel is applied multiple times to the IFM 540, the multiplication result is a 2D matrix of output elements. As such, the 2D output matrix (i.e., the OFM 560) from the standard convolution 563 is referred to as an OFM.
[0083] In the depthwise convolution 583, the input channels are not combined. Rather, MAC operations are performed on an individual input channel and an individual kernel and produce an output channel. As shown in FIG. 5, the depthwise convolution 583 produces a depthwise output tensor 580. The depthwise output tensor 580 is represented by a 5×5×3 3D matrix. The depthwise output tensor 580 includes 3 output channels, each of which is represented by a 5×5 2D matrix. The 5×5 2D matrix includes 5 output elements in each row and 5 output elements in each column. Each output channel is a result of MAC operations of an input channel of the IFM 540 and a kernel of the filter 550. For instance, the first output channel (patterned with dots) is a result of MAC operations of the first input channel (patterned with dots) and the first kernel (patterned with dots) , the second output channel (patterned with horizontal strips) is a result of MAC operations of the second input channel (patterned with horizontal strips) and the second kernel (patterned with horizontal strips) , and the third output channel (patterned with diagonal stripes) is a result of MAC operations of the third input channel (patterned with diagonal stripes) and the third kernel (patterned with diagonal stripes) . In such a depthwise convolution, the number of input channels equals the number of output channels, and each output channel corresponds to a different input channel. The input channels and output channels are referred to collectively as depthwise channels. After the depthwise convolution, apointwise convolution 593 is then performed on the depthwise output tensor 580 and a 1×1×3 tensor 590 to produce the OFM 560. The tensor 590 is a 1D tensor.
[0084] The OFM 560 is then passed to the next layer in the sequence. In some embodiments, the OFM 560 is passed through an activation function. An example activation function is ReLU. ReLU is a calculation that returns the value provided as input directly, or the value zero if the input is zero or less. The convolutional layer 510 may receive several images as input and calculate the convolution of each of them with each of the kernels. This process can be repeated several times. For instance, the OFM 560 is passed to the subsequent convolutional layer 510 (i.e., the convolutional layer 510 following the convolutional layer 510 generating the OFM 560 in the sequence) . The subsequent convolutional layers 510 perform a convolution on the OFM 560 with new kernels and generate a new feature map. The new feature map may also be normalized and resized. The new feature map can be kernelled again by a further subsequent convolutional layer 510, and so on.
[0085] In some embodiments, aconvolutional layer 510 has four hyperparameters: the number of kernels, the size F kernels (e.g., akernel is of dimensions F×F×D pixels) , the S step with which the window corresponding to the kernel is dragged on the image (e.g., astep of one means moving the window one pixel at a time) , and the zero-padding P (e.g., adding a black contour of P pixels thickness to the input image of the convolutional layer 510) . The convolutional layers 510 may perform various types of convolutions, such as 2D convolution, dilated or atrous convolution, spatial separable convolution, depthwise separable convolution, transposed convolution, and so on. The CNN 500 includes 56 convolutional layers 510. In other embodiments, the CNN 500 may include a different number of convolutional layers.
[0086] The pooling layers 520 down-sample feature maps generated by the convolutional layers, e.g., by summarizing the presence of features in the patches of the feature maps. A pooling layer 520 is placed between two convolutional layers 510: apreceding convolutional layer 510 (the convolutional layer 510 preceding the pooling layer 520 in the sequence of layers) and a subsequent convolutional layer 510 (the convolutional layer 510 subsequent to the pooling layer 520 in the sequence of layers) . In some embodiments, apooling layer 520 is added after a convolutional layer 510, e.g., after an activation function (e.g., ReLU, etc. ) has been applied to the OFM 560.
[0087] A pooling layer 520 receives feature maps generated by the preceding convolutional layer 510 and applies a pooling operation to the feature maps. The pooling operation reduces the size of the feature maps while preserving their important characteristics. Accordingly, the pooling operation improves the efficiency of the DNN and avoids over-learning. The pooling layers 520 may perform the pooling operation through average pooling (calculating the average value for each patch on the feature map) , max pooling (calculating the maximum value for each patch of the feature map) , or a combination of both. The size of the pooling operation is smaller than the size of the feature maps. In various embodiments, the pooling operation is 2×2 pixels applied with a stride of two pixels, so that the pooling operation reduces the size of a feature map by a factor of 2, e.g., the number of pixels or values in the feature map is reduced to one quarter the size. In an example, apooling layer 520 applied to a feature map of 5×6 results in an output pooled feature map of 3×3. The output of the pooling layer 520 is input into the subsequent convolutional layer 510 for further feature extraction. In some embodiments, the pooling layer 520 operates upon each feature map separately to create a new set of the same number of pooled feature maps.
[0088] The fully-connected layers 530 are the last layers of the DNN. The fully-connected layers 530 may be convolutional or not. The fully-connected layers 530 receive an input operand. The input operand defines the output of the convolutional layers 510 and pooling layers 520 and includes the values of the last feature map generated by the last pooling layer 520 in the sequence. The fully-connected layers 530 apply a linear combination and an activation function to the input operand and generate a vector. The vector may contain as many elements as there are classes: element i represents the probability that the image belongs to class i. Each element is therefore between 0 and 1, and the sum of all may be one. These probabilities are calculated by the last fully-connected layer 530 by using a logistic function (binary classification) or a SoftMax function (multi-class classification) as an activation function. In some embodiments, the fully-connected layers 530 multiply each input element by weight, make the sum, and then apply an activation function (e.g., logistic if N=2, SoftMax if N>2) . This is equivalent to multiplying the input operand by the matrix containing the weights.
[0089] FIG. 6 is a flowchart of a method of accelerating a diffusion model to perform an AI task, in accordance with various embodiments. The method 600 may be performed by the AI system 100 in FIG. 1. Although the method 600 is described with reference to the flowchart illustrated in FIG. 6, many other methods for accelerating diffusion models to perform AI tasks may alternatively be used. For example, the order of execution of the steps in FIG. 6 may be changed. As another example, some of the steps may be changed, eliminated, or combined.
[0090] The AI system 100 determines 610 a skip-step length for performing a task using an input sample. The task has a sampling-step length that indicates a total number of executions of a diffusion model for generating a sequence of samples from the input sample. The skip-step length indicates a number of executions of the diffusion model to be skipped for performing the task. In some embodiments, the input sample is an input image. In some embodiments, the sequence of samples are images having less noise than the input image. In some embodiments, the AI system 100 determines the skip-step length based on one or more attributes of a hardware device. The diffusion model or the residual feedback model is executed by the hardware device.
[0091] The AI system 100 generates 620 a first sample by performing a single execution of the diffusion model based on the input sample and the sampling-step length. The first sample corresponds to a sample in the sequence of samples. A position of the sample in the sequence of samples is determined based on the skip-step length. In some embodiments, the AI system 100 performs the single execution of the diffusion model to estimate a noise of the input sample based on the input sample and the sampling-step length. The AI system 100 generates the first sample by removing the estimated noise from the input sample.
[0092] The AI system 100 executes 630 a residual feedback model to estimate a residual feedback based on the input sample, the sampling-step length, the first sample, and the skip-step length. The residual feedback indicates a difference between a noise of the first sample and a noise of the sample. In some embodiments, the AI system 100 generates the residual feedback model from the diffusion model. The AI system 100 fine tunes the residual feedback model to minimize a difference between noise estimate for one or more samples generated by skipping one or more steps and noise estimate of the diffusion model for one or more samples in the sequence of samples.
[0093] In some embodiments, the residual feedback model has the same structure as the diffusion model. In some embodiments, a layer in the residual feedback model and a layer in the diffusion model are of the same type. In some embodiments, the layer in the residual feedback model has less channels than the layer in the diffusion model. In some embodiments, a tensor of the layer in the residual feedback model has a smaller height or width than a tensor of the layer in the diffusion model.
[0094] The AI system 100 generates 640 a second sample from the first sample based on the residual feedback. In some embodiments, the AI system 100 generates the second sample by refining the first sample based on the residual feedback.
[0095] The AI system 100 produces 650 an output for the task by using the second sample as the sample in the sequence of samples. In some embodiments, the AI system 100 generates a third sample by performing another execution of the diffusion model based on the second sample. The AI system 100 executes the residual feedback model to estimate an additional residual feedback based on the third sample. The AI system 100 generates a fourth sample by refining the third sample based on the additional residual feedback. The output is produced by using the fourth sample as another sample in the sequence of samples. In some embodiments, a distance between the sample and the other sample in the sequence of samples is determined based on the skip-step length.
[0096] FIG. 7 is a block diagram of an example computing device 700, in accordance with various embodiments. In some embodiments, the computing device 700 can be used as at least part of the AI system 100. A number of components are illustrated in FIG. 7 as included in the computing device 700, but any one or more of these components may be omitted or duplicated, as suitable for the application. In some embodiments, some or all of the components included in the computing device 700 may be attached to one or more motherboards. In some embodiments, some or all of these components are fabricated onto a single system on a chip (SoC) die. Additionally, in various embodiments, the computing device 700 may not include one or more of the components illustrated in FIG. 7, but the computing device 700 may include interface circuitry for coupling to the one or more components. For example, the computing device 700 may not include a display device 706, but may include display device interface circuitry (e.g., aconnector and driver circuitry) to which a display device 706 may be coupled. In another set of examples, the computing device 700 may not include an audio input device 718 or an audio output device 708 but may include audio input or output device interface circuitry to which an audio input device 718 or audio output device 708 may be coupled.
[0097] The computing device 700 may include a processing device 702 (e.g., one or more processing devices) . The processing device 702 processes electronic data from registers and / or memory to transform that electronic data into other electronic data that may be stored in registers and / or memory. The computing device 700 may include a memory 704, which may itself include one or more memory devices such as volatile memory (e.g., DRAM) , nonvolatile memory (e.g., read-only memory (ROM) ) , high bandwidth memory (HBM) , flash memory, solid state memory, and / or a hard drive. In some embodiments, the memory 704 may include memory that shares a die with the processing device 702. In some embodiments, the memory 704 includes one or more non-transitory computer-readable media storing instructions executable to perform operations for accelerating diffusion models to perform AI tasks (e.g., the method 600 described in conjunction with FIG. 6) or some operations performed by one or more components of the AI system 100 in FIG. 1. The instructions stored in the one or more non-transitory computer-readable media may be executed by the processing device 702.
[0098] In some embodiments, the computing device 700 may include a communication chip 712 (e.g., one or more communication chips) . For example, the communication chip 712 may be configured for managing wireless communications for the transfer of data to and from the computing device 700. The term "wireless" and its derivatives may be used to describe circuits, devices, systems, methods, techniques, communications channels, etc., that may communicate data through the use of modulated electromagnetic radiation through a nonsolid medium. The term does not imply that the associated devices do not contain any wires, although in some embodiments they might not.
[0099] The communication chip 712 may implement any of a number of wireless standards or protocols, including but not limited to Institute for Electrical and Electronic Engineers (IEEE) standards including Wi-Fi (IEEE 802.10 family) , IEEE 802.16 standards (e.g., IEEE 802.16-2005 Amendment) , Long-Term Evolution (LTE) project along with any amendments, updates, and / or revisions (e.g., advanced LTE project, ultramobile broadband (UMB) project (also referred to as "3GPP2" ) , etc. ) . IEEE 802.16 compatible Broadband Wireless Access (BWA) networks are generally referred to as WiMAX networks, an acronym that stands for worldwide interoperability for microwave access, which is a certification mark for products that pass conformity and interoperability tests for the IEEE 802.16 standards. The communication chip 712 may operate in accordance with a Global System for Mobile Communication (GSM) , General Packet Radio Service (GPRS) , Universal Mobile Telecommunications System (UMTS) , High Speed Packet Access (HSPA) , Evolved HSPA (E-HSPA) , or LTE network. The communication chip 712 may operate in accordance with Enhanced Data for GSM Evolution (EDGE) , GSM EDGE Radio Access Network (GERAN) , Universal Terrestrial Radio Access Network (UTRAN) , or Evolved UTRAN (E-UTRAN) . The communication chip 712 may operate in accordance with Code-division Multiple Access (CDMA) , Time Division Multiple Access (TDMA) , Digital Enhanced Cordless Telecommunications (DECT) , Evolution-Data Optimized (EV-DO) , and derivatives thereof, as well as any other wireless protocols that are designated as 3G, 4G, 5G, and beyond. The communication chip 712 may operate in accordance with other wireless protocols in other embodiments. The computing device 700 may include an antenna 722 to facilitate wireless communications and / or to receive other wireless communications (such as AM or FM radio transmissions) .
[0100] In some embodiments, the communication chip 712 may manage wired communications, such as electrical, optical, or any other suitable communication protocols (e.g., the Ethernet) . As noted above, the communication chip 712 may include multiple communication chips. For instance, afirst communication chip 712 may be dedicated to shorter-range wireless communications such as Wi-Fi or Bluetooth, and a second communication chip 712 may be dedicated to longer-range wireless communications such as global positioning system (GPS) , EDGE, GPRS, CDMA, WiMAX, LTE, EV-DO, or others. In some embodiments, afirst communication chip 712 may be dedicated to wireless communications, and a second communication chip 712 may be dedicated to wired communications.
[0101] The computing device 700 may include battery / power circuitry 714. The battery / power circuitry 714 may include one or more energy storage devices (e.g., batteries or capacitors) and / or circuitry for coupling components of the computing device 700 to an energy source separate from the computing device 700 (e.g., AC line power) .
[0102] The computing device 700 may include a display device 706 (or corresponding interface circuitry, as discussed above) . The display device 706 may include any visual indicators, such as a heads-up display, acomputer monitor, aprojector, atouchscreen display, aliquid crystal display (LCD) , alight-emitting diode display, or a flat panel display, for example.
[0103] The computing device 700 may include an audio output device 708 (or corresponding interface circuitry, as discussed above) . The audio output device 708 may include any device that generates an audible indicator, such as speakers, headsets, or earbuds, for example.
[0104] The computing device 700 may include an audio input device 718 (or corresponding interface circuitry, as discussed above) . The audio input device 718 may include any device that generates a signal representative of a sound, such as microphones, microphone arrays, or digital instruments (e.g., instruments having a musical instrument digital interface (MIDI) output) .
[0105] The computing device 700 may include a GPS device 716 (or corresponding interface circuitry, as discussed above) . The GPS device 716 may be in communication with a satellite-based system and may receive a location of the computing device 700, as known in the art.
[0106] The computing device 700 may include another output device 710 (or corresponding interface circuitry, as discussed above) . Examples of the other output device 710 may include an audio codec, a video codec, a printer, awired or wireless transmitter for providing information to other devices, or an additional storage device.
[0107] The computing device 700 may include another input device 720 (or corresponding interface circuitry, as discussed above) . Examples of the other input device 720 may include an accelerometer, agyroscope, acompass, an image capture device, akeyboard, acursor control device such as a mouse, astylus, atouchpad, abar code reader, aQuick Response (QR) code reader, any sensor, or a radio frequency identification (RFID) reader.
[0108] The computing device 700 may have any desired form factor, such as a handheld or mobile computer system (e.g., a cell phone, a smart phone, a mobile internet device, a music player, atablet computer, a laptop computer, a netbook computer, an ultrabook computer, a personal digital assistant (PDA) , an ultramobile personal computer, etc. ) , a desktop computer system, a server or other networked computing component, a printer, a scanner, a monitor, a set-top box, an entertainment control unit, a vehicle control unit, a digital camera, a digital video recorder, or a wearable computer system. In some embodiments, the computing device 700 may be any other electronic device that processes data.
[0109] The following paragraphs provide various examples of the embodiments disclosed herein.
[0110] Example 1 provides a method, including determining a skip-step length for performing a task using an input sample, the task having a sampling-step length that indicates a total number of executions of a diffusion model for generating a sequence of samples from the input sample, the skip-step length indicating a number of executions of the diffusion model to be skipped for performing the task; generating a first sample by performing a single execution of the diffusion model based on the input sample and the sampling-step length, the first sample corresponding to a sample in the sequence of samples, in which a position of the sample in the sequence of samples is determined based on the skip-step length; executing a residual feedback model to estimate a residual feedback based on the input sample, the sampling-step length, the first sample, and the skip-step length, the residual feedback indicating a difference between a noise of the first sample and a noise of the sample; generating a second sample from the first sample based on the residual feedback; and producing an output for the task by using the second sample as the sample in the sequence of samples.
[0111] Example 2 provides the method of example 1, in which producing the output of the task includes generating a third sample by performing another execution of the diffusion model based on the second sample; executing the residual feedback model to estimate an additional residual feedback based on the third sample; and generating a fourth sample from the third sample based on the additional residual feedback, in which the output is produced by using the fourth sample as another sample in the sequence of samples.
[0112] Example 3 provides the method of example 2, in which a distance between the sample and the other sample in the sequence of samples is determined based on the skip-step length.
[0113] Example 4 provides the method of any one of examples 1-3, in which generating the first sample includes performing the single execution of the diffusion model to estimate a noise of the input sample based on the input sample and the sampling-step length; and generating the first sample by removing the estimated noise from the input sample.
[0114] Example 5 provides the method of any one of examples 1-4, further including generating the residual feedback model from the diffusion model; and fine-tuning the residual feedback model to minimize a difference between noise estimate for one or more samples generated by skipping one or more steps and noise estimate of the diffusion model for one or more samples in the sequence of samples.
[0115] Example 6 provides the apparatus of any one of examples 1-5, in which a layer in the residual feedback model and a layer in the diffusion model are of the same type.
[0116] Example 7 provides the method of example 6, in which the layer in the residual feedback model has less channels than the layer in the diffusion model.
[0117] Example 8 provides the method of example 6 or 7, in which a tensor of the layer in the residual feedback model has a smaller height or width than a tensor of the layer in the diffusion model.
[0118] Example 9 provides the method of any one of examples 1-8, in which determining the skip-step length for the task includes determining the skip-step length based on one or more attributes of a hardware device, in which the diffusion model or the residual feedback model is executed by the hardware device.
[0119] Example 10 provides one or more non-transitory computer-readable media storing instructions executable to perform operations, the operations including determining a skip-step length for performing a task using an input sample, the task having a sampling-step length that indicates a total number of executions of a diffusion model for generating a sequence of samples from the input sample, the skip-step length indicating a number of executions of the diffusion model to be skipped for performing the task; generating a first sample by performing a single execution of the diffusion model based on the input sample and the sampling-step length, the first sample corresponding to a sample in the sequence of samples, in which a position of the sample in the sequence of samples is determined based on the skip-step length; executing a residual feedback model to estimate a residual feedback based on the input sample, the sampling-step length, the first sample, and the skip-step length, the residual feedback indicating a difference between a noise of the first sample and a noise of the sample; generating a second sample from the first sample based on the residual feedback; and producing an output for the task by using the second sample as the sample in the sequence of samples.
[0120] Example 11 provides the one or more non-transitory computer-readable media of example 10, in which producing the output of the task includes generating a third sample by performing another execution of the diffusion model based on the second sample; executing the residual feedback model to estimate an additional residual feedback based on the third sample; and generating a fourth sample from the third sample based on the additional residual feedback, in which the output is produced by using the fourth sample as another sample in the sequence of samples.
[0121] Example 12 provides the one or more non-transitory computer-readable media of example 11, in which a distance between the sample and the other sample in the sequence of samples is determined based on the skip-step length.
[0122] Example 13 provides the one or more non-transitory computer-readable media of any one of examples 10-12, in which generating the first sample includes performing the single execution of the diffusion model to estimate a noise of the input sample based on the input sample and the sampling-step length; and generating the first sample by removing the estimated noise from the input sample.
[0123] Example 14 provides the one or more non-transitory computer-readable media of any one of examples 10-13, in which the operations further include generating the residual feedback model from the diffusion model; and fine-tuning the residual feedback model to minimize a difference between noise estimate for one or more samples generated by skipping one or more steps and noise estimate of the diffusion model for one or more samples in the sequence of samples.
[0124] Example 15 provides the one or more non-transitory computer-readable media of any one of examples 10-14, in which a layer in the residual feedback model and a layer in the diffusion model are of the same type.
[0125] Example 16 provides the one or more non-transitory computer-readable media of example 15, in which the layer in the residual feedback model has less channels than the layer in the diffusion model.
[0126] Example 17 provides the one or more non-transitory computer-readable media of example 15 or 16, in which a tensor of the layer in the residual feedback model has a smaller height or width than a tensor of the layer in the diffusion model.
[0127] Example 18 provides the one or more non-transitory computer-readable media of any one of examples 10-17, in which determining the skip-step length for the task includes determining the skip-step length based on one or more attributes of a hardware device, in which the diffusion model or the residual feedback model is executed by the hardware device.
[0128] Example 19 provides an apparatus, including a computer processor for executing computer program instructions; and a non-transitory computer-readable memory storing computer program instructions executable by the computer processor to perform operations, the operations including determining a skip-step length for performing a task using an input sample, the task having a sampling-step length that indicates a total number of executions of a diffusion model for generating a sequence of samples from the input sample, the skip-step length indicating a number of executions of the diffusion model to be skipped for performing the task, generating a first sample by performing a single execution of the diffusion model based on the input sample and the sampling-step length, the first sample corresponding to a sample in the sequence of samples, in which a position of the sample in the sequence of samples is determined based on the skip-step length, executing a residual feedback model to estimate a residual feedback based on the input sample, the sampling-step length, the first sample, and the skip-step length, the residual feedback indicating a difference between a noise of the first sample and a noise of the sample, generating a second sample from the first sample based on the residual feedback, and producing an output for the task by using the second sample as the sample in the sequence of samples.
[0129] Example 20 provides the apparatus of example 19, in which producing the output of the task includes generating a third sample by performing another execution of the diffusion model based on the second sample; executing the residual feedback model to estimate an additional residual feedback based on the third sample; and generating a fourth sample from the third sample based on the additional residual feedback, in which the output is produced by using the fourth sample as another sample in the sequence of samples.
[0130] Example 21 provides the apparatus of example 20, in which a distance between the sample and the other sample in the sequence of samples is determined based on the skip-step length.
[0131] Example 22 provides the apparatus of any one of examples 19-21, in which generating the first sample includes performing the single execution of the diffusion model to estimate a noise of the input sample based on the input sample and the sampling-step length; and generating the first sample by removing the estimated noise from the input sample.
[0132] Example 23 provides the apparatus of any one of examples 19-22, in which the operations further include generating the residual feedback model from the diffusion model; and fine-tuning the residual feedback model to minimize a difference between noise estimate for one or more samples generated by skipping one or more steps and noise estimate of the diffusion model for one or more samples in the sequence of samples.
[0133] Example 24 provides the apparatus of any one of examples 19-23, in which a layer in the residual feedback model and a layer in the diffusion model are of the same type, in which: the layer in the residual feedback model has less channels than the layer in the diffusion model, or a tensor of the layer in the residual feedback model has a smaller height or width than a tensor of the layer in the diffusion model.
[0134] Example 25 provides the apparatus of any one of examples 19-24, in which determining the skip-step length for the task includes determining the skip-step length based on one or more attributes of a hardware device, in which the diffusion model or the residual feedback model is executed by the hardware device.
[0135] The above description of illustrated implementations of the disclosure, including what is described in the Abstract, is not intended to be exhaustive or to limit the disclosure to the precise forms disclosed. While specific implementations of, and examples for, the disclosure are described herein for illustrative purposes, various equivalent modifications are possible within the scope of the disclosure, as those skilled in the relevant art can recognize. These modifications may be made to the disclosure in light of the above detailed description.
Claims
1.A method, comprising:determining a skip-step length for performing a task using an input sample, the task having a sampling-step length that indicates a total number of executions of a diffusion model for generating a sequence of samples from the input sample, the skip-step length indicating a number of executions of the diffusion model to be skipped for performing the task;generating a first sample by performing a single execution of the diffusion model based on the input sample and the sampling-step length, the first sample corresponding to a sample in the sequence of samples, wherein a position of the sample in the sequence of samples is determined based on the skip-step length;executing a residual feedback model to estimate a residual feedback based on the input sample, the sampling-step length, the first sample, and the skip-step length, the residual feedback indicating a difference between a noise of the first sample and a noise of the sample;generating a second sample from the first sample based on the residual feedback; andproducing an output for the task by using the second sample as the sample in the sequence of samples.2.The method of claim 1, wherein producing the output of the task comprises:generating a third sample by performing another execution of the diffusion model based on the second sample;executing the residual feedback model to estimate an additional residual feedback based on the third sample; andgenerating a fourth sample from the third sample based on the additional residual feedback,wherein the output is produced by using the fourth sample as another sample in the sequence of samples.3.The method of claim 2, wherein a distance between the sample and the other sample in the sequence of samples is determined based on the skip-step length.4.The method of any one of claims 1-3, wherein generating the first sample comprises:performing the single execution of the diffusion model to estimate a noise of the input sample based on the input sample and the sampling-step length; andgenerating the first sample by removing the estimated noise from the input sample.5.The method of any one of claims 1-4, further comprising:generating the residual feedback model from the diffusion model; andfine-tuning the residual feedback model to minimize a difference between noise estimate for one or more samples generated by skipping one or more steps and noise estimate of the diffusion model for one or more samples in the sequence of samples.6.The method of any one of claims 1-5, wherein a layer in the residual feedback model and a layer in the diffusion model are of the same type.7.The method of claim 6, wherein the layer in the residual feedback model has less channels than the layer in the diffusion model.8.The method of claim 6 or 7, wherein a tensor of the layer in the residual feedback model has a smaller height or width than a tensor of the layer in the diffusion model.9.The method of any one of claims 1-8, wherein determining the skip-step length for the task comprises:determining the skip-step length based on one or more attributes of a hardware device, wherein the diffusion model or the residual feedback model is executed by the hardware device.10.One or more non-transitory computer-readable media storing instructions executable to perform operations, the operations comprising:determining a skip-step length for performing a task using an input sample, the task having a sampling-step length that indicates a total number of executions of a diffusion model for generating a sequence of samples from the input sample, the skip-step length indicating a number of executions of the diffusion model to be skipped for performing the task;generating a first sample by performing a single execution of the diffusion model based on the input sample and the sampling-step length, the first sample corresponding to a sample in the sequence of samples, wherein a position of the sample in the sequence of samples is determined based on the skip-step length;executing a residual feedback model to estimate a residual feedback based on the input sample, the sampling-step length, the first sample, and the skip-step length, the residual feedback indicating a difference between a noise of the first sample and a noise of the sample;generating a second sample from the first sample based on the residual feedback; andproducing an output for the task by using the second sample as the sample in the sequence of samples.11.The one or more non-transitory computer-readable media of claim 10, wherein producing the output of the task comprises:generating a third sample by performing another execution of the diffusion model based on the second sample;executing the residual feedback model to estimate an additional residual feedback based on the third sample; andgenerating a fourth sample from the third sample based on the additional residual feedback,wherein the output is produced by using the fourth sample as another sample in the sequence of samples.12.The one or more non-transitory computer-readable media of claim 11, wherein a distance between the sample and the other sample in the sequence of samples is determined based on the skip-step length.13.The one or more non-transitory computer-readable media of any one of claims 10-12, wherein generating the first sample comprises:performing the single execution of the diffusion model to estimate a noise of the input sample based on the input sample and the sampling-step length; andgenerating the first sample by removing the estimated noise from the input sample.14.The one or more non-transitory computer-readable media of any one of claims 10-13, wherein the operations further comprise:generating the residual feedback model from the diffusion model; andfine-tuning the residual feedback model to minimize a difference between noise estimate for one or more samples generated by skipping one or more steps and noise estimate of the diffusion model for one or more samples in the sequence of samples.15.The one or more non-transitory computer-readable media of any one of claims 10-14, wherein a layer in the residual feedback model and a layer in the diffusion model are of the same type.16.The one or more non-transitory computer-readable media of claim 15, wherein the layer in the residual feedback model has less channels than the layer in the diffusion model.17.The one or more non-transitory computer-readable media of claim 15 or 16, wherein a tensor of the layer in the residual feedback model has a smaller height or width than a tensor of the layer in the diffusion model.18.The one or more non-transitory computer-readable media of any one of claims 10-17, wherein determining the skip-step length for the task comprises:determining the skip-step length based on one or more attributes of a hardware device, wherein the diffusion model or the residual feedback model is executed by the hardware device.19.An apparatus, comprising:a computer processor for executing computer program instructions; anda non-transitory computer-readable memory storing computer program instructions executable by the computer processor to perform operations, the operations comprising:determining a skip-step length for performing a task using an input sample, the task having a sampling-step length that indicates a total number of executions of a diffusion model for generating a sequence of samples from the input sample, the skip-step length indicating a number of executions of the diffusion model to be skipped for performing the task,generating a first sample by performing a single execution of the diffusion model based on the input sample and the sampling-step length, the first sample corresponding to a sample in the sequence of samples, wherein a position of the sample in the sequence of samples is determined based on the skip-step length,executing a residual feedback model to estimate a residual feedback based on the input sample, the sampling-step length, the first sample, and the skip-step length, the residual feedback indicating a difference between a noise of the first sample and a noise of the sample,generating a second sample from the first sample based on the residual feedback, andproducing an output for the task by using the second sample as the sample in the sequence of samples.20.The apparatus of claim 19, wherein producing the output of the task comprises:generating a third sample by performing another execution of the diffusion model based on the second sample;executing the residual feedback model to estimate an additional residual feedback based on the third sample; andgenerating a fourth sample from the third sample based on the additional residual feedback,wherein the output is produced by using the fourth sample as another sample in the sequence of samples.21.The apparatus of claim 20, wherein a distance between the sample and the other sample in the sequence of samples is determined based on the skip-step length.22.The apparatus of any one of claims 19-21, wherein generating the first sample comprises:performing the single execution of the diffusion model to estimate a noise of the input sample based on the input sample and the sampling-step length; andgenerating the first sample by removing the estimated noise from the input sample.23.The apparatus of any one of claims 19-22, wherein the operations further comprise:generating the residual feedback model from the diffusion model; andfine-tuning the residual feedback model to minimize a difference between noise estimate for one or more samples generated by skipping one or more steps and noise estimate of the diffusion model for one or more samples in the sequence of samples.24.The apparatus of any one of claims 19-23, wherein a layer in the residual feedback model and a layer in the diffusion model are of the same type, wherein:the layer in the residual feedback model has less channels than the layer in the diffusion model, ora tensor of the layer in the residual feedback model has a smaller height or width than a tensor of the layer in the diffusion model.25.The apparatus of any one of claims 19-24, wherein determining the skip-step length for the task comprises:determining the skip-step length based on one or more attributes of a hardware device, wherein the diffusion model or the residual feedback model is executed by the hardware device.