Class ClusterFollower

java.lang.Object
smile.llm.cluster.ClusterFollower
All Implemented Interfaces:
AutoCloseable

public final class ClusterFollower extends Object implements AutoCloseable
The follower side of a multi-node model: connects to a ClusterLeader, learns its ranks and the NCCL unique id, then executes every message the leader sends, in order, acknowledging each. See ClusterLeader for the wire format.
  • Method Details

    • connect

      public static ClusterFollower connect(String host, int port, int nodeIndex, int ranks, long timeoutMs) throws IOException
      Connects to the leader (retrying until it listens) and completes the handshake.
      Parameters:
      host - the leader's host.
      port - the leader's cluster port.
      nodeIndex - this follower's node number (1, 2, ...; ranks are assigned in node order).
      ranks - number of ranks (GPUs) this follower owns.
      timeoutMs - how long to keep retrying.
      Returns:
      the connected follower.
      Throws:
      IOException - if the leader cannot be reached or the handshake is wrong.
    • welcome

      public ClusterFollower.Welcome welcome()
      Returns what the leader assigned.
      Returns:
      what the leader assigned.
    • run

      public void run(ClusterFollower.Handler handler) throws Exception
      Executes the leader's messages until it shuts the cluster down or disconnects. A failing message is reported to the leader and the exception is rethrown (the caller should then exit: the other ranks cannot continue).
      Parameters:
      handler - executes the messages.
      Throws:
      Exception - the first failure of handler.
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable