mirror of
https://github.com/mudler/LocalAI.git
synced 2026-06-23 08:08:52 -04:00
Retire the central numeric risk from the design: feeding gather-to-scratch KV (a sequence whose blocks are non-contiguous in the shared pool, [2,1,5]) into ggml's standard attention ops produces correct attention. Path under test: set_rows write -> get_rows gather (K and V) -> mul_mat(K,Q) -> soft_max_ext -> mul_mat(V^T, probs). Result is compared against an independent host-computed softmax attention over the same K/V/Q. Max abs error ~7.5e-08 (n_kv=48, d=8, n_q=4). This proves the paged read path is numerically sound on CPU with no new ggml op. Remaining: wire build_attn_paged into llama-graph.cpp and validate Gate 0 (token-identical greedy generation in a real model). Phase 2 (core) of docs/superpowers/plans/2026-06-19-paged-attention-llamacpp.md. Assisted-by: Claude:opus-4.8 [Claude Code] Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
36 lines
1.2 KiB
Makefile
36 lines
1.2 KiB
Makefile
CXX ?= g++
|
|
CXXFLAGS ?= -std=c++17 -O2 -Wall -Wextra -I.
|
|
|
|
TESTS = test_free_block_queue test_block_pool test_paged_kv_manager test_prefix_cache
|
|
BINS = $(addprefix tests/,$(TESTS))
|
|
|
|
all: $(BINS)
|
|
|
|
tests/%: tests/%.cpp paged_kv_manager.cpp paged_kv_manager.h
|
|
$(CXX) $(CXXFLAGS) -o $@ $< paged_kv_manager.cpp
|
|
|
|
check: all
|
|
@for t in $(BINS); do echo "== $$t =="; ./$$t || exit 1; done
|
|
|
|
# --- Optional ggml integration test (Phase 1: paged write/gather mechanism) ---
|
|
# Requires a built ggml. Override these to point at your checkout / build:
|
|
# make ggml-check GGML_SRC=<llama.cpp>/ggml GGML_BUILD=<ggml-build>
|
|
GGML_SRC ?= ../../llama-cpp-fallback-build/llama.cpp/ggml
|
|
GGML_BUILD ?= /tmp/ggml-build
|
|
GGML_LIBDIR = $(GGML_BUILD)/src
|
|
|
|
GGML_TESTS = test_ggml_paged_rw test_ggml_paged_attn
|
|
GGML_BINS = $(addprefix tests/,$(GGML_TESTS))
|
|
|
|
tests/test_ggml_%: tests/test_ggml_%.cpp paged_kv_manager.cpp paged_kv_manager.h
|
|
$(CXX) $(CXXFLAGS) -I$(GGML_SRC)/include -o $@ $< paged_kv_manager.cpp \
|
|
-L$(GGML_LIBDIR) -lggml -lggml-base -lggml-cpu -Wl,-rpath,$(GGML_LIBDIR)
|
|
|
|
ggml-check: $(GGML_BINS)
|
|
@for t in $(GGML_BINS); do echo "== $$t =="; ./$$t || exit 1; done
|
|
|
|
clean:
|
|
rm -f $(BINS) $(GGML_BINS)
|
|
|
|
.PHONY: all check ggml-check clean
|