Repository navigation
poly: Inkling 2 Mini (inkling2 / inkling2_loop) - #200
okada-shogo wants to merge 105 commits into
Conversation
Maya-XS GLM-5.3-Flash keeps its gate/up experts (and three layers' downs) in IQ1_S, which native_mmvq_supported refused, so every expert ran on the CPU. Adds llama.cpp's vec_dot_iq1_s_q8_1 and dequantize_iq1_s (transcribed), a decode-once Split<19> sharing IQ1_M's staged iq1s_grid_gpu table, and type 19 in the gate/up, down and mmvq lists. iq_parity: dequant bitwise equal to gguf-py, mmvq rel 7.6e-3. iq_multi_parity: new kernels bitwise equal to the per-column ones; its float guard is 2e-2 for IQ1_S, whose delta term uses the q8_1 float sum.
4e3e151 to
9702b2b
Compare
Inkling 2 Mini (Thinking Machines) is a 26B mixture of 128 experts, 8 a token, with a sigmoid router and SiTU activation. Its 24 layers run 6-17 three times (48 visits) with cross-pass messages and rank-64 controllers; attention residuals; a sliding window of 1024 on five layers of six; a relative-position bias and per-query sinks; short convolutions; an output gate; a logit softcap. The engine reads both GGUF forms: ggml-org's inkling2_loop (the loop unrolled) and Unsloth's inkling2 (24 blocks). - kernels_inkling.cu: the bias and the sinks are applied inside the attention kernel, which reads the fp16 or q8_0 cache directly and builds no score matrix, so a 128K context fits beside an 8 GB card. - The three passes share one cached copy of each expert (Layer::alias, home_of); the expert prefetch follows the run order across the loop. - Unsloth's *_exps.scale tensors apply on every pass (load_moe takes scales of any expert type when asked). - Q2_0 and IQ1_S experts (Unsloth's UD-Q2_K_XL) on the CPU (cpu_lowbit, AVX2) and Q2_0 in MMQ, opt-in per engine: only this engine turns them on, so other families' files take the same paths as before. IQ1_S on the GPU comes from the commit before this one (PR 199). - The engine loads its CUDA modules eagerly and reserves MMQ's fixup buffer: lazy loading took VRAM after the expert cache had filled it. - Not on Metal or HIP yet: opening the model there says so. - poly_logits_dump writes a prompt's logits, and those of tokens fed one at a time after it, for comparison with llama.cpp's. Checked against llama.cpp's logits on IQ4_NL and UD-Q2_K_XL, short, 302- and 1,500-token prompts, each run twice: cosine 0.9989-0.9998, 16-20 of the top 20 the same, and with llama.cpp's answer fed in the same most likely token at 29-32 of 32 steps. RTX 2070 Super 8 GB, Ryzen 5 3600XT, DDR4, 128K context, q8_0 caches: IQ4_NL writes 37 tokens/s and reads 270-434; UD-Q2_K_XL 45-47 and 366-544. Built and tested with CUDA 12.9 only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
InklingParser reads Inkling's replies, a list of blocks (thinking, text, tool calls), into the server's events. A forced tool_choice is written after the thinking, or at the start of the reply with thinking off; the reply ends with that call. The tokenizer treats inkling2 as an ignore_merges pre-tokenizer, as Hugging Face's does (llama.cpp splits some words, such as "kwargs", differently). Checked against Hugging Face's tokenizers (1,006 strings) and llama.cpp's chat code (14 prompts, 11 replies); serve/test_inkling.py keeps a fixture of them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
setup --family inkling installs ggml-org's IQ4_NL (the default) or Q8_0, or Unsloth's UD-Q2_K_XL, each pinned and checked by SHA-256, with q8_0 caches allowed. The family is CUDA only, so the Mac setup leaves it out. docs/models/inkling.md has what was measured, what was checked and what was not run (Q8_0, Windows, AMD); the README, AI_SETUP, BACKENDS and the MCP server's catalog list it. On 100 questions (50 GSM8K, 50 MMLU-Pro, greedy) IQ4_NL got 93 right and UD-Q2_K_XL 89. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
9702b2b to
d784ec4
Compare
Inkling's engine now says it sees, so GENI's pictures reach it. At the first visit a picture's rows go in as the encoder made them: llama.cpp 29b52d398b norms the token embeddings only (inkling2.cpp, "if (ubatch.token)"), and a call here can hold text and picture rows, so the raw rows are copied back over the normed ones row by row. With no picture in the sequence nothing changes. poly_logits_dump takes --images FILE --image-pad ID: strata-vision's SVE1 records at the prompt's runs of the pad token, as GENI places them, so the engine can be checked against llama.cpp's mtmd with the same rows. Its prompt calls go through whole(). Checked on an RTX 2070 Super 8 GB (IQ4_NL, fp16 cache) against llama.cpp's mtmd on the CPU, given llama.cpp's rows, for 6 prompts (pictures of 1 to 990 rows, one with two pictures): the prompt's logits had a cosine similarity of 0.99986 or more and greedy decoding chose the same token at all 33 positions in each. With the rows normed, as before, it was 0.98485 or more and 29 to 32 of 33. A picture split across calls (--prompt-batch 64) and --kv q8_0 kept the agreement (32 or 33 of 33, the one miss at a near tie). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Inkling's template writes <|content_image|><|unused_200054|> in a block of its own for a picture. The server now puts one <|unused_200054|> a row of the picture after <|content_image|>, which is the sequence llama.cpp 29b52d398b's mtmd feeds (its img_beg is <|content_image|>, it writes no end). The other formats' marks are unchanged. serve/test_inkling.py checks the ids around two pictures and the image_pad the engine is told, two pictures back to back, a picture in a tool's message (its header has the tool's name), that the same marks inside a message stay text, and that a picture in an assistant message is refused by the template. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The other families' encoder is built from llama.cpp 69f201a, which has neither the inkling2v projector nor the inkling2 tokenizer. Moving that pin would change every family's encoder, so Inkling gets a third pin (INKLING_VISION_LLAMA_CPP_COMMIT, 29b52d398b) through the family's "vision_llama": build_vision_own() compiles tools/vision from it into engine-poly/vision-inkling/ with a BUILD.json of its own, and before a start update_vision_own() rebuilds it from that stamp, after the engine's update and with a warning of its own when it fails. Its stamp records the toolkit's library folders, which go into the run config's lib_dirs; a CPU-only one is not rebuilt for another toolkit, as the shared check. The shared engine-poly/strata-vision and its stamp are not touched: for such a family the shared engine is built with vision "none". get_llama_cpp() takes commit= for that checkout; its vision True and False do what they did. The family entry: vision on offer (the question's default stays no, so --yes installs text only), ggml-org's Q8_0 mmproj at the pinned revision with its SHA-256, and ggml-org's mmproj for Unsloth's size too. "vision_vram_gb" 0.6: the encoder's process held 576 MiB after its warm-up on an RTX 2070 Super. Q8_0 rather than BF16, and the encoder's flash attention left on (its default), from measurements there and on a Ryzen 5 3600XT: Q8_0 is half the download, 576 against 904 MiB of VRAM, 2.1 against 3.3 s for 256 rows on 6 CPU threads; flash attention off was slower (22.7 against 12.3 s for 990 rows on the CPU) and took 1,584 MiB on the GPU. The engine's logits with rows from any of these were as close to llama.cpp's (cosine 0.99989 or more, the same greedy tokens, 2 pictures). The token limits stay setup's (1,024 GPU, 300 CPU). strata-vision built at the new pin needs no change to tools/vision; on the CPU with flash attention off its rows were bit-identical to llama.cpp's mtmd for 6 cases (7 drawn pictures). End to end the server answered as llama-mtmd-cli did about a test picture, and a real install (./setup.sh --family inkling --model IQ4_NL --cuda 12 --vision gpu on the RTX 2070 Super) built engine-poly/vision-inkling/ with its own stamp, left the shared engine's stamp at vision "none", and its server described a photo (llama.cpp's tools/mtmd/test-1.jpeg) as llama-mtmd-cli did: the New York Times of July 20, 1969, "MEN WALK ON MOON". An install with --vision cpu built the encoder without CUDA (stamp vision "cpu"; config gpu false, 6 threads, 300 tokens) and its server answered about the photo word for word as llama-mtmd-cli; a GPU encoder asked for the CPU is kept, a CPU one asked for the GPU is compiled again. UD-Q2_K_XL reads pictures with the same encoder (its server answered about the photo as llama-mtmd-cli on the same weights). docs/models/inkling.md has the numbers. The setup tests pass; tools/test_setup_inkling.py covers the opt-in, the own folder and stamp, the shared encoder left alone, the update path (a failed encoder build leaves the engine's update), the toolkit libraries and the checkout each pin takes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
NoLeakedSampler counted every "(_loop)" thread in the process, so a sampler still finishing from an earlier test made it fail now and then. It now records the threads alive before serve() and checks only the one its own server started. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2c703b2 to
c808b53
Compare
|
Thanks for this PR! I built and ran it on Windows, and it works. Setup: Windows 11, RTX 4060 Laptop 8 GB (driver 621.01), Ryzen 7 8845HS, 32 GB DDR5, CUDA 13.0, MSVC from VS 2022 Build Tools. One build fix was needed for MSVC: #if defined(_MSC_VER) && !defined(__clang__)
// MSVC has no _cvtsh_ss; the same F16C conversion through the vector intrinsic.
inline float h2f(uint16_t h) { return _mm_cvtss_f32(_mm_cvtph_ps(_mm_cvtsi32_si128(h))); }
#else
LOWBIT_FN inline float h2f(uint16_t h) { return _cvtsh_ss(h); }
#endifWith that, everything else compiled and ran. Speed (IQ4_NL, one request):
Answers: on a small set of 30 (14 tool-call cases, then 4 each of GSM8K, MATH-500, MMLU-Pro and HumanEval with a 16K-token cap), it got 25/30, with the same accuracy items right as the llama.cpp prebuilt. Tool calls came through the server correctly, including parallel calls and nested arguments. Three agent tasks in the Pi coding agent (write and run a script, fix a bug against its tests) all passed. Not tested: images, Q8_0, UD-Q2_K_XL. Thanks again! |
|
Thanks for the build fix for MSVC! I'll add that in |
MSVC has no _cvtsh_ss, so src/poly/cpu_lowbit.cpp did not compile there (error C3861). Under MSVC the same F16C conversion now goes through _mm_cvtph_ps. The AVX2 path itself stays off on MSVC (cpu_ok() is false there), so nothing changes at run time. Reported, with the fix, by Svirful on PR 200 (Windows 11, MSVC from VS 2022 Build Tools, CUDA 13.0). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…sequences Engine::step()'s rows are each the next token of a sequence of its own. Five calls take such rows in one launch, each row with its own caches, convolution state and position passed by value: inkling_kv_store_seqs, inkling_clip_many_seqs (tau at each row's position), inkling_attend_seqs (the split path, each row split as it is alone) and inkling_conv_seqs / inkling_conv_acc_seqs, up to kInklingSeqRows (16) rows. Flint calls its single-sequence kernels a row at a time; Inkling would make five such calls a row in each of its 48 visits, 240 launches a sequence for every step, and a step is not replayed from a recorded graph (the positions differ every step). The single-sequence calls run the same arithmetic as before: their kernels take where a row's caches, state and position come from as a template parameter (the attention, the K/V store, the clip and the convolution's walk alike). poly_inkling_kernels_test checks each new call against a call for each row alone, to the bit: 1 to 16 rows, fp16 and q8_0, full caches and rings, positions across the window's edge, the ring's wrap and the room steps, rows of one split beside rows of several, a full-attention row at 131,000 of a 128K context, and that every call refuses 17 rows. 0 failures on an RTX 2070 Super (CUDA 12.9). Not built for HIP: there is no ROCm toolchain here. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Inkling no longer refuses --batch (up to kInklingSeqRows - 1, the _seqs kernels' rows). Its step() rows go through one head (batch_heads()): the projections, the depth mixes, the loop's messages and controllers, the norms and the router run once for all rows. Each row's caches, convolution states and position come from its own sequence (seq_buf(), seq_state()), through the _seqs kernels. The routed experts are shared, as for the other families. The head keeps step()'s rows for the tail's FFN convolution. A slot's rows, rings and state are the ones bind() already gives every sequence. --check-stagger (with --check-batch K): sequence j's prompt is the first n >> 3 (K - 1 - j) of the --tokens' n (16 at least), read when the others have taken j * max_new / (2K) steps, and it writes max_new - j * max_new / K tokens: prompts of different lengths, sequences that join between steps and steps of fewer rows as they leave. --check-batch gave each sequence the tokens it gets alone, every token, in all 20 runs (RTX 2070 Super; IQ4_NL and UD-Q2_K_XL; fp16 and q8_0; 2, 3 and 4 sequences after a 302-token prompt, 4 after a 3,000-token one, and 4 with --check-stagger after prompts of 16, 46, 375 and 3,000 tokens, 64 to 16 tokens each). One request is unchanged. With every expert on the CPU (poly_logits_dump --no-gpu-experts, a 302-token prompt and 32 tokens fed after it) the base (c808b53) and this build wrote byte-identical logits, fp16 and q8_0. With the expert cache frozen and of one size in both (STRATA_FREEZE_EXPERTS, --expert-swaps 0, --cpu-share 0, --vram-reserve-mib 1024) both wrote the same 48 tokens and top-5 probabilities, fp16 and q8_0. Its speed, the server's flags, two runs each, base and then this build: decode after a 302-token prompt IQ4_NL 37.6-38.2 and 37.3-38.1 tok/s, UD-Q2_K_XL 49.4-51.3 and 50.7-53.0; a 1,500-token prompt read at 453-455 and 452-455 tok/s (IQ4_NL), 587-591 and 586-611 (UD-Q2_K_XL). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Its engine takes batch slots now. Setup writes "parallel" for it when asked and suggests it by poly_parallel_note()'s rule, as for the other families of strata-poly. The rule suggests 2 to 4 where the card holds every expert of the size. On a smaller card it says that requests at once gain less. "one_request" goes, and so does the branch that read it. tools/test_setup_inkling.py: --parallel 3 is written and carried over to a later run without --parallel, and so is an earlier "parallel": 1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
models/inkling.md: a section on several requests at once, and BATCHING.md: Inkling in the list of strata-poly models, its numbers and its --check-batch runs. AI_SETUP.md: Inkling's line no longer says one request at a time or text only. Measured on an RTX 2070 Super 8 GB (Ryzen 5 3600XT, 62 GB DDR4) through the server: 128K context, q8_0 caches, the expert profile, chats of 300 tokens, two runs a row, a fresh server for each row, "parallel" equal to the chats except one row. All chats together: chats "parallel" IQ4_NL UD-Q2_K_XL 1 1 37.1-37.7 46.2-47.8 1 4 34.5-35.0 44.3-44.9 2 2 44.6-45.5 57.7-59.7 3 3 48.9-49.0 63.2-64.5 4 4 51.2-51.9 64.1-66.5 "parallel": 2 took about 0.5 GiB of the expert cache at load (two sequences beside the first), each slot after it about 0.27 GiB. The one-request table is measured again, all on one day with the same flags (the server's, with each model's expert profile): UD-Q2_K_XL wrote 50.7-53.0 tok/s after a 302-token prompt, where the page had 46.9 from an earlier day; IQ4_NL 37.3-38.1 (it had 37.4). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
inkling_attend() walked a prompt batch's keys in float on the CUDA cores (attn_kernel), which made the attention most of a long prompt's time. A call of more than 16 tokens (every call that the split path does not take) now runs attn_mma_kernel on cards of Turing or newer. It works the way kernels.cu's attn_flash128_kernel does: 21 tokens of a group a block, four warps of 16 rows (a token's three heads side by side), keys 32 at a time in shared memory as halves, S = Q K^T and O += P V as m16n8k16 steps (two of k = 8 on Turing) that sum floats, and an online softmax in floats. A Q8_0 cache's codes times their scales go to shared memory as halves. The relative-position bias is a product too: each warp's R times the table rows of the distances a tile spans, put in shared memory as floats and read back at each score's distance, only in the tiles that hold a distance below the extent. The per-token sinks come at the end. The tiles count from position 0, so a token's result does not depend on the tokens beside it in the call (tested to the bit). The split path (decode), the batch slots' per-sequence calls and the old unsplit kernel (calls of up to 16 tokens without work, older cards, HIP) are unchanged. No other family's code is touched. The switch at 17 tokens is measured (poly_inkling_kernels_test bench, RTX 2070 Super; the unsplit kernel's times from the day before): 17 tokens at position 8192 took 0.88 ms against 5.2 ms (full layer) and 0.15 against 0.74 ms (window layer). 4,096 tokens from 0 took 4.8 ms against 128.7 (full) and 2.7 against 63.6 (window). poly_inkling_kernels_test checks the new path against the doubles for fp16 and q8_0 caches, full and window layers, the ring's wrap, the extent's edge, 16 to 2,048 rows and rows about the switch. Its bound is fattn_test.cu's for the other families' tensor-core attention, 7.5e-3 of the largest result: Q, R, the table's rows, P and V are halves in the products, as in llama.cpp's flash attention (Q, P and V); the bias stays a float. The most error seen was 3.8e-3 of 1 (sm_75). Probes whose weights are exact (q = 0 and R = 0, so the result is the mean of the visible values; and a table that is nonzero only at distance extent - 1) hold the mask, the window, the ring's wrap and the extent's edge to 1e-5 (2.2e-6 seen on the tensor cores). The old paths keep 2e-5. Parity against llama.cpp (run_parity.sh, IQ4_NL and UD-Q2_K_XL): prompt cosine 0.99919 to 0.99984, top-20 18 to 20 of 20, decode 30 to 31 of 32, inside the range in inkling.md (0.9989 to 0.9998, 16 to 20 of 20). Speed against 791be9e, the same card on the same day (strata-poly --serve, a 128K context, q8_0 caches, a fresh copy of the expert profile each run): IQ4_NL prompts of 302 and 1,500 tokens 282-290 and 521-523 tokens/s against 271-272 and 458-461; UD-Q2_K_XL 557-561 and 881-888 against 504-508 and 609-611 (two runs each); IQ4_NL 2K 658 against 504, 32K 820 against 263, 131,008 tokens 659 against 92 (199 s against 1,421). Writing (256 tokens after the 302- and 1,500-token prompts) does not run the new kernel and differed by up to 4.5% in single runs, both ways (at most 1.5% on the means of two runs). Built for sm_75 and compiled for sm_61, 80, 86, 89 and 120 (no spills; 30,336 bytes of shared memory a block). HIP compiles the kernel empty and never launches it; HIP was not built here. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Engine::window() keeps the recurrent state as it is after some of a window's tokens, so that keep() can go back to it after a wrong guess. For Inkling that state is its short convolutions' (the last three inputs of a channel). inkling_conv_snaps() writes, for each token whose bit is set, the state inkling_conv() leaves after that token. It reads the call's input and the state before the call changes it, so the convolution kernels stay as they are. poly_inkling_kernels_test checks each snapshot against the state that inkling_conv() leaves after that many tokens, to the bit (4, 8 and 2 rows, several sets of bits), and that bits at or past the call's rows, and past the kernel's 32 tokens (a call of 40 rows), write nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Inkling no longer refuses --window above 1. A window's convolutions leave their state after the window's snapshot tokens (inkling_conv_snaps(), through Inkling::conv_snaps(), before each convolution advances it: the K and V convolutions in kv_store, the attention's and the FFN's post-convolutions), so keep() can go back after a wrong guess. The other per-position state (the window visits' rings and the full visits' rows) is rewritten when a position gets its real token, as for the other families. With experts on the CPU a window can go through the layers in two halves (Engine::shift_rows()). Inkling's shift_rows() moves its gathered stream (res_) with the engine's buffers, and a layer's head and tail each take the stream at their own rows (work_stream()), not one the head leaves in a member: in halves the other half's head runs between them. The file has no block that guesses ahead, so the guesses come from the conversation's repeats (--lookup) alone, and a guessed window is opt-in: without --window it stays 1, identical to --window 1, where the engine's default would be 4. The draft model is still refused. tools/window_agree.py checks that a window changes no answer: it runs --window 4 and --window 1 with every expert on the CPU and compares their tokens and likeliest tokens at every step, and fails when the window took no guesses. tools/test_window_agree.py tests its verdicts against a stand-in engine, without a GPU. Built and tested with CUDA only. kernels_inkling.cu and inkling.cpp are also in the HIP build, which was not built: there is no ROCm on the machine this was written on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
models/inkling.md: a section on --window for Inkling, which is
opt-in and whose guesses come from the conversation's repeats alone,
with its speed against --window 1 and how its answers were checked.
GLM.md's options table: --window's default for Inkling is 1.
Greedy answers of 300 tokens, 128K context, q8_0 caches, two runs
each, tokens/s with --window 1 -> 4:
RTX 2070 Super 8 GB (Ryzen 5 3600XT), a fresh copy of the expert
profile each run, this build
IQ4_NL code 35.1-35.4 -> 38.8-40.0
IQ4_NL text 36.7-37.8 -> 36.7-37.2
UD-Q2_K_XL code 47.1-47.4 -> 47.9-48.1
UD-Q2_K_XL text 48.2-48.4 -> 48.8-48.8
RTX 3090 24 GB (rented, every expert in VRAM), an earlier build:
the same window code on inkling2-batch 79d48fe
IQ4_NL code 59.4-59.8 -> 64.3-64.4
IQ4_NL text 58.0-59.8 -> 59.9-60.1
UD-Q2_K_XL code 68.1-68.2 -> 74.6-75.2
UD-Q2_K_XL text 68.2-68.5 -> 70.1-70.2
On the 2070 Super, 200 greedy tokens: with every expert on the CPU,
--window 4 gave the tokens and top-5 probabilities of --window 1
(both sizes, three prompts; on this build tools/window_agree.py: both
sizes on the code prompt and UD-Q2_K_XL on its own prompt); with the same experts cached and frozen,
the same for UD-Q2_K_XL (code and text); IQ4_NL's runs held one expert
apart and parted at near ties (ln p1/p2 0.01 and 0.07).
Without --window, 200 greedy tokens against inkling2 791be9e's (tokens
and top-20 probabilities; both sizes, fp16 and q8_0, code and text,
every expert on the CPU and with the same experts cached): 15 of 16
identical. In the 16th (UD-Q2_K_XL, fp16, code, cached) the two runs
never held the same experts (1,864 and 1,869 at load), and they first
differ at a near tie (ln p1/p2 0.15).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
native_mmvq_jobs() takes up to 8 matrices of one format and input width, each with its own rows, Q8_1 columns and output, in one launch: an attention's projections of the same normed input. Each row block is native_mmvq_multi_kernel's exact layout for its matrix, so the outputs are those of native_mmvq() for each matrix, bit for bit. Q8_0, Q4_K, Q5_K and Q6_K; it declines (launching nothing) other formats, repacked matrices (STRATA_Q8_PACKED, STRATA_Q6_PACKED), the gfx906 wave layout and the switches whose several-column bits are another layout's, and the caller then launches the matrices one by one. Metal's stub declines. A new call only: nothing calls it yet. On an RTX 2070 Super, Inkling 2 Mini's six Q8_0 projections of a 2304-value input (3072, 3072, 384, 24, 1024 and 1024 rows) took 62.3 us in one launch against 79.0 us one by one for a token, 67.8 against 92.8 for 2 and 92.3 against 101.3 for 4 (a microbenchmark, the weights not in L2). poly_inkling_kernels_test checks it against native_mmvq() for each matrix, to the bit: the four formats, 8 matrices of 2304 values (a row a block) for 1, 2, 4 and 8 columns, and 3 and 8 of 512 (2 rows a block, matrices of odd rows) for 1 and 3. It now links strata_kernels. 0 failures on the RTX 2070 Super (CUDA 12.9). Not built for HIP: there is no ROCm toolchain here. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Engine::lin_jobs() takes several matrices, each as lin() gives it, and puts those of one quantized format and input width whose inputs are in Q8_1 through native_mmvq_jobs(); the rest, and everything for more than 8 tokens (a prompt batch, MMQ), go through lin() one by one. Each output is lin()'s, bit for bit. Inkling::attn() takes its 6 projections (8 in a full-attention layer, with the convolution's taps) through it: in IQ4_NL's and UD-Q2_K_XL's files they are all Q8_0 of 2304 values, 3 inputs, in one launch where they were 6 or 8. The other families do not call it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MmvqSlots::lanes and MmvqIds::lanes (default false) take the same bits through other kernels. native_mmvq.cu's formats: a warp a row instead of a block of 4 warps, lane l doing the work of the block's threads l, 32 + l, 64 + l and 96 + l, each into its own sum, added in the order the block adds its warps' partials; the same terms in the same order, with no shared memory, no barrier and no thread idle where the block's threads do not divide a row evenly (an IQ4_NL expert's 2304 and 1152 values are 72 and 36 blocks for the block's 64 pairs of threads). iq_kernels.cu's formats whose grid is staged in shared memory (IQ1_S, IQ1_M, IQ2_XXS, IQ2_XS, IQ2_S): the grid staged once for 8 rows a warp, each row row_dot_multi's for one column, row_dot's arithmetic in its order (not with STRATA_OLD_IQ_MMVQ or STRATA_IQ_STAGE_GRID=0). The other IQ formats' launches are as without it. Unset, every launch is as before. Metal takes no notice. It takes precedence over native_mmvq_slots_wide(), which HIP has on by default; measured on CUDA only. On an RTX 2070 Super, 8 cached experts' launch, these kernels against the slots kernels (a microbenchmark, the weights not in L2): IQ4_NL 2304 -> 2304 80.9 -> 73.8 us, 1152 -> 2304 46.9 -> 43.3; Q2_0 1152 -> 2304 45.6 -> 33.8; IQ1_S 2304 -> 2304 101.2 -> 78.4, IQ2_XXS 94.6 -> 81.5, IQ2_XS 119.0 -> 87.6, IQ2_S 119.3 -> 91.4. poly_inkling_kernels_test checks both launches (by slot and through the card's picks) against native_mmvq() for each expert, and the slots launch against itself without lanes, to the bit: IQ4_NL, Q8_0 and Q2_0 (Inkling 2's experts), IQ1_S, IQ1_M, IQ2_XXS, IQ2_XS and IQ2_S, 1 and 8 experts; Q4_0, Q5_0, MXFP4, Q2_K, Q3_K, Q4_K, Q5_K, Q6_K and IQ4_XS; and row counts that leave a partial block (2301, 37). 0 failures on the RTX 2070 Super (CUDA 12.9). Not built for HIP: there is no ROCm toolchain here. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Engine::lane_slots_ (Inkling sets it, as lowbit_experts_) sets MmvqSlots::lanes and MmvqIds::lanes on the cached experts' launches, and with it one cached expert also goes through the slots launch rather than native_mmvq(): the same bits, faster where the format has a lanes kernel (Inkling 2's do). Off, the other families' launches are as they were. Not set on HIP, where it is unmeasured (and the engine does not run Inkling 2 yet). Measured on an RTX 2070 Super 8 GB (Ryzen 5 3600XT), strata-poly alone: 302-token prompt, 128 tokens written, 128K context, q8_0 caches, two interleaved runs each, this commit and the three before it against their base: IQ4_NL wrote 38.9 and 38.3 tok/s before, 39.8 and 40.1 after (38.2 and 38.7 -> 39.5 and 39.0 with a copy of its expert profile); UD-Q2_K_XL 51.2 and 51.9 -> 55.2 and 54.6. Nsys over the decode (before the rebase onto the batch slots): a visit's dense work 124 -> 108 us, its cached experts 109 -> 96 us, 31 -> 26 launches. The logits against llama.cpp's stay as close: IQ4_NL prompt cos 0.99969, 0.99902 and 0.99964, the same argmax at 31 and 32 of 32 steps; UD-Q2_K_XL 0.99969, 0.99948 and 0.99955, 32 and 31 of 32 (its medium prompt's top two, 0.068 apart in llama.cpp's logits, swap places). --check-batch with the expert cache held still: every sequence got the tokens it gets alone, both files, 2 and 4 sequences, q8_0 caches. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ed again models/inkling.md: the 302-token row's writing speeds with the projections in one launch and the cached experts a warp a row, and what they were before in the same runs (the gain, +2% and +6%); the page says the row's prompt speeds are from the earlier runs, and the other rows and the batch table that they are from before. Measured on an RTX 2070 Super 8 GB (Ryzen 5 3600XT, 62 GB DDR4), strata-poly alone with the server's flags (128K context, q8_0 caches), 128 tokens written, two interleaved runs each: IQ4_NL with a copy of its expert profile 38.2-38.7 -> 39.0-39.5 tok/s, UD-Q2_K_XL (no profile) 51.2-51.9 -> 54.6-55.2. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cts split in halves On HIP ink_attend_batch() took nothing (ink_flash_kernel is NVIDIA's mma.sync), so a prompt batch went to attend_batch(), which writes every score out and rounds the queries and the weights to one half each. On gfx12 (the card asked: gfx_arch_is_gfx12_wmma()) it now takes ink_wmma_kernel, for fp16 caches and Inkling 2 Mini's heads (128 values, 3 on a key head, 16 relative values); elsewhere, and with STRATA_INK_FLASH=0, the path is as it was. - S^T = K Q^T and O^T = V^T P^T as v_wmma_f32_16x16x16_f16 steps: a lane's C fragment of S^T is its row's scores at 8 keys, which is the same lane's B fragment of P^T, so the weights never leave the registers and a row's online softmax lives in two lanes (one shuffle). The queries (in log2 units) and R stay in registers. - The queries, R, the bias table's rows and the weights go into the products as a half and the half of what it leaves (two or three steps a product), so the sums are float-exact to about 2^-22 of a term; fp16 caches are exact halves. The weights go in times 2^12 (the output comes out divided by it), so a small weight's lo half is a normal half. - The bias is R times the table's rows of the distances a warp's rows reach in a tile (three steps), through the warp's shared memory; only tiles with a distance below the extent compute it. The sink's term and the gate as ink_flash_kernel has them. - 4 warps of 16 rows (21 tokens of a 3-head group), 32-key tiles counted from position 0, so a token's result does not depend on the call it is in; about 37 KB of shared memory a block. poly_inkling2_wmma_test (HIP, gfx12; 77 elsewhere) holds it to an FP64 reference at 2e-5, next to ink_attend()'s float kernels, and checks a token's result to the bit in two calls that start at other tokens. RDNA3 (gfx11) keeps attend_batch(): a gfx11 variant of this kernel missed both checks on an RX 7900 XT. CUDA builds compile the same code (all of it is under __HIPCC__). The kernel is Tako88's idea and start (his WMMA prompt attention for RDNA4 on PR simplexai-labs#200); this one is the rewrite of it that our first Inkling engine shipped. There, on an RX 9070 XT (gfx1201, ROCm 7.2.4), --max-context 16384, fp16 caches, prompt tok/s, medians of 3, its scalar kernel -> this one: UD-Q2_K_XL 2,048 tokens 923.7 -> 1269.6, 8,192 801.0 -> 1331.6; IQ4_NL 1062.3 -> 1503.9, 628.8 -> 871.4; against an RTX 3090's logits its KL was within the card-to-card range. Tako88 measured it at +64-96% over his own kernel on a gfx1200. Here the path it replaces is attend_batch() on rocBLAS, so the gain is to be measured again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Where run() and step() replay a token's layer launches, they recorded each layer's shared expert apart (Layer::shared) and replayed it, a graph launch a layer visit. Inkling 2's shared expert is one memset of fo_ (moe_shared()), and on HIP, where the doorbell is off, a token with experts outside VRAM goes layer by layer: 48 visits, each with that extra graph launch. A family can now say its shared expert is launched as it is (Engine::shared_recorded()), and Inkling 2 does on HIP. The same kernels in the same order, so the same bits. CUDA and the other families replay it as before. In our first Inkling engine (PR simplexai-labs#200), the same change (the shared expert launched as it is where the heads are) wrote IQ4_NL +17% faster on an RX 9070 XT (gfx1201, ROCm 7.2.4) with the same logits; there the heads were launched one by one too, here they stay recorded, so the gain is to be measured on this engine. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…P card table16_lookup() (IQ4_NL, IQ4_XS, MXFP4, the formats of 16 values) took llama.cpp's v_perm_b32 sequence on gfx906 only, and the __byte_perm one elsewhere. Both give the same bytes; on RDNA4 the v_perm_b32 one is faster. In our first Inkling engine (PR simplexai-labs#200) on an RX 9070 XT (gfx1201, ROCm 7.2.4), 8 cached IQ4_NL experts' products read at 337 -> 411 GB/s (2,304 values) and 244 -> 349 (1,152), and Inkling 2 Mini IQ4_NL wrote 256 tokens after 302 at 43.2 -> 45.6 tok/s, medians of 3. So every HIP build takes it. CUDA builds compile the same code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…Q build) Mmq::fits() in mmq.cu leaves MXFP4 out on a Blackwell card other than 12.0, whose CUDA build has no image of the instance, by comparing the card's cc with GGML_CUDA_CC_BLACKWELL. An AMD card's cc carries GGML_CUDA_CC_OFFSET_AMD and is above every NVIDIA one, so on HIP MXFP4 never fitted, although its instance is built for the HIP architectures and RDNA has its configurations. UD-Q2_K_XL's layer 20 has MXFP4 down experts, and the engine takes MMQ for a layer's prompt experts only when gate|up and down both fit, so that layer's prompt MoE took the decode kernels a token at a time. The check is now CUDA's only. Only the -DSTRATA_POLY_MMQ=ON build has mmq.cu; the default build's mmq_own.cu has no such check. Measured in our first Inkling engine (PR simplexai-labs#200), on an RX 9070 XT (gfx1201, ROCm 7.2.4), UD-Q2_K_XL, q8_0 caches, prompt tok/s, medians of 2: 2,048 tokens 1454 -> 1613, 8,192 1678 -> 1873, 32,768 1467 -> 1620. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…inux) Between prompts the expert cache takes the VRAM of the buffers only a prompt batch uses (lend_prompt()), and a prompt maps them again. ROCm on Linux gives VRAM back only with its addresses (vmm_unmap() frees and reserves them again), which the staging buffer's widening already stays away from (Engine::alloc(), `lend`). With the buffers lent strata-poly crashed in 15 of 16 runs of Inkling 2 Mini IQ4_NL on an RX 9070 XT with 2,443 of its 3,072 experts in VRAM (ROCm 7.2.4 container): SIGSEGV inside hipLaunchKernel, the dequantize launch of a prompt's dense product (Mmq::mul's BLAS path) into the lent work memory. With every expert in VRAM nothing is lent, and it ran. With this change 8 of 8 runs on that card finished (2,424 of 3,072 experts in VRAM, 16 tokens written, the same first tokens as on an RX 7900 XT). Where STRATA_VMM_RELEASE_WITH_ADDRESSES is defined (HIP on Linux) the buffers are now allocated as they are without VMM (our engine in simplexai-labs#200, which ran this case, never lent them). CUDA and Windows HIP are unchanged (the preprocessed CUDA engine.cpp is identical). Class: placement only (the buffers' VRAM stays theirs; the expert cache does not grow into it between prompts). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cts split in halves On HIP ink_attend_batch() took nothing (ink_flash_kernel is NVIDIA's mma.sync), so a prompt batch went to attend_batch(), which writes every score out and rounds the queries and the weights to one half each. On gfx12 (the card asked: gfx_arch_is_gfx12_wmma()) it now takes ink_wmma_kernel, for fp16 caches and Inkling 2 Mini's heads (128 values, 3 on a key head, 16 relative values); elsewhere, and with STRATA_INK_FLASH=0, the path is as it was. - S^T = K Q^T and O^T = V^T P^T as v_wmma_f32_16x16x16_f16 steps: a lane's C fragment of S^T is its row's scores at 8 keys, which is the same lane's B fragment of P^T, so the weights never leave the registers and a row's online softmax lives in two lanes (one shuffle). The queries (in log2 units) and R stay in registers. - The queries, R, the bias table's rows and the weights go into the products as a half and the half of what it leaves (two or three steps a product), so the sums are float-exact to about 2^-22 of a term; fp16 caches are exact halves. The weights go in times 2^12 (the output comes out divided by it), so a small weight's lo half is a normal half. - The bias is R times the table's rows of the distances a warp's rows reach in a tile (three steps), through the warp's shared memory; only tiles with a distance below the extent compute it. The sink's term and the gate as ink_flash_kernel has them. - 4 warps of 16 rows (21 tokens of a 3-head group), 32-key tiles counted from position 0, so a token's result does not depend on the call it is in; about 37 KB of shared memory a block. poly_inkling2_wmma_test (HIP, gfx12; 77 elsewhere) holds it to an FP64 reference at 2e-5, next to ink_attend()'s float kernels, and checks a token's result to the bit in two calls that start at other tokens. RDNA3 (gfx11) keeps attend_batch(): a gfx11 variant of this kernel missed both checks on an RX 7900 XT. CUDA builds compile the same code (all of it is under __HIPCC__). The kernel is Tako88's idea and start (his WMMA prompt attention for RDNA4 on PR simplexai-labs#200); this one is the rewrite of it that our first Inkling engine shipped. There, on an RX 9070 XT (gfx1201, ROCm 7.2.4), --max-context 16384, fp16 caches, prompt tok/s, medians of 3, its scalar kernel -> this one: UD-Q2_K_XL 2,048 tokens 923.7 -> 1269.6, 8,192 801.0 -> 1331.6; IQ4_NL 1062.3 -> 1503.9, 628.8 -> 871.4; against an RTX 3090's logits its KL was within the card-to-card range. Tako88 measured it at +64-96% over his own kernel on a gfx1200. Here the path it replaces is attend_batch() on rocBLAS, so the gain is to be measured again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Where run() and step() replay a token's layer launches, they recorded each layer's shared expert apart (Layer::shared) and replayed it, a graph launch a layer visit. Inkling 2's shared expert is one memset of fo_ (moe_shared()), and on HIP, where the doorbell is off, a token with experts outside VRAM goes layer by layer: 48 visits, each with that extra graph launch. A family can now say its shared expert is launched as it is (Engine::shared_recorded()), and Inkling 2 does on HIP. The same kernels in the same order, so the same bits. CUDA and the other families replay it as before. In our first Inkling engine (PR simplexai-labs#200), the same change (the shared expert launched as it is where the heads are) wrote IQ4_NL +17% faster on an RX 9070 XT (gfx1201, ROCm 7.2.4) with the same logits; there the heads were launched one by one too, here they stay recorded, so the gain is to be measured on this engine. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…P card table16_lookup() (IQ4_NL, IQ4_XS, MXFP4, the formats of 16 values) took llama.cpp's v_perm_b32 sequence on gfx906 only, and the __byte_perm one elsewhere. Both give the same bytes; on RDNA4 the v_perm_b32 one is faster. In our first Inkling engine (PR simplexai-labs#200) on an RX 9070 XT (gfx1201, ROCm 7.2.4), 8 cached IQ4_NL experts' products read at 337 -> 411 GB/s (2,304 values) and 244 -> 349 (1,152), and Inkling 2 Mini IQ4_NL wrote 256 tokens after 302 at 43.2 -> 45.6 tok/s, medians of 3. So every HIP build takes it. CUDA builds compile the same code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…Q build) Mmq::fits() in mmq.cu leaves MXFP4 out on a Blackwell card other than 12.0, whose CUDA build has no image of the instance, by comparing the card's cc with GGML_CUDA_CC_BLACKWELL. An AMD card's cc carries GGML_CUDA_CC_OFFSET_AMD and is above every NVIDIA one, so on HIP MXFP4 never fitted, although its instance is built for the HIP architectures and RDNA has its configurations. UD-Q2_K_XL's layer 20 has MXFP4 down experts, and the engine takes MMQ for a layer's prompt experts only when gate|up and down both fit, so that layer's prompt MoE took the decode kernels a token at a time. The check is now CUDA's only. Only the -DSTRATA_POLY_MMQ=ON build has mmq.cu; the default build's mmq_own.cu has no such check. Measured in our first Inkling engine (PR simplexai-labs#200), on an RX 9070 XT (gfx1201, ROCm 7.2.4), UD-Q2_K_XL, q8_0 caches, prompt tok/s, medians of 2: 2,048 tokens 1454 -> 1613, 8,192 1678 -> 1873, 32,768 1467 -> 1620. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for all the work on this! I just built and benchmarked the latest Two Windows Build Fixes Needed1. MSVC if(WIN32)
add_compile_definitions(_ENABLE_EXTENDED_ALIGNED_STORAGE)
endif()2. Windows f.extractall(tmp, [m for m in f.namelist() if "/tools/ui/" not in m and "/ui/" not in m])With those two changes, everything built and ran cleanly. Benchmark ResultsSetup: Windows, NVIDIA RTX 3080 Ti (12 GB VRAM), 64 GB system RAM, MSVC Build Tools, CUDA.
(Note: VRAM and RAM figures reflect peak total machine usage during the run.) |
Title
poly: Inkling 2 Mini (inkling2 / inkling2_loop)
Refs #198. Depends on #199: the first commit here is #199's IQ1_S GPU kernel, unchanged. If #199 merges first, I'll rebase and it drops out of this PR.
What it is
A strata-poly engine for Thinking Machines' Inkling 2 Mini (26B, 128 experts, 8 a token), text and pictures. It reads ggml-org's
inkling2_loopfiles (IQ4_NL, Q8_0) and Unsloth'sinkling2file (UD-Q2_K_XL). Its shared-engine hooks are used only by Inkling. One change reaches other families: the load order of a layer split.How to use it
./setup.sh --family inkling(IQ4_NL by default)--model UD-Q2_K_XLor--model Q8_0--vision cpu|gpu"parallel": N--gpus 0,1, or"layer_split"--window 4--dspark yesin setup, or--draft-model FILESpeed
Tokens/s, q8_0 caches, one request. "After 302" and "8,192" are prompt lengths in tokens.
fc96949)fc96949) *a9ffc2bhere (fewer CPU threads, below); the next push addresses it.How it was checked
conv_accbit cases fail.Platforms and limits
--kv q8_0, 32 KiB in fp16). No KV streaming.Credits
More
See
docs/models/inkling.mdand the sections below. I can split parts into their own PRs if you prefer.Speed: RTX 2070 Super 8 GB
Local PC: RTX 2070 Super 8 GB (PCIe 3.0 x16), Ryzen 5 3600XT, 62 GB DDR4-3200, Ubuntu 22.04, CUDA 12.9. One request, q8_0 caches, guesses off, tokens/s.
Reading a prompt:
Writing:
Speed: A100, RTX 3090, 2x RTX 3070, RTX 5080
A100 PCIe 40 GB (rented). Driver 580.126.09, 96 CPUs (11 CPU threads used). Code: c69df6a, which is the head's CUDA code. Every expert on the card (3,072 of 3,072).
strata-poly --serve, q8_0, one fresh engine a prompt, 256 tokens written. 16K context; 40K for the 32K prompt, 132K for the 131K one. Medians of 3 runs [min-max], tokens/s.STRATA_POLY_EXPERT_TILES=1A100, prompts of 262K to 1M tokens (UD-Q2_K_XL, every expert in VRAM, q8_0, one run each):
STRATA_KV_INT8=1A100, prompt attention kernel (
attn_fa2_kernel) size gate. Kernel bench, one run, ms,attn_mma_kernel/attn_fa2_kernel, a full layer's 1,024-token call:attn_mma_kernelattn_mma_kernelattn_mma_kernel, 28.4 ms with FA2.attn_mma_kernel, 1.32 ms with FA2. So window layers stay onattn_mma_kernel.RTX 3090 24 GB (rented). EPYC 7B12, 15 CPU threads, PCIe 4.0. Every expert in VRAM, q8_0, tokens/s. The 6e61054 rows: 16K context, 256 tokens written, two runs.
2x RTX 3070 8 GB, split at layer 18 (rented, 6e61054).
RTX 5080 16 GB (c808b53, an early tree, one run each). UD-Q2_K_XL fits whole. IQ4_NL holds 2,469 of 3,072 experts.
RTX 4060 Laptop 8 GB, Windows 11 (Svirful, an earlier build). MSVC from VS 2022 Build Tools, CUDA 13.0. IQ4_NL wrote 26 tokens/s and read 484.
Speed: RX 9070 XT (AMD)
Box: RX 9070 XT 16 GB (gfx1201), Ryzen 7 7800X3D, 31 GB RAM for WSL2, Windows with WSL2 Ubuntu 24.04, ROCm 7.2.4, librocdxg 1.2.2. The desktop holds 2-3.5 GB of the card's VRAM. One request, tokens/s.
q8_0 caches, 131,072 context, 256 tokens written, two runs each:
a9ffc2bfc96949a9ffc2bfc96949The head uses 8 CPU threads on this 8-core CPU (one a core), against 11 before; that costs IQ4_NL prompts a few percent, since part of their experts run on the CPU.
fp16 caches, 16K context:
STRATA_INKLING_WMMA=1inkling2_loop) pp512 1,096-1,172, pp2048 224-555, tg128 37-44.Opt-in features: speed
Batch slots (
--batch/"parallel"). All chats together, tokens/s.RTX 2070 Super (791be9e, a fresh server per row, 300-token chats, greedy, two runs):
"parallel"RTX 3090 (4d7ca06, 32K context):
Guesses from the conversation (
--window 4) and the DSpark drafter.RTX 3090 (every expert in VRAM, 16K context, q8_0, 256 tokens written, two runs each; 6e61054 + the window graphs), tokens/s:
--window 1--window 4--window 8on a prose prompt: 127.8 tokens/s (UD-Q2_K_XL).--window 4(nsys): 5.6 (IQ4_NL) and 24 (UD-Q2_K_XL) with the graph, 787 and 921 without.RTX 2070 Super,
--window 1->--window 4(68d4c86; the code prompt asks for a file back with a change), tokens/s:--window 4pays where the answer copies the prompt.Drafter on an 8 GB card (a rented RTX 2070, 6e61054 + the drafter, greedy, frozen experts, 256 tokens, two runs each, against the same build without the drafter):
MMQ expert tiles (
STRATA_POLY_EXPERT_TILES=1, CUDA only).Prompt reading, default -> tiles, tokens/s:
Kernel bench (
poly_mmq_tiles_test bench, 8 calls, rows from the IQ4_NL expert profile), TOPS:STRATA_KV_INT8=1(past 32K, needs a q8_0 cache).STRATA_KV_INT8=1.Pictures (
--vision cpu|gpu, RTX 2070 Super, 6 encoder threads).More tables are in
docs/models/inkling.md(Guesses from the conversation; Guesses from its DSpark drafter).Accuracy
Against llama.cpp's logits.
poly_logits_dumpand llama.cpp at the commit that added the model. IQ4_NL and UD-Q2_K_XL, a short prompt and prompts of 302 and 1,500 tokens, twice each, RTX 2070 Super.AMD (HIP) against NVIDIA. Reference: an RTX 3090's CUDA default dumps. Noise floor: an A100's CUDA default against the same RTX 3090. 12 cases: both files, fp16 and q8_0, prompts of 286, 2,048 and 8,192 tokens, prompt + 32 decode rows. HIP code: the AMD commits before they were merged into this branch.
Opt-in features against the default.
STRATA_KV_INT8=1STRATA_KV_INT8=1--prompt-batch 64) moves the logits by the same amount.--no-gpu-experts: the same answers in 6 of 6 cases. Graphs on and off: the same in 2 of 2.Pictures (llama.cpp 29b52d398b, IQ4_NL, the Q8_0 mmproj).
llama-mtmd-clidescribed the photo in nearly the same words.Answers (50 GSM8K + 50 MMLU-Pro, greedy, an early build): IQ4_NL 93, UD-Q2_K_XL 89. The same answer to 92 of 100.
Tokenizer and chat format.
tokenizerson 1,006 strings (about 587,000 tokens).serve/test_inkling.py).Kernel accuracy. Tensor-core prompt attention: the largest error against a double reference was 3.8e-3 (kernel test, sm_75).
Byte-identity checks and tests
"The same bytes" means the md5 of the dumped logits is equal (
poly_logits_dump, experts frozen).--no-graphsSTRATA_KV_INT8=1at 16,500--no-graphsSTRATA_GPU_EXPERTSat the same N (773 to 1,884), equal set hashes--no-graphsSTRATA_KV_INT8off and on--serve, four prompts in one engine--check-batch 2STRATA_GPU_EXPERTS(UD-Q2_K_XL N=2,971, IQ4_NL N=1,932), equal set hashes--no-graphs--no-gpu-experts--vram-poolattn_fa2_kernelvsattn_mma_kernel, kernel test--window 4and 8, and the drafter at windows 4 and 8, vs--window 1and vs--no-graphs--no-graphs, for--window 4and for the drafter--no-gpu-experts, both files, fp16 and q8_0, prompts of 302 to 7,500 tokens (RTX 2070 Super, RTX 2070, RTX 2080 Ti); IQ4_NL after 30,000 tokensSTRATA_FREEZE_EXPERTS=1--serveafter checkpointed and resumed reads--window 4vs--window 1, every expert on the CPU"auto"; 3, 20 and 3+18 on an earlier treeTests:
poly_inkling_kernels_test): 0 failures on sm_75, sm_60 and sm_80. It compares every fused launch with the separate launches, to the bit.conv_accbit cases fail (fused vs separate launches). They also fail on Tako88's own tree.python -m unittest discover -s serve: 1,049 passed (18 skipped), on a build without batch slots.serve/test_inkling.py: 44 (3 skipped).tools/test_setup_*.py: 799 (1 skipped).poly_mmq_tiles_test: the tiles match llama.cpp's MMQ run without splits bit for bit, for the seven expert types.What changed, by file area
Engine (
src/poly/inkling.*,kernels_inkling.cu,include/strata/poly/inkling_kernels.hpp)attn_mma_kernel, FP16 MMA, Turing or newer) for prompt calls of more than 16 tokens. The bias stays in float.attn_fa2_kernel, A100 and A800): full layers past position 2,048. Same steps in the same order asattn_mma_kernel, so the same bits. Measured on an A100-PCIE-40GB only, not on the A30 or A800. Other cards keepattn_mma_kernel.STRATA_KV_INT8=1(opt-in, as Kolibri's): a written token's full-layer attention over 32K or more, with__dp4a. Needs a q8_0 cache. The bits differ.native_mmvq.cu's fast-math operations as PTX so their bits match; on HIP they are plain IEEE operations.STRATA_INKLING_MIX_SPREAD=0turns it off. On HIP it stays one block.--window N, the drafter) is one graph too.--no-graphsturns it off; the bits are the same either way.--batch, pictures,--dump-layers, and the drafter's own launches.--layer-split,"auto"): layers 6-17 stay on one card, so a card starts at layer 1-6 or 18-22. A card hands the next one 64.5 KB a token through pinned memory.DSpark drafter (opt-in)
dspark-Inkling-2-Mini-Q8_0.gguf(0.4 GB, pinned by SHA-256), run as llama.cpp's PR 32218 runs it.--batch,--layer-splitor several cards.poly_dspark_paritycompares its guesses with a record of llama.cpp's run;--reloadchecks save and restore.MMQ expert tiles (opt-in,
STRATA_POLY_EXPERT_TILES=1)Mmq::mul_tiles()runs llama.cpp's MMQ tiles from a table. One launch takes all of a layer's cached experts, each in tiles of its own width (16 to 128).Expert cap (test only,
STRATA_GPU_EXPERTS=N)cache set N experts fnv <hash>. Two builds can then be compared byte for byte with experts on the card.Shared engine (
engine.*,cpu_experts.*,mmq.*). Each change is gated, so other families keep their path.Layer::alias,home_of).load_moetakes expert scales of any type when asked (only Inkling asks).Engine::lowbit_experts_(only Inkling).native_mmvq_jobs(),native_mmvq_jobs_mixed(), the slots launch a warp a row, the norm rows with a Q8_1 copy,layer_graphs(),card_sum_in_tail(),act_rows_q8_1(),windows_on_card(), the drafter hooks,Mmq::mul_tiles(),Mmq::Allow.strata_poly_cpustatic library, linked by every engine and test target.native_mmvq_supported(additive), and theSTRATA_GPU_EXPERTStest knob.HIP (AMD)
Engine::openno longer refuses the model on HIP.Engine::nvfp4_int8_). Other families' HIP runs keep their path unlessSTRATA_PREFILL_NVFP4=w4a8.attn_kernel(built for CUDA too, with the same arithmetic in the same order), and an opt-in RDNA4 WMMA attention (STRATA_INKLING_WMMA=1, gfx12 only).Metal: Inkling is not ported. Opening the model says so (
metal/src/poly/unported.cpp). SYCL compiles nosrc/polycode.Server (
serve/frontend.py,serve/server.py,tools/strata_tokenizer.py)InklingParser, forcedtool_choice, andignore_mergesforinkling2.strata_prefixmatches withreasoning_effortand thinking off.<|end_message|>is parsed.test_responses.NoLeakedSampler(test only, its own commit) checks only its own server's sampler thread.Pictures (opt-in): llama.cpp 29b52d398b's mtmd encoder, built into
engine-poly/vision-inkling/. The sharedstrata-visionis unchanged. Picture rows skiptoken_embd_norm, as in llama.cpp.build_vision_ownin setup.py copies the shared encoder build's steps rather than sharing a helper, to keep the other families' path as it is.Batch slots (
--batch/"parallel"): the generic slot machinery, with five_seqskernels.Guesses from the conversation (
--window 4): after a repeat of the last 3+ tokens, up to three guesses. A partly kept window rolls back.Setup and docs
--family inklingwith three pinned files, and--dspark yes|no. Several cards and"parallel"as for the other families. Setup still marks the familycuda_only.docs/models/inkling.md(English only), and rows in GLM.md (STRATA_GPU_EXPERTS), NVFP4.md (HIP), MULTI_GPU.md, README, AI_SETUP, BACKENDS and Q8_KV.md.Tools and tests:
poly_logits_dump,poly_dspark_parity,poly_inkling_kernels_test,poly_cpu_lowbit_test,poly_lowbit_gpu_test,poly_mmq_tiles_test,tools/window_agree.py.AMD (HIP): WSL2 caveats
Seen on the RX 9070 XT box (WSL2 Ubuntu 24.04, ROCm 7.2.4, librocdxg 1.2.2). The commits are in "Commits named in this text".
HSA_ENABLE_DXG_DETECTION=1.hipMemSetAccesson a VMM piece mapped after a larger one in the same reservation. Without the fix the cache lost its last piece (3,058 of 3,072 experts) and a full-length KV cache failed to grow.--vram-poolat 774 experts.STRATA_GPU_EXPERTSfor byte comparisons.rocprofv3does not work under WSL2 (rocprof v1 does).--n-cpu-moecrashed in librocdxg after the first one. Not resolved.Known issues and follow-ups
Known issues
Follow-ups, not in this PR
Engine::card_moe()andEngine::load_state()copy from pageable memory with a plaincudaMemcpyon the legacy stream, which the engine's non-blocking streams do not wait for. This needs a separate fix.STRATA_PREFILL_NVFP4=w4a4x2), poly: NVFP4 prompt products with two-term FP4 activations on RTX 50 (STRATA_PREFILL_NVFP4=w4a4x2), Inkling 2 Mini #202.llama.cpp problems found while checking
inkling2_loopcopies the core layers into slots 24-47 before it attaches the*_exps.scaletensors. So passes 2 and 3 run without the scales on Unsloth's files.inkling2file as it is. The UD-Q2_K_XL reference was made from a copy converted toinkling2_loop. Loading was fixed upstream (#32704).Commits named in this text
fc96949a9ffc2bplus faster F32 prompt products, the shared expert launched plainly, one CPU thread a core for Inkling, docs.a9ffc2b3cb428dd4eba79c69df6ad4eba79changes HIP only; equal preprocessed CUDA source).aabcf2dd4eba79minus five commits: the A100 kernel and its gate, the test-only alignment fix, and two HIP-only changes. None of them runs on the RTX 2070 Super's default path.6e61054e6c285e1d91dab16f3585attn_kernel, and the opt-in RDNA4 WMMA attention. It does not build on CUDA until07e6249. Its test-only TQ 2 alignment fault lasts untildbd4227.07e6249__trap()instead of__builtin_trap()).63ec88f,a92763c032794de61c27c,e85c7aahip_compatnames.cee948edbd4227attn_kernel(a test-only shape; CUDA too).1dcd568e0b37b9,f5a29160720b38,3b2189e,a6511c21b6dca2,576681ccde2d1b,ec63e7fSTRATA_GPU_EXPERTS).f5e5a7e802b20dc5f26c67df039924243777f3f4574d7ca06,c808b53,99e993f,249b2de,791be9e,68d4c86🤖 Generated with Claude Code
https://claude.ai/code/session_01Erqa3PhC87SPTfVSKZ3Ri5