Table of Contents

Class DiffusionMemoryConfig

Namespace
AiDotNet.Diffusion.Memory
Assembly
AiDotNet.dll

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

int

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

DiffusionMemoryConfig

MaxPoolMemoryMB

Maximum memory for activation pool in MB.

public long MaxPoolMemoryMB { get; set; }

Property Value

long

MaxTensorsPerSize

Maximum tensors per size class in the pool.

public int MaxTensorsPerSize { get; set; }

Property Value

int

MemoryEfficient

Creates a memory-efficient configuration with aggressive checkpointing.

public static DiffusionMemoryConfig MemoryEfficient { get; }

Property Value

DiffusionMemoryConfig

NumDevices

Number of devices for model sharding.

public int NumDevices { get; set; }

Property Value

int

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

ShardingStrategy

SpeedOptimized

Creates a speed-optimized configuration with less checkpointing.

public static DiffusionMemoryConfig SpeedOptimized { get; }

Property Value

DiffusionMemoryConfig

UseActivationPooling

Whether to use activation pooling.

public bool UseActivationPooling { get; set; }

Property Value

bool

UseGradientCheckpointing

Whether to use gradient checkpointing.

public bool UseGradientCheckpointing { get; set; }

Property Value

bool

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

bool

Methods

MultiGpu(int)

Creates a multi-GPU configuration.

public static DiffusionMemoryConfig MultiGpu(int numDevices)

Parameters

numDevices int

Number of GPUs.

Returns

DiffusionMemoryConfig