pymllm.orchestrator.ipc_utils ============================= .. py:module:: pymllm.orchestrator.ipc_utils .. autoapi-nested-parse:: ZMQ IPC utilities for inter-process communication. Provides helpers to generate unique IPC addresses and create pre-configured ZMQ sockets so that every process uses the same conventions. Functions --------- .. autoapisummary:: pymllm.orchestrator.ipc_utils.make_ipc_address pymllm.orchestrator.ipc_utils.create_zmq_socket pymllm.orchestrator.ipc_utils.close_zmq_socket pymllm.orchestrator.ipc_utils.cleanup_ipc_files pymllm.orchestrator.ipc_utils.setup_subprocess_logging Module Contents --------------- .. py:function:: make_ipc_address(name, unique_id = None) Return an ``ipc://`` address for *name*, optionally scoped by *unique_id*. :param name: Logical channel name, e.g. ``"rr_to_tokenizer"``. :param unique_id: Per-engine identifier (typically ``str(os.getpid())``) to avoid collisions when multiple engines run on the same host. .. py:function:: create_zmq_socket(ctx, socket_type, address, bind) Create a ZMQ socket, bind or connect it, and return it. :param ctx: A ``zmq.Context`` shared within the process. :param socket_type: One of ``zmq.PUSH``, ``zmq.PULL``, ``zmq.PAIR``, etc. :param address: The ``ipc://`` address string. :param bind: If ``True`` the socket calls ``bind``; otherwise ``connect``. .. py:function:: close_zmq_socket(sock) Close a ZMQ socket, ignoring errors. .. py:function:: cleanup_ipc_files(unique_id = None) Remove IPC socket files for the given engine (or all if no id given). .. py:function:: setup_subprocess_logging(log_level = 'info') Configure logging for a spawned subprocess. When Python spawns a subprocess (``mp.set_start_method('spawn')``), the child starts with a blank logging configuration. Call this function at the very beginning of every subprocess entry point so that log records are emitted at the correct level. :param log_level: Case-insensitive level name, e.g. ``"debug"``, ``"info"``, ``"warning"``.