优化器配置
Pick the optimizer and LR without touching a config file
- optimizer_config
Every training run needs an optimizer, and the optimizer is where the "just use these settings" advice gets messy. OptimizerConfigNode is the node that packages that decision into something you can pick from a dropdown and wire straight into GeneralConfig. It's the difference between editing a TOML by hand and choosing from four well-known options in ComfyUI.
The defaults it ships with are telling: the default optimizer is AdamW8bitKahan, not the Prodigy that dominated the SDXL era. That tracks with where the community landed - the modern training docs describe the old Prodigy-default instinct as an SDXL-era thing, replaced by 8-bit AdamW-family optimizers for the current architectures.
How it works
You pick an optimizer_type and the node assembles the right config dict for it. It doesn't invent parameters - each optimizer gets exactly the fields that make sense for it:
AdamW8bitKahan(default) - 8-bit AdamW with Kahan summation, the VRAM-friendly workhorse. Getslr,betas,weight_decay.adamw_optimi- full-precision AdamW from torch-optimi. Getslr,betas,weight_decay, pluseps.Prodigy- the auto-tuned-LR optimizer. Still getslr,betas,weight_decay(it uses them as starting points).automagic- the "pick the settings for me" option. Onlyweight_decayis passed; the optimizer figures out the rest.
The output, optimizer_config, is an OPTIMIZER_CONFIG wire that feeds into GeneralConfig alongside your model config and dataset config. In the example workflow that's exactly where it goes.
The inputs that matter
optimizer_type- the four-way dropdown above. If you don't know,AdamW8bitKahanis the safe modern default.lr- default2e-5, the single most important number in your run. The modern rule of thumb has drifted from the old SDXL tables; current recipes talk about effective-batch-size-dependent LRs from ~1e-4 down to 2e-5.beta1/beta2- default0.9/0.99. Leave them unless you know why you're changing them.weight_decay- default0.01. Regularization; higher fights overfitting, too high kills learning.
Install
Pack-wide: ComfyUI Manager → search "Diffusion_pipe_in_ComfyUI", or:
cd ComfyUI/custom_nodes
git clone --recurse-submodules https://github.com/TianDongL/Diffusion_pipe_in_ComfyUI.git
cd Diffusion_pipe_in_ComfyUI
git submodule init && git submodule update
pip install -r requirements.txt
The optimizer libraries (torch-optimi, pytorch-optimizer, bitsandbytes) are in the requirements. Linux/WSL2 only.
Where people get burned
The subtle one: some of these optimizers ignore some of the sliders. Set eps on AdamW8bitKahan and it won't be forwarded - that field only ships for adamw_optimi. Likewise automagic ignores your lr entirely. So if you spent ages tuning a number and the run "ignored" it, check whether that optimizer actually consumes it. Also, 2e-5 is a reasonable starting LR but not universal - on the new transformer models, small batch sizes + high LR is exactly the recipe the community warns produces garbage. If you're coming from an old SDXL settings table, read the current guidance before you trust those numbers here.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| optimizer_type | COMBO | AdamW8bitKahan | 优化器类型选择 |
| lropt | FLOAT | 01e-8–1 | 学习率 |
| beta1opt | FLOAT | 0.900–1 | Adam优化器的beta1参数 |
| beta2opt | FLOAT | 0.990–1 | Adam优化器的beta2参数 |
| weight_decayopt | FLOAT | 0.0100–1 | 权重衰减系数 |
| epsopt | FLOAT | 01e-12–0.0001 | Adam 的数值稳定性参数 |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| optimizer_config | OPTIMIZER_CONFIG | — |