Class DiffusionMemoryConfig
Configuration for diffusion model memory management.
public class DiffusionMemoryConfig
- Inheritance
-
DiffusionMemoryConfig
- Inherited Members
Properties
CheckpointEveryNLayers
Number of layers between checkpoints.
public int CheckpointEveryNLayers { get; set; }
Property Value
Remarks
Smaller values = more checkpoints = less recomputation but more memory. Larger values = fewer checkpoints = more recomputation but less memory. Default of 2 is a good balance for most models.
Default
Creates a default configuration for single-GPU training.
public static DiffusionMemoryConfig Default { get; }
Property Value
MaxPoolMemoryMB
Maximum memory for activation pool in MB.
public long MaxPoolMemoryMB { get; set; }
Property Value
MaxTensorsPerSize
Maximum tensors per size class in the pool.
public int MaxTensorsPerSize { get; set; }
Property Value
MemoryEfficient
Creates a memory-efficient configuration with aggressive checkpointing.
public static DiffusionMemoryConfig MemoryEfficient { get; }
Property Value
NumDevices
Number of devices for model sharding.
public int NumDevices { get; set; }
Property Value
Remarks
Set to 1 for single-GPU/CPU training. Set to higher values for multi-GPU training.
ShardingStrategy
Strategy for distributing layers across devices.
public ShardingStrategy ShardingStrategy { get; set; }
Property Value
SpeedOptimized
Creates a speed-optimized configuration with less checkpointing.
public static DiffusionMemoryConfig SpeedOptimized { get; }
Property Value
UseActivationPooling
Whether to use activation pooling.
public bool UseActivationPooling { get; set; }
Property Value
UseGradientCheckpointing
Whether to use gradient checkpointing.
public bool UseGradientCheckpointing { get; set; }
Property Value
Remarks
For Beginners: Enable this to reduce memory usage by about 50% at the cost of about 30% more computation time.
UsePipelineParallelism
Whether to use pipeline parallelism for overlapping compute and transfer.
public bool UsePipelineParallelism { get; set; }
Property Value
Methods
MultiGpu(int)
Creates a multi-GPU configuration.
public static DiffusionMemoryConfig MultiGpu(int numDevices)
Parameters
numDevicesintNumber of GPUs.