sgl-project/sglang · error · ValueError

generate_action requires an ACTION pipeline, got {sampling_p

Error message

generate_action requires an ACTION pipeline, got {sampling_params.data_type}

What it means

DiffusionGenerator.generate_action validates that the resolved SamplingParams have data_type == DataType.ACTION. If the server/args were configured for another pipeline (e.g. image/video generation), action-specific generation cannot proceed and this ValueError is raised before a request is built.

Source

Thrown at python/sglang/multimodal_gen/runtime/entrypoints/diffusion_generator.py:460

        self._log_summary(results)

        if not results:
            return None
        return results[0] if len(results) == 1 else results

    def generate_action(
        self,
        sampling_params_kwargs: dict | None = None,
        external_trace_header: dict[str, str] | None = None,
    ) -> dict[str, Any]:
        sampling_params_kwargs = sampling_params_kwargs or {}
        sampling_params = SamplingParams.from_user_sampling_params_args(
            self.server_args.model_path,
            server_args=self.server_args,
            **sampling_params_kwargs,
        )
        if sampling_params.data_type != DataType.ACTION:
            raise ValueError(
                f"generate_action requires an ACTION pipeline, got {sampling_params.data_type}"
            )

        req = prepare_request(
            server_args=self.server_args,
            sampling_params=sampling_params,
            external_trace_header=external_trace_header,
        )
        output_batch = self._send_to_scheduler_and_wait_for_response(req)
        if output_batch.error:
            raise RuntimeError(output_batch.error)
        if output_batch.output is None:
            raise RuntimeError("action policy returned no output")
        return output_batch.output[0]

    def _resolve_prompts(
        self,
        prompt: str | list[str] | None,

View on GitHub (pinned to 0132848349)

Solutions

  1. Initialize/launch with the ACTION data type (e.g. pass data_type=DataType.ACTION or the matching CLI flag) before calling generate_action
  2. Use the plain generate() API if you actually want image/video output
  3. Re-create the DiffusionGenerator with server_args matching the action model

Example fix

# before
generator.generate_action(prompt="...")  # server configured for IMAGE
# after
generator.generate_action(prompt="...", data_type=DataType.ACTION)
Defensive patterns

Strategy: type-guard

Validate before calling

from sglang.srt.samplers.sampling_params import SamplingParams  # data_type lives on SamplingParams/server_args
data_type = getattr(server_args, "data_type", None)
if data_type is not None:
    assert str(data_type).endswith("ACTION"), f"need ACTION pipeline, got {data_type}"

Type guard

def supports_action_generation(server_args) -> bool:
    return str(getattr(server_args, "data_type", "")).upper().endswith("ACTION")

Prevention

When it happens

Trigger: Calling generate_action() against a server whose server_args/data_type resolve to a non-ACTION data type; omitting the data_type argument so it defaults to the server's configured pipeline type.

Common situations: Reusing a DiffusionGenerator initialized for image generation to also drive an action policy; forgetting to pass data_type=DataType.ACTION or the corresponding --data-type flag when launching the action pipeline.

Related errors


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