search
HomeTechnology peripheralsAIFor $1,890, you can train a decent 1.2 billion parameter diffusion model from scratch.

With only 1890 US dollars and 37 million images, you can train a pretty good diffusion model.

Currently, visual generative models are good at creating realistic visual content, however the cost and effort of training these models from scratch is still high. For example, Stable Diffusion 2.1 took 200,000 A100 GPU hours. Even if researchers use the most advanced method, it still takes more than a month to train on an 8×H100 GPU.

In addition, training large models also poses challenges to data sets. These data are basically in units of hundreds of millions, which also brings challenges to training models.

High training costs and data set requirements create insurmountable obstacles for the development of large-scale diffusion models.

Now, researchers from Sony AI and other institutions have spent only $1,890 to train a good diffusion model, a sparse transformer with 1.16 billion parameters.

For $1,890, you can train a decent 1.2 billion parameter diffusion model from scratch.

  • Paper address: https://arxiv.org/pdf/2407.15811

  • Paper title: Stretching Each Dollar: Diffusion Training from Scratch on a Micro-Budget

  • project (forthcoming) : https://github.com/SonyResearch/micro_diffusion

Specifically, in this work, the author develops a low-cost end-to-end pipeline for text-to-image diffusion model, making the training cost lower than SOTA The model is more than an order of magnitude faster, while not requiring access to billions of training images or proprietary datasets.

The author considered a latent diffusion model based on visual transformer for text to image generation. The main reason is that this method is simple to design and widely used. To reduce the computational cost, the authors exploit the strong dependence of the transformer computational cost on the input sequence size (i.e., the number of patches per image).

The main goal of this article is to reduce the number of effective patches used by the transformer to process each image during the training process. This can be easily achieved by randomly masking out some tokens in the input layer of the transformer.

However, existing masking methods are unable to extend the masking rate beyond 50% without significantly reducing performance, especially at high masking rates where a large portion of the input patch is not observed at all by the diffusion transformer.

In order to alleviate the significant performance degradation caused by masking, the author proposes a deferred masking strategy, in which all patches are preprocessed by a lightweight patch-mixer and then transferred to the diffusion transformer . Patch mixers contain a fraction of the number of parameters found in diffusion transformers.

Compared to naive masking methods, masking after patch mixing allows unmasked patches to retain semantic information about the entire image and enables reliable training of diffusion transformers at very high masking rates while competing with the best existing methods. There is no additional computational cost compared to advanced masking.

The authors also demonstrate that the delayed masking strategy achieves better performance than downsizing (i.e. reducing model size) under the same computational budget. Finally, the authors incorporate recent advances in Transformer architecture, such as layer-by-layer scaling, sparse Transformer using MoE, to improve the performance of large-scale training.

The low-cost training pipeline proposed by the author reduces experimental overhead. In addition to using real images, the authors also considered combining other synthetic images in the training dataset. The combined dataset contains only 37 million images, much less data than most existing large-scale models require.

On this combined dataset, the author trained a 1.16 billion parameter sparse transformer at a cost of $1890 and achieved 12.7 FID in zero-shot generation on the COCO dataset.

It is worth noting that the model trained in this article achieves competitive FID and high-quality generation, while costing only 1/118 of the stable diffusion model and 1/1 of the current state-of-the-art method (costing $28,400) 15.

For $1,890, you can train a decent 1.2 billion parameter diffusion model from scratch.

Introduction to the method

In order to greatly reduce the computational cost, patch masking requires discarding most of the input patches before inputting to the backbone transformer, so that the transformer cannot obtain the information of the masked patch. High masking rates (such as 75% masking rate) can significantly reduce the overall performance of the transformer. Even with MaskDiT, only a weak improvement over naive masking can be observed, since this method also discards most of the image patches in the input layer itself.

Delayed masking, retaining the semantic information of all patches

Since high masking rate will remove most of the valuable learning signals in the image, the author can't help but ask, is it necessary to mask in the input layer? As long as the computational cost remains constant, this is just a design choice and not a fundamental limitation. In fact, the authors discovered a significantly better masking strategy that costs almost the same as the existing MaskDiT method. Since patches come from non-overlapping image regions in the diffusion Transformer, each patch embedding does not embed any information from other patches in the image. Therefore, the authors aim to preprocess patch embeddings before masking so that unmasked patches can embed information from the entire image. They call the preprocessing module patch-mixer.

Use patch-mixer to train diffusion transformer

The author believes that patch-mixer is any neural architecture that can fuse individual patch embeddings. In the transformer model, this goal can naturally be achieved through a combination of attention and feed-forward layers. Therefore, the authors use a lightweight transformer consisting of only a few layers as patch-mixer. After the input sequence tokens are processed by patch-mixer, they mask them (Figure 2e).

For $1,890, you can train a decent 1.2 billion parameter diffusion model from scratch.

Figure 2: Compress patch sequence to reduce computational cost. Since the training cost of a diffusion transformer is proportional to the sequence size (i.e. the number of patches), it is best to reduce the sequence size without degrading performance. This can be achieved by: b) using a larger patch; c) randomly masking a portion of the patch; or d) using MaskDiT, which combines naive masking with additional autoencoding objectives. The authors found that all three methods lead to significant degradation in image generation performance, especially at high masking rates. To alleviate this problem, they proposed a straightforward delayed masking strategy that masks the patch after it has been processed by the patch-mixer. Their approach is similar to naive masking in all aspects except using patch-mixer. Compared to MaskDiT, their method does not require optimization of any surrogate objective and has almost the same computational cost.

Assuming that the mask is a binary mask m, the author uses the following loss function to train the model:

For $1,890, you can train a decent 1.2 billion parameter diffusion model from scratch.

where, M_ϕ is the patch-mixer model and F_θ is the backbone transformer. Note that compared to MaskDiT, the proposed method also simplifies the overall design and does not require additional loss functions or corresponding hyperparameter tuning between the two losses during training. During inference, this method does not mask any patches.

Unmasked fine-tuning

Since an extremely high masking rate will greatly reduce the ability of the diffusion model to learn the global structure of the image and introduce a train-test distribution shift on the sequence size, the author considers doing a small amount after masked pre-training of unmasked fine-tuning. Fine-tuning can also mitigate any generation artifacts caused by using patch masking. Therefore, in previous work, it is crucial to recover performance that drops sharply due to masking, especially when using classifier-free bootstrapping in sampling. However, the authors argue that this is not entirely necessary, as their method achieves comparable performance to baseline unmasked pre-training even with masked pre-training. The authors only use this approach in large-scale training to mitigate any unknown-unknown generation artifacts due to high patch masking.

Using MoE and layer-wise scaling to improve the backbone transformer architecture

The author also leverages innovations in transformer architecture design to improve model performance under computational constraints.

They use hybrid expert layers because they increase the parameters and expressiveness of the model without significantly increasing the training cost. They use a simplified MoE layer based on expert selection routing, where each expert decides which tokens are routed to it, as it does not require any additional auxiliary loss function to balance the load among experts. They also considered layer-wise scaling, which has recently been shown to outperform typical transformers in large language models. This method linearly increases the width of the transformer block, i.e. the hidden layer dimension of the attention and feedforward layers. Therefore, deeper layers in the network are assigned more parameters than earlier layers. The authors believe that since deeper layers in a visual model tend to learn more complex features, using higher parameters in deeper layers will lead to better performance. The authors describe the overall architecture of their proposed diffusion Transformer in Figure 3.

For $1,890, you can train a decent 1.2 billion parameter diffusion model from scratch.

Figure 3: The overall architecture of the diffusion transformer proposed in this article. The authors added a lightweight patch-mixer to the backbone transformer model, which processes all patches in the input image before they are masked. Following the current work, the authors use an attention layer to process caption embeddings, which are then used for conditioning. They use sinusoidal embedding to represent the time step. Their model only denoises unmasked patches, so the diffusion loss (Equation 3 in the paper) is only calculated for these patches. They modified the backbone transformer to use layer-wise scaling on individual layers and mixed expert layers in alternating transformer blocks.

Experiment

The experiment uses two variants of diffusion Transformer (DiT), DiT-Tiny/2 and DiT-Xl/2.

As shown in Figure 4, the delay masking method achieves better performance in multiple metrics. Furthermore, as the masking rate increases, the performance gap widens. For example, at 75% masking rate, naive masking reduces the FID score to 16.5 (lower is better), while our method can achieve 5.03, which is closer to the FID score of 3.79 without masking.

For $1,890, you can train a decent 1.2 billion parameter diffusion model from scratch.

Table 1 shows that the layer-wise scaling method has a better fitting effect in the masking training of diffusion transformer.

For $1,890, you can train a decent 1.2 billion parameter diffusion model from scratch.

Compare different masking strategies. The authors first compare our method with strategies using larger patches. Increasing the patch size from 2 to 4 equates to 75% patch masking. Compared to delayed masking, other methods perform poorly, achieving only 9.38, 6.31 and 26.70 FID, Clip-FID and Clip-score respectively. In comparison, latency masking achieves 7.09, 4.10, and 28.24 FID, Clip-FID, and Clip-score respectively.

For $1,890, you can train a decent 1.2 billion parameter diffusion model from scratch.

The picture below shows the comparison of delayed masking vs. model shrinking to reduce training cost. Until the masking rate reaches 75%, the authors find that delayed masking outperforms network reduction in at least two of three metrics. However, at extremely high masking rates, delayed masking tends to achieve lower performance. This may be caused by the loss of information masked at these ratios being too high.

For $1,890, you can train a decent 1.2 billion parameter diffusion model from scratch.

Table 5 provides details about the model training hyperparameters. The training process is divided into two stages.

For $1,890, you can train a decent 1.2 billion parameter diffusion model from scratch.

Calculate the cost. Table 2 provides a breakdown of the computational costs for each training stage, including training FLOPs and economic costs. Phase 1 and 2 training consumed 56% and 44% of the total computational cost, respectively. The total clock training time of the model on an 8×H100 GPU cluster is 2.6 days, which is equivalent to 6.6 days on an 8×A100 GPU cluster.

For $1,890, you can train a decent 1.2 billion parameter diffusion model from scratch.

For more results, please refer to the original paper.

The above is the detailed content of For $1,890, you can train a decent 1.2 billion parameter diffusion model from scratch.. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
4090生成器:与A100平台相比,token生成速度仅低于18%,上交推理引擎赢得热议4090生成器:与A100平台相比,token生成速度仅低于18%,上交推理引擎赢得热议Dec 21, 2023 pm 03:25 PM

PowerInfer提高了在消费级硬件上运行AI的效率上海交大团队最新推出了超强CPU/GPULLM高速推理引擎PowerInfer。PowerInfer和llama.cpp都在相同的硬件上运行,并充分利用了RTX4090上的VRAM。这个推理引擎速度有多快?在单个NVIDIARTX4090GPU上运行LLM,PowerInfer的平均token生成速率为13.20tokens/s,峰值为29.08tokens/s,仅比顶级服务器A100GPU低18%,可适用于各种LLM。PowerInfer与

思维链CoT进化成思维图GoT,比思维树更优秀的提示工程技术诞生了思维链CoT进化成思维图GoT,比思维树更优秀的提示工程技术诞生了Sep 05, 2023 pm 05:53 PM

要让大型语言模型(LLM)充分发挥其能力,有效的prompt设计方案是必不可少的,为此甚至出现了promptengineering(提示工程)这一新兴领域。在各种prompt设计方案中,思维链(CoT)凭借其强大的推理能力吸引了许多研究者和用户的眼球,基于其改进的CoT-SC以及更进一步的思维树(ToT)也收获了大量关注。近日,苏黎世联邦理工学院、Cledar和华沙理工大学的一个研究团队提出了更进一步的想法:思维图(GoT)。让思维从链到树到图,为LLM构建推理过程的能力不断得到提升,研究者也通

复旦NLP团队发布80页大模型Agent综述,一文纵览AI智能体的现状与未来复旦NLP团队发布80页大模型Agent综述,一文纵览AI智能体的现状与未来Sep 23, 2023 am 09:01 AM

近期,复旦大学自然语言处理团队(FudanNLP)推出LLM-basedAgents综述论文,全文长达86页,共有600余篇参考文献!作者们从AIAgent的历史出发,全面梳理了基于大型语言模型的智能代理现状,包括:LLM-basedAgent的背景、构成、应用场景、以及备受关注的代理社会。同时,作者们探讨了Agent相关的前瞻开放问题,对于相关领域的未来发展趋势具有重要价值。论文链接:https://arxiv.org/pdf/2309.07864.pdfLLM-basedAgent论文列表:

吞吐量提升5倍,联合设计后端系统和前端语言的LLM接口来了吞吐量提升5倍,联合设计后端系统和前端语言的LLM接口来了Mar 01, 2024 pm 10:55 PM

大型语言模型(LLM)被广泛应用于需要多个链式生成调用、高级提示技术、控制流以及与外部环境交互的复杂任务。尽管如此,目前用于编程和执行这些应用程序的高效系统却存在明显的不足之处。研究人员最近提出了一种新的结构化生成语言(StructuredGenerationLanguage),称为SGLang,旨在改进与LLM的交互性。通过整合后端运行时系统和前端语言的设计,SGLang使得LLM的性能更高、更易控制。这项研究也获得了机器学习领域的知名学者、CMU助理教授陈天奇的转发。总的来说,SGLang的

大模型也有小偷?为保护你的参数,上交大给大模型制作「人类可读指纹」大模型也有小偷?为保护你的参数,上交大给大模型制作「人类可读指纹」Feb 02, 2024 pm 09:33 PM

将不同的基模型象征为不同品种的狗,其中相同的「狗形指纹」表明它们源自同一个基模型。大模型的预训练需要耗费大量的计算资源和数据,因此预训练模型的参数成为各大机构重点保护的核心竞争力和资产。然而,与传统软件知识产权保护不同,对预训练模型参数盗用的判断存在以下两个新问题:1)预训练模型的参数,尤其是千亿级别模型的参数,通常不会开源。预训练模型的输出和参数会受到后续处理步骤(如SFT、RLHF、continuepretraining等)的影响,这使得判断一个模型是否基于另一个现有模型微调得来变得困难。无

FATE 2.0发布:实现异构联邦学习系统互联FATE 2.0发布:实现异构联邦学习系统互联Jan 16, 2024 am 11:48 AM

FATE2.0全面升级,推动隐私计算联邦学习规模化应用FATE开源平台宣布发布FATE2.0版本,作为全球领先的联邦学习工业级开源框架。此次更新实现了联邦异构系统之间的互联互通,持续增强了隐私计算平台的互联互通能力。这一进展进一步推动了联邦学习与隐私计算规模化应用的发展。FATE2.0以全面互通为设计理念,采用开源方式对应用层、调度、通信、异构计算(算法)四个层面进行改造,实现了系统与系统、系统与算法、算法与算法之间异构互通的能力。FATE2.0的设计兼容了北京金融科技产业联盟的《金融业隐私计算

220亿晶体管,IBM机器学习专用处理器NorthPole,能效25倍提升220亿晶体管,IBM机器学习专用处理器NorthPole,能效25倍提升Oct 23, 2023 pm 03:13 PM

IBM再度发力。随着AI系统的飞速发展,其能源需求也在不断增加。训练新系统需要大量的数据集和处理器时间,因此能耗极高。在某些情况下,执行一些训练好的系统,智能手机就能轻松胜任。但是,执行的次数太多,能耗也会增加。幸运的是,有很多方法可以降低后者的能耗。IBM和英特尔已经试验过模仿实际神经元行为设计的处理器。IBM还测试了在相变存储器中执行神经网络计算,以避免重复访问RAM。现在,IBM又推出了另一种方法。该公司的新型NorthPole处理器综合了上述方法的一些理念,并将其与一种非常精简的计算运行

制作莫比乌斯环,最少需要多长纸带?50年来的谜题被解开了制作莫比乌斯环,最少需要多长纸带?50年来的谜题被解开了Oct 07, 2023 pm 06:17 PM

自己动手做过莫比乌斯带吗?莫比乌斯带是一种奇特的数学结构。要构造一个这样美丽的单面曲面其实非常简单,即使是小孩子也可以轻松完成。你只需要取一张纸带,扭曲一次,然后将两端粘在一起。然而,这样容易制作的莫比乌斯带却有着复杂的性质,长期吸引着数学家们的兴趣。最近,研究人员一直被一个看似简单的问题困扰着,那就是关于制作莫比乌斯带所需纸带的最短长度?布朗大学RichardEvanSchwartz谈到,对于莫比乌斯带来说,这个问题没有解决,因为它们是「嵌入的」而不是「浸入的」,这意味着它们不会相互渗透或自我

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.