Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 2 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# Clean-clone CI: sibling private deps checked out into deps/.
#
# Default GITHUB_TOKEN cannot read other private repos. Set repository secret
# CROSS_REPO_PAT (classic PAT or fine-grained with contents:read on
# safetensors-zig + tokenizers-zig) for multi-checkout to work.
# Clean-clone CI: dependencies are fetched by `zig build` from the
# url+hash pins in build.zig.zon.
name: CI

on:
Expand All @@ -21,22 +18,6 @@ jobs:
with:
fetch-depth: 1

- name: Checkout safetensors-zig into deps/
uses: actions/checkout@v4
with:
repository: SMC17/safetensors-zig
path: deps/safetensors-zig
fetch-depth: 1
token: ${{ secrets.CROSS_REPO_PAT || github.token }}

- name: Checkout tokenizers-zig into deps/
uses: actions/checkout@v4
with:
repository: SMC17/tokenizers-zig
path: deps/tokenizers-zig
fetch-depth: 1
token: ${{ secrets.CROSS_REPO_PAT || github.token }}

- uses: mlugg/setup-zig@v2
with:
version: 0.16.0
Expand Down
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,4 @@ zig-out/
*.log
.DS_Store


# Local/CI dependency checkouts (see scripts/fetch-deps.sh)
deps/*
!deps/.gitkeep
zig-pkg/
14 changes: 4 additions & 10 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,10 @@ parity with Berkeley vLLM / SGLang. STATUS uses explicit non-claims — keep the

1. Read `README.md` and `STATUS.md` (Type-I notes on benches matter).
2. Run the proof gate before claiming tests green.
3. Dependencies live under `deps/` (gitignored checkouts or symlinks):

```text
deps/safetensors-zig -> path dep (clone or symlink)
deps/tokenizers-zig -> path dep (clone or symlink)
```

Bootstrap: `./scripts/fetch-deps.sh` (uses `gh` or sibling symlinks).
CI checks private siblings into `deps/` via multi-checkout (see `.github/workflows/ci.yml`).
Private GitHub archive `url`+`hash` is not used: unauthenticated fetch 404s.
3. Dependencies (safetensors-zig, tokenizers-zig) are pinned in
`build.zig.zon` as public GitHub archive `url`+`hash` entries, so a
fresh clone fetches them with no extra step. To bump one, run
`zig fetch <archive-url-at-new-sha>` and update both `url` and `hash`.

## Proof gate

Expand Down
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![CI](https://github.com/SMC17/vllm-zig/actions/workflows/ci.yml/badge.svg)](https://github.com/SMC17/vllm-zig/actions)
[![License: AGPL-3.0](https://img.shields.io/badge/License-AGPL_3.0-blue.svg)](LICENSE)
[![Zig: 0.16](https://img.shields.io/badge/Zig-0.16-orange.svg)](https://ziglang.org/)
[![Tests: 77/77](https://img.shields.io/badge/tests-77%2F77-success.svg)](#tests)
[![Tests: 82 pass, 9 skip](https://img.shields.io/badge/tests-82%20pass%2C%209%20skip-success.svg)](#tests)

## What ships (v0.0.6)

Expand All @@ -16,8 +16,8 @@
- PagedAttention KV substrate (`page_manager.zig` + `paged_attention.zig`):
K and V planes split, 64-byte-aligned, per-block per-head views
- Streaming `generate()` — each decoded token emitted via caller callback
- Parallel BF16→F32 weight load (safetensors-zig as a path dependency)
- 77/77 unit tests pass; SIMD ↔ scalar matmul agreement across 7
- Parallel BF16→F32 weight load (safetensors-zig as a pinned `url`+`hash` dependency)
- 82/91 unit tests pass, 9 skipped off Linux; SIMD ↔ scalar matmul agreement across 7
`(M, K, N)` shape variants

## What does NOT ship yet
Expand All @@ -31,7 +31,7 @@
## Quickstart

```sh
zig build test # 77 unit tests
zig build test # 91 unit tests
zig build forward-skeleton # Wiring smoke test
zig build bench-matmul # Matmul scalar vs SIMD speedup table
zig build bench-pool # Persistent pool vs ad-hoc spawn
Expand Down Expand Up @@ -168,7 +168,9 @@ cost dominating at M=1) was closed by the persistent worker pool at v0.0.5.

## Tests

77/77 unit tests pass at v0.0.6 (`zig build test`). SIMD ↔ scalar
`zig build test --summary all` on Zig 0.16.0, macOS arm64: 82/91 pass,
9 skipped (the `thread_pool.zig` tests need Linux futex and skip on
other OSes). Measured from a fresh clone on 2026-11-17. SIMD ↔ scalar
matmul agreement verified across 7 `(M, K, N)` shape variants. The
`forward-skeleton`, `infer-tinyllama`, and `bench-tinyllama-pool`
steps exercise the full pipeline end-to-end against real weights.
Expand Down
6 changes: 4 additions & 2 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@
.dependencies = .{
// Upstream: https://github.com/SMC17/safetensors-zig
.safetensors = .{
.path = "deps/safetensors-zig",
.url = "https://github.com/SMC17/safetensors-zig/archive/17328a3f984ab2b657396302f438a572e8a05be9.tar.gz",
.hash = "safetensors_zig-0.3.0-jWdPYkEIHgDRmmzZ7WK3QsUDZ9AhbWm7yhY1hQg8mscU",
},
// Upstream: https://github.com/SMC17/tokenizers-zig
.tokenizers = .{
.path = "deps/tokenizers-zig",
.url = "https://github.com/SMC17/tokenizers-zig/archive/558bfbcaf29319aacf6641ce81c901e571f14a15.tar.gz",
.hash = "tokenizers_zig-0.26.0-bcGp7yR1BwBZpxEKAKwwLkm1r56lGZOBuCieYOvfYUZ8",
},
},
}
Empty file removed deps/.gitkeep
Empty file.
9 changes: 8 additions & 1 deletion examples/infer_tinyllama.zig
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,14 @@ pub fn main(init: std.process.Init) !void {
std.debug.print("prompt tokens: {d}\n", .{ids_with_bos.len});

// --- KV cache ---
var kv = try vllm.kv_cache.KVCache.init(alloc, cfg.num_hidden_layers, cfg.max_position_embeddings, cfg.num_key_value_heads, cfg.head_dim);
// Paged KV: enough blocks for max_position_embeddings tokens in every layer.
const BLOCK_SIZE = vllm.page_manager.PageManager.BLOCK_SIZE;
const kv_blocks = cfg.num_hidden_layers * ((cfg.max_position_embeddings + BLOCK_SIZE - 1) / BLOCK_SIZE);
var pm = try vllm.page_manager.PageManager.init(alloc, kv_blocks, cfg.num_key_value_heads, cfg.head_dim);
defer pm.deinit();
var ba = try vllm.paged_attention.BlockAllocator.init(alloc, kv_blocks);
defer ba.deinit();
var kv = try vllm.kv_cache.KVCache.init(alloc, cfg.num_hidden_layers, cfg.num_key_value_heads, cfg.head_dim, &pm, &ba);
defer kv.deinit();

// --- Generate ---
Expand Down
30 changes: 0 additions & 30 deletions scripts/fetch-deps.sh

This file was deleted.

Loading