Skip to main content

The Narwhal logo, a black narwhal with a teal spiral tusk above the wordmark

Apache-2.0 license Python 3.11 through 3.13 Lint and format by ruff Types checked with mypy Latest PyPI version

Documentation Deployment API reference Issues Contributing

What is Narwhal?

Narwhal is a disaggregated inference framework that automatically hot-swaps prefill and decode roles as demand changes, without reloading model weights. It runs on a single GPU or across multi-node deployments.

A terminal running narwhal dev up with eight engines, narwhal dev ask answering that the capital of France is Paris, then narwhal dev demo: the engines change roles in the live view, prefill engines moving to decode under long replies and back to prefill under long prompts, shown on a role history per engine

Eight llama.cpp engines on a machine with no GPU: start the fleet, ask one question, then run the demo load. Under long replies the router moves prefill engines to decode. When long prompts arrive, it moves them back to prefill. None of the demo's 757 requests failed or was turned away.

Trying it

Open in GitHub Codespaces

The button opens a codespace with Narwhal installed from this repository. Run the commands below in its terminal; the fleet runs on the CPU. On your own machine, install Narwhal first.

Narwhal dev runs four llama.cpp engines and a router on one Linux or WSL2 machine, on an NVIDIA GPU or on the CPU alone. Setup downloads the engine and a model under one billion parameters, 0.3 GB with the CPU build of the engine and 1.0 GB with the CUDA 12 build.

narwhal dev up
narwhal dev ask "What is the capital of France?"
narwhal dev demo
narwhal dev down --remove

up downloads the engine and the model on its first run, then starts the fleet with four engines; the recording above adds --engine-count 8. ask prints a reply and the engines that served its prefill and decode. demo sends long replies and then long prompts for 30 seconds each while the live view shows the engines change roles. down --remove stops the fleet and deletes the downloads. To drive the fleet yourself, run narwhal dev watch in one terminal and narwhal dev ask --repeat 200 --concurrency 8 in another.

To run vLLM, SGLang or TensorRT-LLM engines on one NVIDIA GPU instead, use narwhal dev init. That fleet goes through the same attestation, profiling and KV transfer checks as a deployed fleet.

Quick start documentation narwhal dev command reference vLLM, SGLang and TensorRT-LLM engine documentation RTX 5090 reference documentation

What it does

Capability Behavior Guide
Role hot-swap Reassigns prefill and decode roles across a GPU fleet, with NIXL key-value (KV) transfer between them Core concepts documentation
Serving Serves completion and chat requests, streamed or buffered, with latency-aware admission HTTP API reference documentation
Fault tolerance Fails over to a warm-standby router, readmits engines against their live process generation, and joins or removes engines without a restart Operating Narwhal documentation
Measurement Profiles engines, runs ordered benchmark points, and keeps the evidence from each point Measuring a fleet documentation
Observability Exports router and engine metrics to Prometheus and a provisioned Grafana dashboard Setting up observability documentation
Operator tooling Validates fleet files offline and collects private diagnostic bundles CLI reference documentation
Development mode Runs two to eight engines on one workstation under Ubuntu or WSL2, on a GPU or the CPU Narwhal dev documentation

How engines change roles

The role controller scores the current role split and each adjacent split, one engine move away. It uses measured engine profiles, offered demand, and resident work, and moves one engine only when the worst projected SLO ratio improves and every role, lifecycle, and resident-work guard passes. New requests follow the revised split, and resident requests finish on their assigned engines.

Role control and capacity floors documentation

Role controller changing engine roles with weights resident.

Evaluation

The evaluation ran Narwhal v0.1.0, Dynamo Planner and Ray Serve LLM on identical six-engine hardware, under two request schedules whose mix changes quickly. With prefix caching on, these are the shares of offered requests that met the SLO: a first token within 2.1 s, at most 45 ms per output token, and a natural finish.

Workload Narwhal Dynamo Planner Ray Serve LLM
Chat and documents 76.2% 56.8% 51.7%
Mixed 45.6% 21.7% 37.1%

Each configuration ran once. On mixed traffic, Narwhal's 95th-percentile time to first token was 11.3 s against 1.2 s for Ray Serve LLM. The post covers the setup, every metric and the limits of the comparison.

Installing

Install on Linux with Python 3.11 or newer:

python3 -m venv .venv
source .venv/bin/activate
python -m pip install narwhal-inference
narwhal-serve --version
narwhal --help

The wheel installs narwhal, narwhal-engine, narwhal-serve, narwhal-attest, narwhal-profile, and narwhal-check. To verify the installation, follow Installing from PyPI. For each command's options, use the CLI reference.

Bringing up a fleet

Run the deployment gates in Deploying a fleet from a management workstation. The documentation site has the rest.

Contributing

Contributing Code of conduct Security policy

Built on Arrow

Narwhal's scheduling algorithms are based on Arrow: Adaptive Scheduling Mechanisms for Disaggregated LLM Inference Architecture by Wu et al. (2025).

Arrow paper on arXiv Citation metadata for Arrow and Narwhal Apache-2.0 license

Changelog

0.13.0 (2026-11-26)

Features

  • dev: narwhal dev demo starts the fleet when it is not up, then sends long replies and long prompts for 30 seconds each while the live view shows the engines change roles, and reports the requests, role switches and final split. (#480) (3afd653)
  • dev: narwhal dev watch draws each engine's role history across the terminal's width with a mark at each role switch, shows the Narwhal logo when the terminal is tall enough, and names the role controller's last decision and its reason. The --once frame gains a controller field. (#476) (6c92325)

Fixes

  • dev: narwhal dev ask with one prompt decodes greedily unless the template sets a temperature, so the same prompt gets the same reply. (#480) (3afd653)
  • dev: narwhal dev sizes llama.cpp engine threads by a container's CPU quota, so engines under docker run --cpus or a Kubernetes CPU limit no longer oversubscribe it. (#479) (c5c64a0)

Documentation

  • The README opens with a recording of narwhal dev, an "Open in GitHub Codespaces" button and the evaluation's results. The repository's dev container runs make setup, so a codespace runs narwhal dev on the CPU without installing anything. (#477) (32b33c3)
  • The README's recording and "Trying it" commands go step by step: up, ask, then demo. (#480) (3afd653)

0.12.0 (2026-11-26)

⚠ BREAKING CHANGES

  • serving: A client that matched type standby during a hold on the lease holder now receives not_ready.
  • lifecycle: The router refuses an engine whose model files differ from the rest of the fleet. Engines from earlier releases do not report their model files, so they cannot share a fleet with 0.12.0 engines. Upgrading therefore takes the whole fleet out of service at once (docs/operate/04-Upgrade-and-Validate.md, "Upgrading to model file digests").
  • profiling: SGLang narwhal-profile --only sweeps require --router-url, or --no-router when no router serves the engines.
  • serving: A router without the lease answers GET /narwhal/engines, /lifecycle, /state, /handoff and /targets with HTTP 503 instead of its own snapshot. A request with X-Narwhal-Diagnostic: true still gets a standby's state and lifecycle.
  • observability: Metrics contract 3: each /metrics counter covers one router process and restarts at 0 when that process restarts, including on --resume. Deployment totals stay in /narwhal/state. make observe for a router pair requires NARWHAL_TARGETS_URL.

Features

  • calibration: narwhal-check --calibrate-first-token --pairs-with MEMBER --router-url URL calibrates a joining engine one member at a time while the other members serve clients. (#475) (0b29dfc)
  • deployment: The deploy path can deploy a vLLM fleet from a GGUF model file. (#454) (b9712fe)
  • dev: narwhal dev init --gpus runs each engine on its own GPU, so a dev fleet can join and remove engines. (#454) (b9712fe)
  • fleet-control: Join and Leave actions. Restore baseline returns engines that left and removes engines that joined. (#454) (b9712fe)
  • lifecycle: A drain with restart: false holds a running engine out of placement and readmits the same process. (#475) (0b29dfc)
  • lifecycle: Join, readmission, finalize-fleet and preflight refuse an engine whose model files differ from the fleet's. (#454) (b9712fe)
  • observability: Request outcomes draws not-ready refusals as rejected (not ready), apart from rejected (capacity). (#475) (0b29dfc)
  • observability: The router exports the membership generation and join and leave outcomes. The dashboard marks membership changes and keeps a departed engine's history. make observe scrapes both routers of a pair. (#454) (b9712fe)
  • profiling: narwhal-profile --copy-from MEMBER --only NEW gives a new engine the measured profile of a member without a sweep, when the engine's launch, model files and KV capacity match the member's. (#475) (0b29dfc)
  • serving: A lease holder that is not ready answers HTTP 503 with type and code not_ready and the cause in reason. (#475) (0b29dfc)
  • serving: The router adds and removes engines while it runs, through GET, POST and DELETE /narwhal/engines. A joining engine receives work only after it passes the contract, profile, calibration and readmission checks. A leaving engine drains before the router removes it. (#454) (b9712fe)
  • sglang: On SGLang 0.5.23 and later, engines launch with the overlap scheduler and FlashInfer decode attention. (#440) (5af93bc)

Fixes

  • calibration: First-token calibration asks for at least two output tokens per request, so it completes at the longest input length. (#454) (b9712fe)
  • dev: narwhal dev init reads the interface address without the ip command, so the TensorRT-LLM container no longer needs iproute2. (#454) (b9712fe)
  • ha: A lease holder stopped with SIGTERM keeps serving for --shutdown-drain seconds, 0.5 by default, after its readiness fails, so HAProxy no longer returns 502 during a takeover. (#475) (0b29dfc)
  • ha: The shipped HAProxy configuration holds requests through a router takeover instead of returning 503, also when the stopped router restarts at once as standby. (#454) (b9712fe)
  • profiling: An SGLang profiling sweep refuses to run until the router confirms that the peer it switches is out of service. (#454) (b9712fe)

Documentation

  • deploy: Fabric qualification shows how to send KV between engines of one host over their HCAs. (#475) (0b29dfc)
  • membership: New pages for the engine membership HTTP API and for joining and removing engines. (#454) (b9712fe)
  • The narwhal dev command reference is linked from the dev pages and narwhal dev --help. (#443) (c9ff72f)

0.11.0 (2026-11-22)

Features

  • observability: show the NVIDIA logo mark for TensorRT-LLM engines (#437) (40e2c33)
  • TensorRT-LLM engine backend (milestone 25) (#425) (28cba69)

Fixes

  • serving: release the router lease when shutdown starts (#436) (8980147)
  • SGLang role-switch transfers, profiler role restore and decode spread (#434) (8ae03b0)

Documentation

  • name TensorRT-LLM on the llama.cpp page and the shutting-down router state (#439) (d7566f0)
  • operate: name the readmission error a stopped sidecar causes in the whole-wave drill (#432) (bce4af3)
  • pre-release sweep of the operator and reference pages (#438) (40a15c1)

0.10.0 (2026-11-21)

Features

  • controller.reactive.decode_recovery schedules an early evaluation of a move to decode after a slot_wait refusal (5b8d174)
  • serving.prefill_on_decode lets placement borrow a decode-role engine for a prefill leg when every prefill-role engine misses the TTFT budget, and the journal records prefill_role (5b8d174)
  • tools/measurement/trace_convert.py writes public timestamped traces as mooncake_trace files (5b8d174)
  • a queued request whose decode-slot wait would pass its TTFT budget is refused with reason slot_wait, and the journal's admission price records the wait (2bbe619)
  • decode profiles reach each engine's sequence limit, and preflight warns when a profile stops short of it (2bbe619)

Fixes

  • a concurrent decode leg holds its decode seat from placement until its prefill completes plus its decode time, and refused or queued decode work counts as decode demand (2bbe619)
  • observability: recreate Prometheus when make observe stages a new config (#428) (9b649f8)
  • role control sees a decode shortfall on the confirmation span as well as the window, and prices arriving prefill work by each prompt's share of a batch (2bbe619)

0.9.0 (2026-11-14)

Features

  • narwhal dev ask sends prompts through the fleet and reports latency, throughput and the engines that served each request (7de19ff)
  • narwhal dev up sets up and starts a llama.cpp fleet on one Linux or WSL2 workstation, on an NVIDIA GPU or the CPU alone, and narwhal dev down --remove stops it and deletes its files (7de19ff)
  • narwhal dev watch shows each engine's role and load, latency, throughput and role switches in a live terminal view (7de19ff)
  • llama.cpp engine backend: prefill and decode run on separate llama-server processes, each request's KV cache moves between them through slot files, and the router switches engine roles under load (7de19ff)
  • the small vLLM and SGLang dev templates state GPU memory in MiB and run on GPUs with about 8 GiB and 10 GiB free (7de19ff)

Fixes

  • a native engine's identity holds when the host clock is corrected, as under WSL2 (7de19ff)

Documentation

  • quick start, live view and llama.cpp engine pages (7de19ff)

0.8.0 (2026-10-20)

Features

  • operator visibility and setup (#384) (3261c0d)
  • reuse still-valid calibrations and profiles (#373) (0181298)
  • take prefill capacity back on load surges and fix decode pressure and seat placement (#364) (d4ee7b0)

Fixes

  • ship characterization golden records in the sdist (#371) (5a0ae2e)
  • ship docs walkthroughs in the sdist and widen stage test budgets (#369) (4c08716)

0.7.0 (2026-10-12)

Features

  • SGLang engine backend and engine-neutral backend interfaces (#336) (c7ccf28)

Documentation

  • fit fleet walkthrough to viewport (#330) (0457952)
  • replace dashboard screenshots with a walkthrough (#333) (055f547)
  • trim duplicated documentation (#325) (cdeadb8)

0.6.0 (2026-10-10)

Features

  • fleet control service (#301) (f1f1164)
  • qualified admission, queueing and retries (#312) (05df12f)
  • redesign the fleet control console as a standalone page linked from Grafana (#313) (4d7be2e)

Documentation

0.5.0 (2026-10-05)

⚠ BREAKING CHANGES

  • engine-role environments drop NARWHAL_ENGINE_LAUNCHER and NARWHAL_ENGINE_LAUNCHER_SHA256; run engine actions with narwhal-engine. The attestation contract tool runs as python -m narwhal.deployment.attestation_contract.cli.

  • concurrent first-token calibration with measured and reused reporting (#242)

  • split oversized modules by concern (#252) (e29cadc), closes #239

Features

  • colour dashboard series by meaning (#270) (9212382)
  • concurrent first-token calibration with measured and reused reporting (#242) (683b83b)
  • enhance reactive policy to manage unsettled evaluations and departure leads (#251) (4712899)
  • faster role changes and slot-aware decode admission (#234) (55f7854)
  • make AIPerf 0.13.0 the documented benchmark client (#280) (cadcc87), closes #271
  • router data-plane throughput (#267) (1be680b)

Fixes

  • check idle engine connections with poll() (#281) (714adb7)
  • keep a departure leading through one evaluation below the margin (#250) (551fa2f)
  • pin Narwhal dev to vLLM 0.30.0 (#269) (25f5383)
  • use one red across the dashboard (#279) (37b5f5b)

Documentation

  • document resetting engine prefix caches (#283) (01cc58d)

0.4.1 (2026-10-02)

Features

  • give dashboard series one colour palette (#235) (c160ad5)

0.4.0 (2026-10-01)

Features

0.3.2 (2026-09-30)

Documentation

  • add Google Search Console verification file (#225) (ded08a8)
  • define milestone delivery and deployment privacy rules (#202) (6255337)
  • Refresh (#223) (f71a178)
  • refresh README introduction and link benchmark write-up (#217) (c10c3ae)
  • split Narwhal dev guide into numbered pages (#222) (5f2d3fa)
  • tighten contributor and issue-form prose (#210) (8d85ed8)

0.3.1 (2026-09-27)

Fixes

  • calibrate and enforce fleet timeout budgets (#158) (0629f01)
  • enforce generation-bound engine readmission and document lifecycle drills (#161) (03d3ac1)

Documentation

  • agent: define operator contract and plugin boundaries (#140) (b142e6a)
  • clarify cancellation in deployment attainment (#139) (2215401)
  • remove repeated guidance and clarify benchmark scope (27b573c)

0.3.0 (2026-09-25)

Features

  • add four-engine WSL2 development mode (8c5b980)
  • cli: add offline inspection, diagnostics and bounded lifecycle (9df3904), closes #122 #123 #124 #125 #126
  • docs: add selectable dark mode (1c87cae)
  • link Grafana icon to Narwhal repository (ea1d6df)
  • reproducible benchmark runs (#55) (671bf35)

Fixes

  • bind profiles to live engine generations (4ea5be0)
  • ci: remove release build pip cache (#77) (28fe2e0)
  • ci: validate release SHA before candidate checkout (1976ef8)
  • cli: enforce launch checks and consistent command output (49133c9)
  • include documentation commits in releases (d6e84bc)
  • serving: hide upstream exception details from clients (#75) (15482c8)

Documentation

  • clarify runbooks and align validation guidance (#104) (9cfe74b)
  • document issue labels and fix bug template (d8c37a5)
  • hide page edit action (04ed085)
  • refresh README installation and references (1612192)
  • remove obsolete CPU tooling references (#52) (b836a91)
  • simplify fleet deployment runbook (#92) (bd93aaf)

0.2.1 (2026-09-23)

Features

  • publish Narwhal distributions to PyPI (a328d00)

0.2.0 (2026-09-23)

Features

  • make first fleet deployment reproducible (14f27f0)

Fixes

  • ci: give deployment bundle tests Git history (33c2f9f)

0.1.0 (2026-09-20)

Narwhal's initial public release routes LLM inference across prefill and decode engines and changes their roles while model weights remain loaded.

Serving and admission

  • OpenAI-compatible completion and chat endpoints with streaming, input validation, and vLLM engine support.
  • Profile-based request placement with predictive admission and bounded queueing.
  • Optional transient retries restart the complete prefill/decode attempt before visible output. One deadline and a shared retry budget bound every original request.
  • Deployment-owned engine credentials authenticate serving, profiling, preflight and lifecycle probes.
  • Client cancellation releases capacity and bypasses the engine-failure counters. First-token deadlines remain active through metadata-only stream frames.
  • Engine health monitoring, quarantine, ejection, and recovery of the configured prefill and decode floors.

Fleet control

  • One reactive controller moves engines between prefill and decode roles. Each decision scores the current split and its adjacent alternatives. Role pinning and minimum pool sizes constrain those changes.
  • Decode capacity estimates account for active sequences and resident KV tokens. Profile coverage, demand evidence, resident work, and consolidation safety constrain role changes.
  • Warm-standby control-plane handoff preserves router state across takeover.

Deployment and validation

  • Generic vLLM/NIXL kv_both fleet support binds one model, hardware shape and KV layout through fleet configuration, engine attestations and measured profiles. Operators own image selection and process launch.
  • Kubernetes, Ansible, Terraform or site automation provisions hosts, distributes artifacts, configures routes and launches engines; Narwhal validates the running engine and KV-transfer contracts.
  • Preflight checks cover engine health, process-bound compatibility, generation, profiles, SLOs, and the transfer fabric.
  • Fleet schema 1 groups controller, serving, engine I/O, recovery and profile policy under their runtime owners. Ingress owns client identity and content capture; Narwhal owns one global admission budget and retains timings, identifiers, placements and outcomes.
  • Profile and configuration validation reject invalid types, non-finite values, incomplete measured domains, and mismatched engine sets.
  • Deployments record source identity and file digests.

Measurement and operations

  • Profiling measures per-engine prefill and decode curves; correctness canaries track exact output across live controller events.
  • Per-request journals, controller state, Prometheus metrics, a Grafana dashboard, and engine-down alerts. One startup command derives router and engine scrape targets from the deployed fleet, then verifies target health and populated dashboard queries.

Deployment qualification

  • Collect per-engine profiles, live runtime evidence, exact-output canaries and deployment load results before serving client traffic.
  • Validate prefix caching and speculative decoding against the selected model, engine build and KV layout before enabling them. Prefix caching requires exact-replay and continuation checks. Use whole-wave restart policy when the engine build shares peer registrations across the fleet.

See the configuration reference for defaults and the measurement guide for deployment requirements.

Metadata

Release files for narwhal-inference 0.13.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for narwhal-inference 0.13.0
File Size Uploaded Provenance Actions
narwhal_inference-0.13.0.tar.gz 4.8 MB With provenance Details for narwhal_inference-0.13.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for narwhal-inference 0.13.0
File Interpreter ABI Platform Actions
narwhal_inference-0.13.0-py3-none-any.whl Python 3 none any Details for narwhal_inference-0.13.0-py3-none-any.whl

Total release size: 5.4 MB

Release files / narwhal_inference-0.13.0.tar.gz

Download URL narwhal_inference-0.13.0.tar.gz
Size 4.8 MB
Tags Source
SHA-256 checksum
How to use checksums
82b223514287b65cc8fb5fca1ba717e7fab01c787ebb0ed591c382095cb1afa6
BLAKE2b-256 checksum
How to use checksums
dfc6b231c3894a946b220eec0fecd30f22d111cddc11967758f3389f6688d3a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

Release files / narwhal_inference-0.13.0-py3-none-any.whl

Download URL narwhal_inference-0.13.0-py3-none-any.whl
Size 586.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8d0d625fa77c89f3e8fa671ede64ce1b049281ee7e0d2e412d5273862d161e14
BLAKE2b-256 checksum
How to use checksums
1a61729a5f9ce126619506f23831b4af8e15d97a6b02416b12ab0cb9172727de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

Security for narwhal-inference 0.13.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for narwhal_inference-0.13.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page