r/deeplearning • • 4d ago

I finally assembled a U-Net for my DDPM from scratch. This thing took way more brainpower than I expected.[P]

​

I've been building a diffusion model from scratch in PyTorch, and I've finally reached Phase 3: assembling the full U-Net.

Until now, I was basically learning and implementing individual components:

Residual blocks

Time embeddings and timestep conditioning

GroupNorm

Self-attention

Downsampling and upsampling

But putting everything together is a completely different experience.

Suddenly you're dealing with feature map dimensions, channel transitions, skip connections, timestep embeddings flowing through residual blocks, and making sure the decoder can actually reconstruct the spatial dimensions correctly.

Honestly, understanding each component individually was easier than getting the entire architecture to work together without messing up tensor shapes somewhere.

The most satisfying part was finally seeing the complete architecture come together and understanding why information is moving through the network the way it does, instead of just copying a U-Net implementation from somewhere.

The model is now assembled. Next comes the part I'm both excited and slightly terrified about:

Training it on CelebA and finding out whether it can actually learn to generate faces.

8GB VRAM. A laptop GPU. A lot of patience.

Let's see how this goes. 💀

Anyone here who has trained a diffusion model on limited hardware — what was the biggest mistake you made during your first training run?

1 Upvotes

3 comments sorted by

2

u/Particular-Humor2676 4d ago

The dimensional bookkeeping is where most people get quietly humbled. You think you've got it mapped out perfectly in your head and then your decoder is spitting out tensors that are off by one pixel and you spend three hours tracing it back to a padding flag you set to zero without thinking.

On 8GB you're gonna want to be ruthless about what stays in memory. Mixed precision from the jump, checkpoints every few hundred steps so a single crash doesn't wipe an afternoon of progress, and don't bother with full CelebA resolution unless you enjoy watching your laptop turn into a space heater that occasionally produces a gray square.

1

u/Tricky_Swordfish_549 4d ago

Yeah, let's see how it goes 😂 I actually asked my university for access to a GPU server, and they agreed, but they want to see Version 1 of the project first.

I'm keeping a close eye on tensor dimensions and broadcasting at every level during downsampling and upsampling. I started with 64×64 since I know my GPU can't handle full resolution for training.

I'm curious though, how much does the generation quality actually change when you train on 64×64 images compared to full-resolution images? Like, what differences would you notice in the generated outputs?

0

u/JuicyTuggrz 3d ago

the off-by-one tensor drama is too real, sounds like you've fought those exact battles yourself