nemo_rl.models.generation.vllm.multi_api#

Module Contents#

Classes#

MultiAPIServerPool

Manage child HTTP frontends and their shared vLLM engine.

API#

class nemo_rl.models.generation.vllm.multi_api.MultiAPIServerPool(owner: Any, count: int)#

Manage child HTTP frontends and their shared vLLM engine.

The owning frontend stays in the worker process. The pool owns child processes and the shared engine manager; the caller owns its AsyncLLM client.

Initialization

Initialize a pool whose frontend count includes the owning worker.

raise_if_unavailable() → None#

Reject operations after the first failure.

create_engine(
engine_args: Any,
stat_loggers: list[Any],
) → Any#

Launch one shared engine and attach its frontend clients.

Parameters:
  • engine_args – vLLM arguments updated with the frontend count and rank.

  • stat_loggers – Additional logger factories for the owning client.

Returns:

The owning frontend’s AsyncLLM client attached to the shared engine.

async command(name: str, *args: Any) → list[Any]#

Serialize a control operation and wait for every child acknowledgement.

Parameters:
  • name – Control operation or query to broadcast to child frontends.

  • *args – Operation-specific positional values sent to each child.

Returns:

Reply payloads in child frontend order.

stop_children() → None#

Terminate and join child frontends, then close their control pipes.

close_engines() → None#

Shut down the shared engines and clean up frontend IPC listeners.

static receive_reply(
connection: multiprocessing.connection.Connection,
timeout: float = 600,
) → Any#

Read a child acknowledgement and raise on timeout or reported failure.

Parameters:
  • connection – Parent end of the frontend control pipe.

  • timeout – Maximum seconds to wait for a reply.

Returns:

The payload from a successful acknowledgement.

static run_api_process(
connection: multiprocessing.connection.Connection,
generation_config: nemo_rl.models.generation.vllm.config.VllmConfig,
engine_args: Any,
engine_config: Any,
client_addresses: dict[str, Any],
*,
count: int,
index: int,
listener: socket.socket,
node_ip: str,
namespace: str,
routed_experts_dtype: Any,
) → None#

Attach a child frontend to the shared engine and serve control operations.

Parameters:
  • connection – Child end of the frontend control pipe.

  • generation_config – NeMo RL configuration used by the frontend.

  • engine_args – vLLM arguments copied for this frontend’s process rank.

  • engine_config – vLLM configuration updated with this frontend’s rank.

  • client_addresses – Engine input/output addresses and optional tensor queue.

  • count – Total frontend count, including the owning worker.

  • index – This child frontend’s client index.

  • listener – Listening socket shared by all frontends.

  • node_ip – Node address used in the advertised HTTP URL.

  • namespace – Ray namespace used when token capture connects to the cluster.

  • routed_experts_dtype – Dtype used to carry captured routed-expert IDs.