A diffusion model adaptive acceleration sampling method based on probability mask optimization
By constructing a candidate time step set and utilizing probability masks and policy gradient optimization, the system automatically learns the fewer sampling time steps of the diffusion model, solving the problems of excessive sampling steps and inconsistent generation quality in the diffusion model, and achieving high generation efficiency and quality improvement.
Patent Information
- Application Number
- CN202611491970.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-23
- Publication Date
- 2026-11-27
AI Technical Summary
Existing diffusion models have a large number of sampling steps and slow inference speed. The manual time step scheduling rules are not adaptable enough, and the distribution of training sampling time steps is inconsistent, which affects the generation quality.
By constructing a candidate time step set and parameterizing the binary mask variable into a probability vector, the probability vector is updated using policy gradient estimation. Combined with a two-layer optimization mechanism, the system automatically learns a small number of sampling time steps, thus alleviating the problem of inconsistent time step distribution between the training and inference stages.
It significantly reduces the number of sampling steps, improves generation efficiency, enhances generation quality with fewer sampling steps, adapts to various diffusion models and sampling solvers, and improves inference speed and generation quality.
Smart Images

Figure CN123180230A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of artificial intelligence generative models, deep learning model inference acceleration, and diffusion model sampling optimization technology. Specifically, it relates to an adaptive accelerated sampling method for diffusion models based on probability mask optimization. Background Technology
[0002] Diffusion probabilistic models are an important class of generative models. They typically introduce noise into real data step by step through a forward diffusion process and then gradually recover the data samples from the noise distribution through a reverse denoising process. Due to their good training stability and high generation quality, diffusion models have been widely used in tasks such as image generation, video generation, image editing, super-resolution reconstruction, and 3D content generation.
[0003] However, high-quality generation of diffusion models typically relies on numerous inverse denoising iterations. Traditional diffusion models may require hundreds or even thousands of sampling time steps to accurately approximate the inverse diffusion trajectory, which makes the model inference speed significantly slower than single-step or few-step generation models, limiting their application in scenarios such as real-time interaction, mobile deployment, and batch content generation.
[0004] To improve the sampling efficiency of diffusion models, existing techniques mainly fall into two categories: model distillation and fast numerical solutions. Model distillation methods typically train a student model to mimic the multi-step sampling trajectory of the teacher model to reduce inference steps. However, these methods often require additional training or large-scale fine-tuning, resulting in high training costs and complex adaptation to conditional generation scenarios. Fast numerical solutions, on the other hand, typically represent the inverse process of the diffusion model as a probabilistic flow ordinary differential equation and design higher-order or more stable numerical solvers to complete sampling with fewer function evaluations.
[0005] While the methods described above can reduce the number of sampling steps to some extent, existing numerical solution-based few-step sampling methods typically still rely on manually designed time-step scheduling rules, such as uniform time steps, signal-to-noise ratio-based time steps, or empirical rules specific to a particular sampler. These manually designed rules are not necessarily applicable to different diffusion models, different data distributions, and different sampling solvers. When the number of candidate time steps is large and the target number of sampling steps is small, selecting the optimal few-step sampling sequence from the candidate time steps is essentially a high-dimensional discrete combinatorial optimization problem, and directly enumerating or exhaustively solving it results in extremely high computational complexity.
[0006] Furthermore, existing diffusion models typically cover a large number of discrete time steps or continuous time ranges during the training phase, enabling the model to learn to predict noise or fractional functions across a full range of noise levels. However, during the inference phase, to accelerate sampling, the model is often only invoked on a small number of selected time steps. The significant difference in the distribution of time steps used during the training and inference phases can easily lead to insufficient consistency in the model's output on the limited sampling trajectory, thereby affecting the generation quality under limited sampling.
[0007] Therefore, there is an urgent need for an efficient sampling method that can automatically learn the diffusion model with fewer sampling time steps, avoid relying on manual time step rules, and alleviate the problem of inconsistent training sampling time steps. Summary of the Invention
[0008] To address the problems of numerous sampling steps, slow inference speed, insufficient adaptability of manual time-step scheduling rules, and inconsistent distribution of training sampling time steps in existing diffusion model sampling methods, this invention aims to provide an adaptive accelerated sampling method for diffusion probabilistic models. This method learns a small number of representative sampling time steps through probability masks during the backpropagation denoising sampling process of the diffusion probability model, and improves the quality of small-step sampling by combining training sampling consistency constraints. This invention transforms the time step selection problem in small-step sampling of diffusion models from a discrete combinatorial optimization problem into an optimizable probabilistic parameter learning problem; it achieves time step probability updates without complete backpropagation through policy gradient estimation; and it enables lightweight adaptation of the model to the selected small number of time steps through a two-layer optimization mechanism. This invention can significantly reduce the number of sampling steps, improve generation efficiency, and enhance generation quality under small-step sampling while maintaining compatibility with various diffusion model structures and sampling solvers.
[0009] To achieve the above objectives, the present invention adopts the following technical solution:
[0010] This invention provides an adaptive accelerated sampling method for diffusion models based on probability mask optimization. The method is used in the reverse denoising sampling process of the diffusion model, achieving adaptive accelerated sampling by replacing the original complete time step sequence with a small number of learned sampling time steps. The method includes the following steps:
[0011] 1) Obtain the trained diffusion model and the original time step range or original discrete time step sequence corresponding to the diffusion model;
[0012] 2) Construct a candidate time step set including multiple candidate sampling time points based on the original time step range or the original discrete time step sequence, and set a binary mask variable for at least some of the candidate time steps in the candidate time step set; the intermediate candidate time step is a candidate time step selected at a preset interval between the start time step and the end time step; the binary mask variable is a binary variable that corresponds one-to-one with the intermediate candidate time step in the candidate time step set, the dimension of the binary mask variable is equal to the number of intermediate candidate time steps, and the binary mask variable is used to indicate whether the corresponding candidate time step participates in the inverse denoising sampling;
[0013] 3) The binary mask variable is parameterized into a random mask controlled by a probability vector, so that the selection of candidate time steps is determined by probability parameters; each element in the probability vector is the probability of the corresponding candidate time step being selected, i.e., the Bernoulli distribution parameter, which is used to represent the probability of the corresponding candidate time step participating in inverse denoising sampling.
[0014] 4) Perform backsampling of the diffusion model based on the sampling time step corresponding to the random mask, and construct a loss function for evaluating the quality of time step scheduling based on the sampling results; the loss function is constructed based on evaluation indicators, including the distribution distance between the sampling results and the reference sampling results or the sample quality evaluation indicator, and the loss function is used as a reward signal for the time step scheduling optimization;
[0015] 5) Based on the loss function and the probability distribution of the random mask, the probability vector is updated using the policy gradient estimation method; the policy gradient estimation method updates the mask parameters represented by the probability vector, and only performs forward quality evaluation on the sampling results;
[0016] 6) After the probability vector satisfies the convergence condition or reaches the preset number of iterations, the final sampling time step is determined according to the probability vector, and the diffusion model is sampled in smaller steps based on the final sampling time step.
[0017] In this invention, in step 2), the candidate time step set includes multiple candidate positions in the original time step sequence, and includes a fixed start time step and an end time step; the start time step and the end time step are fixed sampling nodes and do not participate in mask selection; the candidate time step set is initialized according to uniformity rules, signal-to-noise ratio rules, EDM rules or empirical sampling rules.
[0018] For an intermediate candidate time step located between the start time step and the end time step, a binary mask variable is set to obtain the following mask vector:
[0019]
[0020] in, Indicates the first One candidate time step was selected for the sampling process. Indicates the first One candidate time step was skipped during the sampling process. This indicates the number of candidate time steps.
[0021] In this invention, in step 3), the binary mask variable is reparameterized into a Bernoulli random variable:
[0022]
[0023] in, For the first The probability of a candidate time step being selected. Let be a probability vector; the probability vector satisfies the following constraints:
[0024]
[0025] in, Represents a set of constraints. This indicates the target minimum sampling budget or the maximum number of intermediate time steps allowed.
[0026] This step constructs a probabilistic mask reparameterization, modeling the binary mask as a Bernoulli random variable and representing the probability of each candidate time step being selected with a probability vector, thus transforming the original discrete and non-differentiable time step selection problem into a continuous probabilistic parameter optimization problem.
[0027] In this invention, in step 4), the loss function for the time-step scheduling quality is constructed based on the distribution distance between the first sampling result and the second sampling result; wherein, the first sampling result is generated by the trained diffusion model along the few-step time-step sequence corresponding to the random mask, and the second sampling result is generated by the same or different sampling solvers along the reference time-step sequence, and the loss function is expressed as:
[0028]
[0029] in, Represents the noise variable sampled from a standard Gaussian distribution. Take the expected value; This indicates the diffusion model at the start of backsampling. Noise samples; This indicates that the mean vector is 0 and the covariance matrix is the identity matrix. The standard Gaussian distribution Represents the identity matrix. This indicates the parameters of the trained diffusion model. Indicates based on random mask and sampling solver The generated samples, This indicates a solution based on a reference time step sequence and a sampling solver. The generated reference sample, (·) is a distance function used to measure the difference between two sampling results.
[0030] In this invention, in step 5), the optimization objective of the probability vector is:
[0031]
[0032] In the formula, Indicates the distribution from a random mask. Mask obtained by mid-sampling Take the expected value. This represents the random binary mask corresponding to the candidate time step. This represents a probability vector that controls the probability of each candidate time step being selected. This indicates that, given a probability vector Generate random mask under certain conditions The probability distribution, This represents the time-step scheduling optimization objective with probability vector s as the independent variable. This indicates that the gradient of the probability vector s is calculated.
[0033] The gradient of the optimization objective with respect to the probability vector is calculated using the following strategy gradient estimator:
[0034]
[0035] This gradient estimation method only requires forward evaluation of the sampling quality corresponding to the random mask, without needing to perform backpropagation through the complete sampling chain of the diffusion model.
[0036] In this invention, in step 5), the probability vector is updated using projective stochastic gradient descent:
[0037]
[0038] in, For learning rate, This means projecting the probability vector onto the constraint set. The projection operator.
[0039] In this invention, in step 6), after multiple rounds of updates, when the elements in the probability vector approach 0 or 1, an approximately deterministic few-step sampling time step sequence is determined based on the elements in the probability vector that satisfy the preset selection conditions. The preset selection conditions include: selecting several candidate time steps with the highest probability values, or selecting candidate time steps with probability values exceeding a preset threshold.
[0040] The present invention also includes a training sampling consistency constraint step; the training sampling consistency constraint step is used to alleviate the model adaptation bias caused by the diffusion model training phase covering a large number of time steps or a continuous time range, while the inference sampling phase only uses a small number of selected time steps.
[0041] In this invention, the selection of the time step and the lightweight fine-tuning of the diffusion model are constructed as a two-level optimization problem:
[0042]
[0043]
[0044] In the formula, Indicates the real sample Noise variables And the expected value is obtained together with the time step t selected by the mask m; This represents a real sample in the training data; This represents noise sampled from a standard Gaussian distribution; This indicates that the training time steps are sampled from the set of time steps selected by the random mask m. For time-related weighting functions, Represents a neural network. This represents a noisy sample. Indicates diffusion time. Indicates noise variables;
[0045] The outer optimization is used to learn the sampling time step selection probability, while the inner optimization is used to fine-tune the diffusion model parameters at the selected time step corresponding to the random mask.
[0046] In this invention, each round of outer-layer iteration in the two-layer optimization process includes the following steps:
[0047] Based on the current probability vector Sampling yields a random mask ;
[0048] The model parameters from the previous round are used as the initial parameters for the current inner layer optimization, rather than re-initializing the model parameters;
[0049] In the random mask Perform the inner fine-tuning update a preset number of times at the corresponding selected time step;
[0050] The outer approximate gradient is calculated based on the fine-tuned model parameters and the random mask;
[0051] Update the probability vector based on the outer layer approximate gradient. .
[0052] The present invention also provides an adaptive accelerated sampling device for a diffusion model based on probability mask optimization, comprising:
[0053] The model acquisition module is used to acquire the trained diffusion model and the original time step range or original discrete time step sequence corresponding to the diffusion model.
[0054] A candidate time step construction module is used to construct a candidate time step set based on the original time step range or the original discrete time step sequence, and to set a binary mask variable for at least some of the candidate time steps in the candidate time step set. The binary mask variable is used to indicate whether the corresponding candidate time step participates in inverse denoising sampling.
[0055] The probability mask parameterization module is used to parameterize the binary mask variable into a random mask controlled by a probability vector, so that the selection of candidate time steps is determined by probability parameters.
[0056] The sampling quality evaluation module is used to perform backsampling of the diffusion model based on the sampling time step corresponding to the random mask, and to construct a loss function for evaluating the scheduling quality of the time step based on the sampling results;
[0057] The policy gradient update module is used to update the probability vector based on the probability distribution of the loss function and the random mask using the policy gradient estimation method.
[0058] The few-step sampling execution module is used to determine the final sampling time step based on the probability vector after the probability vector satisfies the convergence condition or reaches the preset number of iterations, and to perform the diffusion model few-step sampling based on the final sampling time step.
[0059] Furthermore, the present invention provides an electronic device, including a memory and a processor; the memory stores a computer program, and the processor executes the computer program to implement the steps of the above-described adaptive accelerated sampling method based on probability mask optimization diffusion model.
[0060] Furthermore, the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the above-described adaptive accelerated sampling method for diffusion models based on probability mask optimization.
[0061] Compared with the prior art, the present invention has the following beneficial effects:
[0062] 1. This invention can automatically learn a few sampling time steps suitable for the current diffusion model, data distribution, and sampling solver, reducing reliance on manual time step scheduling rules.
[0063] 2. This invention transforms a high-dimensional discrete combinatorial optimization problem into a continuous probabilistic parameter optimization problem by reparameterizing the probabilistic mask, significantly reducing the difficulty of solving the time step selection problem.
[0064] 3. This invention uses a policy gradient estimator to update the time step selection probability, which only requires forward quality evaluation of the sampling results and does not require backpropagation through the complete diffusion sampling process, making the calculation more efficient.
[0065] 4. The present invention controls the number of selected time steps by sparse constraints, and can obtain an approximately deterministic sequence of few sampling time steps under a preset sampling budget.
[0066] 5. This invention alleviates the problem of inconsistent time step distribution between the training and inference phases of the diffusion model through a two-layer optimization mechanism, enabling the model to better adapt to the selected time steps in scenarios with few sampling steps, thereby improving the quality of few sampling generation.
[0067] 6. This invention does not limit the specific diffusion model structure and sampling solver, and can be used in conjunction with various diffusion model architectures, ODE samplers, DDIM-type samplers and multi-step numerical solvers, thus having good versatility. Attached Figure Description
[0068] Figure 1 This is a comparison of the sampling quality between selected time-step training and full-time-step training.
[0069] Figure 2 This is a comparison of the sampling quality of the present invention with that of the manual time-step scheduling rule.
[0070] Figure 3 It is a comparison of sampling quality under multiple datasets and multiple samplers.
[0071] Figure 4 It is a visual comparison of generated samples under different time step scheduling rules. Detailed Implementation
[0072] The present invention will be further described below with reference to specific embodiments. It should be understood that the following embodiments are only used to explain the present invention and are not intended to limit the scope of protection of the present invention.
[0073] To address the issues of existing diffusion probability models typically requiring numerous inverse denoising iterations and exhibiting slow sampling speeds during image, video, and 3D content generation, and the limitations of existing few-step sampling methods that rely on manually designed time-step scheduling rules and struggle to adapt to different diffusion models and numerical solvers, this invention provides an adaptive accelerated sampling method for diffusion models based on probability mask optimization. This method first constructs a set of candidate sampling time steps and uses a binary mask to represent whether each candidate time step is selected during the sampling process. Furthermore, the binary mask is reparameterized into a Bernoulli random variable controlled by a probability vector, thus transforming the originally discrete, non-directly gradient-optimizable time-step selection problem into a continuous probability parameter optimization problem. Based on the distance between the samples generated by the sampling trajectories corresponding to the random mask and the target sample distribution, a time-step scheduling quality evaluation objective is constructed, and a policy gradient estimator is used to optimize the probability vector to avoid high-cost backpropagation throughout the entire diffusion model sampling process. After optimization, a small number of sampling time steps for diffusion model inference are determined based on the probability vector. Furthermore, to alleviate the inconsistency in training sampling caused by the diffusion model covering a large number or continuous time steps during training and only using a small number of selected time steps during inference, this invention combines time step selection with lightweight model fine-tuning into a two-layer optimization process: the outer layer optimizes the time step selection probability based on generation quality, and the inner layer performs finite-step fine-tuning of the diffusion model based on the time steps determined by the outer layer, enabling the model to better adapt to the selected time steps under conditions of fewer sampling steps. The specific details of this invention are described below.
[0074] (a) Basic representation of the sampling process in the diffusion model
[0075] The diffusion model includes a forward diffusion process and a backward denoising sampling process. Let the real sample be... The diffusion time is The noise variable is Then, the noisy sample during the diffusion process can be represented as:
[0076]
[0077] in, and To keep pace with time The corresponding noise scheduling parameters. The diffusion model uses a neural network. Predict noise, and train it based on the following objectives:
[0078]
[0079] in, This is a time-related weighting function.
[0080] During the inference phase, the diffusion model extracts Gaussian noise. Starting from the selected time step sequence, reverse denoising sampling is performed step by step to finally generate samples. When sampling with a small number of time steps, the choice of time step sequence can significantly affect the generation quality and sampling efficiency.
[0081] (II) Construction of Candidate Time Step Set and Binary Mask
[0082] In one specific implementation, a candidate time step set is first constructed from the original time step range [0,T] or the original discrete time step sequence:
[0083]
[0084] in, Indicates the sampling start point. Indicates the sampling endpoint. For intermediate candidate time steps... Set a binary mask:
[0085]
[0086] when At that time, candidate time step Added to the few-step sampling sequence; when At that time, candidate time step These steps are skipped. Therefore, the sequence of fewer sampling time steps can be determined by the activation positions in the mask.
[0087] The candidate time step set can be initialized according to uniformity rules, signal-to-noise ratio rules, EDM rules, empirical sampling rules, or other preset rules. This invention does not limit the construction method of the candidate time step set.
[0088] (III) Probabilistic Mask Reparameterization
[0089] Because directly from Select from candidate time steps The problem involves multiple time steps, which fall under combinatorial optimization, and its complexity increases rapidly with the number of candidate time steps. To reduce the difficulty of solving this problem, in one specific implementation, this invention reparameterizes the binary mask variable into a Bernoulli random variable:
[0090]
[0091] in, Indicates candidate time step The probability of being selected, the probability vector is:
[0092]
[0093] To control the few-step sampling budget, a sparsity constraint is imposed on the probability vector:
[0094]
[0095] Through the aforementioned reparameterization, time step selection is transformed from discrete mask search into probability vector optimization. As the probability vector gradually converges, some elements approach 1, indicating that the corresponding time step is likely to be selected; some elements approach 0, indicating that the corresponding time step is likely to be skipped.
[0096] (iv) Construction of sampling quality evaluation objectives
[0097] In one specific implementation, based on a random mask The determined sampling time step sequence is sampled using a diffusion model, and the generation quality of the sampling time step sequence is evaluated.
[0098] Let the parameters of the trained diffusion model be... From Gaussian noise Starting with a random mask m and a sampling solver Generate samples:
[0099]
[0100] Meanwhile, based on the reference time step sequence and the sampling solver Generate reference samples:
[0101]
[0102] The following evaluation loss can then be constructed:
[0103]
[0104] in, This is a distance function used to measure the difference between two sampling results. This invention does not limit the specific form of the evaluation function.
[0105] (v) Time-step probability optimization based on policy gradient
[0106] In one specific implementation, the optimization objective of the time step selection probability vector s is:
[0107]
[0108] Due to random mask From probability vector For control, the gradient of the objective function with respect to the probability vector can be estimated using the policy gradient method:
[0109]
[0110] In practical implementation, this can be achieved by analyzing the current probability distribution. One or more random masks are sampled, and corresponding few-step sampling is performed and the evaluation loss is calculated. Then, the product of the evaluation loss and the log probability gradient is used to construct the stochastic gradient estimate.
[0111] Compared to backpropagation through sampling links in a diffusion model, this gradient-based strategy only requires forward evaluation of the generation quality, thus reducing memory usage and backpropagation overhead, making it suitable for time-step scheduling optimization of complex diffusion models.
[0112] (vi) Probability vector projection update and final time step determination
[0113] In one specific implementation, the probability vector s is updated via projective stochastic gradient descent:
[0114]
[0115] in, For learning rate, This is a projection operator used to ensure that the updated probability vector still satisfies... Interval constraints and sampling budget constraints.
[0116] After multiple iterations, the final time step sequence can be determined based on the probability vector. Specifically, several candidate time steps with the highest probability values can be selected, or candidate time steps with probability values exceeding a preset threshold can be selected, and combined with fixed start and end time steps to form the final few-step sampling sequence.
[0117] After obtaining the final few-step sampling sequence, this sequence can be used in the diffusion model inference stage to reduce the number of neural network function evaluations and improve sampling speed.
[0118] (vii) Introduce training sampling consistency constraints
[0119] During the training phase of a diffusion model, the model typically learns a noise prediction function over a large number of discrete time steps or a continuous time range, enabling the model to cover the full noise level. However, in the few-step sampling inference phase, only a small number of time steps are actually used. At this point, the large number of unused time steps learned during training leads to insufficient allocation of computational power, and the continuity and consistency of the trajectories between the selected time steps are not adequately constrained during training.
[0120] Therefore, this invention further introduces training sampling consistency constraints, enabling the model to perform lightweight adaptation on a small number of selected time steps, thereby improving the stability and generation quality of the small-step sampling trajectory.
[0121] This invention constructs the time step selection and lightweight model fine-tuning as a two-level optimization problem:
[0122]
[0123] in, Indicates a random mask The inner optimization objective of the diffusion model parameters after fine-tuning at the corresponding time step is:
[0124]
[0125] In the aforementioned two-layer optimization, the outer layer is used to select a better time step, while the inner layer is used to make the model better fit the time step selected by the outer layer. Since the optimal time step may change under different model parameter states, performing time step selection and model fine-tuning simultaneously can improve the adaptability of the final few-step sampling scheme.
[0126] The two-layer optimization process includes the following steps:
[0127] 1. Initialize the probability vector Diffusion model parameters Inner learning rate Outer learning rate and inner update count .
[0128] 2. In the first In the outer layer iteration, based on the current probability vector Sampling random mask .
[0129] 3. Set the current model parameters As the initial parameters for inner layer fine-tuning, that is:
[0130] 4. In a random mask At the selected time step, sample a small batch of training data and execute... Secondary inner layer fine-tuning update: ,in, This represents the training loss of the diffusion model built based on the selected time step.
[0131] 5. Use the fine-tuned model parameters from the inner layer as the model parameters for the next round: .
[0132] 6. Based on the fine-tuned model parameters and random mask Calculate the approximate gradient of the outer layer:
[0133]
[0134] in, This represents the sampling quality evaluation function obtained based on the current model and the random mask.
[0135] 7. Update the probability vector:
[0136]
[0137] 8. Repeat the above steps until the convergence condition is met or the maximum number of outer iterations is reached.
[0138] In practical applications, inner-layer fine-tuning does not need to converge completely every time; a fixed number of update steps can be used, thereby reducing the computational cost of two-layer optimization.
[0139] This invention does not limit the specific sampling solver. In one embodiment, when using a DDIM-type sampler, updates can be performed based on the selected time step sequence in the following form:
[0140]
[0141] in, and The adjacent sampling time steps are determined by the final mask. In addition to DDIM, this invention can also be used in conjunction with iPNDM, DPM-Solver, DPM-Solver++, Uni-PC, probabilistic flow ODE solvers, or other diffusion model samplers.
[0142] The following are the specific experimental verification results.
[0143] As shown in Figure 1, on the AFHQV2 and CIFAR10 datasets, NCSN++ was used as the diffusion model network structure, and DDIM was used as the sampling solver. After training or fine-tuning the diffusion model only at selected time steps, a lower FID value was achieved compared to the model trained at all time steps under the same sampling step condition. Since a lower FID value indicates that the generated sample distribution is closer to the real sample distribution, this result demonstrates that when using fewer sampling steps in the inference phase, concentrating the model training process on selected time steps can alleviate the problem of inconsistent time step distribution between the training and sampling phases, thereby improving the quality of fewer sampling steps. This verifies that the training sampling consistency constraint in this invention can improve the quality of fewer sampling steps.
[0144] As shown in Figure 2, on the CIFAR10 dataset, the time-step sequence learned by this invention is compared with manually scheduled rules such as uniform time step, LogSNR time step, and EDM time step. Under the DDIM sampler and iPNDM sampler, this invention achieves lower FID values with the same NFE budget. For example, with an NFE of 4, the FID of this invention in the DDIM sampler is significantly lower than that of uniform, LogSNR, and EDM scheduling; in the iPNDM sampler, this invention also significantly outperforms the aforementioned manually scheduled time step rules. This result indicates that manually designed time-step scheduling is difficult to adapt to different samplers simultaneously, while this invention, through adaptive learning of time steps using probability masks, can obtain a fewer-step sampling sequence that is more suitable for the current model and sampler.
[0145] As shown in Figure 3, experiments were conducted on multiple image generation datasets, including CIFAR10, ImageNet, FFHQ, and AFHQv2, combining the present invention with DDIM and iPNDM samplers, and compared with various optimized time step selection methods. Experimental results show that the present invention is highly competitive across different datasets, samplers, and NFE budgets; further, with lightweight fine-tuning, the present invention can typically continue to reduce the FID value. These results demonstrate that the present invention is not dependent on a specific dataset or sampler, but can be used as a general framework for few-step sampling optimization of diffusion models.
[0146] As shown in Figure 4, NCSN++ is used as the diffusion model network structure, and a candidate time step set is constructed within the EDM diffusion model framework. Figure 4(a) shows the DDIM sampling solver on the FFHQ dataset with an NFE of 7; Figure 4(b) shows the iPNDM sampling solver on the ImageNet dataset with an NFE of 7. Under the same number of sampling steps, the samples generated by different time step scheduling rules show significant differences in visual quality. Compared to uniform time steps, LogSNR time steps, and EDM time steps, the time step sequence learned in this invention can generate clearer, more structurally stable, and more detailed samples. This visualization result is consistent with the aforementioned FID metric results, further demonstrating that this invention can maintain or improve the generation quality while reducing the number of sampling steps in the diffusion model.
[0147] In summary, this invention proposes an adaptive accelerated sampling method for diffusion models based on probabilistic mask optimization. This method automatically learns fewer sampling time steps through probabilistic mask reparameterization and policy gradient optimization, and alleviates the inconsistency in time step distribution between the training and inference phases of the diffusion model through a two-layer optimization mechanism. This method is adaptable to various diffusion models and sampling solvers, improving generation quality while reducing the number of sampling steps and increasing inference efficiency, thus possessing significant engineering application value.
Claims
1. An adaptive accelerated sampling method for a diffusion model based on probability mask optimization, characterized in that, The method is used for the reverse denoising sampling process of a diffusion model; it includes the following steps: 1) Obtain the trained diffusion model and the original time step range or original discrete time step sequence corresponding to the diffusion model; 2) Construct a candidate time step set including a fixed start time step and an end time step based on the original time step range or the original discrete time step sequence, and set a binary mask variable for the intermediate candidate time step in the candidate time step set. The binary mask variable is used to indicate whether the corresponding candidate time step participates in the reverse denoising sampling. 3) The binary mask variable is parameterized into a random mask controlled by a probability vector, where each element in the probability vector is the probability that the corresponding candidate time step is selected to participate in the reverse denoising sampling; 4) Perform backsampling of the diffusion model based on the sampling time step corresponding to the random mask, and construct a loss function for evaluating the scheduling quality of the time step based on the sampling results; 5) Based on the loss function and the probability distribution of the random mask, update the probability vector using policy gradient estimation; 6) After the probability vector satisfies the convergence condition or reaches the preset number of iterations, determine the final sampling time step based on the probability vector, and perform the diffusion model small-step sampling based on the final sampling time step.
2. The adaptive accelerated sampling method for diffusion models based on probability mask optimization according to claim 1, characterized in that, In step 2), the candidate time step set is initialized according to the uniformity rule, signal-to-noise ratio rule, EDM rule, or empirical sampling rule; a binary mask variable is set for the intermediate candidate time steps, resulting in the following mask vector: ; in, Indicates the first One candidate time step was selected for the sampling process. Indicates the first One candidate time step was skipped during the sampling process. This indicates the number of candidate time steps.
3. The adaptive accelerated sampling method for diffusion models based on probability mask optimization according to claim 2, characterized in that, In step 3), the binary mask variable is reparameterized into a Bernoulli random variable: ; In the formula, For the first The probability of a candidate time step being selected. It is a probability vector; The probability vector satisfies the following constraints: ; In the formula, Represents a set of constraints. This indicates the target minimum sampling budget or the maximum number of intermediate time steps allowed.
4. The adaptive accelerated sampling method for diffusion models based on probability mask optimization according to claim 3, characterized in that, In step 4), the loss function is expressed as: ; In the formula, Represents the noise variable sampled from a standard Gaussian distribution. Take the expected value. This indicates the diffusion model at the start of backsampling. noise samples, This indicates that the mean vector is 0 and the covariance matrix is the identity matrix. The standard Gaussian distribution Represents the identity matrix. This indicates the parameters of the trained diffusion model. Indicates based on random mask and sampling solver The generated samples, This indicates a solution based on a reference time step sequence and a sampling solver. The generated reference sample, (·) is a distance function used to measure the difference between two sampling results.
5. The adaptive accelerated sampling method for diffusion models based on probability mask optimization according to claim 4, characterized in that, In step 5), the optimization objective of the probability vector is: ; In the formula, Indicates the distribution from a random mask. Mask obtained by mid-sampling Take the expected value. This represents the random binary mask corresponding to the candidate time step. This represents a probability vector that controls the probability of each candidate time step being selected. This indicates that, given a probability vector Generate random mask under certain conditions The probability distribution, This represents the time-step scheduling optimization objective with probability vector s as the independent variable. This indicates that the gradient of the probability vector s is calculated. The gradient of the optimization objective with respect to the probability vector is calculated using the following strategy gradient estimator: ; This strategy uses gradient estimation to perform forward evaluation of the sampling quality corresponding to the random mask, without performing backpropagation on the complete sampling chain of the diffusion model.
6. The adaptive accelerated sampling method for diffusion models based on probability mask optimization according to claim 5, characterized in that, The probability vector is updated using projective stochastic gradient descent: ; in, For learning rate, This means projecting the probability vector onto the constraint set. The projection operator; After multiple rounds of updates, when the elements in the probability vector approach 0 or 1, an approximately deterministic few-step sampling time step sequence is determined based on the elements in the probability vector that satisfy the preset selection conditions.
7. The adaptive accelerated sampling method for diffusion models based on probability mask optimization according to claim 1, characterized in that, It also includes a training sampling consistency constraint step, which is used to mitigate the model adaptation bias caused by the diffusion model training phase covering a large number of time steps or a continuous time range, while the inference sampling phase only uses a small number of selected time steps.
8. The adaptive accelerated sampling method for diffusion models based on probability mask optimization according to claim 7, characterized in that, The time step selection and the diffusion model are lightly fine-tuned to construct a two-level optimization problem: ; ; In the formula, Indicates the real sample Noise variables And the expected value is obtained together with the time step t selected by the mask m. This represents the real samples in the training data. This represents noise sampled from a standard Gaussian distribution. This indicates that the training time steps are sampled from the set of time steps selected by the random mask m. For time-related weighting functions, Represents a neural network. This represents a noisy sample. Indicates diffusion time. Indicates noise variables; The outer optimization is used to learn the sampling time step selection probability, while the inner optimization is used to fine-tune the diffusion model parameters at the selected time step corresponding to the random mask.
9. The adaptive accelerated sampling method for diffusion models based on probability mask optimization according to claim 8, characterized in that, In the two-layer optimization process, each outer iteration includes the following steps: Based on the current probability vector Sampling yields a random mask ; The parameters from the previous model round are used as the initial parameters for the current inner layer optimization; In the random mask Perform the inner fine-tuning update a preset number of times at the corresponding selected time step; The outer approximate gradient is calculated based on the fine-tuned model parameters and the random mask; Update the probability vector based on the outer layer approximate gradient. .
10. An adaptive accelerated sampling device for a diffusion model based on probability mask optimization, characterized in that, include: The model acquisition module is used to acquire the trained diffusion model and the original time step range or original discrete time step sequence corresponding to the diffusion model. The candidate time step construction module is used to construct a candidate time step set including a fixed start time step and an end time step based on the original time step range or the original discrete time step sequence, and to set a binary mask variable for the intermediate candidate time step in the candidate time step set. The binary mask variable is used to indicate whether the corresponding candidate time step participates in the inverse denoising sampling. The probability mask parameterization module is used to parameterize the binary mask variable into a random mask controlled by a probability vector, so that the selection of candidate time steps is determined by probability parameters. The sampling quality evaluation module is used to perform backsampling of the diffusion model based on the sampling time step corresponding to the random mask, and to construct a loss function for evaluating the scheduling quality of the time step based on the sampling results; The policy gradient update module is used to update the probability vector based on the probability distribution of the loss function and the random mask using a policy gradient estimation method. The few-step sampling execution module is used to determine the final sampling time step based on the probability vector after the probability vector satisfies the convergence condition or reaches the preset number of iterations, and to perform the diffusion model few-step sampling based on the final sampling time step.
