Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
1e77016
v4: restore model-specific tensor, safetensors and native-quant infra…
DrewZt Jul 21, 2026
ca6b8bb
v4: forward-port the DeepSeek V4 target engine
DrewZt Jul 21, 2026
433a2f9
v4: forward-port DSpark drafting and verification
DrewZt Jul 21, 2026
2430625
build: integrate V4 targets and tests with the current colibri tree
DrewZt Jul 21, 2026
68d9f7c
tests: restore the tiny token-exact V4 and DSpark oracle
DrewZt Jul 21, 2026
29f7a3c
ci: run the tiny V4 oracle on supported platforms
DrewZt Jul 21, 2026
9684279
docs: update DeepSeek V4 build and validation instructions
DrewZt Jul 21, 2026
94ef1be
build: validate the full V4 oracle from the make target
DrewZt Jul 21, 2026
0c17d02
docs: add Chinese DeepSeek V4 guide
DrewZt Jul 21, 2026
db1463e
docs(v4): track dynamic DSpark tuning
DrewZt Jul 21, 2026
83522db
fix(v4): harden production DSpark config parsing
DrewZt Jul 21, 2026
052fd67
fix(v4): support standard non-DSpark checkpoints
DrewZt Jul 23, 2026
b09ab5d
fix(v4): support Pro and decouple resident tiers
DrewZt Jul 27, 2026
4eadd93
build: enable DeepSeek V4 engine on aarch64 Linux
Jul 19, 2026
4aaf564
quant: NEON rows16 fp4 kernels for aarch64
Jul 19, 2026
5091374
Merge pull request #1 from anrasi/gb10-aarch64-v4
DrewZt Aug 1, 2026
27637f0
Merge upstream/dev and resolve PR #165 conflicts
DrewZt Aug 1, 2026
fddb786
Merge remote-tracking branch 'upstream/dev' into dev
DrewZt Aug 2, 2026
9869094
feat(st): support V4 checkpoint metadata
DrewZt Aug 2, 2026
8245eea
refactor(v4): preserve target-only runtime
DrewZt Aug 2, 2026
43c5db8
feat(cli): route DeepSeek V4 through coli serving
DrewZt Aug 2, 2026
f8888ae
test(v4): generate target-only oracle in CI
DrewZt Aug 2, 2026
aa1ec16
docs(v4): describe target-only engine split
DrewZt Aug 2, 2026
e68058d
st: retain tensor shapes and shard sizes
DrewZt Aug 3, 2026
12e172c
refactor(v4): complete target-only engine migration
DrewZt Aug 3, 2026
764c450
test(st): cover hostile shape rejection
DrewZt Aug 3, 2026
f60e3be
merge: sync st shape validation tests
DrewZt Aug 3, 2026
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
34 changes: 33 additions & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,21 @@ on:
pull_request:
branches: [main, dev]

permissions:
contents: read

concurrency:
group: check-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
PYTHONUTF8: '1'

jobs:
linux:
name: Linux
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- name: make check
Expand All @@ -20,7 +32,9 @@ jobs:
windows:
# The job that would have caught #68/#137 pre-merge: native MinGW-w64
# (MSYS2/UCRT64), the exact toolchain the README's Windows port targets.
name: Windows UCRT64
runs-on: windows-latest
timeout-minutes: 20
defaults:
run:
shell: msys2 {0}
Expand All @@ -45,13 +59,31 @@ jobs:
name: colibri-windows-exe
path: c/colibri.exe

v4-tiny:
name: Linux (generated tiny V4 target oracle)
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.13'
cache: pip
cache-dependency-path: c/tools/requirements-deepseek-v4-tiny.txt
- name: Install pinned tiny-fixture dependencies
run: python -m pip install -r c/tools/requirements-deepseek-v4-tiny.txt
- name: Generate fixture and run target oracle
run: make -C c deepseek-v4-tiny-check

macos:
# clang; libomp for the threaded path (Makefile falls back to
# single-threaded automatically if it's ever missing).
name: macOS (colibri + V4 platform gate)
runs-on: macos-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- name: install libomp
run: brew install libomp
- name: make check
- name: make check (V4 execution gated off)
run: make -C c check
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: all glm portable test check cuda-test clean install uninstall
.PHONY: all glm deepseek-v4 portable test check cuda-test clean install uninstall

all glm portable test check cuda-test clean install uninstall:
all glm deepseek-v4 portable test check cuda-test clean install uninstall:
$(MAKE) -C c $@
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,25 @@ Two things that differ per model, both documented in the per-model page:
| Grammar-forced drafts (structured output) | [docs/grammar-draft.md](docs/grammar-draft.md) |
| Environment variable inventory | [docs/ENVIRONMENT.md](docs/ENVIRONMENT.md) |

## DeepSeek V4

The experimental CPU path for **DeepSeek V4 Flash** uses native FP4 experts,
automatic RAM planning, shared `st.h` / `quant.h` infrastructure, and a
persistent target engine. DSpark is intentionally kept for a separate stacked
follow-up. The target engine is supported on x86-64/aarch64 Linux and
Windows/MSYS2.

```bash
cd c
make deepseek-v4
python ./coli run --model /path/to/DeepSeek-V4-Flash --ram 32 \
"What is the capital of France?"
# The same model also works with: coli chat / coli serve / coli web
```

See [docs/deepseek-v4.md](docs/deepseek-v4.md) for status, checkpoint
validation, unified CLI/server usage, and the generated tiny independent oracle.

## What's next

- **Inference-systems research is the product.** The current hierarchy is LRU +
Expand Down Expand Up @@ -499,7 +518,7 @@ c/
└── tests/ dependency-free C and Python tests
web/ browser UI (pure OpenAI-API client)
desktop/ Tauri v2 desktop shell wrapping the web UI
docs/ reference docs, experiments, media
docs/ reference docs, experiments, media, DeepSeek V4
```

The runtime path intentionally stays flat and readable: `glm.c` plus its small
Expand Down
21 changes: 20 additions & 1 deletion README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,25 @@ COLI_MODEL=/nvme/glm52_i4 ./coli doctor # 只读就绪检查
| 语法强制草稿(结构化输出) | [docs/grammar-draft.md](docs/grammar-draft.md) |
| 环境变量完整清单 | [docs/ENVIRONMENT.md](docs/ENVIRONMENT.md) |

## DeepSeek V4

实验性的 **DeepSeek V4 Flash** CPU 路径使用原生 FP4 专家、自动 RAM
规划、共享的 `st.h`/`quant.h` 基础设施,以及常驻 target engine。
DSpark 有意保留给紧随其后的独立 stacked PR。本 target engine 支持
x86-64/aarch64 Linux 与 Windows/MSYS2。

```bash
cd c
make deepseek-v4
python ./coli run --model /path/to/DeepSeek-V4-Flash --ram 32 \
"法国的首都是哪里?"
# 同一模型也支持:coli chat / coli serve / coli web
```

状态、checkpoint 验证、统一 CLI/server 用法和动态生成的 tiny 独立
oracle 说明,请参阅[中文版 DeepSeek V4 文档](docs/deepseek-v4.zh-CN.md);
英文原文见 [docs/deepseek-v4.md](docs/deepseek-v4.md)。

## 下一步

- **推理系统研究就是产品。**当前层级采用 LRU 与学习型固定集;正在研究模型格式、压缩、
Expand Down Expand Up @@ -323,7 +342,7 @@ c/
└── tests/ 零依赖的 C 与 Python 测试
web/ 浏览器 UI(纯 OpenAI API client)
desktop/ 封装网页 UI 的 Tauri v2 桌面 shell
docs/ 参考文档、实验与媒体文件
docs/ 参考文档、实验、媒体文件与 DeepSeek V4 说明
```

运行时路径刻意保持扁平、易读:`colibri.c` 加上若干头文件。
Expand Down
133 changes: 129 additions & 4 deletions c/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,23 @@ else
PYTHON ?= python3
endif
CUDA_OBJ =

# DeepSeek V4 is a separate x86-64/aarch64 runtime. Portable infrastructure
# tests run everywhere; the engine and token-exact fixture run on x86-64
# Linux/Windows and aarch64 Linux. SIMD fast paths are gated per-feature
# inside the sources, so a plain armv8-a build stays correct.
COLI_V4_SUPPORTED :=
ifneq (,$(X86_64))
ifneq (,$(IS_WIN)$(LINUX))
COLI_V4_SUPPORTED := 1
endif
endif
ifneq (,$(AARCH64))
ifneq (,$(LINUX))
COLI_V4_SUPPORTED := 1
endif
endif

# Gates are exactly the tests that have a build rule further down -- derived from those
# rules, so adding a gate means adding your tests/test_*.c and its rule, and nothing else.
# There is no shared list to conflict on.
Expand All @@ -261,12 +278,17 @@ CUDA_OBJ =
# work-in-progress test, test_fse, test_tok, test_tok_kimi, test_vk_mxfp4) into gates, and
# they fail to link. Having a rule is the honest definition of "this is a gate".
TEST_RULES := $(shell sed -n 's|^tests/\(test_[a-z0-9_]*\)\$$(EXE):.*|\1|p' $(firstword $(MAKEFILE_LIST)))
# test_uring has a rule but is Linux-only; it is appended conditionally just below.
TEST_EXCLUDE = test_uring
# test_uring is Linux-only. V4 engine tests are appended below only on supported
# x86-64 Linux/Windows and aarch64 Linux hosts; the V4 infrastructure tests have
# unconditional rules and therefore remain portable gates.
TEST_EXCLUDE = test_uring test_deepseek_v4 test_v4_ownership
TEST_BINS = $(addprefix tests/,$(addsuffix $(EXE),$(filter-out $(TEST_EXCLUDE),$(TEST_RULES))))
ifneq (,$(LINUX))
TEST_BINS += tests/test_uring$(EXE)
endif
ifeq ($(COLI_V4_SUPPORTED),1)
TEST_BINS += tests/test_deepseek_v4$(EXE) tests/test_v4_ownership$(EXE)
endif

# Windows CUDA DLL path: host links the loader, NOT cudart.
ifneq ($(IS_WIN),)
Expand Down Expand Up @@ -368,6 +390,47 @@ endif

all: colibri$(EXE)

.PHONY: deepseek-v4 deepseek-v4-oracle deepseek-v4-tiny-generate \
deepseek-v4-tiny-check deepseek-v4-clean
ifeq ($(COLI_V4_SUPPORTED),1)
deepseek-v4:
$(MAKE) -f Makefile.deepseek-v4 ARCH=$(ARCH) deepseek-v4

deepseek-v4-clean:
$(MAKE) -f Makefile.deepseek-v4 deepseek-v4-clean

deepseek-v4-tiny-generate:
$(PYTHON) tools/make_deepseek_v4_tiny.py \
--output ./deepseek_v4_tiny --force

deepseek-v4-tiny-check: deepseek-v4-tiny-generate
$(MAKE) -f Makefile.deepseek-v4 deepseek-v4-clean
$(MAKE) -f Makefile.deepseek-v4 ARCH=$(if $(strip $(ARCH)),$(ARCH),$(PORTABLE_ARCH)) deepseek-v4
$(PYTHON) tests/test_deepseek_v4_tiny.py \
--binary ./$(if $(IS_WIN),deepseek_v4.exe,deepseek_v4) \
--fixture ./deepseek_v4_tiny

deepseek-v4-oracle: deepseek-v4
@test -n "$(MODEL)" || { echo "usage: make deepseek-v4-oracle MODEL=/path/to/checkpoint" >&2; exit 2; }
$(PYTHON) tools/make_deepseek_v4_oracle.py --model "$(MODEL)" \
--binary ./$(if $(IS_WIN),deepseek_v4.exe,deepseek_v4) \
--output tests/deepseek_v4_oracle.json \
--memory-gb $(or $(MEMORY_GB),32) \
--prompt "$(or $(ORACLE_PROMPT),The capital of France is)" \
--validate \
--teacher-forcing $(or $(ORACLE_TEACHER_FORCING),32) \
--greedy $(or $(ORACLE_GREEDY),20)
else
deepseek-v4 deepseek-v4-oracle:
@echo "$@ is supported only on x86-64/aarch64 Linux and Windows/MSYS2" >&2; exit 1
deepseek-v4-clean:
@:
deepseek-v4-tiny-check:
@echo "SKIP deepseek-v4-tiny-check: V4 runtime requires x86-64/aarch64 Linux or Windows/MSYS2"
deepseek-v4-tiny-generate:
@echo "SKIP deepseek-v4-tiny-generate: V4 runtime requires x86-64/aarch64 Linux or Windows/MSYS2"
endif

# phony targets — 'glm' kept for backward compatibility
colibri: colibri$(EXE)
glm: colibri$(EXE)
Expand Down Expand Up @@ -553,6 +616,9 @@ tests/test_tok_o200k$(EXE): tests/test_tok_o200k.c tok.h tok_unicode.h tok_unico
tests/test_st_pread$(EXE): tests/test_st_pread.c st.h json.h compat.h
$(CC) $(CFLAGS) -DST_PREAD_CHUNK=7 $< -o $@ $(LDFLAGS)

tests/test_st_shape$(EXE): tests/test_st_shape.c st.h json.h compat.h
$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)

tests/test_st$(EXE): tests/test_st.c st.h json.h compat.h
$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)

Expand Down Expand Up @@ -649,6 +715,59 @@ tests/test_i4_acc512$(EXE): tests/test_i4_acc512.c
tests/test_compat_direct$(EXE): tests/test_compat_direct.c compat.h
$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)

tests/test_expert_store_ops$(EXE): tests/test_expert_store_ops.c expert_store.h tensor.h
$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)

tests/test_native_quant$(EXE): tests/test_native_quant.c deepseek_v4.c native_quant.h tensor.h quant.h
$(CC) $(CFLAGS) -DCOLI_V4_UNIT_NATIVE_QUANT deepseek_v4.c $< -o $@ $(LDFLAGS)

ifeq ($(COLI_V4_SUPPORTED),1)
include Makefile.deepseek-v4.units
V4_TEST_LINK_OBJS = \
COLI_V4_UNIT_ST.o \
COLI_V4_UNIT_CONFIG.o \
COLI_V4_UNIT_MATH.o \
COLI_V4_UNIT_SPARSE_ATTENTION.o \
COLI_V4_UNIT_RESOURCE_PLAN.o \
COLI_V4_UNIT_PROMPT.o \
$(addsuffix .o,$(V4_TEST_UNITS)) \
COLI_V4_UNIT_NATIVE_QUANT.o

tests/test_deepseek_v4$(EXE): tests/test_deepseek_v4.c deepseek_v4.c deepseek_v4.h \
Makefile.deepseek-v4.units
$(MAKE) -f Makefile.deepseek-v4 ARCH=$(ARCH) deepseek-v4-test-objs \
COLI_V4_UNIT_ST.o COLI_V4_UNIT_CONFIG.o COLI_V4_UNIT_MATH.o COLI_V4_UNIT_SPARSE_ATTENTION.o \
COLI_V4_UNIT_RESOURCE_PLAN.o COLI_V4_UNIT_PROMPT.o COLI_V4_UNIT_NATIVE_QUANT.o
$(CC) $(CFLAGS) $< $(V4_TEST_LINK_OBJS) -o $@ -pthread $(LDFLAGS)

V4_OWN_DIR = build/ownership
V4_OWN_CFLAGS = $(CFLAGS) -DCOLI_V4_TEST_HOOKS
V4_OWNERSHIP_OBJS = \
$(V4_OWN_DIR)/COLI_V4_UNIT_RUNTIME.o \
$(V4_OWN_DIR)/COLI_V4_UNIT_CONFIG.o \
$(V4_OWN_DIR)/COLI_V4_UNIT_ST.o \
$(V4_OWN_DIR)/COLI_V4_UNIT_NATIVE_QUANT.o

$(V4_OWN_DIR):
mkdir -p $(V4_OWN_DIR)

$(V4_OWN_DIR)/COLI_V4_UNIT_RUNTIME.o: deepseek_v4.c deepseek_v4.h deepseek_v4_internal.h | $(V4_OWN_DIR)
$(CC) $(V4_OWN_CFLAGS) -DCOLI_V4_UNIT_RUNTIME -c deepseek_v4.c -o $@

$(V4_OWN_DIR)/COLI_V4_UNIT_CONFIG.o: deepseek_v4.c deepseek_v4.h deepseek_v4_internal.h | $(V4_OWN_DIR)
$(CC) $(V4_OWN_CFLAGS) -DCOLI_V4_UNIT_CONFIG -c deepseek_v4.c -o $@

$(V4_OWN_DIR)/COLI_V4_UNIT_ST.o: deepseek_v4.c deepseek_v4.h deepseek_v4_internal.h st.h | $(V4_OWN_DIR)
$(CC) $(V4_OWN_CFLAGS) -DCOLI_V4_UNIT_ST -c deepseek_v4.c -o $@

$(V4_OWN_DIR)/COLI_V4_UNIT_NATIVE_QUANT.o: deepseek_v4.c deepseek_v4.h deepseek_v4_internal.h quant.h | $(V4_OWN_DIR)
$(CC) $(V4_OWN_CFLAGS) -DCOLI_V4_UNIT_NATIVE_QUANT -c deepseek_v4.c -o $@

tests/test_v4_ownership$(EXE): tests/test_v4_ownership.c $(V4_OWNERSHIP_OBJS)
$(CC) $(V4_OWN_CFLAGS) $< $(V4_OWNERSHIP_OBJS) -o $@ -pthread $(LDFLAGS)

endif

tests/test_route_trace$(EXE): tests/test_route_trace.c route_trace.h
$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)

Expand Down Expand Up @@ -733,13 +852,16 @@ check:
$(MAKE) portable
$(MAKE) test

install: colibri$(EXE) olmoe$(EXE)
install: colibri$(EXE) olmoe$(EXE) $(if $(filter 1,$(COLI_V4_SUPPORTED)),deepseek-v4,)
$(INSTALL) -d $(DESTDIR)$(BINDIR)
$(INSTALL) -d $(DESTDIR)$(LIBEXECDIR)
$(INSTALL) -d $(DESTDIR)$(LIBEXECDIR)/tools
$(INSTALL) -m 755 coli $(DESTDIR)$(BINDIR)/coli
$(INSTALL) -m 755 colibri$(EXE) $(DESTDIR)$(LIBEXECDIR)/colibri$(EXE)
$(INSTALL) -m 755 olmoe$(EXE) $(DESTDIR)$(LIBEXECDIR)/olmoe$(EXE)
@if [ -f deepseek_v4$(EXE) ]; then \
$(INSTALL) -m 755 deepseek_v4$(EXE) $(DESTDIR)$(LIBEXECDIR)/deepseek_v4$(EXE); \
fi
$(INSTALL) -m 644 resource_plan.py doctor.py autotune.py openai_server.py version.py $(DESTDIR)$(LIBEXECDIR)/
$(INSTALL) -m 644 tools/*.py $(DESTDIR)$(LIBEXECDIR)/tools/
@# The dashboard is an optional build artifact (cd web && npm run build), so install
Expand All @@ -761,7 +883,10 @@ clean:

bench: iobench$(EXE)
@if [ -n "$(ARGS)" ]; then ./iobench$(EXE) $(ARGS); else echo "built iobench$(EXE) — run: ./iobench$(EXE) <file> <MB> <iters> <threads> <direct 0|1>"; fi
.PHONY: all colibri glm iq3 rans fuzz-rans cuda-test hip-test gpu-compile cuda-bench cuda-dll portable test-c test-python test check clean install uninstall bench
.PHONY: all colibri glm deepseek-v4 deepseek-v4-clean deepseek-v4-oracle \
deepseek-v4-tiny-generate deepseek-v4-tiny-check \
iq3 rans fuzz-rans cuda-test hip-test gpu-compile cuda-bench cuda-dll portable \
test-c test-python test check clean install uninstall bench

tests/test_kv_prefix$(EXE): tests/test_kv_prefix.c kv_prefix.h
$(CC) $(CFLAGS) tests/test_kv_prefix.c -o tests/test_kv_prefix$(EXE) $(LDFLAGS)
Loading
Loading