narwhal deploy¶
narwhal deploy deploys a fleet to SSH hosts. run runs every stage from host access to a ready router pair behind HAProxy with the monitoring stack running. With --trial it also runs the capacity trial. After a failure, run resumes at the stage that failed.
Every subcommand except init and cache-groups reads the fleet from the NarwhalFleet file that --fleet names, narwhal-fleet.yaml by default. init writes that file from the SSH hosts, as Writing the fleet with init describes. Run each subcommand from the directory that holds the file, because relative paths in it are relative to that directory:
narwhal deploy init --hosts deploy@<host-a>,deploy@<host-b> --known-hosts ssh.known_hosts \
--model /srv/models/<model> --engine-key
narwhal deploy plan
narwhal deploy run
narwhal deploy run --trial capacity-trial.json
narwhal deploy run --run .narwhal/runs/second --reuse-from .narwhal/runs/first-fleet
narwhal deploy status
narwhal deploy down
plan, run, status and down keep the run in .narwhal/runs/<fleet name>, named after spec.ssh.monitoring.fleetName, unless --run names another directory. A new fleet name moves that directory, and the run there starts from nothing while the earlier run's containers still hold the ports. While the new directory holds no run, plan and run print a Note: for each run directory beside it whose run deployed the same engine hosts and roles, with the --run that goes on with that run and the narwhal deploy down --run that stops it. A Kubernetes fleet needs no init. The controller derives the nodes and generates the Secrets. Start from a reference layout and check it with plan:
With --target kubernetes, plan, run, status and down work on the namespace's NarwhalFleet. The fleet controller in the cluster runs the graph. The workstation applies the same file, follows its status and copies the evidence back.
With --target local, init, plan, run, status and down run a development fleet on this workstation from a dev template. --run and --fleet default as narwhal dev describes. The other subcommands work on SSH hosts only.
The fleet file¶
--fleet takes a NarwhalFleet manifest in YAML or JSON. A file that is not valid YAML is refused with the line where the parser stopped, such as narwhal-fleet.yaml is not valid YAML at line 4: mapping values are not allowed here. On SSH hosts it needs spec.ssh and spec.release. narwhal deploy refuses a secrets file that is not a regular file you own, or that other users can read or write. Keep it at mode 0600. The NarwhalFleet reference lists every field, the target that reads it and its default.
narwhal deploy reads no .env and no deployment variable from the environment. This is a breaking change from 0.13.0:
- A
--fleetthat holdsNAME=valuelines is refused with exit code2and error codeinvalid_input. The first error namesinit, which writes a fleet file from the hosts. Each further error names one variable and the field that replaces it, such asNARWHAL_TTFT_S is retired: set spec.slo.ttftS. planandrunrefuse, the same way, an environment that still sets a deployment variable. Unset them before you run either.- The environment keeps only what the workstation itself uses. These are
NARWHAL_KUBERNETES_CONTEXT,NARWHAL_KUBECTLandNARWHAL_KUBERNETES_STATE_CLAIMfor reaching a cluster. They also includeNARWHAL_STAGE_CLEANUP_GRACE_SECONDSandNARWHAL_STAGE_KILL_GRACE_SECONDSfor the stage runner, and theNARWHAL_TRIAL_variables of the measurement pages.
The other subcommands run one stage, or the stages of one gate, alone. transfer-measure, cache-groups, fabric and shell --run need a run directory whose roles stage passed, because it holds every host's role files:
narwhal deploy discover --fleet narwhal-fleet.yaml --out runs/discovery/first-fleet
narwhal deploy access --fleet narwhal-fleet.yaml
narwhal deploy transfer-measure --fleet narwhal-fleet.yaml --run .narwhal/runs/first-fleet \
--out runs/transfer-measure/first-fleet
narwhal deploy cache-groups --run .narwhal/runs/first-fleet --out runs/cache-groups/first-fleet \
--cache-layout engine-1=runs/cache-layouts/engine-1.json --cache-layout engine-2=runs/cache-layouts/engine-2.json
narwhal deploy fabric --fleet narwhal-fleet.yaml --run .narwhal/runs/first-fleet \
--groups runs/cache-groups/first-fleet/cache-groups.json --out runs/fabric/first-fleet
narwhal deploy shell --fleet narwhal-fleet.yaml --run .narwhal/runs/first-fleet --role router
narwhal deploy tunnel --forward 19090:9090 --forward 13000:3000
discover, access and shell without --run read the files that discover writes to the directory --config names, config by default: hosts.local.json, fleet.json and engine-launch.local.json. They also read the variables that discover derived from deployment.env, so you do not source it. When the run directory's record exists, tunnel without --hosts reads the hosts from it. The record is in .narwhal/runs/<fleet name> by default.
| Subcommand | Operation | Procedure |
|---|---|---|
init |
Pulls the release's host image on each SSH host and inspects the host from it. Reads the model's config.json and checkpoint digest there, or fetches a hf:// or s3:// model once. Writes a commented NarwhalFleet that plan accepts as written, with each value's source. Writes a new router token in the secrets file beside it, and an engine key with --engine-key. Prints each value and no secret. |
Writing the fleet with init |
plan |
Checks every input and the --trial file. Then it checks each host: its Docker daemon, the fleet's ports and listen addresses, the checkpoint directory, the engine image and the GPUs. It then prints each stage instance up to --until, with whether run would run it and why. Runs no stage and pulls no image. |
Running the stage graph |
run |
On SSH hosts with no fleet file, writes it from --hosts, --known-hosts and --model, as init does. Checks each host as plan does. Then runs every stage up to --until, and skips each stage whose recorded result still holds. Stops at the first stage that fails. |
Running the stage graph |
status |
Prints each stage's state, attempt and evidence directory from the run record, with the recovery section of a failed stage. Prints the SLO targets in the routers' fleet with their origin. Then checks each engine, sidecar, router and fabric route that the run recorded. Lists each container of the run that the record does not name, which the next run or down removes. |
Running the stage graph |
down |
Stops, in this order, the monitoring containers, HAProxy, the routers, the witness, the sidecars and the engine containers that the run started. It stops the processes of one kind at once, up to --concurrency, and starts on the next kind once they have all stopped. When a host does not answer, the stops under way finish, no further stop starts, and down exits with that host's error. It stops a recorded monitoring or HAProxy container whether it runs or not, so an exited or restarted one stays down. It then removes what a start left without a record, running or not. On each host it removes every container named narwhal-<run-id>-<name> whose io.narwhal.run label holds the run ID. It removes the monitoring containers that Compose started from the run's deployment directory, once the run has reached monitoring. It removes every other engine container that a launch directory of the run started, found by the launch directory's ownership label. If the fleet file does not name a recorded process's host, down looks for the process on every host of the fleet. down reports the process as not found when no host holds it. |
Running the stage graph |
discover |
Logs in to every host of spec.ssh.hosts that an engine, router or load balancer runs on. Inspects the GPUs, the engine image and the checkpoint on each engine host. Checks each checkpoint against spec.engines.model.treeSha256. Writes the host inventory, launch records, fleet and deployment.env. |
Running discovery and access checks |
access |
Checks the inventory, then logs in once to each host and records its hostname output. Prints each host ID with its roles. |
Running discovery and access checks |
transfer-measure |
On SGLang, measures eight KV handoffs from every engine whose backend sizes its fabric budget from them. Each handoff goes to the next engine role with the same launch inputs. Writes each engine's transfer.json. |
Measuring KV handoffs |
cache-groups |
Groups the engine roles of the launch records in engine-launch.local.json under --config. The grouping uses the discovered image and model configuration, the allocation, runtime and transport, and each engine's captured cache layout or measured KV handoff. Writes cache-groups.json. Prints each group's ID, representative and roles. |
Deriving cache-equivalence groups |
fabric |
Sizes each cache group's KV budget. Then checks the tools, routes, test port and RDMA GID entries of every directed edge between engine hosts. Measures each edge with iperf3 or ib_write_bw, or reuses a retained sample whose link record is unchanged. Compares the result against the budget of every source role. |
Qualify the transfer fabric |
shell |
Opens an interactive login shell on a role's host. With --run, the shell runs in the host image instead, in the run's deployment directory with the role environment loaded. |
Opening a role shell |
tunnel |
Forwards workstation loopback ports to a role's host. The run directory's record names the host, or --hosts or the inventory in --config names it when no run recorded one. The forwards stay open until you press Ctrl+C or send SIGTERM or SIGHUP, which close them. |
Tunnelling router, Prometheus, and Grafana to the workstation |
access and shell read the inventory that discovery writes. tunnel reads the inventory that --hosts names. transfer-measure, fabric, shell --run and tunnel without --hosts read the inventory of the run directory's discover. plan, run, status and down derive the hosts from spec.ssh.hosts and the hosts that the engines and routers name, as discover does. Host inventory and SSH trust describes it.
Running the stage graph¶
run keeps a run record, run.json, in the directory --run names, and writes each stage attempt to stages/<stage>/<instance>/attempt-<n>/ beside it. On a host, the attempt works in runs/deploy/<run-id>/stages/<stage>/<instance>/attempt-<n>/ under the deployment directory, and its files come back to the workstation attempt. The stage table lists what reruns each stage.
A first run¶
On SSH hosts with no fleet file yet, run takes the options of init and does the whole deployment:
narwhal deploy run --hosts deploy@<host-a>,deploy@<host-b> --known-hosts ssh.known_hosts --model /srv/models/<model> --engine-key
It writes narwhal-fleet.yaml and its secrets file as init does, makes the host checks of plan, and runs the stages. In a terminal it names the step under way while it pulls the host image, inspects the hosts and hashes the checkpoint. It then prints the fleet in a few lines. Each value's source is a comment in the file. Outside a terminal it prints every value with its source, as init does.
With a fleet file present, run deploys it as written and refuses these options with exit code 2. A later narwhal deploy run with no options resumes or redeploys the fleet.
init and run warn when the router's address is a public one, which init takes from the default route of engine 1's host, or from the interface that --interface names. To serve on another interface, remove the fleet and secrets files and write them again with --interface <name>. plan and later runs note it too.
Before its first stage, run makes the checks plan makes on each host, the first-token estimate and the check of the model's dtype. It stops there with exit code 1 on a problem.
plan and run check every input before they reach a host. They exit with code 2 and name the field of each input that is missing or malformed. The inputs are the discovery, fabric and release inputs and the deployment run inputs.
On SSH hosts, plan and run check the release manifest's signature with cosign verify-blob, unless a first run already checked it in init, as Verifying the release manifest describes. They exit with code 2 and error code invalid_input when cosign is not on PATH, when the manifest's bundle is missing or when cosign refuses the signature. --skip-signature-check deploys a --release-manifest file that a maintainer built locally, such as the one make release-dry-run keeps. init, plan and run then print Note: --skip-signature-check: the release manifest <file> deploys without a check of its signature, as a manifest built locally each time, once for a first run.
plan then checks each host. It exits with code 1 and names each host that fails a check and what to change.
plan also estimates whether preflight's first-token budget can fit spec.slo.ttftS, as Estimating the budget before the run describes. It estimates from the model's config.json: the one --model names, else the one in the tree that init or an earlier run fetched to spec.ssh.modelCache from spec.engines.model.fetch, else the one on engine 1's host. plan fetches nothing itself. When that config.json lacks a field the estimate prices, such as num_hidden_layers, plan makes no estimate. It names the field and the file in a note and still lists the stages.
From the same config.json, plan refuses a model whose dtype the engines do not load, such as float32, while spec.engines.launch names no NARWHAL_MODEL_DTYPE. It exits with code 1 and status failed_gate, with the instruction discover would give: set the spec.engines.launch entry NARWHAL_MODEL_DTYPE to bfloat16 or float16. Without a config.json to read, discover makes that refusal.
When the budget cannot fit, plan exits with code 1 and status failed_gate. It names the term that does not fit and the longest calibration length that would fit, and the error's context holds the terms. A close estimate prints a warning. Every estimate is in the result's data.estimate, with the GPUs and transport it priced in gpus and transport.
plan reads the run record without writing it. It checks the recorded processes and routes read-only. A stage after one that would rerun shows runs after <stage>, whose output changed when that stage's files would change. It shows runs after <stage> if <fact> changes when that stage's new result decides, as a new engine or container identity does. After a run that stopped at discover or roles, the record holds none of the files that the live checks read. plan then decides the later stages from what that stage's rerun would decide, and names each check it could not make as not observed. plan assumes that a container Docker restarted passes its check, because the check writes evidence on the host. It prints a Note: line that names the stage that reruns if the check fails.
What plan checks on each host¶
plan reads each host once over SSH, changes nothing there, and starts no GPU work. A host that it cannot reach, or that does not answer within the time limit, fails the check, and plan goes on to the next host.
| Check | The stage that would fail |
|---|---|
| The SSH user reaches a rootful Docker daemon that neither runs rootless nor remaps user namespaces | Every stage that starts a container |
| Nothing else listens on a port that the fleet will listen on. The ports belong to the router, the engines, their KV side channels and attestation sidecars, the load balancer and the witness. They also belong to Prometheus, Grafana and its image renderer on the primary router's host | The stage that starts the listener, monitoring last |
| No two of the fleet's own processes on a host listen on one port | The stage that starts the second |
Nothing listens on spec.fabric.testPort on a fleet with two or more engine hosts |
fabric-edge |
Each ucx_tcp engine's ucxTcpPortRange holds no port that another of the fleet's processes on its host listens on at the engine's address, and overlaps no other engine's range there. It shares no port with the host's net.ipv4.ip_local_port_range, apart from ports that net.ipv4.ip_local_reserved_ports reserves. An engine's transport is the fleet's, else the one discover derives, else ucx_tcp for engines that share one host |
engine-inspect, or a later stage whose listener or UCX listener finds its port taken |
In a router pair, each router host's wall clock lies within 30 seconds of the witness host's, the window in which the witness accepts a signed request. plan reads each clock with date in its one round trip to the host, and refuses only a difference that the round trips' durations cannot account for |
witness-start, whose router hosts read the lease with signed requests |
The host holds the address in spec.ssh.router.url, spec.ssh.standby.url, spec.ssh.loadBalancer.url, spec.ssh.monitoring.prometheusListenAddress and spec.ssh.monitoring.grafanaBindAddress, or resolves the name there to an address it holds |
router-start, load-balancer or monitoring |
The checkpoint directory exists and holds a file, unless spec.engines.model.fetch stages it |
discover |
The engine image is on the host, unless it is the release's tested image, which images pulls |
discover |
| The release pins the Prometheus, Grafana and renderer images this Narwhal's monitoring stack runs | images |
On the primary router's host, no monitoring stack that another run started runs as the fleet's Compose project, narwhal-observability-<fleet name>. Fleets that leave out spec.ssh.monitoring.fleetName all take the name default, so the monitoring stage of a second one would take over the first one's containers and volumes |
monitoring |
The release's host image inspects the engine host's GPUs, interfaces and HCA ports, with the GPUs passed to the container, and discover accepts the layout |
discover |
| The engines' GPUs, as the inspection lists them, are of one product, and so are each engine's own | discover |
Each engine's url in spec.ssh.engines is http://HOST:PORT with no path, its attestationUrl is http://HOST:PORT/v1/attestation, and its address is an IP address without brackets or a port |
discover |
The spec.engines.launch entry NARWHAL_ENGINE_BACKEND names an installed engine backend |
discover |
In a router pair, spec.ssh.router.url, spec.ssh.standby.url and the witness's address name a host, not the wildcard address 0.0.0.0 or ::. When the witness takes its address from its host's destination, an IPv6 address there is in brackets, as in ssh://deploy@[2001:db8::3] |
witness-start, whose router hosts dial the witness, and the HAProxy and standby that dial each router |
A port passes when a container of this run for that process publishes it, or when the process that listens runs in that container, as on a fleet that already serves. The run's containers are the ones it recorded and the ones down finds without a record, as described for down above. So a container that a failed or interrupted stage left passes, and the next run resumes at that stage, which replaces it. A port that the fleet file moved onto the listener of another process, one of the fleet's own included, does not pass. For any other holder, plan names the process that ss shows, or the container that publishes the port or whose command or environment names it. Otherwise it lists the host's other host-network containers.
An address problem lists the addresses the host holds:
narwhal: deploy plan: node-1: the router will listen on 192.0.2.9, an address this host does not hold; it holds 127.0.0.1, 192.0.2.1, so set spec.ssh.router.url to one of them
plan pulls no image, so it makes the last check only on an engine host that already holds the release's host image, as after init. For a host without the image, plan names the host. It prints Note: plan did not check that Docker passes each engine host's GPUs to a container, or the layout discover derives. A host without ip, hostname or getent is not judged on its addresses.
With --reuse-from, plan and run compare profile and calibrate with an earlier run directory, as Reusing profiles and calibration describes. run copies a stage whose digests all match and prints profile: reuses run <id>'s evidence. Its JSON result lists each compared stage under data.reuse with run_id, reused, mismatches and pending.
With --target kubernetes, the controller compares and copies. Once the fleet is ready, run prints the same line for each stage that the fleet's run record names as copied. It lists them under data.reused.
plan adds the same comparison to each stage row as reuse, and prints reuse of run <id> blocked: with every mismatch. status prints reused from run <id> for a copied stage and gives reused_from in its row.
plan and run refuse an earlier run directory with exit code 2 in five cases. The directory is missing. It holds no run record or salt. It belongs to another user. It lets other users in. It is the --run directory itself.
Each stage runs on its hosts:
| Stage | What run does |
|---|---|
access |
Logs in to the host and keeps its hostname output. |
model |
With spec.engines.model.fetch set, fetches the checkpoint on the workstation and stages it in spec.ssh.modelDir on each engine host, as Fetching the checkpoint describes. |
discover |
Runs discovery into the attempt and writes hosts.local.json, fleet.json, engine-launch.local.json, engine-launch.sources.json and deployment.env to its config/. Later stages read these instead of your config/. |
images |
Pulls and checks the release images that each host runs. Writes every host's role files from the discovered files, and copies each host's files into its deployment directory, as Pulling the release images describes. Every later host command runs in the host image. |
engine-inspect, engine-prepare, engine-check, engine-probe, cache-capture |
Runs narwhal-engine inspect-host, prepare, check, probe or capture-cache for the engine. engine-prepare writes a new launch directory in its attempt. Before engine-inspect runs again, the run stops its own sidecar and engine container of that role, whose ports the inspection checks. |
engine-start |
Removes the container of the engine's previous start, running or not, including one that Docker started again in place. Then runs narwhal-engine start --ready-seconds --replace-unrecorded with the stage limit less 60 seconds. A container that fails to answer is removed after narwhal-engine logs keeps the last 200 lines of its output in engine.log, with the engine key and the control token redacted. A launch directory starts one recorded engine. When engine-start reruns on a directory whose container the run recorded, it stops nothing. engine-prepare writes a fresh directory and the run continues from there. An interrupted start recorded nothing, so the next run starts again from the same directory once the container it left is removed. |
transfer-measure, cache-groups, fabric-budget, fabric-edge |
Measures the engine's KV handoffs, derives the groups and qualifies each edge as the matching subcommand does. fabric-edge reuses the previous attempt's sample while its link record holds. |
fleet-inventory |
Checks two things. The fleet that images copied to the router host names every engine of the inventory. Its role environment defines every ${...} reference of the fleet. |
attest-capture, sidecar-verify, finalize-fleet |
Captures and publishes the engine's attestation, verifies its sidecar, and writes the attested engine_contract into the router's fleet. |
sidecar-start |
Starts the attestation sidecar as a supervised container of the run, in place of the previous attempt's container. Waits for its attestation URL to answer HTTP 200. |
profile, calibrate, preflight |
Runs narwhal-profile or narwhal-check --calibrate-first-token once on the primary router's host, or narwhal-check on each router host. The fleet comes from fleet-limits or the stage before it. |
router-start |
Starts each router of the pair as a supervised container, the primary first, and measures the router overhead, as Starting the router pair describes. |
load-balancer, monitoring |
Starts HAProxy from deploy/ha/haproxy.cfg on the load balancer's host, or the monitoring stack on the primary router's host, as Serve and measure describes. |
trial |
With --trial, runs the load client from the workstation through SSH forwards. Reconciles each rate with the router journals and counters. Checks the engine, request, token, role and pool-load series in Prometheus. Runs the KV ring. Running the initial capacity trial describes it. |
fleet-limits |
Writes the SLO, engine.first_token_timeout_s as the calibrated candidate plus spec.firstTokenMarginS, the calibration path, and the spec.controller, spec.serving and spec.recovery settings into the router's fleet. |
When router-start reruns only because an engine restarted, the router keeps running. This holds when its fleet is unchanged and its router pair settings match the ones it started with. The router that holds the lease waits up to 120 seconds for the router to serve each restarted engine again. The router finds the new process itself, as Detect process replacement describes. An engine that the router holds blocked or drained is readmitted with its own POST /narwhal/lifecycle/readmit. An engine is back when it is active and accepts new requests. The router's accepted process start must also differ from the one it held before the restart. A refused readmission, or an active whole-wave restart, fails the stage with the router's reason.
run and status first check each recorded engine, sidecar, router, witness, HAProxy and monitoring container and fabric route. A container that Docker restarted after its process failed, or that you restarted with docker restart, has a new identity. docker restart sets Docker's restart count back to 0, and the run still reads the container as the one it recorded. When its sidecar verification or router health check passes, the run records the new identity in place and reruns only the later stages. When the check fails, its stage reruns.
status takes the run's lock to record the identity. It exits with code 1 while the last run stopped at a failed or timed-out stage. Otherwise it exits with code 3 when a recorded process is gone or changed, or a route changed. status also lists each container that a start of the run left without a record, as down finds it, by its container, host and process, such as narwhal-<run-id>-router on node-1, the router: running, from a start the run never recorded; the next narwhal deploy run or down removes it. The list does not change the exit code.
While another runner holds the run, status reads the record and each process without running the check. It records nothing, reports a restarted container as restarted, not checked, and sets locked in its JSON data. run and down exit with code 4 in that case.
Once fleet-limits has passed, status prints the SLO targets that it wrote into the routers' fleet, such as slo: ttft 2.871s, tpot 0.0275s, derived. It gives them as slo in its JSON data. origin is configured when spec.slo sets the targets, or derived when fleet-limits derived them. slo is null before fleet-limits passes.
When a stage's container is gone, as after down, the stage says so once, as sidecar-start: a container it started is gone, and runs again. A container that exited is named with its state.
A failed stage prints its cause, its recovery section and its evidence directory:
narwhal: deploy run: engine-check[engine-1] failed: node-1: check the engine-1 launch exited 1: ...
Recovery: https://athrael-soju.github.io/Narwhal/deploy/03-Validate-Engines/#preparing-checking-and-starting-each-engine
Evidence: .narwhal/runs/first-fleet/stages/engine-check/engine-1/attempt-1
Fix the cause and run run again. It resumes at the failed stage. down stops a container only when the run recorded it or its name and labels carry the run ID. It never stops a process that another run started.
In a terminal¶
On SSH hosts, when standard output is a terminal, run draws the run as one view and redraws it as stages start and pass:
⠙⢦⣄ Narwhal deploy first-fleet run 7539debc
⠙⢿⢰⣄ release 0.50.0 · node-1
⠘⢿⡼⣶⡀⡀ ⢀⣀⣀⣀⣀ 8 engines ucx_tcp
⢿⡇⣿⣆⣄ ⣴⣿⠿⠛⠛⠛⠻⢿⣷⣤⡀ served-model · context 8192
⠁⠻⣿⣿⣷⣌⢀⡀ ⠈⠻⣿⣆ checked node-1: Docker answers, and the fleet's ports are free
⠈⠘⣿⣿⣿⣿ ⣿⡷ ⠘⣿⣧⣄⡀ router not started
⢀⡀ ⠈⡙⠋⠁ ⢹⣿⣿⣿⣦⡀
⢀⣀⣀⣿⣿⡆ ⢸⣆ ⢸⣿⣿⣿⣿⣷ ━━━━━━━━━━╸ 7 of up to 24 stages 3:20
⠹⣿⣿⣿⣿⠇ ⣼⡟ ⢠⣷⡀⣸⣿⠇
⠉⠙⣷⣀ ⠠⠤⠴⠟⠋ ⢀⣰⣿⣿⣷⣿⠏
⠈⠻⣷⣤⣀⣀ ⢀⣀⣤⣴⣿⣿⣿⣿⠟⠁
⠉⠛⠿⢿⣿⣿⣿⣿⣿⡿⠿⠟⠋⠁
✓ 1 Discover ran 2 stages 1:07
✓ 2 Install ran 2 stages 0:07
⠹ 3 Validate engines 3 of 7 stages 2:04
✓ engine-inspect ▇▇▇▇▇▇▇▇ 8/8 0:13
✓ engine-prepare ▇▇▇▇▇▇▇▇ 8/8 0:10
✓ engine-check ▇▇▇▇▇▇▇▇ 8/8 0:51
⠹ engine-start ▇▇▇▇▇▄▄▄ 5/8 engine-6, engine-7, engine-8 0:48
· engine-probe ▁▁▁▁▁▁▁▁ 0/8
· cache-capture ▁▁▁▁▁▁▁▁ 0/8
· cache-groups
· 4 Qualify fabric
· 5 Attest
· 6 Profile and preflight
· 7 Serve and measure
▸ node-1: wait for the engine's health endpoint (engine-start)
The heading names the fleet, its release, hosts, engines, model and context, and the hosts that passed the Docker and port checks before the first stage. It names the router's address once router-start has passed. The bar under it covers every stage of the run. A running stage counts by the share of its instances that are settled. A stage that runs for no instance on this fleet, such as model without a model source, is not counted. The cache groups and the fabric edges come from the outputs of earlier stages, so the count reads up to until the run reaches fabric-budget and fabric-edge. The logo needs 96 columns and the rows of the whole view under the command line, 30 for most fleets. A shorter or narrower terminal gets a smaller logo, which needs 26 rows and 80 columns for most fleets, or the heading's text alone.
Each of the seven gates takes one line. It shows holds while its recorded results hold, or how many of its stages and instances ran and how long they took. It counts the stages the same way as the bar, as in 1 of up to 2 stages for Qualify fabric once fabric-budget has passed. The gate that is running lists its stages. The stages of some gates interleave in the stage graph, as access and discover of Discover do with images and roles of Install. Between two such stages a gate is marked · with how many of its stages are done and the stage it waits for, such as 1 of 2 stages, waits for discover.
A stage that runs once for each engine or host shows a block for each instance. The block is low while the instance waits, pulsing while it runs, full once it holds or has passed, and red where it stopped. A stage of more than 16 instances shows a bar. The line also counts the settled instances and names those running now. It gives its time so far, with of ~1:15 when the run record holds earlier attempts to estimate from. A stage that waits to run again gives the reason, such as sidecar_identity[*] is gone after down. An instance that runs again after a failed or interrupted attempt shows its attempt, as engine-4 retry 3.
What a stage reports, such as the measured router overhead, appears below the table, in the lines that the open gate leaves free. The table and those lines keep the height of the table with its largest gate open, so the view keeps one height while it runs. Lines that differ only in their numbers, as each engine's do, appear once with a count. The last line is the host command that just started.
When the run ends, a summary replaces the table and stays in the scrollback. It holds the gates, what the stages reported, and a panel. The panel shows the router's address, the monitoring addresses, the SLO targets, how many stage instances ran and how many held, and the run directory. The commands that come next follow it, such as narwhal deploy status, narwhal fleet status and narwhal deploy tunnel. The notes from before the first stage print last, each as a Note: line, such as the first-token budget estimate and a fleet that runs one router with no standby.
A run that stops at a stage opens that stage's gate and puts the cause in a panel, with any other instance that failed. The host log, the evidence directory, the recovery section and the command that resumes follow, each on its own line. After a first run that wrote the fleet file, that command leaves out the options that wrote it, which run refuses once the file exists. Ctrl+C ends the table the same way, with the cancelled instances and the command that resumes.
status prints the record at once, because the record is on the workstation. It prints one line for each gate whose stages all passed. For a gate where a stage did not pass, it prints the stages, with each such instance in full. It then checks what the run started on the hosts. Each kind of check is a row of blocks, one for each engine, host or router. The blocks fill as the answers come back. The host command under way shows beneath them. The rows end as found. A red block marks each check that does not hold. Below them status prints the count, such as 44 of 44 live checks hold, and each check that needs a look.
down counts the processes as they stop and names the last. It then prints one line for each host, such as node-1: stopped monitoring, the router, 8 sidecars and 8 engines.
Each command prints the plain lines of the sections above when standard output is a pipe or a file, with --format json, and with TERM=dumb. narwhal deploy run | cat gives them in a terminal. NO_COLOR keeps the table and drops its colours. The JSON result is the same in every case. --target kubernetes and --target local print plain lines.
A stage marked concurrent in the stage table, such as engine-start, runs its instances at once, up to --concurrency (8 by default). transfer-measure, fabric-budget, fabric-edge, preflight and router-start run one instance at a time, and --concurrency 1 runs every stage that way. Outside a terminal, each instance's progress lines print together, in instance order, as each one finishes. The run record, plan and status list the instances in the same order.
When an instance of a concurrent stage fails, the instances already running finish and keep their evidence, and no other instance of the stage starts. run reports the first failed instance in instance order, as above, and adds Also failed: with the others. The JSON result lists them in data.also_failed. The next run reruns only the instances that did not pass. Ctrl+C stops the host commands of every running instance, and the record marks each one cancelled.
run, plan and status also check the recorded engines, sidecars, launch directories and images of a concurrent stage's instances. They check them at once, up to the same limit.
Only container engines run on SSH hosts. down keeps the monitoring volumes, the deployment directories on the hosts and the run directory.
run --trial takes the stages to trial, and plan --trial decides them. Without --trial, run stops at monitoring and leaves a recorded trial as it is. --trial needs the default SSH target, and --until trial needs --trial. Both refusals exit with code 2.
Writing the fleet with init¶
init logs in to each host that --hosts names, through --jump when given. It accepts only the host keys in --known-hosts. Each host must accept a key or the SSH agent, because init asks for no password. init first reads the release manifest: that of the installed Narwhal's release, from its GitHub release, or the file --release-manifest names. It refuses a manifest of another release, because the workstation and the hosts run one release. Before it reaches a host, it checks the manifest's signature as plan and run do, with the same refusals and exit code 2, as Verifying the release manifest describes. With --skip-signature-check, the plan command it names carries the option too.
On each host, over SSH, init pulls the release's narwhal-host image, checks its ID against the manifest, creates ~/narwhal/runs, and reads the SSH user's home. It then starts a container of that image with the --model directory mounted read-only and the host's GPUs. It reads config.json in the --model directory. Then it hashes the checkpoint there. It refuses a host that holds no config.json there, or whose checkpoint differs from the first host's, and it names the first file that differs.
init fetches a --model of hf://<owner>/<name> or s3://<bucket>/<prefix> once, on the workstation, into runs/models, the cache that the model stage reads. The fetch gives the tree digest and config.json. A Hub source is pinned to the commit that main names. --model-token-env NAME names the workstation variable that holds a private source's token.
init writes no engine topology, except spec.engines.fabricInterface with --interface, unless that interface is a bridge on an engine host over ucx_tcp. discover derives the engines, their GPUs, ports, fabric interface, HCA port and transport from the hosts on every run, as Engine topology describes. init applies the same derivation to check the hosts, and prints the topology that discover will derive. It refuses a host with too few GPUs for its engines. With --transport ucx_rdma it also refuses a host with no ACTIVE HCA port that has a verbs device. It derives:
| Value | From |
|---|---|
spec.release |
The manifest's version and SHA-256 |
engines.image |
The manifest's tested engine image for the backend, --backend or vLLM |
engines.model.name |
The --model directory's name, or the last segment of its source |
engines.model.treeSha256 |
The tree digest every host's checkpoint shares, or that of the fetched tree |
engines.model.fetch |
A --model source, with a Hub source's commit in revision |
spec.ssh.hosts |
Each --hosts destination, named node-1, node-2 and so on as discovery names them. A host whose inspection finds no GPU device node gets engines: false. init refuses hosts that all lack one, a host whose GPUs it cannot read, and a host without GPUs that takes no role. Leave such a host out of --hosts |
spec.ssh.router.url |
Port 8000 at the address of the default route's interface on engine 1's host, or of the interface that --interface names. The fleet runs one router there |
engines.fabricInterface |
--interface only. discover gives each engine and its sidecar the address of this interface on its host. Over ucx_tcp, init writes none when the interface is a bridge on an engine host, because UCX lists no bridge as a TCP device. It says so in a comment above engines |
spec.ssh.standby, spec.ssh.loadBalancer, spec.ssh.lease.witnessHost |
With --router-pair, a standby router at port 8000 on a host besides the primary's. HAProxy at port 8080 and the witness go on a third host, the first host without GPUs where one is listed. Each is at its default route's address, or at the address of the interface that --interface names. Without it, none: the fleet runs one router, with no failover |
spec.ssh.modelDir, spec.ssh.runDir |
The --model directory, or ~/narwhal/models/<name> for a source, and ~/narwhal/runs, below the SSH user's home. When the homes differ, spec.ssh.engines gives each engine its own host's |
spec.ssh.monitoring.fleetName |
--name, first-fleet by default, which also names the run directory |
NARWHAL_TRANSFER_TRANSPORT in engines.launch |
--transport only |
NARWHAL_MODEL_DTYPE in engines.launch |
bfloat16, only when the model's config.json names a dtype the engines do not load, such as float32. init says so in one line of its output. Set the entry to float16 to serve in float16 instead |
NARWHAL_CONTEXT_LENGTH in engines.launch |
The model's max_position_embeddings, with three upper bounds. The value is at most 16,384. It is at most the longest context that the launch discovers. Over ucx_tcp it is at most 8,192. The transport is the one --transport names, or the one discover would derive |
calibration.inputTokens |
256, half the context, and the longest input that leaves two output tokens within the live context, which SGLang reports six tokens short |
profiling.prefillLens, profiling.decodeInputLens |
The starting lengths of Getting started below the context |
spec.ssh.knownHosts and spec.ssh.jump are the options given. init writes no SLO targets: fleet-limits derives them from the measured fleet, as Deriving the targets describes. The secrets file holds routerToken, engineKey with --engine-key, and modelToken with --model-token-env.
init writes the fleet at --out, narwhal-fleet.yaml by default. It writes the secrets file beside it, named after it with -secrets added, such as narwhal-fleet-secrets.yaml. Both files have mode 0600. It refuses with code 2 when either file exists, or when --out's directory does not, and writes neither. It prints each value with its source, and never a secret. With --format json, data.values lists them, and data.secrets names the file.
plan --target kubernetes --fleet FILE checks the fleet in FILE instead of building one from the environment. It refuses with code 2 naming each field the controller would refuse. Of the environment it reads only NARWHAL_KUBERNETES_NAMESPACE, NARWHAL_KUBERNETES_CONTEXT, NARWHAL_KUBECTL and NARWHAL_KUBERNETES_STATE_CLAIM. It refuses a fleet whose metadata names another namespace or another name than fleet.
On a Kubernetes cluster¶
With --target kubernetes, the subcommands apply the file --fleet names as the namespace's NarwhalFleet, named fleet, in the namespace its metadata.namespace gives. run sets spec.until from --until and spec.stopped to false, and applies every other field as written. The controller ignores spec.ssh, so one file can serve both targets, and plan notes it. A missing or malformed field exits with code 2 before the cluster is touched.
runapplies the fleet server-side as the field managernarwhal-cli, without forcing a conflict. It then follows the fleet's status until the fleet isReadyorStalled, or--timeoutpasses. It prints each stage's progress as it changes, such asengine-check: running (1/2 passed), and copies the evidence each time a stage instance passes.runtries a read of the fleet again for up to 5 minutes, within--timeout, when the API server does not answer. The controller carries on meanwhile. When the fleet stalled on a failed stage and the inputs did not change,runsets a newnarwhal-inference.com/requested-atannotation. The controller then runs the stage again.planchecks the inputs and dry-runs the apply on the API server. Each input that differs from the live fleet's reruns the stages that the stage table names for it. Each stage instance that has not passed in the run record that the run directory last copied also runs again. It starts no Job, and leaves the live pods and routes to the controller, which checks them on each pass. With--reuse-from <uid>, the applied fleet carriesspec.reuseFrom.plannotes that the controller decides on its pass whetherprofileandcalibratereuse that fleet's evidence.statuscopies the evidence again. It then prints the fleet's conditions and each stage of the run record. It also prints the SLO targets with their origin, and the live checks of the engine, sidecar and router pods. When the--rundirectory does not exist, as for a fleet that Helm or kubectl applied,statusonly gets the fleet. It prints the fleet's conditions and each stage from its stage conditions. It copies no evidence, checks no pod and creates no directory. It refuses with code2when the namespace holds no fleet either. A route needs a Job on each node to observe it, sostatusreports each fabric routenot observed. The controller observes the routes on every pass. A stalled fleet exits asrunwould. The code is2for a refused input, even when the run record holds a failed stage from an earlier pass. The code is1for a failed check.downsetsspec.stoppedand waits for the fleet'sStoppedcondition, within--timeout. With--deleteit then deletes the fleet, in the background, and the garbage collector removes what the controller made.downprints each process that the run started asstoppedonly once the fleet reportsStopped. A process whose stopdowndid not see printsnot confirmed stopped. The JSON data then hasstopped: false, andransays whether its pod ran until then. A fleet that has not stopped within--timeoutis not deleted, anddownexits with code4. The volumes stay either way, andrunstarts a stopped fleet again.
When another field manager owns a fleet's spec, such as Helm, Argo CD or Flux, the CLI follows the fleet and never writes it. run prints a note and follows it. down refuses it with code 2. Set spec.stopped through that tool instead. An apply, or plan's dry run of it, can meet a field that another manager took in the meantime. It then exits with code 4 and error code apply_conflict. Its context.fields lists each field and manager.
The run directory belongs to the workstation and keeps the owner and mode checks above. kubernetes-fleet.json names the fleet that the directory follows, by uid. The subcommands refuse a fleet with another uid, such as one that you deleted and made again. Start a new run directory for it. Beside it, the directory mirrors the controller's run directory: run.json and the evidence of every stage attempt that has ended. An attempt still running arrives once it ends, and kubernetes-export.json keeps which attempts the directory holds whole.
The workstation asks for an export through the fleet's narwhal-inference.com/export-request annotation, and the controller runs the export Job, as Evidence and logs describes. The Job has no ServiceAccount token. The workstation imports nothing unless the pod log's digest matches, and a copied file never replaces evidence that the directory holds. A log stays under 8 MiB, below the kubelet's 10 MiB log rotation, and the next Job carries the rest. A file too large for one log stays in the cluster, and the command result names it.
The controller runs one export Job per fleet at a time and takes one request every 5 seconds. A request that arrives while another export Job runs gets the answer an export is running; retry. The workstation then asks again under a new nonce, for up to 540 seconds, the Job's 300-second limit plus two 120-second grace periods. When another request replaces the annotation before the controller takes this one, the workstation asks again 30 seconds later. Only an export Job that an answer in status.exports names counts as running. The controller deletes any other Job that carries the export label and the fleet as its owner. Anyone who may create Jobs can make one. It also deletes the Job of each answer that drops out of status.exports.
The workstation's identity needs the chart's <release>-fleet-editor Role and the Role narwhal-workstation-pods. Write this to config/workstation-role.yaml and create it with kubectl apply --namespace <namespace> -f config/workstation-role.yaml:
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: narwhal-workstation-pods
rules:
- apiGroups: [""]
resources: [pods]
verbs: [get]
- apiGroups: [""]
resources: [pods/log]
verbs: [get]
Of the fleet-editor Role, the workstation uses get, create, patch and delete on narwhalfleets. The Role above lets it read the export Job's pod that the controller names and its log. It also lets the workstation read the engine, sidecar and router pods for the live checks of plan and status.
Editing the fleet still gives access to every Secret of the namespace, as Security and access describes.
To give the workstation a ServiceAccount as that identity, bind both Roles to the account and put a token for it in the workstation's kubeconfig:
kubectl create serviceaccount <account> --namespace <namespace>
kubectl create rolebinding <account>-fleet --namespace <namespace> \
--role <release>-fleet-editor --serviceaccount <namespace>:<account>
kubectl create rolebinding <account>-pods --namespace <namespace> \
--role narwhal-workstation-pods --serviceaccount <namespace>:<account>
kubectl create token <account> --namespace <namespace> --duration 8h
Write the token into a kubeconfig of its own, with the cluster's API server and CA, and point KUBECONFIG at it:
kubectl config set-cluster <cluster> --server https://<api server>:6443 \
--certificate-authority <ca.crt> --embed-certs --kubeconfig ws.kubeconfig
kubectl config set-credentials <account> --token <token> --kubeconfig ws.kubeconfig
kubectl config set-context <account> --cluster <cluster> --user <account> \
--namespace <namespace> --kubeconfig ws.kubeconfig
kubectl config use-context <account> --kubeconfig ws.kubeconfig
export KUBECONFIG=$PWD/ws.kubeconfig
The API server may give the token a shorter life than --duration asks for. Create a new one when it expires.
This identity cannot run kubectl port-forward, which the Kubernetes walkthrough uses to reach Grafana, Prometheus and HAProxy: it fails with cannot get resource "services". Open the forwards with another kubeconfig, or bind a Role such as this one to whoever opens them, as above:
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: narwhal-port-forward
rules:
- apiGroups: [""]
resources: [services]
verbs: [get]
- apiGroups: [""]
resources: [pods]
verbs: [get, list]
- apiGroups: [""]
resources: [pods/portforward]
verbs: [get, create]
kubectl port-forward svc/<service> gets the Service, lists its pods and opens the forward to one of them. The Role reads no Secret. A forward skips the NetworkPolicy. The kubelet connects it to the port on the pod's loopback address, so it reaches whatever a pod in the namespace serves there. The routers listen only on the pod's own address, so a forward to a router pod is refused with connect: connection refused. An engine pod runs on its node's host network. A forward to it reaches what listens on the node's loopback address, including services of the node that are not Narwhal's. Keep this Role apart from the workstation's, and give it only to people who may reach those.
Host keys and time limits¶
Every connection checks the host's key against spec.ssh.knownHosts alone, with OpenSSH StrictHostKeyChecking=yes, before it authenticates. narwhal deploy never adds or replaces a key in that file. A host whose key is missing from the file, or differs from it, fails with <host-id>: blocked at <operation>: the host key differs from the spec.ssh.knownHosts file or is missing from it. Known-hosts handling lists the options that override your SSH config. Jump host describes how to reach the hosts through one.
Key authentication runs with OpenSSH BatchMode=yes, so a key that needs a passphrase fails instead of prompting. Add it to your SSH agent first. shell can prompt.
Each remote command runs under the time limit of its stage:
| Stage | Remote commands | Limit |
|---|---|---|
access |
The login check of discover and access |
60 s |
model |
Each engine host's check, copy and hash of the checkpoint, and each live read of its file status | 21,600 s |
discover |
GPU and image inspection, checkpoint hashing | 3,600 s |
images |
Docker access, image pulls and checks, and the role files' transfer | 1,800 s |
transfer-measure |
Each engine's handoff measurement | 900 s |
fabric-budget |
Copying each representative's budget sources | 300 s |
fabric-edge |
Each tool, route, GID and port check, and each server start, client run and server stop | 300 s |
engine-inspect, engine-prepare, engine-probe, fleet-limits, sidecar-start, sidecar-verify, finalize-fleet, load-balancer |
Each host step of the stage | 300 s |
down |
Each host step, except the stops below | 300 s |
engine-check, engine-start |
The image and checkpoint check, or the start and its wait for /health |
1,800 s |
cache-capture, router-start, monitoring |
The cache layout capture, the router start and its checks, or the monitoring start | 600 s |
fleet-inventory |
Reading the copied fleet and role environment | 60 s |
attest-capture |
The attestation capture and publication | 900 s |
preflight |
narwhal-check |
3,600 s |
profile, calibrate |
narwhal-profile, or the first-token calibration |
7,200 s |
trial |
Each load client run, router journal read and the KV ring | 3,600 s |
down stops each router, the witness and each sidecar under the limit of the stage that starts it. It stops a container that a start left without a record the same way, HAProxy included. A router's stop waits for its stop timeout, spec.serving.gracefulTimeoutS plus 10 seconds, in down and when router-start replaces the router. plan and run refuse a fleet whose router stop timeout leaves less than 15 seconds of the router-start limit, and name the limit that fits.
spec.timeouts.stages.<stage> sets the limit of one stage, by its name, as in fabric-edge, and spec.timeouts.defaultSeconds sets the limit of every stage, in seconds. On SSH hosts each limit applies to each command of the stage, on a host or on the workstation, not to the stage as a whole. On Kubernetes the same fields limit a whole stage attempt, as Deploying on Kubernetes describes. For example, a checkpoint that takes longer than an hour to hash on an engine host needs:
The host runs each command under coreutils timeout. At the limit, timeout sends SIGTERM to the command and every process it started. Five seconds later it sends SIGKILL to a command that ignores SIGTERM. The host's shell then sends SIGKILL to that process group itself, because the uutils timeout of Ubuntu 25.10 and later never does. Both count as exceeding the limit. A host without timeout fails with the host lacks the coreutils timeout command. When the host has not answered 30 seconds after the limit, the workstation kills its ssh. The error names the host, the operation, the limit and the host's log, as in node-2: hash checkpoint files exceeded the 3600s discover time limit; inspect runs/discovery/first-deploy/logs/node-2.log. A run stage past its limit is recorded as timeout.
Each host command opens its own SSH connection. sshd counts a connection against its MaxStartups until the login completes. With OpenSSH's default of 10, sshd starts to drop new connections once 10 are logging in. Across one narwhal deploy command, at most 8 connections log in at once, however many host commands run. Through a jump host each command opens two connections, so 4 commands log in at once.
A connection that fails before its command starts ran nothing on the host. The workstation tries it again after 1, 2, 4 and 8 seconds, as long as the retry starts within 30 seconds of the first attempt. It does not retry a refused host key or login. The host's log lists each retry. After the last one, the error names the failure, as in node-2: blocked at hash checkpoint files: the SSH connection failed before the command started, on each of 5 attempts: Connection closed by 192.0.2.10 port 22; inspect runs/discovery/first-deploy/logs/node-2.log. A connection lost after its command started fails the command without a retry, because the command may have changed the host.
OpenSSH does not signal a command that has no terminal when its client dies. Suppose you stop discover or run with Ctrl+C or SIGTERM, or a host does not answer. The workstation then opens a second connection to every host whose command still ran. It opens them all at once and stops each command the same way within 30 seconds. A command that runs a step in the host image removes the step's narwhal-step-<id> container as it stops. Each host command records its timeout process ID under ~/.cache/narwhal-commands/ on the host, at mode 0600.
A host refuses every command before it runs when it cannot create or write that directory. The error is cannot create $HOME/.cache/narwhal-commands to record the command; make it writable. A host also refuses when the directory is a symbolic link, belongs to another user, or is writable by other users. In the last case the error is $HOME/.cache/narwhal-commands is writable by other users; run chmod go-w on it. OpenSSH gives up on a connection after 30 seconds. shell and tunnel run until you leave them.
Each host's log holds the scripts that ran there, their exit status or time limit, and their output, at mode 0600. The log directory depends on the command:
- Discovery,
transfer-measureandfabric:logs/in the command's output. run:logs/in each stage attempt.- The checks of
run,statusanddown:live/in the run directory. The checks of each host's images and each engine's launch directory, engine and sidecar uselive/<instance>/. access,plan,tunnel, andshellwithout--run:runs/access-<id>/.
Where each process logs lists the logs of the engines, sidecars, routers, HAProxy and monitoring that a run leaves running.
Fabric qualification¶
transfer-measure reads spec.fabric.workload.promptTokens and the role files of the run directory. It refuses with exit code 2 before it reaches a host in these cases:
- The input is missing.
- No engine of the run measures its handoffs.
- An engine has no other engine to decode its handoffs. A decode engine needs the same image, model configuration, accelerator, TP size, GPU visibility variable, runtime settings and transport.
It writes <out>/<role>/ with before.prom, after.prom and transfer.json for each engine, transfer-measure.json with each engine's decode peer, record SHA-256 and payload per handoff, and logs/. With --format json, the result's data holds out and the contents of transfer-measure.json.
fabric reads the fabric qualification inputs and the role files of the run directory. It refuses with exit code 2 before it reaches a host in these cases:
- An input is missing or invalid.
- The groups do not cover every engine role once.
- A representative's
--engine-runor--transfer-recordis missing, itstransfer.jsonmeasured another prompt length, or it does not match the metric snapshots beside it. - A
ucx_rdmaengine names other than one HCA port. - A
ucx_tcpengine sends KV through an interface other than its fabric interface, which isspec.engines.fabricInterfaceor its own inspec.engines.nodes.
It then runs the fabric-budget and fabric-edge stages of the stage graph and writes each instance's evidence to <out>/<stage>/<instance>/, as Qualify the transfer fabric describes:
| Path | Contents |
|---|---|
fabric-budget/<role>/ |
budget.json of the group that <role> represents, and the sources it was sized from |
fabric-edge/<source-host>-to-<destination-host>/<sample>/ |
The route, GID, link, sample and evidence files of each directed sample |
fabric.json |
The input digests, budgets and every sample's verdicts |
logs/<host-id>.log |
The scripts that ran on each host and their output |
Text mode prints one line per stage instance and sample, such as fabric-edge node-1-to-node-2 engine-1-to-engine-2: measured 96.950 Gbit/s; engine-1 needs 0.016; passed. A stopped stage writes narwhal: deploy fabric: <instance>: <cause>. With --format json, the result's data holds out and the contents of fabric.json.
Output and exit codes¶
In text mode, stdout carries progress lines, and a failure writes one stderr line, narwhal: deploy <subcommand>: <cause>.
| Outcome | Exit code |
|---|---|
| Success | 0 |
plan's first-token estimate cannot fit NARWHAL_TTFT_S. A remote command fails or exceeds its time limit. A fabric check fails. A fabric sample is below a role's budget. A stage's check rejects it. A host cannot run units for plan. status finds the last run stopped at a failed or timed-out stage. Another operating-system error occurs. |
1 |
Invalid arguments, inventory, environment, release or discovery inputs. A run directory whose roles stage has not passed. An output that already exists. A fleet that the API server or the controller refuses. |
2 |
status finds a recorded process gone or changed, or a route changed |
3 |
A stage of run fails without a verdict or exceeds its time limit. Another runner holds the run for run or down. An apply or plan's dry run meets another field manager's field. run or down follows a cluster's fleet past --timeout. |
4 |
run or tunnel stopped with Ctrl+C |
130 |
tunnel stopped with SIGTERM or SIGHUP |
143 or 129 |
With --target local, a failed verify stage exits 1 and any other failed stage 4. plan exits 1, and run 2, when the fleet file's settings differ from a fleet that is up. status exits 1 while the last run stopped at a failed stage and its processes still run, and 3 for another degraded fleet.
With --format json, plan, run, status, down, discover, access, transfer-measure, cache-groups and fabric print a versioned command result.
A stage of run exits with status failed_gate and code 1 in two cases. Its host command exited 1, which is the command result contract's rejected gate. Or its check rejected the stage. Any other stage failure exits with status error and code 4. A stage past its time limit has error code stage_timeout. The error carries the stage instance. Its context holds the host, exit status and log, the run record status and the recovery URL.
Each missing or malformed input is one invalid_input error. A failed or timed-out remote command, or a failed fabric check, exits with code 4. Its error carries the stage, and its context names the host, the operation and the log, or the fabric stage instance and host. A fabric sample below a role's budget exits with code 1 and status failed_gate, and its context names the instance, the role and both rates.
status after a failed or timed-out stage gives one failed_gate error for each such stage, with the stage instance and, in its context, the recovery URL.
shell and tunnel are interactive. They refuse --format json with exit code 2.
Options¶
Each option applies to these subcommands:
--format: every subcommand exceptshellandtunnel.--fleet: every subcommand exceptinitandcache-groups. It is optional forstatusanddownwith--target kubernetes.--config: every subcommand exceptinit,plan,run,statusanddown.--target:init,plan,run,statusanddown.--model:init,planand a firstrun.--engine-key,--backend,--transport,--known-hosts,--jump,--name,--router-pair,--model-token-env,--gpus-per-engineand--interface:initand a firstrun.--releaseand--release-manifest:init,planandrun.--skip-signature-check:init,planandrunon SSH hosts, with--release-manifest.--namespace:statusanddownwith--target kubernetes.--timeout:runanddownwith--target kubernetes.--delete:downwith--target kubernetesorlocal.--template,--engine-count,--port-baseand--accelerator:init --target local.--alongside:run --target local.--hosts:init, a firstrun,access,transfer-measure,fabric,shellandtunnel.--out:init,discover,transfer-measure,cache-groupsandfabric.--run:plan,run,status,down,init --target local,transfer-measure,cache-groups,fabric,shellandtunnel.--until,--trialand--reuse-from:planandrun.--concurrency:plan,runanddown.--cache-layoutand--transfer-record:cache-groups.--groupsand--retained:fabric.--role:shellandtunnel.--forwardand--remote-address:tunnel.
| Option | Default | Description | Valid values |
|---|---|---|---|
--format |
text |
Output format, either text or json for versioned command results. |
|
--fleet |
narwhal-fleet.yaml. Exceptions: status and down with --target kubernetes, and tunnel where that file does not exist. With --target local, fleet.yaml in the run directory |
The fleet file, a NarwhalFleet manifest in YAML, such as init writes. On Kubernetes, status and down read the fleet from the cluster instead. |
A file with apiVersion and kind, not an .env |
--config |
config |
The directory of the files discover writes: hosts.local.json, fleet.json, engine-launch.local.json and deployment.env. |
|
--hosts |
hosts.local.json in --config. For tunnel, the inventory of the run directory's record when it holds one. Required for init --target ssh and a first run |
Host inventory. For init and a first run, comma-separated: each engine host's SSH destination. Repeatable. |
For init, SSH destinations such as deploy@host-a |
--known-hosts |
Required for init --target ssh and a first run |
For init and a first run, the known-hosts file whose keys the hosts must present, written as spec.ssh.knownHosts. |
An existing file |
--jump |
None | For init --target ssh and a first run, the jump host to reach the hosts through, written as spec.ssh.jump. |
An SSH destination |
--name |
first-fleet |
For init --target ssh and a first run, the fleet's name, written as spec.ssh.monitoring.fleetName. It is the fleet label of the fleet's series, and the name of its run directory under .narwhal/runs. |
Lowercase letters, digits, ., _ and -, at most 63, starting with a letter or digit |
--router-pair |
Off | For init --target ssh and a first run, a router pair. The hosts get their roles as Writing the fleet with init describes. The fleet file names the host losses the fleet survives: a host's loss must leave two engines, and the loss of the third host stops HAProxy and the witness. init refuses a pair with fewer than three hosts. To place the routers yourself, write spec.ssh.standby, spec.ssh.loadBalancer and spec.ssh.lease by hand. |
|
--model-token-env |
None | For init --target ssh and a first run and a private hf:// or s3:// source, the workstation variable that holds the source's token. init fetches with it and writes it to the secrets file as modelToken. |
A set variable's name |
--model |
Required for init --target ssh and a first run. For plan on SSH hosts, the config.json in spec.ssh.modelDir on engine 1's host |
For init --target ssh and a first run: the checkpoint directory that every engine host holds, at one absolute path, or its config.json. It can also be a hf:// or s3:// source, which init fetches once into the workstation cache and writes as spec.engines.model.fetch. For plan: the model directory, or its config.json, on the workstation. plan estimates the first-token budget from it. |
For init and a first run, an absolute path without : or ,, or a source. For plan, a directory with config.json, or a JSON file |
--engine-key |
Off | For init and a first run, also generate an engine API key, engineKey in the secrets file. |
|
--backend |
The launch policy's own | For init and a first run, the engine backend, such as sglang. init writes it as the launch entry NARWHAL_ENGINE_BACKEND and derives the context and calibration lengths for it. |
A backend name |
--transport |
None written: discover derives the transport |
For init and a first run, how the engines send KV. init writes it as the launch entry NARWHAL_TRANSFER_TRANSPORT. ucx_tcp caps the context at 8,192 tokens. |
ucx_tcp or ucx_rdma |
--gpus-per-engine |
discover derives the engines: two on one host, one on each of several, each with an equal share of its host's GPUs |
For init --target ssh and a first run, how many GPUs each engine takes. Every host then runs as many engines as its GPUs hold. The fleet names each engine in spec.engines.nodes, the first engine of every host before any second one. init refuses a value that does not divide a host's GPUs, because the engines of a host share its GPUs equally. It also refuses a value that leaves the fleet fewer than two engines. |
A whole number of at least 1 |
--interface |
The default route's interface | For init --target ssh and a first run, the network interface every host serves on. The routers and HAProxy listen at its address on their host, and init writes it as spec.engines.fabricInterface, so the engines and their sidecars serve there too. Over ucx_tcp, an interface that is a bridge on an engine host gives the engines no fabric interface: UCX lists no bridge as a TCP device, so discover derives the engines' interface. init refuses a host that lacks the interface or holds no single global address on it. On an interface with both an IPv4 and an IPv6 global address, the address is the one of the default route's IP version. Over ucx_rdma, init also refuses an engine host where the interface has no ACTIVE HCA port with a verbs device. |
An interface name, such as eth1 |
--namespace |
The namespace the run directory follows | For status and down with --target kubernetes and no --fleet, the namespace whose fleet to follow. |
A DNS label |
--out |
narwhal-fleet.yaml for init --target ssh. Required for discover, transfer-measure, fabric and cache-groups |
For init, the fleet file to write, with its secrets file beside it. For discover, transfer-measure and fabric, a new directory for the discovery output, the handoff measurements or the fabric evidence, created at mode 0700. For cache-groups, the directory for cache-groups.json, created at mode 0700 when absent. |
For cache-groups, a directory without cache-groups.json. Otherwise, a path that does not exist |
--cache-layout |
None | ROLE=PATH: the cache-layout.json that narwhal-engine capture-cache wrote for the role. Repeatable, once for each engine that captures its cache layout. |
An engine-<n> role of the launch records |
--transfer-record |
None | ROLE=PATH: the transfer.json that transfer-measure wrote for the role, with before.prom and after.prom beside it. Repeatable, once for each engine whose handoffs are measured. |
An engine-<n> role of the launch records |
--run |
.narwhal/runs/ and the fleet's spec.ssh.monitoring.fleetName on SSH hosts, or its metadata.namespace on Kubernetes. For shell and tunnel, only where that directory holds a run record. Required for cache-groups. runs/dev with --target local |
For plan, run, status and down, the run directory that holds the run record. run creates it at mode 0700. run, status and down refuse a directory that another user owns or may enter. For the other subcommands, a run directory whose roles stage passed. With --target local, init also takes it: the run directory that init writes fleet.yaml and the downloads into. |
|
--target |
ssh |
For init, ssh means the hosts it inspects, and local means this workstation. For plan, run, status and down, it selects where the fleet runs. A run directory keeps the target it started with. |
ssh, kubernetes or local. init takes ssh or local |
--timeout |
86400 for run, 900 for down |
Seconds run follows the fleet until it is ready or stalled, or down waits for it to stop. The controller keeps working once it passes. |
A positive number |
--delete |
Off | down deletes the NarwhalFleet once it has stopped, or with --target local the run directory with its downloads and logs. With --target local, down refuses two kinds of directory. One is a directory whose fleet.yaml sets no spec.local or names another target's fields. The other is a directory that no run has prepared. It holds more than the fleet.yaml and assets that init wrote and the lifecycle.lock that a failed first run leaves. It then deletes nothing, names what it found and exits with code 2. |
|
--until |
monitoring, trial with --trial, or router-start with --target kubernetes |
The last stage plan decides or run runs. |
A stage of the stage table up to trial, which needs --trial |
--trial |
None | A narwhal.capacity-trial file with the capacity trial's workload, rates and thresholds. Its SHA-256 is the run's trial input. |
A readable file, on the ssh target |
--concurrency |
8 |
On SSH hosts, how many instances of a concurrent stage run at once, such as one per engine. The same number applies to their live checks. 1 runs every stage instance in turn. For down, it is how many processes of one kind stop at once, such as the engines. Whatever the value, at most 8 SSH connections log in at once, as Host keys and time limits describes. The local and Kubernetes targets run one instance at a time and refuse it with exit code 2. |
A whole number of at least 1 |
--reuse-from |
None | The earlier run whose profile and calibrate evidence to copy while every input they depend on matches. It is only read. With --target kubernetes, it sets the fleet's spec.reuseFrom. |
A run directory this user owns at mode 0700 other than --run, or with --target kubernetes a fleet UID from status.previousRuns |
--release |
This Narwhal's version for init, spec.release.version for plan and run |
The release whose release manifest to read from its GitHub release over HTTPS. For init it must be this Narwhal's release, and for plan and run equal spec.release.version. Excludes --release-manifest. |
MAJOR.MINOR.PATCH |
--release-manifest |
None: the GitHub release's | For init, plan and run, a copy of narwhal-release-manifest.json to read instead, for an air-gapped or pre-release deploy. For init it must be this Narwhal's release, and for plan and run its SHA-256 must equal spec.release.manifestSha256. On SSH hosts, init, plan and run check its signature with the bundle FILE.sigstore.json beside it. |
A readable file |
--skip-signature-check |
Off | For init, plan and run on SSH hosts, use the --release-manifest file without checking its signature, for a manifest a maintainer built locally. They print a note each time, and a resumed run keeps the option. They refuse it with exit code 2 without --release-manifest or on another target. |
|
--template |
direct-ernie45-03b-v1.json |
For init --target local, the dev template: an installed template's file name, or a template file's path. init writes it as spec.local.template with its SHA-256. |
An installed template, or a narwhal.dev-template file |
--engine-count |
The template's | For init --target local, engines, written as spec.local.engineCount. |
2 to 8 |
--port-base |
The template's | For init --target local, the router's port, written as spec.local.portBase. |
As the field |
--accelerator |
auto |
For init --target local and a template whose engines start directly, the engine build to download, written as spec.local.accelerator. |
auto, none for the CPU, or a build the template pins |
--alongside |
Off | For run --target local, starts this fleet while another local fleet is up. Each fleet takes its own memory. |
|
--groups |
Required | The cache-groups.json that cache-groups derived from the same run directory. fabric takes each group and its representative from it, and sizes each budget from the cache layout or transfer record the groups were derived from. |
A file whose launch record digests and geometry-source digests still match |
--retained |
None | Earlier fabric output whose samples to reuse while their link records hold. |
A directory with fabric.json |
--role |
Required for shell, router for tunnel |
The role whose host to open. | router or engine-<n> from the inventory |
--forward |
Required | LOCAL_PORT:REMOTE_PORT. Forwards workstation 127.0.0.1:LOCAL_PORT to REMOTE_PORT on --remote-address at the host. Repeatable. |
Ports 1 to 65535, a distinct local port per forward |
--remote-address |
127.0.0.1 |
Address that the forwarded ports listen on at the host. | An IPv4 or IPv6 address |