Repository navigation
[Engine] Inkling 2: read Unsloth's top-level inkling2 GGUF files - #225
Open
okada-shogo wants to merge 2 commits into
Open
okada-shogo wants to merge 2 commits into
okada-shogo wants to merge 2 commits into
Conversation
Unsloth's files at the top of unsloth/Inkling-2-Mini-GGUF (UD-Q2_K_XL,
UD-IQ3_XXS, ...) say general.architecture inkling2. They are the same
weights as the Mainline_Support inkling2_loop files under other names:
block_count counts the 48 applications, the loop's keys are num_loops /
loop.core_start / loop.core_end, the controllers are loop_{attn,k,v,mlp}_*
(attn = q, mlp = ffn), and the message queries are two global tensors,
loop_res_query and loop_kv_res_query (core layer 6+i: q = res[2i],
k = kv[2i], v = kv[2i+1], ffn = res[2i+1]). Open() refused them.
Inkling2 now takes them: n_layer_ is block_count less the core's later
passes, meta_alias()/tensor_alias() give the other names (only for an
inkling2 file), each application's sliding_window_pattern entry is
checked against its layer, and msg_query() puts the four rows of a core
layer in the dense arena. inkling2_loop files run the same code as
before. Setup's --gguf-dir and serve's registry take the architecture.
The mapping is the one our first engine (simplexai-labs#200) used, by bytes against
ggml-org's inkling2_loop file. Engine by VecSzn; files by Unsloth.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An Unsloth file's attention.sliding_window_pattern lists the 48 applications, not the 24 layers, but swa_[il] read entry il: for layers 18 to 23 that is an application of the loop's layers 6 to 11. It was right only because the pattern's period (6) divides the loop's length (12); with another pattern the check below would refuse a valid file. Read visit_of(il, 0) instead. The same values for the published files (period 6), so the same bits. Found by an independent review of the PR. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
okada-shogo
marked this pull request as ready for review
November 23, 2026 01:47
okada-shogo
added a commit
to okada-shogo/PolyStrata
that referenced
this pull request
Nov 23, 2026
…l inkling2 GGUF files Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem and result
The files at the top of unsloth/Inkling-2-Mini-GGUF (for example UD-IQ3_XXS and UD-Q2_K_XL) have
general.architecture=inkling2. They hold the same weights as theinkling2_loopfiles, under other names, andEngine::open()refuses them. With this change the Inkling 2 engine reads them as they are, with no conversion.A top-level file gives the same bits as its
inkling2_looprewrite (UD-Q2_K_XL and UD-IQ3_XXS, experts on the cardand every expert on the CPU).
Related discussion
Split out of #200, as the maintainer asked there:
#200 (comment)
Independent of the other split PRs (based on main, not stacked).
Approach
inkling2_loopinkling2(Unsloth top level)block_countn_layer_= 48 - 2 x 12loop.start,loop.end,loop.countloop.core_start,loop.core_end,num_loopsmeta_alias()loop_{q,k,v,ffn}_ctrl_{down,gain,forget}loop_{attn,k,v,mlp}_{down,gain,forget}tensor_alias()blk.N.loop_msg_query[2304, 4]loop_res_query,loop_kv_res_query[2304, 24]inkling2_loopfiles take the same code path as before; the aliases only apply when the architecture isinkling2.from comparing bytes with ggml-org's
inkling2_loopfile: every controller tensor matches byte for byte; core layer6 + i takes q =
loop_res_queryrow 2i, k / v =loop_kv_res_queryrows 2i / 2i+1, ffn =loop_res_queryrow 2i+1.inkling2file through--gguf-dir; serve lists it as runnable; the docs line is updated.Validation
Passed:
CUDA 12.9 build, sm_75:
strata-polybuilds at the head.python3 terminal/tools/test_setup_inkling.py: 5 tests OK;python3 -m unittest discover -s terminal/serve -p "test_model*.py": 58 tests OK;python3 tools/check --only docs: 6 of 6.The real file (
Inkling-2-Mini-UD-IQ3_XXS.gguf, metadata read on the CPU): arch inkling2, block_count 48, num_loops 3, loop core 6 to 18,loop_res_queryandloop_kv_res_queryF32 [2304, 24] (the shapesmsg_query()checks),sliding_window_pattern48 entries of period 6. With that period the second commit reads the same values as the first.Identity, the top-level file (
inkling2) against itsinkling2_looprewrite (a byte copy with the renames),one binary (a CUDA 12.9 sm_75 build of 25aecc2), split frozen (
STRATA_FREEZE_EXPERTS=1 --kv-whole --cpu-share 0 --expert-swaps 0), 302-token prompt, 64 greedy tokens,--top-probs 20, fp16 cache, 32K,order top / loop / top / loop, then both with
--no-gpu-experts. A pair is compared where both runs logged the samenumber of experts in VRAM (main has no expert-count cap):
lines), and identical with every expert on the CPU.
identical. In pair 2 the loop file's run loaded 1,195 experts instead of 1,188, so that pair is not comparable (its
output differs, as the cache differs).
these files (
sliding_window_patternperiod 6, checked above); these runs used the first commit's build.Failed: none observed.
Not run:
Limits
loop_res_queryas Q and FFN come from a byte comparison; the identity runs above check it end to end.terminal/serve/models.pyshows 48 layers for these files, not 24 (display only).Credits: VecSzn's Inkling 2 engine, which this extends; Unsloth for the GGUF files.
🤖 Generated with Claude Code