sgl-project/sglang · error · ValueError

Server was launched with --enable-cfg-parallel but this requ

Error message

Server was launched with --enable-cfg-parallel but this request does not use classifier-free guidance (do_classifier_free_guidance={batch.do_classifier_free_guidance}, guidance_scale={batch.guidance_scale}, true_cfg_scale={batch.true_cfg_scale}, negative_prompt={neg_prompt_state}). CFG-parallel splits cond/uncond across ranks and requires both to be active. Either disable --enable-cfg-parallel or ensure the request enables CFG (set guidance_scale > 1.0 or true_cfg_scale > 1.0, with a non-empty negative_prompt or negative_prompt_embeds).

What it means

The server was started with --enable-cfg-parallel, which splits conditional and unconditional branches across tensor-parallel ranks, but the incoming request was not configured for classifier-free guidance (CFG). Because both branches must be active for the rank split to be valid, the input validation stage rejects any non-CFG request rather than computing garbage on half the ranks.

Source

Thrown at python/sglang/multimodal_gen/runtime/pipelines_core/stages/input_validation.py:364

            raise ValueError(
                f"Guidance scale must be positive, but got {batch.guidance_scale}"
            )

        # Reject requests that do not enable CFG on a server launched with
        # --enable-cfg-parallel. CFG-parallel splits cond/uncond across ranks,
        # so rank 1 has no work and returns None for noise_pred, which crashes
        # scheduler.step() ~30 minutes later under a gloo broadcast timeout.
        # Earlier, field-specific checks above (negative_prompt missing,
        # guidance_scale < 0) fire first and produce better messages for those
        # cases; this is the catch-all for any combination that still leaves
        # do_classifier_free_guidance=False under cfg-parallel.
        if server_args.enable_cfg_parallel and not batch.do_classifier_free_guidance:
            neg_prompt_state = (
                "not set"
                if batch.negative_prompt is None
                else "empty" if batch.negative_prompt == "" else "set"
            )
            raise ValueError(
                f"Server was launched with --enable-cfg-parallel but this "
                f"request does not use classifier-free guidance "
                f"(do_classifier_free_guidance={batch.do_classifier_free_guidance}, "
                f"guidance_scale={batch.guidance_scale}, "
                f"true_cfg_scale={batch.true_cfg_scale}, "
                f"negative_prompt={neg_prompt_state}). "
                f"CFG-parallel splits cond/uncond across ranks and requires "
                f"both to be active. Either disable --enable-cfg-parallel or "
                f"ensure the request enables CFG (set guidance_scale > 1.0 or "
                f"true_cfg_scale > 1.0, with a non-empty negative_prompt or "
                f"negative_prompt_embeds)."
            )

        # for i2v, get image from image_path
        # @TODO(Wei) hard-coded for wan2.2 5b ti2v for now. Should put this in image_encoding stage
        if batch.image_path is not None:
            if isinstance(batch.image_path, list):
                batch.condition_image = []

View on GitHub (pinned to 0132848349)

Solutions

  1. Set guidance_scale > 1.0 (or true_cfg_scale > 1.0) AND provide a non-empty negative_prompt (or negative_prompt_embeds) on every request
  2. If you don't need CFG, restart the server without --enable-cfg-parallel
  3. Add a request-side pre-check that asserts CFG is enabled before dispatching to a CFG-parallel server
  4. Make the negative prompt configurable so it defaults to a meaningful string (e.g. '') instead of None/empty

Example fix

# before
outputs = pipeline("a cat", guidance_scale=1.0)
# after
outputs = pipeline("a cat", guidance_scale=7.5, negative_prompt="blurry, low quality")
Defensive patterns

Strategy: validation

Validate before calling

def assert_cfg_ready(req, server_enable_cfg_parallel: bool):
    if server_enable_cfg_parallel:
        cfg_on = (req.get("guidance_scale", 1.0) > 1.0 or req.get("true_cfg_scale", 1.0) > 1.0) and bool(req.get("negative_prompt") or req.get("negative_prompt_embeds"))
        if not cfg_on:
            raise ValueError("enable_cfg_parallel server requires guidance_scale>1 and a negative prompt")

Try / catch

catch ValueError around the pipeline call, match on 'enable-cfg-parallel' in str(e), and resubmit with a default negative_prompt and guidance_scale>1

Prevention

When it happens

Trigger: Launching the server with --enable-cfg-parallel and then sending a request where guidance_scale <= 1.0 and true_cfg_scale <= 1.0 (or is None), or where negative_prompt/negative_prompt_embeds is empty, so do_classifier_free_guidance evaluates to False in InputValidationStage.forward (input_validation.py:364).

Common situations: Reusing a client/config from a non-CFG deployment against a CFG-parallel server; porting a diffusers-style script where cfg is set post-hoc; forgetting that CFG requires BOTH a scale > 1.0 AND a non-empty negative prompt; sending plain text-to-image requests to a server tuned exclusively for CFG workloads.

Related errors


AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28). Data as JSON: /api/errors/e02113c1d8e57639. Report an issue: GitHub.