Nodes/Diffusion_pipe_in_ComfyUI/通用训练设置
ComfyUI Node

通用训练设置

The hub node — every training run in this pack flows through here

By TianDongL·Created 11 months ago·Updated 7 months ago· 69
通用训练设置
  • optimizer_config
  • model_config
  • dataset_config
  • adapter_config
  • advanced_config
  • eval_dataset_config
  • sampler_config
  • train_config
  • output_dir
  • config_path
output_folder_nametraining_output
epochs50
micro_batch_size_per_gpu2
number_of_gpus1
pipeline_stages1
gradient_accumulation_steps1
gradient_clipping1.0
warmup_steps500
blocks_to_swap20
activation_checkpointingtrue
save_dtypebfloat16
partition_methodparameters
eval_every_n_epochs1
eval_before_first_steptrue
eval_micro_batch_size_per_gpu1
eval_gradient_accumulation_steps1
save_every_n_epochs1
checkpoint_every_n_minutes120
caching_batch_size1
disable_block_swap_for_evalfalse
video_clip_modenone

If the model nodes are the engine and the dataset nodes are the fuel, GeneralConfig is the dashboard you sit at before you turn the key. It's the node that collects every other config - model, dataset, optimizer, adapter, eval - and turns them into the actual TOML file the diffusion-pipe trainer runs. The whole pack is shaped like a funnel, and this node is the neck. Understand it and you understand the pack.

What it takes

Four required inputs are wire-in, not type-in: optimizer_config (from OptimizerConfigNode), model_config (from any model node), and dataset_config (from GeneralDatasetConfig). Plus output_folder_name - the name of the folder created under ComfyUI's output/ directory for this run's artifacts.

Then the hyperparameters. The ones you'll actually touch as a beginner:

  • epochs (default 50) - training rounds. Keep it but watch your eval curve; more isn't automatically better.
  • micro_batch_size_per_gpu (default 2) - the smallest batch unit, per GPU. This is the knob you lower when you OOM. Modern architectures dislike tiny effective batches (the KB's Flux-2-era note: "Klein 9b hates small batch sizes"), so combine it with gradient accumulation rather than just dropping it to 1.
  • gradient_accumulation_steps (default 1) - effective batch = micro batch × accumulation × GPUs. Raise this to grow effective batch without OOM.
  • number_of_gpus and pipeline_stages (both default 1) - set GPUs to your hardware; pipeline_stages is how many GPUs the model is split across and should match your GPU count for pipeline parallelism.
  • blocks_to_swap (default 20) - how many transformer blocks get offloaded to CPU RAM to save VRAM. Bigger swap = lower VRAM, slower training. Tune against your OOM errors.
  • activation_checkpointing (default on) - recomputes activations to save memory; the tooltip says "usually enable." Leave it on.
  • warmup_steps (default 500), gradient_clipping (1), save_dtype (bfloat16), partition_method (parameters) - set once, rarely revisit.

The optional inputs are where the rest of the pack hooks in: adapter_config (from AdapterConfigNode - required for any LoRA run!), advanced_config (from AdvancedTrainConfig), eval_dataset_config (from EvalDatasetConfig), sampler_config, and the eval-frequency and save-frequency controls (eval_every_n_epochs, save_every_n_epochs, checkpoint_every_n_minutes, caching_batch_size, video_clip_mode, and friends).

What comes out

Three outputs. train_config (type TRAIN_CONFIG) and config_path both feed the Train node - the config_path is the written trainconfig.toml the trainer actually reads. output_dir (a plain STRING) is where your run lands inside ComfyUI's output/ folder.

How it works

Under the hood it's a TOML serializer with an opinionated memory strategy. It creates the output folder, writes every setting into trainconfig.toml, folds in your optimizer/model/dataset/adapter/eval configs, and hands the Train node everything it needs to spawn the real diffusion-pipe subprocess (with TensorBoard monitoring on top). Nothing trains until Train runs - this node just makes sure the config file is coherent first.

Installing the pack

Linux/WSL2 only, submodules mandatory:

cd ComfyUI/custom_nodes/
git clone --recurse-submodules https://github.com/TianDongL/Diffusion_pipe_in_ComfyUI.git
git submodule update
pip install -r Diffusion_pipe_in_ComfyUI/requirements.txt

Common issues

The recurring one from the community: the trainer seems to ignore your settings and uses defaults. That's almost always the config-path wiring - make sure the config_path output actually reaches Train, and remember the pack's WSL2 path convention (Z:/..., not /mnt/z/...) for everything you type. And a missing adapter_config means no adapter - "LoRA not applying" is usually just this.

CategoryDiffusion-Pipe/Config

Inputs (28)

NameTypeDefaultDescription
output_folder_nameSTRINGtraining_output输出文件夹名称,将自动创建在 @output/ 目录下
optimizer_configOPTIMIZER_CONFIG优化器配置
model_configmodel_config模型配置(来自模型配置节点)
dataset_configDATASET_CONFIG数据集配置(来自数据集配置节点)
epochsINT501–1000训练轮数
micro_batch_size_per_gpuINT21–32每个GPU的微批次大小
number_of_gpusINT11–8GPU 数量
pipeline_stagesINT11–8管道并行阶段数,将模型拆分到的 GPU 数量,应与 GPU 数量匹配
gradient_accumulation_stepsINT11–64梯度累积步数
gradient_clippingFLOAT1.01–10梯度裁剪阈值
warmup_stepsINT5000–5000学习率预热步数
blocks_to_swapINT200–80要交换的块数量
activation_checkpointingBOOLEANtrue激活检查点,节省显存,通常启用
save_dtypeCOMBObfloat16保存模型时的数据类型
partition_methodCOMBOparameters分区方法
adapter_configoptADAPTER_CONFIG适配器配置(可选,用于LoRA等适配器训练)
advanced_configoptADVANCED_TRAIN_CONFIG高级训练配置(可选,来自AdvancedTrainConfig节点)
eval_every_n_epochsoptINT10–100每N个epoch评估一次,0表示不评估
eval_before_first_stepoptBOOLEANtrue是否在第一步之前评估
eval_micro_batch_size_per_gpuoptINT11–32评估时每个GPU的微批次大小
eval_gradient_accumulation_stepsoptINT11–64评估时的梯度累积步数
save_every_n_epochsoptINT10–100每N个epoch保存一次,0表示禁用
checkpoint_every_n_minutesoptINT1200–1440每N分钟保存检查点,0表示禁用
caching_batch_sizeoptINT11–32预缓存时的批次大小,影响内存使用
disable_block_swap_for_evaloptBOOLEANfalse评估时是否禁用块交换
video_clip_modeoptCOMBOnone仅适用于视频模型训练。视频帧提取模式 - none:不使用视频模式, single_beginning:从视频开头提取一个片段, single_middle:从视频中间提取一个片段, multiple_overlapping:提取多个可能重叠的片段覆盖整个视频
eval_dataset_configoptEVAL_DATASET_CONFIG评估数据集配置(可选,来自EvalDatasetConfig节点)
sampler_configoptSAMPLER_CONFIG训练采样器配置(可选,来自TrainingSamplerConfig节点)

Outputs (3)

NameTypeDescription
train_configTRAIN_CONFIG
output_dirSTRING
config_pathconfig_path