How aailabkaist/tdsm works
Main Components
• Data Preparation Module
– Represented by dataset_tool.py, which handles the conversion of standard datasets (e.g., CIFAR-10) into the specialized noisy labeled ZIP format (with a dataset.json for metadata).
• Model Training Components
– Two primary training scripts: train_classifier.py for classifier training and train_noise.py for the diffusion models using the TDSM objective.
– Common modules under the “training” directory handle augmentation (augment.py), loss computations (loss.py), and discrete training loops (training_loop.py, training_noise_loop.py, and classifier_loop.py).
• Utility Components
– The “dnnlib” directory (including util.py) contains utility functions likely used across various parts of the code.
– The “torch_utils” directory provides distributed training support, persistence, miscellaneous utilities, and training stats, which are essential for handling multi-GPU setups.
• Sample Generation
– The generate.py script is used to generate samples using a pre-trained network, indicating a final inference stage in the system.
• Environment and Deployment
– Dockerfile and environment.yml help manage the containerized and conda-based environment settings, ensuring replicability.
Relationships and Interactions
• Data Flow:
– Start with the data preparation module using dataset_tool.py to convert raw datasets into the required format.
– The prepared dataset is then used by the training scripts (train_classifier.py and train_noise.py).
• Model Training Workflow:
– The training scripts rely on several internal modules: the “training” submodules for data handling, loss functions, and network architectures, and the “dnnlib” and “torch_utils” for utilities and distributed support.
– There’s an interaction between the classifier (trained via train_classifier.py) and the diffusion training (train_noise.py) where the trained classifier network is supplied (using the --cls parameter) to adjust the diffusion model’s training.
• Sample Generation:
– After training, generate.py uses the trained score network and a latent noise seed to produce generated samples.
Architectural Patterns and Principles
• Modularity: The project separates different concerns into distinct modules (data handling, utilities, training, and generation). This clear separation makes the overall architecture more maintainable and reusable.
• Distributed/Parallel Training: The torch_utils components and the usage of torchrun with --nproc_per_node indicate that distributed training principles are applied.
• Custom Loss and Training Loops: The use of custom training loops (e.g., training_loop.py, training_noise_loop.py) highlights that the model uses a specialized training procedure (TDSM – Transition-aware weighted Denoising Score Matching), which is a core idea of the paper.
Technologies, Frameworks, and Libraries
• PyTorch (with specific reliance on its distributed training features) is the backbone for model training.
• CUDA is used for leveraging NVIDIA GPUs (Tesla P40 in the experiments).
• Utility libraries in dnnlib and torch_utils provide essential supporting functions.