{"record":{"id":"aa067ecef161fe0b","repo":"sgl-project/sglang","slug":"i2i-mode-is-not-supported-yet-via-external-sglang","errorCode":null,"errorMessage":"I2I mode is not supported yet via external SGLang encoder URL.","messagePattern":"I2I mode is not supported yet via external SGLang encoder URL\\.","errorType":"validation","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/glm_image.py","lineNumber":454,"sourceCode":"        ).to(device)\n\n        image_grid_thw = inputs.get(\"image_grid_thw\")\n        max_new_tokens, large_image_offset, token_h, token_w = (\n            self._compute_generation_params(\n                image_grid_thw=image_grid_thw, is_text_to_image=is_text_to_image\n            )\n        )\n\n        prior_token_image_ids = None\n\n        # For GLM-Image, greedy decoding is not allowed; it may cause repetitive outputs.\n        # max_new_tokens must be exactly grid_h * grid_w + 1 (the +1 is for EOS).\n        if server_args.srt_encoder_url is not None:\n            if image is not None:\n                logger.error(\n                    \"Image-to-Image tasks is not supported yet when using an external SGLang encoder server.\"\n                )\n                raise NotImplementedError(\n                    \"I2I mode is not supported yet via external SGLang encoder URL.\"\n                )\n\n            payload = {\n                \"input_ids\": inputs[\"input_ids\"][0].tolist(),\n                \"image_data\": [{\"image_grid_thw\": image_grid_thw.tolist()}],\n                \"sampling_params\": self._external_ar_sampling_params(\n                    max_new_tokens, seed\n                ),\n            }\n            data = self._request_external_ar(payload, server_args)\n            generated_ids = data.get(\"output_ids\")\n            usage = _extract_srt_usage(data.get(\"meta_info\"))\n        else:\n            if image is not None:\n                source_grids = image_grid_thw[:-1]\n                prior_token_image_embed = pooled_image_features_to_tensor(\n                    self.vision_language_encoder.get_image_features(","sourceCodeStart":436,"sourceCodeEnd":472,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/glm_image.py#L436-L472","documentation":"The GLM-Image pipeline was configured to use an external SGLang encoder server (server_args.srt_encoder_url set), but the request also included an input image (Image-to-Image mode). The external encoder URL path only supports text-to-image generation, so passing an image raises NotImplementedError.","triggerScenarios":"Setting server_args.srt_encoder_url to an external encoder endpoint and then calling forward()/generate_prior_tokens with image != None (an input image for img2img).","commonSituations":"Deployments that split the encoder from the AR/decoder trying to reuse the same pipeline for img2img; migrating a working T2I external-encoder setup to I2I without realizing the limitation.","solutions":["Remove the input image to run text-to-image through the external encoder","Or unset server_args.srt_encoder_url so the in-process encoder handles I2I","Or wait for/implement I2I support in the external encoder request payload"],"exampleFix":"# before\nserver_args.srt_encoder_url = \"http://encoder:8000\"\nresult = pipe(prompt=\"a cat\", image=input_pil_image)\n\n# after\nserver_args.srt_encoder_url = None  # use in-process encoder for I2I\nresult = pipe(prompt=\"a cat\", image=input_pil_image)","handlingStrategy":"type-guard","validationCode":"if server_args.srt_encoder_url is not None and image is not None:\n    raise NotImplementedError(\n        \"I2I requires the in-process encoder; unset srt_encoder_url\"\n    )","typeGuard":"def supports_i2i(server_args) -> bool:\n    return server_args.srt_encoder_url is None","tryCatchPattern":"try:\n    result = pipe(prompt=p, image=img)\nexcept NotImplementedError as e:\n    if \"I2I mode\" in str(e):\n        server_args.srt_encoder_url = None\n        result = pipe(prompt=p, image=img)  # in-process encoder\n    else:\n        raise","preventionTips":["Gate I2I requests on srt_encoder_url being None","Document the external-encoder limitation in pipeline config","Route img2img traffic to a separate pipeline instance without the external URL"],"tags":["glm-image","external-encoder","image-to-image","notimplemented"],"backgroundTag":"unsupported-operation-mode","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}