{"record":{"id":"e02113c1d8e57639","repo":"sgl-project/sglang","slug":"server-was-launched-with-enable-cfg-parallel-but","errorCode":null,"errorMessage":"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).","messagePattern":"Server was launched with --enable-cfg-parallel but this request does not use classifier-free guidance \\(do_classifier_free_guidance=(.+?), guidance_scale=(.+?), true_cfg_scale=(.+?), negative_prompt=(.+?)\\)\\. 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\\)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/pipelines_core/stages/input_validation.py","lineNumber":364,"sourceCode":"            raise ValueError(\n                f\"Guidance scale must be positive, but got {batch.guidance_scale}\"\n            )\n\n        # Reject requests that do not enable CFG on a server launched with\n        # --enable-cfg-parallel. CFG-parallel splits cond/uncond across ranks,\n        # so rank 1 has no work and returns None for noise_pred, which crashes\n        # scheduler.step() ~30 minutes later under a gloo broadcast timeout.\n        # Earlier, field-specific checks above (negative_prompt missing,\n        # guidance_scale < 0) fire first and produce better messages for those\n        # cases; this is the catch-all for any combination that still leaves\n        # do_classifier_free_guidance=False under cfg-parallel.\n        if server_args.enable_cfg_parallel and not batch.do_classifier_free_guidance:\n            neg_prompt_state = (\n                \"not set\"\n                if batch.negative_prompt is None\n                else \"empty\" if batch.negative_prompt == \"\" else \"set\"\n            )\n            raise ValueError(\n                f\"Server was launched with --enable-cfg-parallel but this \"\n                f\"request does not use classifier-free guidance \"\n                f\"(do_classifier_free_guidance={batch.do_classifier_free_guidance}, \"\n                f\"guidance_scale={batch.guidance_scale}, \"\n                f\"true_cfg_scale={batch.true_cfg_scale}, \"\n                f\"negative_prompt={neg_prompt_state}). \"\n                f\"CFG-parallel splits cond/uncond across ranks and requires \"\n                f\"both to be active. Either disable --enable-cfg-parallel or \"\n                f\"ensure the request enables CFG (set guidance_scale > 1.0 or \"\n                f\"true_cfg_scale > 1.0, with a non-empty negative_prompt or \"\n                f\"negative_prompt_embeds).\"\n            )\n\n        # for i2v, get image from image_path\n        # @TODO(Wei) hard-coded for wan2.2 5b ti2v for now. Should put this in image_encoding stage\n        if batch.image_path is not None:\n            if isinstance(batch.image_path, list):\n                batch.condition_image = []","sourceCodeStart":346,"sourceCodeEnd":382,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/pipelines_core/stages/input_validation.py#L346-L382","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["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","If you don't need CFG, restart the server without --enable-cfg-parallel","Add a request-side pre-check that asserts CFG is enabled before dispatching to a CFG-parallel server","Make the negative prompt configurable so it defaults to a meaningful string (e.g. '') instead of None/empty"],"exampleFix":"# before\noutputs = pipeline(\"a cat\", guidance_scale=1.0)\n# after\noutputs = pipeline(\"a cat\", guidance_scale=7.5, negative_prompt=\"blurry, low quality\")","handlingStrategy":"validation","validationCode":"def assert_cfg_ready(req, server_enable_cfg_parallel: bool):\n    if server_enable_cfg_parallel:\n        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\"))\n        if not cfg_on:\n            raise ValueError(\"enable_cfg_parallel server requires guidance_scale>1 and a negative prompt\")","typeGuard":null,"tryCatchPattern":"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","preventionTips":["Know your server launch flags before writing clients","Centralize request defaults so negative_prompt is never empty on CFG servers"],"tags":["cfg","classifier-free-guidance","cfg-parallel","server-args","request-validation"],"backgroundTag":"request-config-mismatch","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}