Skip to content

SSH hosts

This page deploys a fleet on every SSH host you list. discover places the engines on the hosts: two on a single host with two GPUs or more, and one on each host when there are several. One router runs on engine 1's host. One router has no failover. On three hosts or more, init --router-pair adds a standby, as Adding a router pair shows. Deploying a fleet covers each stage, and the NarwhalFleet reference lists every field.

Prepare each host as Preparing SSH hosts lists. Every engine host needs the checkpoint at one path, unless the model stage fetches it. Each host must accept a key or the SSH agent, because init does not ask for a password.

Installing and trusting the hosts

On the workstation, install the release and write the known-hosts file:

python3 -m venv .venv && . .venv/bin/activate
python -m pip install 'narwhal-inference==<version>'
ssh-keyscan -t ed25519 <host-a> <host-b> > ssh.known_hosts
ssh-keygen -lf ssh.known_hosts

Compare each fingerprint with one from a source you trust, such as the provider console, before you go on. Preparing the workstation covers a jump host and a port other than 22.

Verifying the release manifest

init downloads the release manifest over HTTPS and pins its SHA-256 in spec.release. init checks the manifest's signature on the workstation before it reaches a host, and plan and run check it again before the first stage. Each check runs cosign verify-blob on the manifest's bytes with its keyless bundle, narwhal-release-manifest.json.sigstore.json, and accepts only a certificate that names Narwhal's release workflow running on main, issued by GitHub Actions. Install cosign v3 on the workstation first.

Without --release-manifest, init, plan and run download the bundle from the same GitHub release as the manifest. With --release-manifest FILE, they read it from FILE.sigstore.json beside the file. For an air-gapped deploy, download both into one directory:

gh release download v<version> --repo athrael-soju/Narwhal \
  --pattern 'narwhal-release-manifest.json*'

init, plan and run refuse with exit code 2, before init reaches a host and before the first stage, when cosign is not on PATH, when the bundle is missing or when cosign refuses the signature. plan and run also refuse a manifest whose SHA-256 differs from the pin. The error names what is missing or what cosign said, and the command or page that fixes it. The release manifest describes the file.

A deploy on SSH hosts installs no chart and does not check the images' build provenance. To check it, run gh attestation verify on each image digest in the manifest, as Verifying a release shows.

Deploying in one command

narwhal deploy run --hosts deploy@<host-a>,deploy@<host-b> --known-hosts ssh.known_hosts --model /srv/models/<model> --engine-key

With no fleet file in the directory, run writes narwhal-fleet.yaml and its secrets file as init does below. It checks each host as plan does. Then it runs every stage to a serving router with monitoring. Run narwhal deploy run again, with no options, to resume a run that stopped or to redeploy.

Add --gpus-per-engine 1 on a host with several GPUs to run one engine on each. Without it, discover places two engines on one host and one on each of several, each with an equal share of its host's GPUs.

Writing the fleet with init

narwhal deploy init --hosts deploy@<host-a>,deploy@<host-b> --known-hosts ssh.known_hosts \
  --model /srv/models/<model> --engine-key

init reads the manifest of the installed release from its GitHub release, or from the file that --release-manifest names. On each host, init does these steps:

  • It pulls the release's narwhal-host image and checks its ID against the manifest.
  • It inspects the host from the image: the GPUs, interfaces, default route and HCA ports, config.json in the --model directory, and the checkpoint's tree digest.

It refuses a host that has no checkpoint at that path. It also refuses a host whose checkpoint differs from the first host's, and names the first file that differs.

It writes narwhal-fleet.yaml with every value plan needs, each under a comment that names its source:

  • spec.release, the installed release and its manifest's SHA-256, and spec.engines.image, the release's tested engine image for the backend.
  • spec.engines.model, named after the --model directory, with the tree digest the hosts share.
  • spec.ssh.router.url, port 8000 at the address of engine 1's host's default route.
  • spec.ssh.modelDir and spec.ssh.runDir on the hosts. When the SSH users' homes differ, spec.ssh.engines gives each engine the directories below its own host's home.
  • The context, NARWHAL_CONTEXT_LENGTH: the model's length or 16,384 tokens, whichever is shorter. It is 8,192 at most when the engines send KV over ucx_tcp.
  • With --backend sglang, NARWHAL_DECODE_CUDA_GRAPH_MEMORY_GB, set to 2 as a starting value. It is the CUDA graph memory that each engine reserves when it switches to decode. Raise it for a model whose decode graphs need more.

On a host with a public and a private interface, add --interface <name> to serve on the private one. init then takes the router's address from that interface instead of the default route's, and with --router-pair the standby's and HAProxy's too. It writes spec.engines.fabricInterface, so discover gives each engine and its sidecar that interface's address on its host. When the interface is a bridge on an engine host and the engines send KV over ucx_tcp, init leaves fabricInterface out and says so: UCX lists no bridge as a TCP device, so the engines take the default route's interface. init refuses the option, and writes nothing, when a host lacks the interface or holds no single global address on it. Over ucx_rdma the interface must also be that of an ACTIVE HCA port on each engine host.

It writes no other engine topology, and no SLO targets. discover derives the engines from the hosts on every run, as Engine topology describes, and init prints the result. fleet-limits derives the SLO targets from the measured fleet, as Deriving the targets describes. The reference layout deploy/layouts/ssh/fleet.yaml shows a whole file.

init also writes narwhal-fleet-secrets.yaml at mode 0600, which spec.ssh.secretsFile names: routerToken, a new control token, and with --engine-key, engineKey, a new engine API key. For a host that logs in with a password, add sshPasswords: {node-1: <password>} to it.

To have the model stage fetch the checkpoint, give --model hf://<owner>/<name> or s3://<bucket>/<prefix>. init fetches the checkpoint once into the workstation cache, runs/models, which the model stage reads. It pins a Hub source to the commit that main names and writes the tree digest it found. The stage copies the tree to ~/narwhal/models/<name> on each engine host.

For a private source, --model-token-env NAME names the workstation variable that holds its token. init writes the token to the secrets file as modelToken.

For a release that is not on GitHub, such as a pre-release or an air-gapped one, copy its narwhal-release-manifest.json and pass --release-manifest FILE to init, plan and run.

Adding a router pair

On three hosts or more, add --router-pair to init:

narwhal deploy init --hosts deploy@<host-a>,deploy@<host-b>,deploy@<host-c> \
  --known-hosts ssh.known_hosts --model /srv/models/<model> --engine-key --router-pair

The standby router runs on the second host. HAProxy and narwhal-witness, which grants the pair's lease, run on the third host.

The third host needs no GPU and no checkpoint. List a small host with Docker. init marks it engines: false, places no engine on it, and gives it HAProxy and the witness wherever it comes in --hosts. Open port 8470 on it to both router hosts.

Clients send requests to HAProxy at spec.ssh.loadBalancer.url, port 8080 on that host. The loss of the third host stops HAProxy and the witness. Starting the router pair covers the stages it adds.

Checking, running and following the fleet

narwhal deploy plan
narwhal deploy run
narwhal deploy status

Each command reads narwhal-fleet.yaml and keeps its run in .narwhal/runs/first-fleet, named after spec.ssh.monitoring.fleetName, which init --name sets.

plan checks every field and each host: its Docker daemon, the fleet's ports and listen addresses, the checkpoint directory and the engine image. To estimate the first-token budget, it reads config.json on engine 1's host and the GPUs and HCA ports of each engine host. It prints each stage and why run would run it.

run runs the stages from access to monitoring. When a stage fails, fix the cause that run prints and run run again. It resumes at the failed stage.

narwhal fleet status reports the router, its lease and every engine. It reaches the router over SSH, as status reaches the hosts, so it needs no tunnel.

To send requests and open the dashboard from the workstation, open one tunnel to the router and one to Prometheus and Grafana on its host. Use a separate terminal for each:

narwhal deploy tunnel --remote-address <host-a address> --forward 18000:8000
narwhal deploy tunnel --forward 19090:9090 --forward 13000:3000

Then send a completion through the router:

curl -fsS http://127.0.0.1:18000/v1/completions \
  -H 'content-type: application/json' \
  -d '{"model": "<model>", "prompt": "The capital of France is", "max_tokens": 16}'

Checking the fleet with status and the dashboard shows the dashboard.

Stopping the fleet

narwhal deploy down

down stops what the run started and keeps the run directory; a later run starts the fleet again.