Skip to content

Development

Building

The source code is not public yet; this page is for working on it.

You need a recent stable Rust: 1.88 or newer, and tested with 1.100. Install it from rustup.rs; on Windows it also sets up the MSVC build tools. On Linux you also need a C compiler (sudo apt install build-essential pkg-config on Debian and Ubuntu), because the tokenizer's regular expressions use the Oniguruma C library.

cargo build --release                   # target/release/nvserve
cargo clippy --workspace --all-targets  # lints; kept free of warnings

To build only for your own CPU, with every instruction set it supports, set RUSTFLAGS="-C target-cpu=native" before cargo build.

Layout

Crate Purpose
nvserve-core ggml tensor types, model configuration
nvserve-pack GGUF reader, .nvpack format, converter, reader, verifier
nvserve-io direct I/O, the prefetching block streamer, on-demand block reader, memory limits
nvserve-kernels CPU math: its own AVX2 Q4_K/Q6_K matmul kernels (gemm.rs), candle for the other types, RoPE, attention, KV cache
nvserve-engine tokenizer, model layers (dense, MoE, MLA), layer-streaming executor, sampling, batching, speculative decoding, memory budget
nvserve-cli the nvserve program and its HTTP server

How it fits together is described in docs/ARCHITECTURE.md, and the file format in docs/NVPACK_FORMAT.md, in the repository.

Tests

cargo test --release --workspace
  • Always run:
  • unit tests;
  • the synthetic models: small Qwen3-MoE, DeepSeek-V2 and DeepSeek-V3 GGUFs with random weights, built by the tests themselves;
  • the I/O tests, including direct I/O;
  • the memory-cap test.
  • Need real models, each skipping with a message when its files are missing:

    Test file Needs (under models/, or the environment variable)
    tests/llama_1b.rs Llama-3.2-1B-Instruct-Q4_K_M.{gguf,nvpack} (NVSERVE_TEST_GGUF, NVSERVE_TEST_PACK)
    tests/qwen.rs qwen2.5-0.5b-instruct-q4_k_m.{gguf,nvpack} (NVSERVE_TEST_QWEN_GGUF, NVSERVE_TEST_QWEN_PACK)
    tests/deepseek_real.rs DeepSeek-V2-Lite-Chat.Q4_K_M.nvpack and DeepSeek's tokenizer.json as DeepSeek-V2-Lite-Chat.tokenizer.json; Moonlight-16B-A3B-Instruct-Q4_K_M.nvpack
  • Slow: the exact-f32 checks are opt-in: cargo test --release -p nvserve-engine --test llama_1b -- --ignored.

The real-model tests load one model at a time, so the suite peaks at about 4 GB of RAM.

Matmul kernels

cargo run --release -p nvserve-kernels --example kernel_bench compares NVserve's Q4_K and Q6_K kernels with candle's, for speed and agreement, at several batch sizes. Build with RUSTFLAGS="-C target-cpu=x86-64-v3" so candle uses its AVX2 code too. Set NVSERVE_KERNELS=candle to run any command on candle's kernels instead, for end-to-end comparisons. A laptop on battery gives noisy timings, so compare runs taken one after the other.

Server end-to-end check

nvserve serve models/model.nvpack --mem-limit 4G --port 8080 &
python eval/openai_e2e.py --base-url http://127.0.0.1:8080/v1 --max-tokens 24

Packaging

The scripts in scripts/ build the release archives into dist/:

.\scripts\package.ps1    # Windows: nvserve-<version>-windows-x86_64-{v3,compat}.zip
./scripts/package.sh     # Linux: nvserve-<version>-linux-x86_64-{v3,compat}.tar.gz

Each archive has a .sha256 file next to it. install/install.ps1 and install/install.sh install from a local archive or from a GitHub release. See Installation.

pip wheels

After building both archives, each script also builds the pip wheel for its platform: nvserve-<version>-py3-none-win_amd64.whl on Windows and nvserve-<version>-py3-none-manylinux_2_34_x86_64.whl on Linux. The tag follows the newest glibc the binaries need, and is never lower than 2.34.

  • Contents: both builds, in nvserve/bin/v3/ and nvserve/bin/compat/, plus a small Python launcher from python/nvserve/. The nvserve command and python -m nvserve run the launcher. It checks the CPU (the same check as the install scripts), then runs the matching build. On Linux it replaces itself with the program; on Windows it waits for the program and passes on its exit code. NVSERVE_BUILD=v3|compat overrides the choice.
  • Builder: scripts/build_wheel.py writes the wheel with only the Python standard library, so no build tools are needed. The PyPI page text is python/README.md.
  • Test before uploading: install the wheel into a fresh virtual environment with pip install --no-index dist/<wheel>, then run nvserve --version.
  • Upload: with a PyPI API token, run python -m twine upload dist/*.whl. Twine asks for the token; the user name is __token__. Upload both wheels for each version.

Website

This documentation is also a website, built with MkDocs and the Material theme. The configuration is mkdocs.yml at the repository root, and the pages are under docs/.

pip install -r docs/requirements.txt
mkdocs serve          # live preview at the address it prints
mkdocs build --strict # static site in site/

The landing page is custom:

File Content
overrides/home.html the page itself, a template the theme uses for docs/index.md
docs/assets/landing/landing.js the 3D scene (Three.js) and the animated sections
docs/assets/landing/landing.css its styles
docs/assets/vendor/three/ Three.js r160 and its MIT license, bundled so the site needs no CDN

The 3D scene shows NVserve at work:

  • two RAM slots climb a tower of model layers;
  • data streams from the SSD;
  • routed experts light up, teal for reads from disk and amber for cache hits;
  • every pass emits a token.

It pauses when off screen, and visitors who ask for reduced motion get a still frame. When mkdocs serve does not pick up a change to overrides/, restart it.

Publishing

The site is served at https://nvserve.in by GitHub Pages, from the gh-pages branch of the public nvserve-site repository. That repository holds only the built HTML; the sources stay here. docs/CNAME carries the domain into every build.

Once per clone, add the site repository as a remote:

git remote add site https://github.com/SinghSuraj-04092002/nvserve-site.git

Then, to publish the current docs:

.\scripts\deploy_site.ps1

It builds the site strictly, adds the public repository's README (website/README.md) and both license files, commits the result to gh-pages and pushes it. Pass -Python to use the Python that has mkdocs-material installed, and -NoPush to commit locally only. Pages updates within a minute or two. ARCHITECTURE.md and NVPACK_FORMAT.md are excluded in mkdocs.yml and never published.

Releases

  1. Set the workspace version in Cargo.toml.
  2. Run the tests on Windows and Linux.
  3. Merge dev into main through a pull request.
  4. Tag vX.Y.Z on main, publish the GitHub release with notes, and attach the archives from dist/.