krea2: rebalance presets balanced, detail and subtle at the taps' measured RMS

`rebalance` takes a preset's name beside true/false: "balanced", "detail" and "subtle" are
comfyui-krea2-conditioning's presets with renormalize on at multiplier 1, "legacy" is true
(ConditioningKrea2Rebalance's defaults, about 9x the taps' RMS). The node renormalises by
s = sqrt(sum m_t / sum w_t^2 m_t) per prompt, m_t tap t's mean square; the plugin holds s as a
constant per preset, m_t averaged over twenty prompts through krea/Krea-2-Turbo's text encoder
(scripts/krea2_rebalance_calib.py: balanced 0.44109, detail 0.35702, subtle 0.84759; per prompt
s stayed within 1.7 % of it). The gains are fixed per tap, so the presets reuse #187's
chan_affine into te.h2 with their own `mul`, one declared op per preset and tap.

The preset rides in RAD_GEN_COND_REBALANCE_PRESET, bits 8 to 15 of cond_opts beside
RAD_GEN_COND_REBALANCE, which a plugin declares when it has presets; the driver accepts both
bits, and the server refuses a preset's name on a model whose rebalance declares none. A row the
plugin does not know scales nothing. Enum values only, so no ABI bump.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
AlexandClaude Opus 5.5 committed 2026-10-25 10:55:27 +01:00
1 parent 6efffe2a59
commit aa5dfaec19
9 files changed
+252 -47

No files matched your search

+6 -1
View File
@@ -453,8 +453,13 @@ typedef struct RadGenBatch {
/* A request's conditioning options on a COND pass (RadGenBatch::cond_opts). */
enum {
RAD_GEN_COND_REBALANCE = 1 /* the conditioning at the plugin's fixed rebalance gains (the
RAD_GEN_COND_REBALANCE = 1, /* the conditioning at the plugin's fixed rebalance gains (the
* request field `rebalance`; Krea 2: its text taps) */
/* which of the plugin's rebalance presets, beside RAD_GEN_COND_REBALANCE: 0 its default
* gains, Krea 2: 1 balanced, 2 detail, 3 subtle (arch/krea2). A plugin declares these bits in
* RadGeneratorDecl::cond_opts when it has presets. */
RAD_GEN_COND_REBALANCE_PRESET = 0xff00,
RAD_GEN_COND_REBALANCE_PRESET_SHIFT = 8
};
/* An entry's flags on a DENOISE pass. */