Skip to content

[Engine] Inkling 2: read Unsloth's top-level inkling2 GGUF files - #225

Open
okada-shogo wants to merge 3 commits into
simplexai-labs:mainfrom
okada-shogo:port/arch-inkling2
Open

okada-shogo wants to merge 3 commits into
simplexai-labs:mainfrom
okada-shogo:port/arch-inkling2

Conversation

@okada-shogo

@okada-shogo okada-shogo commented Nov 22, 2026 •

Copy link
Copy Markdown

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 the inkling2_loop files, under other names, and
Engine::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_loop rewrite (UD-Q2_K_XL and UD-IQ3_XXS, experts on the card
and 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_loop inkling2 (Unsloth top level) Engine change
block_count 24 (layers of weights) 48 (applications: 6 + 3 x 12 + 6) n_layer_ = 48 - 2 x 12
loop keys loop.start, loop.end, loop.count loop.core_start, loop.core_end, num_loops meta_alias()
per-layer arrays 24 entries 48 (one per application) each layer's first application used, every other application checked to match it
controllers loop_{q,k,v,ffn}_ctrl_{down,gain,forget} loop_{attn,k,v,mlp}_{down,gain,forget} tensor_alias()
message queries blk.N.loop_msg_query [2304, 4] global loop_res_query, loop_kv_res_query [2304, 24] rows copied into the dense arena
  • inkling2_loop files take the same code path as before; the aliases only apply when the architecture is inkling2.
  • Main refused these files because there was "no public description of it to follow" (a274a3c). The mapping comes
    from comparing bytes with ggml-org's inkling2_loop file: every controller tensor matches byte for byte; core layer
    6 + i takes q = loop_res_query row 2i, k / v = loop_kv_res_query rows 2i / 2i+1, ffn = loop_res_query row 2i+1.
  • Setup takes an inkling2 file through --gguf-dir; serve lists it as runnable; the docs line is updated.

Validation

Passed:

  • CUDA 12.9 build, sm_75: strata-poly builds 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.

  • 42af77e (data/gguf_fingerprints.json remade with tools/strata_inspect.py --poly-rows): tests/terminal/test_own_files*.py 34 OK (test_the_table_has_what_setup_installs failed before it), all terminal/tools/test_setup*.py 1357 OK (1 skipped), 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_query and loop_kv_res_query F32 [2304, 24] (the shapes msg_query() checks), sliding_window_pattern 48 entries of period 6. With that period the second commit reads the same values as the first.

  • Identity, the top-level file (inkling2) against its inkling2_loop rewrite (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 same
    number of experts in VRAM (main has no expert-count cap):

    • UD-Q2_K_XL, RTX 2080 Ti 11 GB (sm_75), 2,931 of 3,072 experts in VRAM: both pairs identical (ids and all 64 top
      lines), and identical with every expert on the CPU.
    • UD-IQ3_XXS, RTX 2070 Super 8 GB (sm_75): pair 1 (1,188 experts in VRAM each) 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).
    • The head's second commit (794e6e1, window layers from each layer's first application) reads the same values for
      these files (sliding_window_pattern period 6, checked above); these runs used the first commit's build.

Failed: none observed.

Not run:

  • The identity runs at the head's build (see the note above on 794e6e1).
  • Metal build (inkling2.cpp and engine.cpp have no Metal-only code in the change).

Limits

  • The name mapping is our own reading of the files (no public spec). Rows 2i and 2i+1 of loop_res_query as Q and FFN come from a byte comparison; the identity runs above check it end to end.
  • terminal/serve/models.py shows 48 layers for these files, not 24 (display only).
  • Only the Unsloth top-level layout seen so far is handled.

Credits: VecSzn's Inkling 2 engine, which this extends; Unsloth for the GGUF files.

🤖 Generated with Claude Code

okada-shogo and others added 2 commits November 23, 2026 05:42
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
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>
The table's strata-poly rows are made from setup.py's POLY_GGUF_ARCHS
(tools/strata_inspect.py --poly-rows), which now takes inkling2 too;
tests/terminal/test_own_files_poly.py compares the two.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
okada-shogo added a commit to okada-shogo/PolyStrata that referenced this pull request Nov 23, 2026
strata_inspect's POLY_ARCHS had no inkling2_loop, so its verdict for every
Inkling 2 Mini file was "not Qwen3.8-Flash-Next" and resolve_custom_gguf
refused it. With the architecture mapped, a quant setup does not offer
would still have been taken for the first offered size (UD-Q2_K_XL).

- POLY_ARCHS maps inkling2_loop to "Inkling 2 Mini".
- FAMILIES["inkling"] has "custom_sizes": a file of another quant
  (IQ4_NL, Q4_K_M, ...) becomes a size of its own, its experts' bytes
  and file size read from the header (custom_size()).
- Unsloth's top-level files (architecture inkling2) are refused with a
  message that names the layout and says to use the Mainline_Support
  file, or an engine that reads it (simplexai-labs#225).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant