Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
6bd8bc9
feat: honor ignore_merges in the BPE tokenizer for o200k-style vocabs
baptisterajaut Nov 21, 2026
9620ae9
feat: inkling2 engine (strata-ink2) and reference path for Inkling-2-…
baptisterajaut Nov 21, 2026
3c7c297
feat: inkling2 oracle checks and stop-gap OpenAI shim
baptisterajaut Nov 21, 2026
52736e2
refactor: address inkling2 experts through per-slot pointer tables
baptisterajaut Nov 21, 2026
1f24ead
feat: inkling2 expert offload to pinned RAM with a device-side LRU (-…
baptisterajaut Nov 21, 2026
2fabb8a
feat: inkling2 DSpark drafter and greedy speculative decoding (--spec…
baptisterajaut Nov 21, 2026
a858056
perf: inkling2 small-T verify kernels (multi-vector GEMVs, grouped ex…
baptisterajaut Nov 21, 2026
e51853c
feat: inkling2 exact sampled speculative decoding, graph-captured ver…
baptisterajaut Nov 21, 2026
a4e207f
fix: inkling2 spec verify with --tc 0 and under expert offload, fallb…
baptisterajaut Nov 21, 2026
5050dca
feat: serve Inkling 2 from the Strata server (reply markers, tool cal…
baptisterajaut Nov 21, 2026
f0e1f75
fix: forced tool_choice in Inkling 2 form (call header and JSON opening)
baptisterajaut Nov 21, 2026
5c86c8d
feat: inkling2 cold experts on the CPU (--cpu-threads), NUMA-placed e…
baptisterajaut Nov 21, 2026
ea559aa
perf: inkling2 CPU experts: lighter visit sync, opt-in int8 activatio…
baptisterajaut Nov 21, 2026
f292ef0
feat: inkling2 STRATA_NUMA_POOL=0 turns the CPU experts NUMA placemen…
baptisterajaut Nov 21, 2026
5bfe4af
perf: inkling2 expert placement by decayed use counts (misses most us…
baptisterajaut Nov 21, 2026
ae362a7
perf: inkling2 CPU experts: vpermps NVFP4 decode, prefetch, fused Swi…
baptisterajaut Nov 21, 2026
5f65029
perf: inkling2 PCIe share of CPU misses, sized per visit from the mea…
baptisterajaut Nov 21, 2026
1096428
fix: inkling2 CPU expert memory bound to its NUMA node, a node full o…
baptisterajaut Nov 21, 2026
6532963
perf: inkling2 NVFP4 expert GEMVs read x through L1, SwiGLU once in g…
baptisterajaut Nov 21, 2026
a16b281
chore: inkling2 validation tools take the checkpoint and work dirs as…
baptisterajaut Nov 21, 2026
bd8c108
merge: upstream main into feat/inkling2
baptisterajaut Nov 21, 2026
b76b43a
inkling2: --kv k8v4 (int8 K, rotated 4-bit V); Turing: the fp32 promp…
merbanan Nov 21, 2026
cbbb95d
perf: inkling2 decode attention keeps k8v4 V loads out of the f16 loo…
baptisterajaut Nov 21, 2026
85af06a
inkling2: --kv k8v8 (int8 K, Hadamard-rotated int8 V)
merbanan Nov 21, 2026
db6849d
inkling2: offload margin 384 -> 128 MiB (INK2_OFF_MARGIN_MIB), the po…
merbanan Nov 21, 2026
b48000c
docs: inkling2 offload margin comment: what the 128 MiB covers, measu…
baptisterajaut Nov 21, 2026
dec6a1e
inkling2: load GGUF files (llama.cpp's merged inkling2_loop layout), …
merbanan Nov 21, 2026
334c0bc
fix: inkling2 GGUF refuses --cpu-threads and --spec (no GGUF kernels …
baptisterajaut Nov 21, 2026
7d38454
inkling2: --kv-grow (the full-attention K/V grows into the expert pools)
merbanan Nov 21, 2026
81ac409
fix: inkling2 --kv-grow pool shrink drops planned CPU-expert promotio…
baptisterajaut Nov 21, 2026
35edb12
inkling2: elastic prompt buffers and staging (--kv-grow with offload)…
merbanan Nov 21, 2026
b63b0a3
fix: inkling2 elastic prompt buffers stay fixed under --spec (its ver…
baptisterajaut Nov 21, 2026
e4377d3
inkling2: short prompts fetch only their routed experts (the routed-p…
merbanan Nov 21, 2026
7e088eb
fix: inkling2 routed short prompts only when the pools hold all their…
baptisterajaut Nov 21, 2026
e17673d
inkling2: big prompt chunks decode each GGUF expert once and run cuBL…
merbanan Nov 21, 2026
2f83ddb
fix: inkling2 decode-once GGUF scratch allocated only for a GGUF mode…
baptisterajaut Nov 21, 2026
6561346
inkling2: long contexts on a small card: the prompt chunk shrinks to …
merbanan Nov 21, 2026
569185f
fix: inkling2 chunk fit counts the staging as the routed-prompt guard…
baptisterajaut Nov 21, 2026
a06ff78
inkling2: dense Q8 GEMV with 16-byte loads (INK2_Q8_WIDE, default on)…
merbanan Nov 21, 2026
48febba
perf: inkling2 GGUF defaults from 3090 measurements: decode-once from…
baptisterajaut Nov 21, 2026
955c8c0
feat: inkling2 conversation cache for --serve: prompt-end checkpoints…
baptisterajaut Nov 21, 2026
5a63687
feat: inkling2 DONE line reports drafts accepted / offered and the pr…
baptisterajaut Nov 21, 2026
b884394
docs: inkling2 conversation cache: no host name in a comment
baptisterajaut Nov 21, 2026
6bbc06f
perf: inkling2 conversation cache: parked rows in power-of-two pinned…
baptisterajaut Nov 22, 2026
af8424b
docs: inkling2 conversation cache: the live checkpoints are not evict…
baptisterajaut Nov 22, 2026
51c5048
fix: inkling2 conversation cache: a conversation being parked counts …
baptisterajaut Nov 22, 2026
4888bf6
fix: inkling2 conversation cache: branch points between conversations…
baptisterajaut Nov 22, 2026
a58cbeb
fix: inkling2 accepts --conversation-cache-slots from Strata configs …
baptisterajaut Nov 22, 2026
7524ae7
feat: inkling2 image input in strata-ink2 (ViT + projector in the eng…
baptisterajaut Nov 21, 2026
fdb2095
feat: serve sends Inkling 2 pictures to strata-ink2 as image= files (…
baptisterajaut Nov 21, 2026
c1207fc
fix: Inkling 2 JPEGs reach strata-ink2 as Pillow-decoded BMP (the ref…
baptisterajaut Nov 21, 2026
eb52e7f
test: inkling2 picture comparison tools (embeddings, multimodal KL), …
baptisterajaut Nov 21, 2026
d3a98a1
docs: inkling2 vision CBA notes (attention at the cap, weights over P…
baptisterajaut Nov 21, 2026
bd533db
fix: inkling2 refuses pictures over 134 MP before decoding them; head…
baptisterajaut Nov 21, 2026
5415261
test: vision_kl.py --together (several pictures in one prompt)
baptisterajaut Nov 22, 2026
cb64c66
feat: inkling2 pictures in the conversation cache: image tokens keyed…
baptisterajaut Nov 22, 2026
078c290
fix: inkling2 thinking off from enable_thinking / Anthropic disabled …
baptisterajaut Nov 21, 2026
ea09d1b
feat: setup installs Inkling-2-Mini (pinned checkpoint, strata-ink2 b…
baptisterajaut Nov 21, 2026
369c7c4
fix: inkling2 setup sizes the offload for small cards (context and re…
baptisterajaut Nov 21, 2026
98c34c2
fix: inkling2 offload sizing counts the VRAM in use and keeps a slack…
baptisterajaut Nov 21, 2026
a8918c9
fix: setup needs CMake 3.25.2 for the engine CUDA20 targets (3.25.1 c…
baptisterajaut Nov 21, 2026
cfcdd1a
fix: inkling2 start message gives its own RAM figure (measured 16.8 G…
baptisterajaut Nov 22, 2026
4539d3b
feat: inkling2 offload configs use --kv-grow with the longest context…
baptisterajaut Nov 22, 2026
24edc26
fix: inkling2 --kv-grow keeps each expert pool at its minimum: prompt…
baptisterajaut Nov 22, 2026
dddda83
feat: inkling2 offload keeps --chunk 1024 and uses i8r (closest 8-bit…
baptisterajaut Nov 22, 2026
dfdf9f4
fix: inkling2 offload sizing counts the prompt buffers a 1024-chunk c…
baptisterajaut Nov 22, 2026
2daf740
feat: inkling2 setup turns pictures on and sizes the conversation cac…
baptisterajaut Nov 22, 2026
dd7fa18
docs: inkling2 engine flags and their measured effect (docs/INKLING2.md)
baptisterajaut Nov 22, 2026
d99e5fa
feat(inkling2): add AMD ROCm/HIP engine support for strata-ink2 and s…
jingx8885 Nov 22, 2026
bc4a937
feat(terminal): enable Inkling-2-Mini setup and HIP engine build on A…
jingx8885 Nov 22, 2026
ddc6038
fix(tests): expect ink2_build HIP flags in test_gh_0217_hipflags
jingx8885 Nov 22, 2026
83a97d8
feat: inkling2 on AMD ROCm/HIP wave32 RDNA (#16 by jingx8885)
baptisterajaut Nov 22, 2026
01f7da1
fix: inkling2 HIP targets on Linux only and out of the default HIP bu…
baptisterajaut Nov 22, 2026
3cbc56b
feat: inkling2 GGUF experts may use one type for layers 0-19 and anot…
baptisterajaut Nov 22, 2026
1f0a0a1
docs: inkling2 GGUF files with a second expert type in layers 20-23, …
baptisterajaut Nov 22, 2026
f2af205
docs: inkling2 --spec greedy output can part from plain decoding at a…
baptisterajaut Nov 22, 2026
454cb91
chore: merge upstream 0.2.19, the official Inkling checkpoint source …
baptisterajaut Nov 22, 2026
81267cc
docs: inkling2 verify products follow decode GEMVs, not decode attention
baptisterajaut Nov 22, 2026
2cea839
fix: keep the official Inkling source out of the catalog table of SQ …
baptisterajaut Nov 22, 2026
41b610c
test: inkling2 offload floor reads pool_slot, pins allow a checkpoint…
baptisterajaut Nov 22, 2026
cad508f
fix: strata-ink2 configs get no --parallel, no Vision shard and a mod…
baptisterajaut Nov 22, 2026
f30718f
fix: /props says strata-ink2 keeps earlier reasoning when its templat…
baptisterajaut Nov 22, 2026
6e237c7
feat: strata-ink2 --spec 1 runs with --cpu-threads, a verify block's …
baptisterajaut Nov 22, 2026
5ae3b0d
feat: inkling2 setup keeps --spec 1 beside the expert offload where t…
baptisterajaut Nov 22, 2026
d3431b1
docs: strata-ink2 --spec 1 with --cpu-threads, measured per card
baptisterajaut Nov 22, 2026
7516ee8
chore: merge upstream 0.2.20, the official Inkling checkpoint keeps i…
baptisterajaut Nov 23, 2026
3f746d1
feat: strata-ink2 --verify-tc 1, the small-T dense products of the sp…
baptisterajaut Nov 23, 2026
2ced29e
feat: strata-ink2 takes a numeric reasoning effort, 0.0 to 0.99, as I…
baptisterajaut Nov 23, 2026
bb137fd
docs: strata-ink2 --verify-tc 1 measured on an RTX 3090, and the nume…
baptisterajaut Nov 23, 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
Prev Previous commit
Next Next commit
feat: inkling2 pictures in the conversation cache: image tokens keyed…
… by the picture hash (vis_id), the image bypass and vis_reuse gone
  • Loading branch information
baptisterajaut committed Nov 22, 2026
commit cb64c66bcad6807062608af1482fb26549334479
5 changes: 2 additions & 3 deletions engine/src/inkling2/ink2_engine.cu
Original file line number Diff line number Diff line change
Expand Up @@ -5032,7 +5032,7 @@ void forward_prefill(const int* toks, int T, int pos0, float* all) {
}
{
vec e(ES);
for (int t = 0; t < T; ++t) embed_row(toks[t], &e[(size_t) t * H]);
for (int t = 0; t < T; ++t) embed_row(toks[t] < 0 ? IMAGE_TOKEN : toks[t], &e[(size_t) t * H]); // (vis_id)
CK(cudaMemcpyAsync(PF.x0, e.data(), ES * 4, cudaMemcpyHostToDevice, cudaStreamPerThread));
CK(cudaStreamSynchronize(cudaStreamPerThread));
}
Expand Down Expand Up @@ -5515,7 +5515,6 @@ int main(int argc, char** argv) {
max_new = std::max(0, std::min(max_new, E.ctx - (int) pr.size()));
const bool reuse = !hist.empty() && pr.size() >= hist.size() && std::equal(hist.begin(), hist.end(), pr.begin());
size_t start = reuse ? hist.size() : 0;
start = vis_reuse(start); // (the reused prefix must hold the same pictures)
if (g_sess.on) start = sess_begin(pr, hist, last_logits, start); // conversation cache (ink2_session.cuh)
kv_trim((int) pr.size() + 1);
if (spec && start == pr.size()) start = pr.size() - 1; // re-fed: the drafter needs its features
Expand Down Expand Up @@ -5579,7 +5578,7 @@ int main(int argc, char** argv) {
}
const double t2 = now_ms();
hist = pr;
vis_done();
g_vis.pending = false;
if (!gen.empty()) hist.insert(hist.end(), gen.begin(), gen.end() - 1); // the last token was never fed
last_logits = logits;
smp.rng = std::move(s.rng);
Expand Down
17 changes: 4 additions & 13 deletions engine/src/inkling2/ink2_session.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
// system prompt and tools) stops its prefill at the branch point once and takes a checkpoint there.
// LRU over whole parked conversations under the budget. Off: none of this runs (the serve loop is the base one).

constexpr int IMAGE_ID = 200054; // <|unused_200054|>: every image's placeholder (the same id whatever the image)
constexpr int SPLIT_MIN = 512; // a branch point is taken when it covers this many tokens more than the best state

struct Pinned { // page-locked host memory (DMA only: any NUMA node)
Expand Down Expand Up @@ -68,7 +67,6 @@ struct Sess {
std::vector<PinnedP> spare; // tails no longer used (cudaHostAlloc is slow): taken again first
uint64_t clock = 0;
int split = -1; // this request: the prefill stops here for a branch checkpoint
bool skip = false; // this request bypasses the cache (an image in it)
std::string note; // this request's log line
} g_sess;

Expand Down Expand Up @@ -196,7 +194,7 @@ bool sess_take(int n, const vec& lg, int kind) {
// The live conversation (hist, last_logits) to the parked set, when worth it: its full rows, its checkpoints and its
// history end. The live checkpoints stay valid for the slots (a later restore may use them).
void sess_park(const std::vector<int>& hist, const vec& last_logits) {
if ((int) hist.size() < g_sess.min_tokens || std::find(hist.begin(), hist.end(), IMAGE_ID) != hist.end()) return;
if ((int) hist.size() < g_sess.min_tokens) return;
Conv v;
v.ids = hist;
v.prompt_n = g_sess.live_prompt;
Expand Down Expand Up @@ -233,16 +231,9 @@ size_t sess_begin(const std::vector<int>& pr, std::vector<int>& hist, vec& last_
g_sess.split = -1;
g_sess.note.clear();
const double t0 = now_ms();
g_sess.skip = std::find(pr.begin(), pr.end(), IMAGE_ID) != pr.end();
// (a picture's image tokens are ids made from its pixels' hash, ink2_vision.cuh vis_id: every comparison below
// tells two pictures of the same size apart)
const size_t l_live = sess_lcp(hist, pr);
// CBA: an image's tokens are the same placeholder whatever the image: a prompt with one bypasses the cache (no
// restore, no checkpoint) and a conversation with one is never parked; key the cache on the image bytes to lift it
if (g_sess.skip) {
for (size_t i = g_sess.live.size(); i-- > 0;) if (g_sess.live[i].n > (int) start) { PinnedP t = g_sess.live[i].tail; g_sess.live.erase(g_sess.live.begin() + i); sess_drop(std::move(t)); }
g_sess.live_prompt = 0;
std::fprintf(stderr, "[ink2] conversation cache: prompt %zu with an image: read from %zu, not cached\n", pr.size(), start);
return start;
}
// the best state: the live history end (start), a live checkpoint, a parked conversation's checkpoint
size_t best = start, share = l_live;
int src = start > 0 ? 0 : -1, ck = -1, pv = -1; // src: 0 live end, 1 live checkpoint, 2 parked, -1 none
Expand Down Expand Up @@ -327,7 +318,7 @@ unsigned long long sess_hash(const vec& lg) {
}
// the prompt read (lg: its last logits), before the first sampled token: the live prompt-end checkpoint
void sess_prompt_end(const std::vector<int>& pr, const vec& lg) {
if (!g_sess.on || g_sess.skip) { // INK2_LOGITS_HASH=1: the hash without the cache too (the reference runs)
if (!g_sess.on) { // INK2_LOGITS_HASH=1: the hash without the cache too (the reference runs)
static const bool h = std::getenv("INK2_LOGITS_HASH") != nullptr;
if (h) std::fprintf(stderr, "[ink2] conversation cache: off, prompt end %zu, logits %016llx\n", pr.size(), sess_hash(lg));
return;
Expand Down
37 changes: 16 additions & 21 deletions engine/src/inkling2/ink2_vision.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@
// Protocol (Hy4-Flash's 1.6b): GEN ... image=<path> ... <ids>, one image= key per <|unused_200054|> of the ids in
// prompt order; the engine decodes the files, expands each placeholder to its rows x cols image tokens and encodes
// them before the prompt is read. INFO images=1 at the start says it can.
//
// Picture identity: an expanded image token is not 200054 in the prompt the engine keeps but a negative id made from
// the picture's key (its pixels' hash) and its offset in the picture (vis_id). Every prefix comparison of the serve
// loop and of the conversation cache (hist, live checkpoints, parked conversations, branch points) therefore sees two
// different pictures of the same size as different tokens: a state is reused only with the same pictures at the same
// places. Only the embedding lookup (forward_prefill) maps a negative id back to the placeholder's row, which the
// picture's row then replaces.
#pragma once

constexpr int VH = 1024, VHEADS = 16, VHD = 64, VFF = 4096, VLAYERS = 23, VGRID = 32, VMERGE_IN = 4 * VH, VPROJ = 4096;
Expand All @@ -56,7 +63,7 @@ struct Vis {
// the request
struct Span { int pos, n; uint64_t key; size_t row; };
std::vector<ink2img::Picture> pics;
std::vector<Span> spans, hist; // this prompt's pictures; those of the tokens the engine holds (serve's hist)
std::vector<Span> spans; // this prompt's pictures
float* emb = nullptr; // pinned [rows][H]: the image rows of this prompt
size_t emb_cap = 0;
bool pending = false; // the prompt being read has image rows to put in
Expand Down Expand Up @@ -382,6 +389,13 @@ std::string vis_run(const ink2img::Picture& pic, float* out) {
}

// ------------------------------------------------------------------------------------------------------- the prompt
// the prompt id of image token j of the picture with key k: negative (never a vocabulary id), 31 bits of a mix of both
// CBA: two different pictures match only if all 31-bit ids of the shared span collide (~2^-31 per token)
int vis_id(uint64_t k, int j) {
uint64_t x = k ^ (0x9e3779b97f4a7c15ull * (uint64_t) (j + 1));
x ^= x >> 33; x *= 0xff51afd7ed558ccdull; x ^= x >> 33; x *= 0xc4ceb9fe1a85ec53ull; x ^= x >> 33;
return -1 - (int) (x & 0x3fffffff);
}
// This prompt's pictures: each IMAGE_TOKEN of `ids` (one per picture, prompt order) becomes its rows x cols image
// tokens. `paths` empty and no placeholder: a text prompt (nothing to do). "" or the error.
std::string vis_prepare(std::vector<int>& ids, const std::vector<std::string>& paths, bool pixels = false) {
Expand All @@ -408,25 +422,12 @@ std::string vis_prepare(std::vector<int>& ids, const std::vector<std::string>& p
const int n = p.rows * p.cols;
g_vis.spans.push_back({(int) out.size(), n, p.key, row});
row += (size_t) n;
out.insert(out.end(), (size_t) n, IMAGE_TOKEN);
for (int j = 0; j < n; ++j) out.push_back(vis_id(p.key, j));
}
ids.swap(out);
return "";
}

// The reused prefix (the first `start` tokens, already in the engine's state) holds the same pictures as this prompt's
// at the same places, else nothing is reused: two different pictures of the same size have the same token ids.
// CBA: one history (g_vis.hist, set by vis_done); a cache of several sessions needs each session's own spans.
size_t vis_reuse(size_t start) {
if (!start) return 0;
auto in = [start](const std::vector<Vis::Span>& v) {
std::vector<uint64_t> r;
for (const auto& s : v) if ((size_t) s.pos < start) { r.push_back((uint64_t) s.pos); r.push_back((uint64_t) s.n); r.push_back(s.key); }
return r;
};
return in(g_vis.spans) == in(g_vis.hist) ? start : 0;
}

// Encodes the pictures whose rows are read from `start` on (the others are in the reused prefix). "" or the error.
std::string vis_encode(size_t start) {
if (g_vis.spans.empty()) return "";
Expand Down Expand Up @@ -465,12 +466,6 @@ void vis_inject(int T, int pos0) {
}
}

// a request is done: its pictures are those of the engine's state from now on
void vis_done() {
g_vis.hist = g_vis.spans;
g_vis.pending = false;
}

// --vis-pixels FILE: the ViT alone on the processor's pixel tensor (no language model loaded), rows to --dump-image-emb
int vis_cli_pixels(const std::string& path) {
std::vector<int> ids = {IMAGE_TOKEN};
Expand Down