invoke-ai/InvokeAI · error · ValueError
Negative text conditioning is required when cfg_scale is not
Error message
Negative text conditioning is required when cfg_scale is not 1.0.
What it means
In Flux denoise_sampling_region (denoise.py), when the per-step CFG scale is not 1.0 the sampler must also run a negative (unconditional) prediction, which requires negative text conditioning supplied via a neg_regional_prompting_extension. When a step's cfg_scale != 1.0 and that extension is None, the sampler cannot form the negative pass and raises. CFG == 1.0 means no negative branch is needed, hence the conditional check.
Source
Thrown at invokeai/backend/flux/denoise.py:177
timesteps=t_vec,
guidance=guidance_vec,
timestep_index=user_step,
total_num_timesteps=total_steps,
controlnet_double_block_residuals=merged_controlnet_residuals.double_block_residuals,
controlnet_single_block_residuals=merged_controlnet_residuals.single_block_residuals,
ip_adapter_extensions=pos_ip_adapter_extensions,
regional_prompting_extension=pos_regional_prompting_extension,
)
if img_cond_seq is not None:
pred = pred[:, :original_seq_len]
# Get CFG scale for current user step
step_cfg_scale = cfg_scale[min(user_step, len(cfg_scale) - 1)]
if not math.isclose(step_cfg_scale, 1.0):
if neg_regional_prompting_extension is None:
raise ValueError("Negative text conditioning is required when cfg_scale is not 1.0.")
neg_img_input = img
neg_img_input_ids = img_ids
if img_cond is not None:
neg_img_input = torch.cat((neg_img_input, img_cond), dim=-1)
if img_cond_seq is not None:
neg_img_input = torch.cat((neg_img_input, img_cond_seq), dim=1)
neg_img_input_ids = torch.cat((neg_img_input_ids, img_cond_seq_ids), dim=1)
neg_pred = model(
img=neg_img_input,
img_ids=neg_img_input_ids,
txt=neg_regional_prompting_extension.regional_text_conditioning.t5_embeddings,
txt_ids=neg_regional_prompting_extension.regional_text_conditioning.t5_txt_ids,
y=neg_regional_prompting_extension.regional_text_conditioning.clip_embeddings,
timesteps=t_vec,View on GitHub (pinned to 0b6a024f2f)
Solutions
- Provide a negative regional prompting extension (with negative text embeddings) whenever cfg_scale != 1.0.
- Keep cfg_scale at 1.0 (guidance-distilled Flux models are trained to run without CFG) if no negative conditioning is available.
- Build the negative prompt embeddings in your pipeline before denoising and pass them through.
- If using a per-step cfg_scale list, ensure every entry that exceeds 1.0 is accompanied by negative conditioning, or clamp them to 1.0.
Example fix
// before result = denoise(..., cfg_scale=4.0, neg_regional_prompting_extension=None) // after neg_ext = build_neg_regional_prompting_extension(negative_prompt="blurry, low quality", ...) result = denoise(..., cfg_scale=4.0, neg_regional_prompting_extension=neg_ext)
Defensive patterns
Strategy: validation
Validate before calling
if any(s != 1.0 for s in (cfg_scale if isinstance(cfg_scale, list) else [cfg_scale])):
assert neg_regional_prompting_extension is not None, \
"cfg_scale != 1.0 requires negative text conditioning" Type guard
def cfg_needs_negative(cfg_scale, neg_ext) -> bool:
values = cfg_scale if isinstance(cfg_scale, list) else [cfg_scale]
return any(s != 1.0 for s in values) and neg_ext is None Try / catch
try:
result = denoise(..., cfg_scale=cfg_scale, neg_regional_prompting_extension=neg_ext)
except ValueError as e:
if "Negative text conditioning is required" in str(e):
raise RuntimeError("Enable CFG only with a negative prompt / conditioning extension configured") from e
raise Prevention
- Keep cfg_scale at 1.0 for guidance-distilled Flux unless you have a negative prompt configured.
- Validate per-step CFG schedules against the presence of negative conditioning before denoising.
- Build negative text embeddings in the text-encoding stage, not inside the sampling loop.
When it happens
Trigger: Calling denoise() with a cfg_scale (scalar or per-step schedule) whose value at some step is not 1.0 while neg_regional_prompting_extension is None — e.g. passing cfg_scale=3.5 without building negative conditioning.
Common situations: Users enabling CFG in a Flux pipeline that was set up without a negative prompt/region extension; per-step CFG schedules where a later step exceeds 1.0; region-based prompting setups lacking the negative extension object.
Related errors
- Negative text conditioning is required when cfg_scale is not
- denoising_start ({self.denoising_start}) must be less than d
- denoising_start should be 0 when initial latents are not pro
- cfg_scale must be greater than 1
- Negative conditioning is required when guidance_scale > 1.0
AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29).
Data as JSON: /api/errors/13439fcacfd449ac.
Report an issue: GitHub.