Mastering Diffusion Models from Scratch: From Theory to DiT Source Code to Publishing Papers

Learn diffusion models theory-first, then source code; master DiT source code before pursuing innovation.
The article presents a systematic learning path for diffusion models: first clarify the theory of forward diffusion and reverse generation, then read source code line by line through lightweight toolkits like DiT to connect formulas with code, and finally innovate in directions like model acceleration, lightweighting, and architecture optimization. The author stresses that model improvements without source-code practice are castles in the air, and that theory and code form a closed loop—theory gives the coordinate system for understanding code, and code validates theory. This path suits zero-foundation learners or those stuck at "can run code but can't modify models," while noting that depth should be gauged individually.
Diffusion models have been hot for several years now. From going viral across the internet in 2022 and 2023, with top-conference papers everywhere, to a slight cooling of enthusiasm today, they remain a core hot direction for paper innovation and model improvement. The problem is that many students get off on the wrong foot from the very beginning: either they grind through impenetrable theory they can't understand, or they can only run open-source code without any grasp of the underlying logic—and when it comes to modifying models or doing innovation, they have no idea where to start.
An AI-focused creator on Bilibili shared a complete "theory—source code—innovation" learning workflow, with a clear central thesis: understand the principles first, thoroughly master the source code, and only then talk about innovation and publishing papers. Model improvements that skip source-code practice are castles in the air. This path works equally well for zero-foundation learners. Below we break down the key stages.
Step 1: Build a solid theoretical foundation—don't rush to run code
When learning diffusion models, the theoretical foundation and core mathematical derivations are unavoidable. The creator points out a reality: many people pile sky-high formulas into their papers, yet can't answer when questioned, and get derailed in defense or revision.
But you don't need to dive into complex high-level derivations right away. The key is to clarify the core ideas of diffusion models—how forward diffusion gradually adds noise, and how reverse generation gradually denoises—and thoroughly master the overall basic framework. This is the foundation for later reading source code and doing innovation.

During the theory stage, you also need to selectively read high-quality papers closely, focusing on mainstream improvement approaches such as model acceleration, lightweighting, and architecture optimization. Getting a clear picture of commonly used innovation ideas gives you a sense of direction for research later, so you won't open a paper list and have no idea where to start reading.

Forward diffusion and reverse generation are the two core processes of diffusion models. Forward diffusion is a fixed Markov chain that gradually adds Gaussian noise to data (such as images); after T steps the data becomes approximately pure noise. Reverse generation learns a denoising network that starts from pure noise, gradually predicts and removes noise, and ultimately generates clear samples. Understanding the mathematical forms of these two processes (such as noise scheduling and the reparameterization trick) is a prerequisite for understanding the loss function and sampling loop in the source code, and also the basis for subsequent innovations like model acceleration and lightweighting.
Step 2: Get hands-on with source code using lightweight toolkits
The pitfall beginners fall into most easily is trying to chew through huge and complex open-source projects right away, only to be scared off. The creator's top recommended entry tool is the DiT (Diffusion Transformer) toolkit—a core tool with very high usage in the industry, bundled with many ready-to-use open-source models, highly adaptable, and with concise, clear source code that is perfect for beginners to compare line by line and debug.
More practically: for your own projects, model modifications, and innovation later on, this toolkit can be used directly—so your learning investment won't be wasted.

The right way to practice is to take the principles, acceleration optimization, and lightweight improvement knowledge from the theory stage and go through the DiT source code line by line. Mathematical formulas you don't understand, algorithm flows you can't sort out, experimental logic you can't connect—all get closed out through hands-on source-code practice. Master two or three core codebases first, fully trace through the algorithm logic, and thoroughly understand the essence of diffusion models; then when you go on to advanced algorithm design, landing your own innovations, and research projects, the difficulty will be cut in half.

DiT (Diffusion Transformer) is a work that introduces the Transformer architecture into diffusion models. It replaces the traditional U-Net with a Transformer as the denoising backbone network, and shows excellent scalability on image generation tasks. The DiT toolkit typically provides pretrained models, training scripts, and concise modular code, suitable for learners to compare theoretical formulas with code implementation line by line. Since the Transformer architecture is widely used in today's research, starting with DiT both lowers the barrier to understanding and keeps you on the cutting edge.
Why this path is worth referencing
There are plenty of diffusion model tutorials on the market. The value of this workflow is that it exposes a common misconception: treating "reading papers" and "running code" as two parallel lines. What the creator emphasizes is a closed loop—theory provides the coordinate system for understanding source code, and source code in turn validates and consolidates theory. Only by feeding each other can you know, when modifying a model, what mathematical meaning each line of change corresponds to.
Another layer of value is pragmatism in tool selection. As a combination of the Transformer architecture and diffusion models, DiT itself is a hot direction in current research. Starting from it both lowers the barrier for beginners and keeps you from going off course.
It should be noted that this workflow leans toward learning-path planning. The depth of each stage (for example, how far to push mathematical derivations, how closely to read the source code) still needs to be gauged by individuals based on their own background and paper direction. The creator also mentions having put together a curated collection of top-conference diffusion model papers, principle-explanation videos, and a full set of runnable source code, covering the complete chain from theory learning and source-code practice to innovation ideas; those who need it can contact them.
For zero-foundation learners who want to get started with diffusion models, or those stuck at the stage of "can run code but can't modify models," first clarifying the framework of forward diffusion and reverse generation, then mapping formulas to code in the DiT source code, is a route worth following.
Model acceleration, lightweighting, and architecture optimization are key challenges in deploying diffusion models. Model acceleration aims to reduce sampling steps (such as DDIM and distillation methods), lightweighting focuses on reducing parameter count and computation (such as pruning and quantization), and architecture optimization explores more efficient network architectures (such as DiT and U-ViT). Reading papers closely in these directions helps you understand current mainstream innovation ideas and provides references for improving models or designing new methods later.
One-line Summary
When learning diffusion models, do theory first and source code second; master DiT source code before talking about innovation.
Paragraph Summary
The article introduces a systematic learning path for diffusion models, with the core thesis that you should first clarify the theoretical framework of forward diffusion and reverse generation, then read source code line by line through lightweight toolkits like DiT to map formulas to code, and finally innovate based on directions such as model acceleration, lightweighting, and architecture optimization. The author emphasizes that model improvements skipping source-code practice are castles in the air, and points out that theory provides the coordinate system for understanding source code while source code in turn validates theory, forming a closed loop. This path is especially suitable for zero-foundation learners or those stuck at the "can run code but can't modify models" stage, while noting that the specific depth should be gauged by individuals based on their own background.
Related articles

Domestic AI Coding Plans Compared: How to Choose Between Zhipu, Kimi, and MiniMax
Compare Zhipu GLM Coding Plan, Kimi Code, and MiniMax M-Plan on pricing, points/quota rules, and model changes, plus scenario-based selection advice.

JetBrains Open-Sources AI IDE ThinkRail: Multi-Workspace Parallelism and Spec-Driven Development
ThinkRail is an open-source agentic IDE from the JetBrains Innovation Hub built on Pi, featuring multi-workspace parallelism, Git worktree isolation, spec-driven development, and diff review. Completely free under Apache 2.0.

Higgsfield: How AI Video Is Moving from the 1-Minute to the 10-Minute Era
Higgsfield shares AI video breakthroughs from 1 minute to over 10 minutes, covering Astra's text rendering, external tool use for 3D modeling, voice-to-movie, and productivity gains for small creative teams.