Skip to content

Deploy parallelism across multiple nodes ​

Run one tokenspeed serve process per node and keep the distributed settings consistent across the deployment.

Prerequisites ​

  • Use the same model, backend, precision, and scheduler settings on every node. Only --node-rank should differ between nodes.
  • Run the nodes on a trusted network. The sockets between the bundled gateway and attention-DP replicas carry no authentication.
  • Keep the gateway port free on node 0 and reachable from the other nodes. The gateway listens on the host of --dist-init-addr, one port below the --dist-init-addr port, which every node derives from its own flags.

Launch the nodes ​

  1. Identify the rank 0 hostname to replace <rank0-host>. On each node, replace <model> with the same model ID or local path and set --node-rank to that node's zero-based rank:

    bash
    tokenspeed serve <model> \
      --nnodes 2 \
      --node-rank 0 \
      --nprocs-per-node 8 \
      --world-size 16 \
      --dist-init-addr <rank0-host>:25000
  2. Run the command once on each node. Node rank 0 serves the HTTP API. Higher ranks run the engine only and expose no endpoint.

    Each attention-DP replica's first rank registers with node 0's bundled gateway: over a same-host socket when every one of them is on node 0, otherwise over TCP.

  3. Validate the parallel deployment before sending load. Check that every rank joins the distributed group and that node 0's API responds.

Launch under Slurm ​

Inside a multi-node Slurm step, TokenSpeed derives --nnodes, --node-rank, and --dist-init-addr from the step environment when you do not give them. Replace <model> with your model ID or local path; the same command line runs on every node:

bash
srun --nodes=2 --ntasks-per-node=1 tokenspeed serve <model> --attn-tp-size 16

The command starts one tokenspeed serve process on each of the two nodes. TokenSpeed derives the distributed arguments from the following Slurm environment variables:

ArgumentDerived from
--nnodesSLURM_STEP_NUM_NODES
--node-rankSLURM_NODEID
--dist-init-addrfirst host of SLURM_STEP_NODELIST, port 23456

The following rules control launcher integration:

  • An explicit --nnodes or --node-rank that contradicts the environment is an error, not an override. Omit the flag to accept the launcher's value.
  • TokenSpeed always uses an explicit --dist-init-addr as given.
  • Derivation only engages inside an srun step of more than one node. Outside a step — including the batch script of a multi-node sbatch — or in a single-node step, behavior is unchanged: launch the ranks yourself and pass --nnodes, --node-rank, and --dist-init-addr.
  • If TokenSpeed detects a multi-node step but cannot resolve the topology, startup fails with the reason rather than falling back to a single node.
  • The derived address is the one the head node's hostname resolves to. Where that is not the interface you want carrying bootstrap traffic, set --dist-init-addr explicitly.
  • TokenSpeed sets GLOO_SOCKET_IFNAME and NCCL_SOCKET_IFNAME from the interface that routes to the head node, unless they are already present in the environment. Gloo needs this: it has no peer-address heuristic and otherwise binds whatever the local hostname resolves to, which is a loopback entry on many hosts. NCCL normally selects correctly on its own. TokenSpeed sets it for consistency.
  • TokenSpeed does not set NCCL_IB_HCA. NCCL's own device selection prefers the higher-bandwidth InfiniBand devices and skips Ethernet-link ones.
  • The rendezvous port is a fixed constant, not a function of --port. Every node has to arrive at the same port without talking to any other node, and under tokenspeed serve TokenSpeed allocates the engine's own port per node. The constant also stays clear of the kernel's ephemeral range, which startup checks. Pass --dist-init-addr to use a different port.

Apply the same NCCL transport and channel settings on every node as well. In particular, do not mix IB and Socket selection or different NCCL_MIN_NCHANNELS and NCCL_MAX_NCHANNELS values across ranks.

After launch, validate the parallel deployment before sending load.

Stop every node ​

Stop every node. A node that stops does not stop the others: they find out at their next collective with it, which fails or can hang.

A node that receives SIGTERM or SIGINT, or whose scheduler fails, sends SIGTERM to the engine rank processes it started and gives them 30 seconds to exit. It then kills whatever is left of them and of the processes they started. On Linux, the rank processes of a node of rank 1 or higher are also killed when the node process itself is killed, for example with SIGKILL at the end of a grace period.

TokenSpeed documentation