Compiles CMAKE_CUDA_ARCHITECTURES=61 and passes -DSTRATA_EXPERIMENTAL_SM60=ON,
with an early error when nvcc is 13+ (which dropped sm_60/sm_70). Default
build is unchanged.
(cherry picked from commit 6afd3ff4d8)
From Niko1221/Strata tag v0.2.4 (commit 96ca4383, 2026-10-24), unmodified: src/dsv41/ (the engine and its vendored
EXL3 / sampler / window kernels), include/strata/dsv41/, tests/dsv41/, tools/dsv41/{pack_gguf,smoke,tune}.py,
data/dsv41/ (the shipped hot-expert profiles), tools/trellis/tqenc.{cpp,hpp} (the tests' encoder),
third_party/project-maya/ (the MIT notice: the engine is a port of Project Maya's maya-ds4),
third_party/ggml/ggml-common-tq.h, docs/DEEPSEEK41.md (upstream's text, to be rewritten for this fork).
src/kernels/cpu: upstream's iq_avx2.{cpp,hpp}, iq_avx2_rows.inl, iq_avx512.{cpp,hpp} replace this fork's
(v0.1.45-poly.1) copies - they add the engine's CPU lane rows iq256x_rows / iq512x_rows and leave the main engine's
iq256_* / iq512_* as they were (upstream's statement; iq_avx2_parity is the check) - and the trellis CPU lane
tq_cpu.{hpp,cpp}, tq_avx2.cpp, tq_avx512.cpp, tq_states.hpp, tq_computed.hpp is new. expert_layout.hpp stays at
layout version 4 (upstream's 5 adds Hadamard-folded packs this fork has no use for yet).
CMakeLists.txt: upstream's strata-dsv41 block, with ggml.h / ggml-cpu.h coming through strata_kernels_cpu's ggml-cpu
link from the submodule (no FetchContent), the tq sources and flags in strata_kernels_cpu, and iq_avx512.cpp built
with -mavx512vpopcntdq -mbmi2 as upstream does (iq512x_rows uses them). Makefile: STRATA_BUILD_DSV41=ON and
strata-dsv41 among the targets `make build` produces.
Target: ISTA-DASLab/DeepSeek-V4.1-Flash-1017-GSQ-RCO-GGUF (IQ1_M / IQ2_XXS + the IQ4_NL Engram) on the A6000 VM.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
A chat client resends the whole conversation every turn, pictures included, and the vision encoder is the slow part
of a request: 6 s a screenshot on 16 CPU threads, 18 s on 6, every turn, while the engine reuses the prompt's KV
prefix in a fraction of a second. Upstream's Python server kept the encoder's output per picture in an LRU of 64
files keyed by the SHA-256 of the picture's bytes (serve/server.py, class Vision); this is that cache for the C++
front end, in memory.
frontend/picture_cache.hpp (header-only, no llama.cpp): PictureCache keeps PictureRows (the projector's output,
n_tok rows of the embedding width) under mtmd's chunk id, which is the SHA-256 of the bitmap's bytes. Shared
pointers, so a request keeps the rows it is writing when the cache lets go of them; two limits, entries and bytes,
the newest entry always kept. engine_key() turns the id into the 64-bit key the engine's conversation cache takes
(img_keys= on the GENI line, #2228), so a picture encoded again with other bits still matches its KV prefix.
encode_pictures is now six short functions: open the file, fill it, find the chunk, its id, its rows (cache or
encoder), its grid, write the record. --picture-cache N (default 64, 1 GiB) sets the size; 0 turns it off.
frontend/tests/picture_cache_test.cpp: hit/miss and counters, LRU order and the entry limit, the byte limit and the
oversize newest entry, a held entry outliving its eviction and a key replaced, off and an empty key, the engine
keys, eight threads at once. In make test.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The rendered prompt was tokenized whole with specials parsed, so "<|image_pad|>" in a
document an agent read became the image pad token and the engine refused the request
("the prompt has more images than the embeddings file"); "<|im_end|>" in a tool
result ended a turn. Upstream's Python server marked these literals before the template
rendered (#537, #554); the C++ front end lost that with the server's removal.
frontend/literals.hpp: the texts of the vocabulary's control tokens and marker-like
added tokens (<think>, <tool_call>, [gMASK]) are swapped for private-use marks in the
messages and tools before oaicompat_chat_params_parse renders the template, swapped
back after, and the spans they covered are tokenized as text: parse_special off, and an
added token the tokenizer matches regardless is split until none is left. Media parts
are not scanned. An assistant message keeps a leading whole <think>...</think> block
as the model's markers (clients that send reasoning inline), as upstream did. A mark
that a template's tojson(ensure_ascii=True) escaped as a surrogate pair is read too.
A request without literals renders and tokenizes exactly as before.
mtmd's logger wrote every level to stderr, its debug line add_text() among them: the
whole rendered prompt once per request into the journal. It now goes through the
common log, where debug lines need the server's verbosity raised.
Tests: frontend/tests/literals_test.cpp (no model; nlohmann json, the interface
common_json copies) in make test; e2e.sh runs a third fake-engine server with upstream's
Qwen3 template (frontend/tests/data/qwen3-chat-template.jinja) and checks
usage.prompt_tokens against the prompt tokenized by hand with the literals as text, for
user content, a tool description and an assistant history message.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
A fresh clone on the VM (2026-10-19) built in 20.6 min with the README's commands as written, but `make test` failed with
'build-frontend/engine_test: No such file or directory': the frontend target sets CMAKE_RUNTIME_OUTPUT_DIRECTORY to
build-frontend/bin and the test target looked one level up. It passed on the Mac only because a stale build-frontend/
there still had the old binary at the root.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
frontend/strata_context.cpp replaces tools/server/server-context.cpp. The other seven server files
(server-http, -queue, -task, -common, -chat, -schema, -stream) compile unmodified from the submodule into
the static library strata_llama_server; frontend/ui_stub/ supplies the empty web-UI asset table that
server-http.cpp references. The context runs one slot: the engine is a child process spoken to over its
line protocol (docs/BACKENDS.md), a vocab-only llama_model provides tokenizing, the chat template and the
reasoning and tool-call parsers, and the server's own task and result types carry the OpenAI JSON, SSE
framing and client-disconnect cancel. Routes kept: /health, /v1/models, /v1/chat/completions, /tokenize,
/detokenize. The strata engine's 8-token reserve is kept out of max_new. A supervisor thread ends the
process with exit code 1 when the engine dies, for a unit with Restart=on-failure.
frontend/engine.hpp is the child adapter: fork+exec, READY/INFO, GEN/GENI, T/PP/RESUME/DONE/ERR/FATAL,
STOP with drain to DONE, non-blocking reap. quit() and the supervisor's reap_exit() share the pid through
an atomic that quit() takes over by exchange, and only a positive local copy ever reaches kill(). The
first draft kept a plain pid_t and the supervisor set it to -1 on reaping, so a SIGTERM during shutdown
raced into kill(-1, SIGKILL), which killed every process of the user; it did so twice on 2026-10-17.
Build: STRATA_FRONTEND (default on) gates the llama.cpp libraries and the front end, not CUDA, so they
build on a machine without a GPU. Makefile: unbiased-strata joins `make build`; `make frontend` builds it
alone without CUDA into build-frontend/; `make test` builds engine_test there and runs it and
frontend/tests/e2e.sh against a fake engine (frontend/tests/fake-engine.py). The nvcc probes run only
when there is an nvcc and only the build and configure goals demand one. UPSTREAM.md records all of it.
Verified on macOS arm64 without CUDA: `make frontend` and `make test` pass. engine_test, 7 cases: READY,
a request, STOP mid-request with drain and a clean next request, a 100k-token burst the caller abandons,
ERR leaves the adapter usable, the engine dying mid-request is diagnosed, a DONE with the wrong prompt
size is visible. e2e.sh, 12 checks: /health, /v1/models, a non-streaming chat with content, finish and
usage, a stream whose deltas join to the content and end with finish_reason and [DONE], a client that
disconnects mid-stream (the server logs the cancel and the next request completes), an oversize prompt
refused with 400, a tokenize/detokenize round trip. Zero new patch lines to llama.cpp, so the step-4
gate of PLAN.md section 5 passes and design C stands. Not yet run against a real engine.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
ggml now comes from third_party/llama.cpp, the commit upstream pins, instead of
a FetchContent clone at configure time; the configure stops with the submodule
command if the checkout is missing. patches/*.patch are applied to the submodule
at configure time, idempotently (checked in reverse first); the one patch is the
Qwen3-Coder any-argument-order parser fix carried from UnbiasedStrata 1. A second
add_subdirectory builds llama.cpp's llama, common, cpp-httplib and mtmd for the
coming C++ front end with every download switch off. Makefile: make build
configures once and builds strata, strata-poly, strata_kq, llama-common and
mtmd into build/bin for CUDA archs 61;75;86;89 (SM60 flag added for 61), finds
nvcc on PATH or in /usr/local/cuda/bin, and probes for the newest GCC nvcc
accepts, passing it as the C, C++ and CUDA host compiler so one libstdc++ is
linked (a GCC 14 / GCC 13 mix failed to link strata on __cxa_call_terminate).
PLAN.md and UPSTREAM.md added.
Verified: a fresh clone and 'git submodule update --init' on a networked box
checks out the shallow pin in 37 s. On VM 220 (Debian 13, GCC 13/14, CUDA 12.4,
no outbound internet) 'unshare -rn make build JOBS=6' inside a network namespace
with no interfaces built strata, strata-poly and libstrata_kq.so for 61;75;86;89
in 24 min with zero network errors in the log; strata --version prints 0.1.45.
Every tracked file, .gitignore, .gitmodules and both submodules (llama.cpp at
3cf03257, llama-muse at 335916a) are removed so the next commit can import
PolyStrata v0.1.45-poly.1 unmodified and be the diff baseline of the fork.
UnbiasedStrata 1 remains at tags unbiasedstrata-1 (main, b124b59) and
unbiasedstrata-1-muse-spark-native (4c824e6).
Verified: git ls-files is empty; the working directory holds only .git.
The branch took f07b81e from main but not 121d23a, so a build of the branch
answered 500 "prompt (N tokens) + max_new (M) exceeds the context" to every
request without max_tokens, and to any with max_tokens at or above
context - prompt - 7, on Flash-Next and on Qwen3.6 alike. The hunk in
frontend/main.cpp is main's, unchanged.
tests/python/serve_max_tokens_check.py (make test-serve PORT=...) sends five
such requests to a running server: 0 of 5 before, 5 of 5 after, on
Flash-Next at 196,608 and on Qwen3.6 Q4_K_XL at 262,144 (RTX 4090).
REGINA-112.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
CUDA_ARCHS defaults to 61;70;75;86;89;120 (STRATA_EXPERIMENTAL_SM60 follows
from the 61 / 70 as before). The list is filtered against `nvcc
--list-gpu-arch` with a note for what is dropped, so the default builds on
CUDA 12.4 (no 120: VM 221 built 61;70;75;86;89 in 6 min 17 s at -j 14) and
on CUDA 13 (no 61 / 70) alike; without nvcc on the PATH the list is kept
as given. `make build CUDA_ARCHS=61` is unchanged.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
REGINA-104 (a Qwen3.6 tool call dropped when its required parameter is not
written first) was upstream's required-first rule running unpatched: the
any-argument-order patch was applied only by `make build`, and every VM tree
of the port was configured with cmake directly, on a copied submodule.
Qwen3.6's template routes to the Qwen3-Coder parser the patch covers, so
CMake now applies it when third_party/llama.cpp is configured (patch -p1 -N,
a reverse dry run first so an applied tree is a no-op; a tree the patch does
not fit fails the configure instead of building the wrong parser). Verified:
a fresh submodule checkout reports the patch applied and a second configure
says nothing; on VM 221 the rebuilt libllama-common parses `limit offset
path`, `offset path limit`, `path limit offset` and `path` on
Qwen3.6-35B-A3B-UD-IQ3_XXS.gguf (make test-chat-parser PASS).
`make build` also passes -DSTRATA_MMQ_KQUANTS=ON: the Q4_K_XL file's Q6_K
down experts take the MMQ prompt path (docs/qwen36-port/step3-experts.md),
which that option builds.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
generate.cpp: every cudaMemGetInfo the planners read goes through vram_info, which clamps the free
figure to cap - used under --vram-cap MIB; a blocker of total - cap is allocated before the weight
arena. --ram-cap GIB bounds the RAM tier (host_available_memory is clamped, the resident budget
too) and the pinned arena. A model whose architecture has no per-layer token embedding starts
without --ple-gguf (no PLE kernels selected, and session.cpp carves no PLE history for it). For a
qwen35moe file the start reads the geometry, checks the pack's layout against it, makes the 4.2
plan from this card's free VRAM and the file's own census (non-expert weights, the draft block,
KV per token in the chosen format, the session, the reserve, the prompt buffers unless prefill
borrows), prints the three tiers, and stops at the step 2 gate naming the steps not done. The
serve loop answers STATS with one JSON line: experts, VRAM slots and how many hold an expert, RAM
copies, mapped experts, tokens served, VRAM hits of lookups, RAM-copy and file reads, warm hints,
and the major page faults since start (the disk-read proxy); the same line is logged at start.
frontend: /health carries that line as "tiers" (the last reading, marked stale, during a request);
--vram-cap and --ram-cap pass through; a one-file model needs no second shard. Makefile: any
CUDA_ARCHS entry below 75 switches STRATA_EXPERIMENTAL_SM60 on (make build CUDA_ARCHS=61).
Not compiled yet: the CUDA translation units need the VM (its sweep is running); this commit is
checked on the VM in the Pascal build commit that follows.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017tPVMg2wGSNR1KANEiUtwr
Images: --mmproj PATH loads the Qwen3.8 Flash-Next projector through llama.cpp's mtmd
library and encodes image_url parts on the CPU (frontend/vision.hpp). The embeddings go to
the engine as a GENI request, its existing vision path, with the prompt's <|image_pad|>
runs standing in for each image. --vision-tokens caps the tokens per image. GET /v1/models
lists "image" under input_modalities when the encoder is loaded. Checked on an RTX 4090:
screenshots, photos, several images in one message, and pi's file attachments and
clipboard paste.
Engine process: the engine is started and watched from frontend/engine.hpp; when it exits
or its stall watchdog fires, the front end exits too, for a supervisor to restart. Stall
reports add the current stage and thread wait channels. Reasoning streams; content and
tool calls are sent once the whole message is parsed, so partial JSON never changes
arguments already sent.
Tests: make test-frontend (child exit, protocol, backpressure; no model needed) and
make test-chat-parser MODEL=<gguf> (template and tool-call parsing against the real GGUF).
The image path and the supervision were written by a Codex session; this commit finishes,
documents and checks them.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
llama.cpp's Qwen3-Coder grammar takes a tool call's required arguments first and
the optional ones after. Qwen3.8 Flash-Next often writes the optional ones first
(limit, offset, path), and because the grammar's tool-call group is optional and
has no end anchor, such a call parsed as no call at all: no error, finish_reason
"stop", an empty answer. A coding agent sees its turn end after it announced the
call.
The grammar now accepts the arguments in any order; whether a required one is
missing is for the tool to report. The change is kept as a patch under patches/
that `make build` applies to the submodule. The front end logs the raw output
when it contains <tool_call> but no call was parsed, so the next case of this is
visible in the journal.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
unbiased-strata is the engine plus a front end. Started normally it runs
the front end, which starts a copy of itself as the engine (--engine) and
talks to it over a pipe in the engine's own line protocol, as upstream's
Python server does. The engine source is included unchanged; only its
entry point is renamed at compile time.
Tokenizer, Jinja chat template and HTTP library come from the pinned
llama.cpp submodule. Endpoints: POST /v1/chat/completions (with
streaming and reasoning_content), GET /v1/models, GET /health.
Builds on the RTX 3090 pod. Not yet verified end to end.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
ggml now comes from third_party/llama.cpp (commit 3cf03257, the one upstream
pins) instead of a clone made during the build. 'make build' configures and
builds the engine for RTX 30/40/50 cards with an AVX2 CPU baseline.
Not yet verified on a CUDA machine.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>