Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

fix: floor guidance and CFG at 1 everywhere

Josh Corbett9c8b233867f7
diff --git a/invokeai/backend/architectures/capabilities.py b/invokeai/backend/architectures/capabilities.py
index 070e2f4e5a..cbfccd5619 100644
--- a/invokeai/backend/architectures/capabilities.py
+++ b/invokeai/backend/architectures/capabilities.py
@@ -53,7 +53,10 @@ class ArchitectureFeatures(BaseModel):
)
guidance_label: str = Field(description="What to call the guidance slider: 'CFG' or 'Guidance'.")
guidance_min: float = Field(
- description="Lowest guidance value the denoise node accepts; a smaller one fails at enqueue."
+ description=(
+ "Lowest guidance value the slider offers: 1.0, which is no guidance, or the denoise node's own "
+ "floor where that is higher."
+ )
)
guidance_max: float | None = Field(
default=None,
diff --git a/invokeai/backend/architectures/facets/features.py b/invokeai/backend/architectures/facets/features.py
index 548af9baa4..e15fbbd9bf 100644
--- a/invokeai/backend/architectures/facets/features.py
+++ b/invokeai/backend/architectures/facets/features.py
@@ -77,17 +77,19 @@ class FeaturesFacet(Facet):
otherwise. Today only FLUX sets both (cfg_scale 1.0 meaning "off", guidance 3.5 meaning the
distilled embedding)."""
- guidance_min: float = 0.0
+ guidance_min: float = 1.0
"""Lowest value the guidance slider may offer.
- Pinned to the `ge` of the node field the slider's value is actually sent as -- `guidance` for
- the models whose `guidance_label` says so, `cfg_scale` or `guidance_scale` for the rest -- so a
- test asserts the two agree and the UI cannot offer a number the graph will refuse. 0.0 is the
- default because most denoise nodes constrain neither end, and a slider still starts somewhere.
+ 1.0 means "no guidance" on every sampler, and nothing below it is a value a person picks on
+ purpose -- so 1.0 is the UI's floor everywhere, raised to the node field's `ge` where that is
+ higher. The node field is the one the slider's value is actually sent as: `guidance` for the
+ models whose `guidance_label` says so, `cfg_scale` or `guidance_scale` for the rest. A test
+ asserts the two agree, so the UI cannot offer a number the graph will refuse.
- Anima, ERNIE-Image, Wan and Z-Image are the exceptions: their `guidance_scale` is `ge=1.0`,
- 1.0 meaning "off", with nothing below it. The UI offered 0 and 0.5 for them anyway, and
- `graph.ts` forwarded the value unchanged into an enqueue that failed validation."""
+ Anima, ERNIE-Image, Wan and Z-Image enforce `ge=1.0` on the node itself; SD's `cfg_scale`
+ enforces the same floor through a validator the JSON schema cannot see. The UI used to offer 0
+ and 0.5 for all of them, and `graph.ts` forwarded the value unchanged into an enqueue that
+ failed validation."""
guidance_max: float | None = None
"""Highest value the guidance slider may offer, or None where the node enforces no ceiling.
diff --git a/invokeai/frontend/web/openapi.json b/invokeai/frontend/web/openapi.json
index 63fa48f4f3..d9778ec42f 100644
--- a/invokeai/frontend/web/openapi.json
+++ b/invokeai/frontend/web/openapi.json
@@ -17890,7 +17890,7 @@
"guidance_min": {
"type": "number",
"title": "Guidance Min",
- "description": "Lowest guidance value the denoise node accepts; a smaller one fails at enqueue."
+ "description": "Lowest guidance value the slider offers: 1.0, which is no guidance, or the denoise node's own floor where that is higher."
},
"guidance_max": {
"anyOf": [
diff --git a/invokeai/frontend/web/src/services/api/schema.ts b/invokeai/frontend/web/src/services/api/schema.ts
index af0650ccda..5751b2e307 100644
--- a/invokeai/frontend/web/src/services/api/schema.ts
+++ b/invokeai/frontend/web/src/services/api/schema.ts
@@ -5192,7 +5192,7 @@ export type components = {
guidance_label: string;
/**
* Guidance Min
- * @description Lowest guidance value the denoise node accepts; a smaller one fails at enqueue.
+ * @description Lowest guidance value the slider offers: 1.0, which is no guidance, or the denoise node's own floor where that is higher.
*/
guidance_min: number;
/**
diff --git a/invokeai/frontend/webv2/src/features/generation/core/__fixtures__/architectureCapabilities.json b/invokeai/frontend/webv2/src/features/generation/core/__fixtures__/architectureCapabilities.json
index 9e619a7eff..a3d2541766 100644
--- a/invokeai/frontend/webv2/src/features/generation/core/__fixtures__/architectureCapabilities.json
+++ b/invokeai/frontend/webv2/src/features/generation/core/__fixtures__/architectureCapabilities.json
@@ -65,7 +65,7 @@
},
"dimension_grid": 32,
"guidance_label": "CFG",
- "guidance_min": 0.0,
+ "guidance_min": 1.0,
"guidance_max": null,
"scheduler_set": "standard",
"scheduler_applies_to_graph": false,
@@ -154,7 +154,7 @@
},
"dimension_grid": 16,
"guidance_label": "Guidance",
- "guidance_min": 0.0,
+ "guidance_min": 1.0,
"guidance_max": null,
"scheduler_set": "flow",
"scheduler_applies_to_graph": true,
@@ -198,7 +198,7 @@
},
"dimension_grid": 16,
"guidance_label": "Guidance",
- "guidance_min": 0.0,
+ "guidance_min": 1.0,
"guidance_max": null,
"scheduler_set": "flow",
"scheduler_applies_to_graph": true,
@@ -242,7 +242,7 @@
},
"dimension_grid": 16,
"guidance_label": "Guidance",
- "guidance_min": 0.0,
+ "guidance_min": 1.0,
"guidance_max": null,
"scheduler_set": "flow",
"scheduler_applies_to_graph": true,
@@ -286,7 +286,7 @@
},
"dimension_grid": 16,
"guidance_label": "Guidance",
- "guidance_min": 0.0,
+ "guidance_min": 1.0,
"guidance_max": 20.0,
"scheduler_set": "flow",
"scheduler_applies_to_graph": true,
@@ -327,7 +327,7 @@
},
"dimension_grid": 16,
"guidance_label": "Guidance",
- "guidance_min": 0.0,
+ "guidance_min": 1.0,
"guidance_max": 20.0,
"scheduler_set": "flow",
"scheduler_applies_to_graph": true,
@@ -368,7 +368,7 @@
},
"dimension_grid": 16,
"guidance_label": "Guidance",
- "guidance_min": 0.0,
+ "guidance_min": 1.0,
"guidance_max": 20.0,
"scheduler_set": "flow",
"scheduler_applies_to_graph": true,
@@ -409,7 +409,7 @@
},
"dimension_grid": 16,
"guidance_label": "Guidance",
- "guidance_min": 0.0,
+ "guidance_min": 1.0,
"guidance_max": 20.0,
"scheduler_set": "flow",
"scheduler_applies_to_graph": true,
@@ -450,7 +450,7 @@
},
"dimension_grid": 16,
"guidance_label": "Guidance",
- "guidance_min": 0.0,
+ "guidance_min": 1.0,
"guidance_max": null,
"scheduler_set": "flow",
"scheduler_applies_to_graph": false,
@@ -498,7 +498,7 @@
},
"dimension_grid": 16,
"guidance_label": "CFG",
- "guidance_min": 0.0,
+ "guidance_min": 1.0,
"guidance_max": null,
"scheduler_set": "flow",
"scheduler_applies_to_graph": false,
@@ -550,7 +550,7 @@
},
"dimension_grid": 16,
"guidance_label": "CFG",
- "guidance_min": 0.0,
+ "guidance_min": 1.0,
"guidance_max": null,
"scheduler_set": "flow",
"scheduler_applies_to_graph": false,
@@ -602,7 +602,7 @@
},
"dimension_grid": 32,
"guidance_label": "Guidance",
- "guidance_min": 0.0,
+ "guidance_min": 1.0,
"guidance_max": null,
"scheduler_set": null,
"scheduler_applies_to_graph": false,
@@ -643,7 +643,7 @@
},
"dimension_grid": 16,
"guidance_label": "CFG",
- "guidance_min": 0.0,
+ "guidance_min": 1.0,
"guidance_max": null,
"scheduler_set": "standard",
"scheduler_applies_to_graph": false,
@@ -695,7 +695,7 @@
},
"dimension_grid": 8,
"guidance_label": "CFG",
- "guidance_min": 0.0,
+ "guidance_min": 1.0,
"guidance_max": null,
"scheduler_set": "standard",
"scheduler_applies_to_graph": true,
@@ -739,7 +739,7 @@
},
"dimension_grid": 8,
"guidance_label": "CFG",
- "guidance_min": 0.0,
+ "guidance_min": 1.0,
"guidance_max": null,
"scheduler_set": "standard",
"scheduler_applies_to_graph": true,
@@ -780,7 +780,7 @@
},
"dimension_grid": 16,
"guidance_label": "CFG",
- "guidance_min": 0.0,
+ "guidance_min": 1.0,
"guidance_max": null,
"scheduler_set": "standard",
"scheduler_applies_to_graph": false,
@@ -821,7 +821,7 @@
},
"dimension_grid": 8,
"guidance_label": "CFG",
- "guidance_min": 0.0,
+ "guidance_min": 1.0,
"guidance_max": null,
"scheduler_set": "standard",
"scheduler_applies_to_graph": true,
@@ -865,7 +865,7 @@
},
"dimension_grid": 8,
"guidance_label": "CFG",
- "guidance_min": 0.0,
+ "guidance_min": 1.0,
"guidance_max": null,
"scheduler_set": "standard",
"scheduler_applies_to_graph": true,
diff --git a/invokeai/frontend/webv2/src/features/generation/core/architectureCapabilities.ts b/invokeai/frontend/webv2/src/features/generation/core/architectureCapabilities.ts
index 35ce9af5c7..d5ae040e91 100644
--- a/invokeai/frontend/webv2/src/features/generation/core/architectureCapabilities.ts
+++ b/invokeai/frontend/webv2/src/features/generation/core/architectureCapabilities.ts
@@ -126,7 +126,7 @@ export const toBaseGenerationConfig = (row: ArchitectureCapabilitiesRow): BaseGe
// `??` like every sibling here: a backend that predates these fields would otherwise put
// `undefined` into a `number`, and `Math.max(undefined, value)` is NaN -- a broken thumb rather
// than the unbounded control this had before the fields existed.
- guidance: { min: features.guidance_min ?? 0, max: features.guidance_max ?? null },
+ guidance: { min: features.guidance_min ?? 1, max: features.guidance_max ?? null },
negativePrompt: features.negative_prompt,
ui: {
sdVaeOverride: features.sd_vae_override,
diff --git a/invokeai/frontend/webv2/src/features/generation/core/baseGenerationPolicies.ts b/invokeai/frontend/webv2/src/features/generation/core/baseGenerationPolicies.ts
index f1284e1939..063c60129b 100644
--- a/invokeai/frontend/webv2/src/features/generation/core/baseGenerationPolicies.ts
+++ b/invokeai/frontend/webv2/src/features/generation/core/baseGenerationPolicies.ts
@@ -222,7 +222,8 @@ const FALLBACK_GENERATION_CONFIG: BaseGenerationConfig = {
// Deliberately the widest range, not the narrowest: without a table `getGenerationValidationReasons`
// already blocks generation outright, so tightening the control here would only clamp a persisted
// value the user legitimately had -- FLUX Fill's 30 -- away while the capabilities are still in flight.
- guidance: { min: 0, max: null },
+ // 1 is "no guidance" on every sampler; nothing offers less.
+ guidance: { min: 1, max: null },
negativePrompt: { visible: true, usage: 'never' },
ui: { sdVaeOverride: false, colorCompensation: false, vaePrecision: false, seamless: false, cfgRescale: false },
};
diff --git a/invokeai/frontend/webv2/src/features/generation/ui/GenerateRenderSection.browser.test.tsx b/invokeai/frontend/webv2/src/features/generation/ui/GenerateRenderSection.browser.test.tsx
index 139768dcd2..2f86a4b5a9 100644
--- a/invokeai/frontend/webv2/src/features/generation/ui/GenerateRenderSection.browser.test.tsx
+++ b/invokeai/frontend/webv2/src/features/generation/ui/GenerateRenderSection.browser.test.tsx
@@ -362,7 +362,7 @@ describe('GenerateRenderSection guidance field', () => {
// accessible name in the product, which is its own (pre-existing) problem — asserting both
// ranges at once is what keeps this test honest about which is which.
expect(ranges('Guidance')).toEqual([
- ['0', '10'],
+ ['1', '10'],
['1', '20'],
]);
expect(ranges('Steps')).toEqual([
diff --git a/invokeai/frontend/webv2/src/features/upscale/core/settings.test.ts b/invokeai/frontend/webv2/src/features/upscale/core/settings.test.ts
index f099dea57e..741dd74723 100644
--- a/invokeai/frontend/webv2/src/features/upscale/core/settings.test.ts
+++ b/invokeai/frontend/webv2/src/features/upscale/core/settings.test.ts
@@ -107,10 +107,11 @@ describe('upscale settings', () => {
it('validates required fields and ranges and clears a deleted input image', () => {
const defaults = createDefaultUpscaleWidgetValues();
- expect(getUpscaleValidationReasons({ ...defaults, scale: 17 })).toEqual(
+ expect(getUpscaleValidationReasons({ ...defaults, cfgScale: 0.5, scale: 17 })).toEqual(
expect.arrayContaining([
'Upscale needs an input image. Upload one or send one from Gallery.',
'Scale must be between 1 and 16.',
+ 'CFG scale must be between 1 and 100.',
])
);
diff --git a/invokeai/frontend/webv2/src/features/upscale/core/settings.ts b/invokeai/frontend/webv2/src/features/upscale/core/settings.ts
index a787da5e3c..428459e9ac 100644
--- a/invokeai/frontend/webv2/src/features/upscale/core/settings.ts
+++ b/invokeai/frontend/webv2/src/features/upscale/core/settings.ts
@@ -270,7 +270,7 @@ export const getUpscaleValidationReasons = (values: UpscaleWidgetValues, models?
addRangeReason(reasons, 'Tile size', values.tileSize, UPSCALE_TILE_SIZE_MIN, UPSCALE_TILE_SIZE_MAX);
addRangeReason(reasons, 'Tile overlap', values.tileOverlap, UPSCALE_TILE_OVERLAP_MIN, UPSCALE_TILE_OVERLAP_MAX);
addRangeReason(reasons, 'Steps', values.steps, 1, 1000);
- addRangeReason(reasons, 'CFG scale', values.cfgScale, 0, 100);
+ addRangeReason(reasons, 'CFG scale', values.cfgScale, 1, 100);
addRangeReason(reasons, 'Seed', values.seed, 0, SEED_MAX);
if (models) {
diff --git a/invokeai/frontend/webv2/src/features/upscale/ui/UpscaleWidgetView.tsx b/invokeai/frontend/webv2/src/features/upscale/ui/UpscaleWidgetView.tsx
index ca6b53855a..58fa558137 100644
--- a/invokeai/frontend/webv2/src/features/upscale/ui/UpscaleWidgetView.tsx
+++ b/invokeai/frontend/webv2/src/features/upscale/ui/UpscaleWidgetView.tsx
@@ -241,7 +241,7 @@ export const UpscaleWidgetView = () => {
);
const errors = useMemo(
() => ({
- cfgScale: getRangeError(t('widgets.upscale.cfgScale'), values.cfgScale, 0, 100),
+ cfgScale: getRangeError(t('widgets.upscale.cfgScale'), values.cfgScale, 1, 100),
creativity: getRangeError(
t('widgets.upscale.creativity'),
values.creativity,
@@ -558,7 +558,7 @@ export const UpscaleWidgetView = () => {
inputMax={100}
label={t('widgets.upscale.cfgScale')}
max={CFG_SLIDER_MAX}
- min={0}
+ min={1}
step={0.5}
value={values.cfgScale}
onChange={set.cfgScale}
diff --git a/invokeai/frontend/webv2/src/features/video/core/settings.test.ts b/invokeai/frontend/webv2/src/features/video/core/settings.test.ts
index b58929eff1..7886a9ecc1 100644
--- a/invokeai/frontend/webv2/src/features/video/core/settings.test.ts
+++ b/invokeai/frontend/webv2/src/features/video/core/settings.test.ts
@@ -87,6 +87,11 @@ describe('normalizeVideoSettings', () => {
expect(isVideoSettings(settings)).toBe(true);
});
+ it('folds a low-noise CFG below 1 back into reuse-primary', () => {
+ expect(normalizeVideoSettings({ ...createSettings(), cfgScaleLowNoise: 0.5 })?.cfgScaleLowNoise).toBeNull();
+ expect(normalizeVideoSettings({ ...createSettings(), cfgScaleLowNoise: 1 })?.cfgScaleLowNoise).toBe(1);
+ });
+
it('rejects non-records but heals partial records field-by-field, upscale-style', () => {
expect(normalizeVideoSettings(null)).toBeNull();
expect(normalizeVideoSettings(7)).toBeNull();
diff --git a/invokeai/frontend/webv2/src/features/video/core/settings.ts b/invokeai/frontend/webv2/src/features/video/core/settings.ts
index 1ef73c08d2..b050e1ca23 100644
--- a/invokeai/frontend/webv2/src/features/video/core/settings.ts
+++ b/invokeai/frontend/webv2/src/features/video/core/settings.ts
@@ -411,7 +411,11 @@ export const normalizeVideoSettings = (values: unknown): VideoSettings | null =>
aspectRatioId: isVideoAspectRatioId(values.aspectRatioId) ? values.aspectRatioId : SETTINGS_FALLBACKS.aspectRatioId,
batchCount: sanitizeBatchCount(values.batchCount),
cfgScale: hasFiniteNumber(values, 'cfgScale') ? (values.cfgScale as number) : SETTINGS_FALLBACKS.cfgScale,
- cfgScaleLowNoise: hasFiniteNumber(values, 'cfgScaleLowNoise') ? (values.cfgScaleLowNoise as number) : null,
+ // Below 1 the node falls back to the primary CFG, which the widget spells `null`.
+ cfgScaleLowNoise:
+ hasFiniteNumber(values, 'cfgScaleLowNoise') && (values.cfgScaleLowNoise as number) >= 1
+ ? (values.cfgScaleLowNoise as number)
+ : null,
firstFrameImage,
fps: hasFiniteNumber(values, 'fps') ? (values.fps as number) : SETTINGS_FALLBACKS.fps,
h3HybridBaseModel: isMainModelConfig(values.h3HybridBaseModel) ? values.h3HybridBaseModel : null,
diff --git a/invokeai/frontend/webv2/src/features/video/core/videoPolicies.test.ts b/invokeai/frontend/webv2/src/features/video/core/videoPolicies.test.ts
index 71b00e7e49..0e8de5cdd3 100644
--- a/invokeai/frontend/webv2/src/features/video/core/videoPolicies.test.ts
+++ b/invokeai/frontend/webv2/src/features/video/core/videoPolicies.test.ts
@@ -1057,6 +1057,15 @@ describe('getVideoValidationReasons', () => {
]);
});
+ it('floors the low-noise CFG at 1 and accepts reuse-primary', () => {
+ const model = wanModel('t2v_a14b', 'diffusers');
+ const reason = 'CFG (Low Noise) must be at least 1.';
+
+ expect(getVideoValidationReasons(model, settingsFor(model, { cfgScaleLowNoise: 0.5 }))).toContainEqual(reason);
+ expect(getVideoValidationReasons(model, settingsFor(model, { cfgScaleLowNoise: 1 }))).not.toContainEqual(reason);
+ expect(getVideoValidationReasons(model, settingsFor(model, { cfgScaleLowNoise: null }))).not.toContainEqual(reason);
+ });
+
it('rejects a destination image while extending on TI2V-5B', () => {
const model = wanModel('ti2v_5b', 'diffusers');
const settings = settingsFor(model, { lastFrameImage: LAST_FRAME, sourceVideo: SOURCE_VIDEO });
diff --git a/invokeai/frontend/webv2/src/features/video/core/videoPolicies.ts b/invokeai/frontend/webv2/src/features/video/core/videoPolicies.ts
index 350f81239f..65cab03999 100644
--- a/invokeai/frontend/webv2/src/features/video/core/videoPolicies.ts
+++ b/invokeai/frontend/webv2/src/features/video/core/videoPolicies.ts
@@ -1770,8 +1770,8 @@ export const getVideoValidationReasons = (model: MainModelConfig, settings: Vide
reasons.push('CFG must be at least 1.');
}
- if (config.cfg.lowNoiseVisible && settings.cfgScaleLowNoise !== null && settings.cfgScaleLowNoise < 0) {
- reasons.push('CFG (Low Noise) must be at least 0.');
+ if (config.cfg.lowNoiseVisible && settings.cfgScaleLowNoise !== null && settings.cfgScaleLowNoise < 1) {
+ reasons.push('CFG (Low Noise) must be at least 1.');
}
if (settings.acceleratorEnabled && !config.accelerator) {
diff --git a/invokeai/frontend/webv2/src/features/video/ui/VideoWidgetView.tsx b/invokeai/frontend/webv2/src/features/video/ui/VideoWidgetView.tsx
index 5c6c6e4ebc..3981e78476 100644
--- a/invokeai/frontend/webv2/src/features/video/ui/VideoWidgetView.tsx
+++ b/invokeai/frontend/webv2/src/features/video/ui/VideoWidgetView.tsx
@@ -730,7 +730,7 @@ export const VideoWidgetView = () => {
inputMax={100}
label={t('widgets.video.cfgLowNoise')}
max={15}
- min={0}
+ min={1}
step={0.1}
value={values.cfgScaleLowNoise ?? values.cfgScale}
onChange={set.cfgScaleLowNoise}
diff --git a/invokeai/frontend/webv2/src/workbench/image-actions/videoRecall.test.ts b/invokeai/frontend/webv2/src/workbench/image-actions/videoRecall.test.ts
index 07c0276de7..01b7a1292f 100644
--- a/invokeai/frontend/webv2/src/workbench/image-actions/videoRecall.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/image-actions/videoRecall.test.ts
@@ -339,6 +339,16 @@ describe('buildVideoRecallSettings', () => {
});
expect(withKey?.values.cfgScaleLowNoise).toBe(3);
+
+ // Below 1 the node reused the primary CFG, so the recalled state does too.
+ const belowFloor = buildVideoRecallSettings({
+ currentValues: withLow,
+ kind: 'all',
+ metadata: wanMetadata({ guidance_scale_low_noise: 0.5 }),
+ models: catalog,
+ });
+
+ expect(belowFloor?.values.cfgScaleLowNoise).toBeNull();
});
it('clears held conditioning media when the recorded run had none — mode is part of the recall', () => {
diff --git a/invokeai/frontend/webv2/src/workbench/image-actions/videoRecall.ts b/invokeai/frontend/webv2/src/workbench/image-actions/videoRecall.ts
index eb38974617..a5bee6421e 100644
--- a/invokeai/frontend/webv2/src/workbench/image-actions/videoRecall.ts
+++ b/invokeai/frontend/webv2/src/workbench/image-actions/videoRecall.ts
@@ -570,7 +570,7 @@ export const buildVideoRecallSettings = ({
// The graph records the key only when the setting was non-null; absence
// means "reuse the primary CFG", so restore that exact semantics.
...(policy.ui.cfgLowNoiseVisible
- ? { cfgScaleLowNoise: cfgScaleLowNoise !== null && cfgScaleLowNoise >= 0 ? cfgScaleLowNoise : null }
+ ? { cfgScaleLowNoise: cfgScaleLowNoise !== null && cfgScaleLowNoise >= 1 ? cfgScaleLowNoise : null }
: {}),
};
fields.push('cfg');
diff --git a/tests/backend/architectures/test_guidance_range.py b/tests/backend/architectures/test_guidance_range.py
index 64c40e4827..d39cfd0917 100644
--- a/tests/backend/architectures/test_guidance_range.py
+++ b/tests/backend/architectures/test_guidance_range.py
@@ -6,11 +6,11 @@ is `le=20`, so 30 -- a value FLUX Fill genuinely wants, on a *different* archite
on a FLUX.2 model and failed at enqueue. `ernie_image_denoise.guidance_scale` is `ge=1.0`, so 0 and
0.5 were offered, forwarded unchanged by `graph.ts`, and failed the same way.
-`FeaturesFacet.guidance_min` / `guidance_max` move those bounds to the architecture, and this module
-pins them to the node that actually validates the value -- the same way
-`test_features.py::test_the_dimension_grid_matches_the_node_that_enforces_it` pins the dimension
-grid to the node's `multipleOf`. Transcribing 1.0 and 20.0 into assertions here would check a number
-against itself; reading them off the invocation schema is what makes the pin worth having.
+`FeaturesFacet.guidance_min` / `guidance_max` move those bounds to the architecture. The ceiling and
+any floor above `GUIDANCE_FLOOR` are read off the invocation schema rather than transcribed, the
+same way `test_features.py::test_the_dimension_grid_matches_the_node_that_enforces_it` pins the
+dimension grid to the node's `multipleOf`; the floor itself is a product rule (see `GUIDANCE_FLOOR`)
+and is the one number asserted directly.
"""
from typing import Any
@@ -64,9 +64,14 @@ NO_GUIDANCE_SLIDER = frozenset(
}
)
-UNCONSTRAINED_MIN = 0.0
-"""What an architecture whose node enforces no floor declares. A slider has to start somewhere and
-none of these samplers reads a negative guidance, so zero is the UI's floor rather than the node's.
+GUIDANCE_FLOOR = 1.0
+"""The lowest guidance the UI offers anywhere. 1.0 is "no guidance" on every sampler and nothing
+below it is a value a person picks on purpose, so an architecture declares this floor unless its
+node enforces a higher one. SD's `cfg_scale` enforces the same floor through a `field_validator`
+the JSON schema cannot express, which is why the floor is not read off the node. A node whose own
+floor is lower (FLUX.2's `guidance` is `ge=0`) is absorbed by this rule on purpose: the UI declares
+1.0 for it too. A sampler that someday wants values below 1.0 offered is the moment to revisit the
+rule.
"""
@@ -108,11 +113,12 @@ def test_the_guidance_range_matches_the_node_that_enforces_it(base: BaseModelTyp
node_min, node_max = _numeric_bounds(node_type, field_name)
facet = require(base, FeaturesFacet)
- expected_min = UNCONSTRAINED_MIN if node_min is None else node_min
+ expected_min = GUIDANCE_FLOOR if node_min is None else max(GUIDANCE_FLOOR, node_min)
assert (facet.guidance_min, facet.guidance_max) == (expected_min, node_max), (
f"'{base.value}' declares guidance {facet.guidance_min}..{facet.guidance_max} but "
- f"{node_type}.{field_name} accepts {expected_min}..{node_max}. Whichever is wrong, a UI "
- f"reading the declaration offers a value the graph rejects -- see "
+ f"{node_type}.{field_name} constrains it to {node_min}..{node_max} and the UI floor is "
+ f"{GUIDANCE_FLOOR}, so it should declare {expected_min}..{node_max}. Whichever is wrong, a UI "
+ f"reading the declaration offers a value the graph rejects or hides one it takes -- see "
f"invokeai/backend/architectures/defs/{base.value.replace('-', '_')}.py."
)
@@ -122,7 +128,7 @@ def test_an_architecture_with_no_slider_declares_no_range(base: BaseModelType) -
"""Nothing sends these a guidance value, so a narrowed range here would be a claim about a
control that does not exist."""
facet = require(base, FeaturesFacet)
- assert (facet.guidance_min, facet.guidance_max) == (UNCONSTRAINED_MIN, None), base.value
+ assert (facet.guidance_min, facet.guidance_max) == (GUIDANCE_FLOOR, None), base.value
def test_a_range_that_holds_no_values_is_refused() -> None: