Skip to content
Open
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: strata-ink2 --verify-tc 1, the small-T dense products of the sp…
…ec verify on tensor cores
  • Loading branch information
baptisterajaut committed Nov 23, 2026
commit 3f746d13c8392b638780d276189bdada27b406f0
69 changes: 68 additions & 1 deletion engine/src/inkling2/ink2_engine.cu
Original file line number Diff line number Diff line change
Expand Up @@ -1508,6 +1508,60 @@ __global__ void __launch_bounds__(256) k_gemv_bf16_multi_k64(const uint16_t* __r
if (j == 0 && row < N) Y[(size_t) t * ldy + row] = x;
}
}
// opt-in (--verify-tc 1): the same products on tensor cores, mma m16n8k16 with the prefill's hgemm numbers (fp16
// weights and inputs, fp32 accumulation). A warp takes 16 rows x the 8 vectors over a K slice (64-column chunks,
// strided over the block's 8 warps); the warps' partial tiles are added in warp order (deterministic). Within a
// chunk the 16 columns a lane loads (2 x 16 B per row: whole 32 B sectors) are spread over the 4 mma steps; the
// vectors' columns follow the same permutation, so the dot products are the same sums in another order. Not decode's
// GEMV order: greedy --spec output can differ from the default path, hence opt-in. K % 64 == 0, CUDA sm_80+.
__device__ __forceinline__ uint32_t h2bits(float a, float b) {
const __half2 h = __floats2half2_rn(a, b);
return *reinterpret_cast<const uint32_t*>(&h);
}
__global__ void __launch_bounds__(256) k_gemv_bf16_tc(const uint16_t* __restrict__ W, const float* __restrict__ X, int ldx,
float* __restrict__ Y, int ldy, int N, int K, int T) {
#if !defined(STRATA_USE_HIP) && defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 800
__shared__ float4 red[8][32];
const int lane = threadIdx.x & 31, wp = threadIdx.x >> 5, g = lane >> 2, c = lane & 3, row0 = blockIdx.x * 16;
const uint4* wa = reinterpret_cast<const uint4*>(W + (size_t) min(row0 + g, N - 1) * K);
const uint4* wb = reinterpret_cast<const uint4*>(W + (size_t) min(row0 + g + 8, N - 1) * K);
const float4* x = reinterpret_cast<const float4*>(X + (size_t) min(g, T - 1) * ldx);
const bool xv = g < T;
float acc[4] = {0.0f, 0.0f, 0.0f, 0.0f};
#pragma unroll 2
for (int ch = wp; ch < K / 64; ch += 8) {
const int o = ch * 8 + c * 2; // this lane's columns of the chunk: 16c .. 16c + 15 (uint4 2c, 2c + 1)
const uint4 a0 = __ldg(wa + o), a1 = __ldg(wa + o + 1), b0 = __ldg(wb + o), b1 = __ldg(wb + o + 1);
float4 xq[4];
#pragma unroll
for (int q = 0; q < 4; ++q) xq[q] = xv ? __ldg(x + ch * 16 + c * 4 + q) : make_float4(0.0f, 0.0f, 0.0f, 0.0f);
const uint32_t ra[8] = {a0.x, a0.y, a0.z, a0.w, a1.x, a1.y, a1.z, a1.w};
const uint32_t rb[8] = {b0.x, b0.y, b0.z, b0.w, b1.x, b1.y, b1.z, b1.w};
#pragma unroll
for (int s = 0; s < 4; ++s) { // step s: the lane's columns 4s .. 4s + 3 (logical k 2c, 2c+1 and 2c+8, 2c+9)
const uint32_t A0 = h2bits(bf16lo(ra[2 * s]), bf16hi(ra[2 * s])), A1 = h2bits(bf16lo(rb[2 * s]), bf16hi(rb[2 * s]));
const uint32_t A2 = h2bits(bf16lo(ra[2 * s + 1]), bf16hi(ra[2 * s + 1]));
const uint32_t A3 = h2bits(bf16lo(rb[2 * s + 1]), bf16hi(rb[2 * s + 1]));
const uint32_t B0 = h2bits(xq[s].x, xq[s].y), B1 = h2bits(xq[s].z, xq[s].w);
asm volatile("mma.sync.aligned.m16n8k16.row.col.f32.f16.f16.f32 {%0,%1,%2,%3}, {%4,%5,%6,%7}, {%8,%9}, {%0,%1,%2,%3};\n"
: "+f"(acc[0]), "+f"(acc[1]), "+f"(acc[2]), "+f"(acc[3])
: "r"(A0), "r"(A1), "r"(A2), "r"(A3), "r"(B0), "r"(B1));
}
}
red[wp][lane] = make_float4(acc[0], acc[1], acc[2], acc[3]);
__syncthreads();
if (threadIdx.x < 128) { // (lane l, element q): row g or g + 8 (q / 2), vector 2c + q % 2
const int l = threadIdx.x >> 2, q = threadIdx.x & 3;
float v = 0.0f;
#pragma unroll
for (int u = 0; u < 8; ++u) v += reinterpret_cast<const float*>(&red[u][l])[q];
const int row = row0 + (l >> 2) + (q >> 1) * 8, t = (l & 3) * 2 + (q & 1);
if (t < T && row < N) Y[(size_t) t * ldy + row] = v;
}
#else
__trap();
#endif
}
// grouped experts: the rows of one expert (blockIdx.y = tile of kb_moe_plan; with T <= SMALL_T an expert has at most
// SMALL_T rows, one tile) times its weights, read once. C[r][n] = factor_e * W_e[n] . A[arow(r)], arow = rows[r] or r.
// R rows per warp; each word's weights decoded once for all the tile's rows; inputs read from L1 / L2.
Expand Down Expand Up @@ -2634,6 +2688,7 @@ size_t ex_layer_off(int l) { // offset of layer l's first expert in the reside
}
size_t pool_slot(bool nv) { return ex_bytes(nv ? 0 : NL - 1); } // bytes of a pool_nv / pool_mx slot (offload)
int g_slot = 0; // the layer application being built (host side, baked into the launches)
bool g_verify_tc = false; // --verify-tc 1: small-T dense products on tensor cores (k_gemv_bf16_tc)
int g_rpw = 4; // decode GEMV rows per warp, upper bound (INK2_RPW: 1, 2, 4, 8)
int g_sel_rpw = 2; // expert (selected) GEMV rows per warp (INK2_SEL_RPW: 1, 2, 4, 8)
int g_grp_r = 4; // small-T grouped expert GEMV rows per warp (INK2_GRP_R: 1, 2, 4)
Expand Down Expand Up @@ -4413,6 +4468,10 @@ void gemv_multi(const DMat& W, int first, int n, const float* X, int ldx, float*
k_gemv_bf16_multi_rows<<<(unsigned) n, 256>>>(W.d + (size_t) first * W.k, X, ldx, Y, ldy, W.k, T);
return;
}
if (g_verify_tc && W.k % 64 == 0) {
k_gemv_bf16_tc<<<(unsigned) ((n + 15) / 16), 256>>>(W.d + (size_t) first * W.k, X, ldx, Y, ldy, n, W.k, T);
return;
}
int R = 4; // as gemv(): fewer rows per warp while the grid is short
while (R > 1 && (n + 8 * R - 1) / (8 * R) < g_gemv_min_blocks) R /= 2;
const unsigned g = (unsigned) ((n + 8 * R - 1) / (8 * R));
Expand Down Expand Up @@ -5468,6 +5527,7 @@ int main(int argc, char** argv) {
else if (a == "--graph") E.graph = std::atoi(v) != 0;
else if (a == "--chunk") PF.TP = std::atoi(v);
else if (a == "--tc") PF.tc = std::atoi(v) != 0;
else if (a == "--verify-tc") g_verify_tc = std::atoi(v) != 0;
else if (a == "--vram-reserve-mib") E.reserve_mib = std::atoi(v);
else if (a == "--spec") spec = std::atoi(v) != 0;
else if (a == "--cpu-threads") E.cpu_threads = std::atoi(v);
Expand Down Expand Up @@ -5498,7 +5558,7 @@ int main(int argc, char** argv) {
if (E.grow) vmm_init();
if (dir.empty() || (ids.empty() && !serve && vis_pixels.empty())) {
std::fprintf(stderr, "usage: strata-ink2 --model DIR (--serve | --tokens IDS | --tokens-file F) [--n N] [--ctx N] "
"[--chunk N] [--tc 0|1] [--kv f16|fp16|f32|i8|int8|i8r|k8v4|k8v8] [--kv-grow 1 [--kv-grow-step N]] [--vram-reserve-mib N [--cpu-threads N]] [--spec 0|1] [--dump-logits F] [--conversation-cache-mib N [--conversation-cache-min-tokens N]] [--image FILE ... [--image-max-tokens N] [--dump-image-emb F]] [--vis-pixels F]\n");
"[--chunk N] [--tc 0|1] [--verify-tc 0|1] [--kv f16|fp16|f32|i8|int8|i8r|k8v4|k8v8] [--kv-grow 1 [--kv-grow-step N]] [--vram-reserve-mib N [--cpu-threads N]] [--spec 0|1] [--dump-logits F] [--conversation-cache-mib N [--conversation-cache-min-tokens N]] [--image FILE ... [--image-max-tokens N] [--dump-image-emb F]] [--vis-pixels F]\n");
return 2;
}
if (serve && PF.TP <= 0) { std::fprintf(stderr, "--serve needs --chunk > 0\n"); return 2; }
Expand All @@ -5515,6 +5575,13 @@ int main(int argc, char** argv) {
// until IQ3_S / IQ4_NL / Q8_0 CPU dots and a GGUF drafter exist
if (g_is_gguf && E.cpu) { std::fprintf(stderr, "--cpu-threads: not with a GGUF model (no GGUF CPU expert kernels yet)\n"); return 2; }
if (g_is_gguf && spec) { std::fprintf(stderr, "--spec: not with a GGUF model (no drafter for it yet)\n"); return 2; }
if (g_verify_tc) { // mma m16n8k16 f16: CUDA sm_80+
int cc = 0;
#if !defined(STRATA_USE_HIP)
cudaDeviceGetAttribute(&cc, cudaDevAttrComputeCapabilityMajor, 0);
#endif
if (cc < 8) { std::fprintf(stderr, "[ink2] --verify-tc 1 ignored: it needs a CUDA card of compute capability 8.0 or later\n"); g_verify_tc = false; }
}
if (g_is_gguf) { // --model FILE.gguf: llama.cpp's merged inkling2_loop layout
const std::string e = gg_open(dir, gg);
if (!e.empty()) { std::fprintf(stderr, "%s\n", e.c_str()); return 1; }
Expand Down