Class ClusterFollower
java.lang.Object
smile.llm.cluster.ClusterFollower
- All Implemented Interfaces:
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.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceExecutes one message; the follower acknowledges it afterwards.static final recordWhat the leader tells a follower on connection. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()static ClusterFollowerConnects to the leader (retrying until it listens) and completes the handshake.voidrun(ClusterFollower.Handler handler) Executes the leader's messages until it shuts the cluster down or disconnects.welcome()Returns what the leader assigned.
-
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
Returns what the leader assigned.- Returns:
- what the leader assigned.
-
run
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 ofhandler.
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-