sgl-project/sglang · critical · ValueError

Encoder DP mode requires --dp-size > 1 and --tp-size 1; got

Error message

Encoder DP mode requires --dp-size > 1 and --tp-size 1; got dp_size={get_parallel().dp_size}, tp_size={get_parallel().tp_size}.

What it means

launch_dp_runtime builds the DP-mode encoder backend and enforces its contract: DP mode needs more than one data-parallel rank (--dp-size > 1) and exactly one tensor-parallel rank (--tp-size 1). Violating either raises ValueError at startup.

Source

Thrown at python/sglang/srt/disaggregation/encoder/runtime.py:1574

        coalesce_same_turn=coalesce_same_turn,
    )
    return EncoderRuntime(
        encoder=encoder,
        scheduler=scheduler,
        send_sockets=send_sockets,
        zmq_context=zmq_context,
        tp_processes=tp_processes,
    )


def launch_dp_runtime(server_args: ServerArgs) -> DPDispatcher:
    """Launch the protocol-neutral DP backend and return its dispatcher.

    HTTP uses this entry point today.  gRPC can reuse it later without
    importing HTTP application state or Uvicorn.
    """
    if get_parallel().dp_size <= 1 or get_parallel().tp_size != 1:
        raise ValueError(
            "Encoder DP mode requires --dp-size > 1 and --tp-size 1; got "
            f"dp_size={get_parallel().dp_size}, tp_size={get_parallel().tp_size}."
        )
    dp_size = get_parallel().dp_size
    logger.info(f"Launching encoder in DP mode: dp_size={dp_size}")

    # DP mode: workers (subprocesses) write metrics to the shared multiproc dir;
    # the main process exposes the aggregated /metrics endpoint.
    if get_observability().enable_metrics:
        set_prometheus_multiproc_dir()

    ctx = mp.get_context("spawn")
    ipc_prefix = random_uuid()
    async_zmq_ctx = zmq.asyncio.Context(dp_size + 1)

    result_path = f"ipc:///tmp/{ipc_prefix}_dp_result"
    result_socket = get_zmq_socket(async_zmq_ctx, zmq.PULL, result_path, True)
    dispatch_sockets: List[zmq.asyncio.Socket] = [

View on GitHub (pinned to 0132848349)

Solutions

  1. Set --tp-size 1 and keep --dp-size > 1 for DP encoder mode
  2. For TP encoder scaling, use launch_local_runtime with --dp-size 1 instead
  3. Audit shared launch scripts so tp_size is not silently carried over into DP deployments

Example fix

# before
--dp-size 4 --tp-size 4
# after
--dp-size 4 --tp-size 1
Defensive patterns

Strategy: validation

Validate before calling

p = get_parallel()
assert p.dp_size > 1 and p.tp_size == 1, 'DP encoder needs dp>1, tp=1'

Prevention

When it happens

Trigger: Launching the DP encoder runtime with --dp-size 1 (which is the local runtime's domain), or combining --dp-size > 1 with --tp-size > 1, which the DP encoder topology does not support.

Common situations: Trying to scale the encoder with tensor parallelism while in DP mode; migrating a TP deployment to DP without removing --tp-size; defaults where tp_size is inherited from a shared config.

Related errors


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