Skip to content

Studio: size and offload both Inkling 2 looped GGUF layouts - #18754

Merged
danielhanchen merged 2 commits into
mainfrom
studio-inkling2-loop-arch
Nov 21, 2026
Merged

danielhanchen merged 2 commits into
mainfrom
studio-inkling2-loop-arch

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Inkling-2-Mini GGUFs come in two layouts: the looped inkling2 files (one block per layer visit, 48 visits) and the inkling2_loop files (24 physical layers, loop core expanded to cache slots at load). The next llama.cpp prebuilt loads both through one implementation. This makes Studio size and offload both the same way.

  • Memory: KV cache and recurrent state are budgeted per cache slot (48) on both layouts, weights counted once, and inkling2_loop gets the same relative-bias compute buffer estimate as inkling2.
  • Offload: -ngl, the gpu-layers ceiling and the offload layout count physical layers (24), the unit llama.cpp uses for looped models (-ngl, -ts and --n-cpu-moe). Each cache slot's KV is placed with its physical layer.
  • The offload layout for Inkling 2 files is now complete; before, the per-layer head count list made it abstain.
  • Non-looped architectures, including inkling2 without loop keys, are unchanged.

Tests:

  • tests/test_inkling2_loop_layout.py: both layouts plus a non-looped control (slot count 48, physical count 24, -ngl cut-off, UI ceiling, offload rows and slot order, matching KV pricing between layouts, per-device fold).
  • 85 related backend test files on base and head: identical failing test IDs (all pre-existing).
  • Real file headers (UD-IQ1_S in both layouts): 48 slots, 24 physical layers, 24 MoE layers, the same KV bytes per token.

Screenshots

Run settings for Inkling-2-Mini UD-IQ1_S in both layouts, base (left) vs this PR (right). The GPU Layers maximum for the root file drops from 49 to 25, matching the 24 physical layers llama.cpp counts for -ngl. The mainline file now gets the same KV estimate as the root file, since both allocate 48 cache slots.

GPU layers and memory estimate, base vs PR

…lots

The inkling2_loop layout keeps each physical layer once and lets llama.cpp
expand the looped core to one cache slot per visit. Read loop.start, loop.end
and loop.count, expand block_count and the per-layer arrays to those slots, and
give the layout the same relative-bias compute estimate as inkling2, so both
GGUF layouts of one model get the same KV and compute estimates.
llama.cpp counts -ngl, -ts and --n-cpu-moe for looped models in physical
layers (llama_model_n_layer_weights), 24 for Inkling-2-Mini on both GGUF
layouts, while KV and recurrent state stay per cache slot (48).

- llama_cpp: read the visit-indexed loop keys (loop.core_start/core_end,
  num_loops) and keep a separate _n_weight_layers; n_layers, n_moe_layers,
  the pipeline-parallel predicate and the output-row device use it, KV
  sizing keeps the slots.
- gguf_metadata: the staged layer_count drops the repeat passes of a
  visit-indexed loop core, so the gpu-layers ceiling is 24.
- routes: runtime layer_count follows the physical layers.
- offload_layout: looped layouts list the physical layers as rows, record
  the physical row of each cache slot and price KV per slot from per-layer
  head counts; the per-device split and the tensor spill fold slot caches
  onto their rows.

Non-looped architectures, including inkling2 without loop keys, are
unchanged.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-21T15:55:55.083985Z 5310eb5 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 5310eb5835

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Nov 21, 2026
@danielhanchen
danielhanchen merged commit e169100 into main Nov 21, 2026
@danielhanchen
danielhanchen deleted the studio-inkling2-loop-arch branch November 21, 2026 17:39
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