Skip to content

Repository files navigation

Diffusion Steering: Pre-Class Notes

Guided, visual pre-class notes for undergraduates studying generative models, diffusion, flow matching, deterministic sampling, and post-hoc steering. Each chapter asks for a prediction before showing a paired experiment, explains the result in plain language, and leaves one bounded parameter to vary. The same unconditional 2D generator carries the main story before one mechanism is transferred to a pretrained image model.

The maintained notes do not use EPiC layers. This repository began from an EPiC-FM research-code tree because the original toy notebooks lived there; the teaching sequence itself uses small ordinary MLPs.

Reading sequence

# Read with outputs Main idea
00 How noise becomes a sample Separate data, base noise, the learned field, and the sampler
01 Train an unconditional flow Watch local velocity training produce a global flow; use circle and eight-mode transfer checks
02 Deterministic samplers and denoisers Compare Euler, Heun, and RK4 from the same noise, then read velocity as a clean estimate
03 Class-minus-full denoiser correction Denoise held-out MNIST images before constructing the 2D distribution-level correction
04 Objective-gradient guidance Compare timing, strength, endpoint behavior, and inference cost
05 Hidden-feature readout and control Separate probe accuracy from causal activation steering and compare intervention sites
06 Class-minus-full correction in CIFAR-10 EDM Read paired images, one trajectory, and three complementary measurements

The executed snapshots are intended for reading on GitHub. Pause at each Before you run prompt before revealing the next output. The output-free source notebooks remain the canonical code generated by scripts/build_toy_notes.py.

Start with the reading guide. Compact derivations and terminology are in the background notes.

There is no attraction-to-a-point controller in the maintained sequence. A class is represented by examples, fitted distributions, class objectives, or held-out activation directions, never by a chosen target point.

CIFAR-10 image experiment

The toy notes make each mechanism visible. The image experiment then asks whether a distribution-level correction has a measurable effect in a real pretrained nonlinear generator. It uses NVIDIA's official unconditional CIFAR-10 EDM checkpoint, deterministic 18-step sampling, and a class-minus-full PCA denoiser correction. Paired baseline, zero-strength, target-class, and wrong-class rows make the alternatives visible. On final seeds not used to choose the setting, the frozen evaluator's cat rate rose from 6.6% to 41.8% while retaining 70.9% of baseline feature variance. The notebook presents this as measurable partial steering, not reliable class-conditional generation.

Read the CIFAR-10 notebook with outputs, its source notebook, and the experiment contract.

Run the core notes

python -m venv --system-site-packages .venv-toy-notes
source .venv-toy-notes/bin/activate
pip install -r notebooks/toy_data/requirements-notes.txt
python scripts/run_toy_notes.py

Executed copies and an execution report are written to notebooks/toy_data/executed/. The notebook snapshots are published; the machine-specific execution report is ignored. Use the default training budgets for the figures and metrics in the notes; reduced environment-variable overrides are intended only for quick code-path checks.

The CIFAR-10 notebook needs the external assets and GPU environment locked by its manifest. On the UCSD host:

bash scripts/validate_cifar10_edm_bridge_ucsd.sh

Repository layout

  • notebooks/toy_data/: maintained notes, reading material, tests, and shared helpers;
  • notebooks/toy_data/executed/: published snapshots with inline figures and tables;
  • notebooks/toy_data/optional/: manifest and source code for the image experiment;
  • notebooks/toy_data/legacy/: preserved exploratory notebooks that are not part of the reading sequence;
  • scripts/build_toy_notes.py: readable source for the six generated notebooks;
  • scripts/run_toy_notes.py: ordered notebook runner;
  • scripts/validate_toy_notes_ucsd.sh: full core validation on one GPU;
  • scripts/validate_all_notes_ucsd.sh: one UCSD run for the complete 00-06 series;
  • src/, configs/, checkpoints/: retained upstream EPiC-FM research code.

References

About

Guided undergraduate notebooks on diffusion, flow matching, deterministic sampling, and post-hoc generative-model steering, with a validated CIFAR-10 EDM bridge.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages