Skip to content

model : Inkling 1 (ggml-org#25731) on b12533 for the prebuilt - #378

Open
danielhanchen wants to merge 65 commits into
base/upstream-0df40737cfrom
inkling1-b12533
Open

danielhanchen wants to merge 65 commits into
base/upstream-0df40737cfrom
inkling1-b12533

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Inkling 1 (TML Inkling, unsloth/Inkling-Small-GGUF) for the unslothai prebuilt, as its own unslothai pin.

The prebuilt is an aged upstream b#### tag plus the pins in scripts/unsloth/pr-set.json. Inkling 1 is ggml-org#25731. Until now it reached the prebuilt inside ggml-org#32187 (our Inkling 2, stacked on Inkling 1). Upstream now ships Inkling 2 itself (ggml-org#32217) and a unified Inkling 1 + 2 chat parser (ggml-org#32381), so ggml-org#32187 no longer merges and is dropped from the set. This PR keeps Inkling 1 in the build: it is the head of ggml-org#25731 (eeac951) merged with upstream b12533, and nothing else. Drop it once ggml-org#25731 is updated or lands upstream.

Base: base/upstream-d4f5c2604 (tag b12533), so the diff is the Inkling 1 change only.

Merge with b12533

git merge --no-ff b12533, upstream kept verbatim, only Inkling 1's own lines re-applied:

file upstream change resolution
common/parsers/inkling.cpp, parsers.h, common/chat.cpp, common/chat-peg-parser.* ggml-org#32381 ships a unified Inkling 1 + 2 parser and detection take upstream, drop our parser, detection block and the parser option only it used. The Inkling-Small-GGUF template is byte-identical to models/templates/Inkling.jinja and upstream's is_inkling_template detects it
tests/test-chat.cpp same Inkling 1 block rewritten for upstream's parser: content, thinking + content, thinking + tool call, parallel tool calls, on the shipped template
ggml/src/ggml-cuda/fattn-mma-f16.cuh ggml-org#32407 rotates the K/V read order (kb0_next, kb0_max, new nstages > 1 loop) upstream calls kept, the banded rel-logit arguments added at every call site. The rel-logit positions come from k_VKQ_0 = kb0 * nbatch_fa, the real block index, so the rotated order stays correct
ggml/src/ggml-cuda/mmq.cuh ggml-org#32374 makes the dst offsets 64-bit take upstream, keep only the two (int64_t) ids_dst[j]*stride casts in the MoE write-back that upstream lacks
src/llama-vocab.h LLAMA_VOCAB_PRE_TYPE_ZONOS3 = 67 keep upstream, INKLING moves to 68 (the GGUF stores the pre-tokenizer as the string inkling)
gguf-py/gguf/tensor_mapping.py model.embed_norm mapped for inkling2 keep upstream's entry; both arch blocks kept
conversion/*, src/llama-arch.cpp, src/llama-hparams.cpp, src/llama-kv-cache.cpp, src/llama-vocab.cpp add/add with Inkling 2 and other new models keep both

b12533 rather than b12532 because b12533 (ggml-org#32374) is the oldest tag that leaves the branch conflict-free against ggml-org master.

Evidence

  • CPU: test-llama-archs -a inkling and -a inkling2 pass, test-chat passes from the tree root, test-backend-ops -o FLASH_ATTN_EXT -b CPU passes.
  • git merge-tree against b12532, b12542 and ggml-org master: no conflicts.
  • Numeric gate (unsloth/Inkling-Small-GGUF UD-IQ1_S, wikitext-2 -c 512 --chunks 20, B200), arm A = eeac951, the KLD base:
run PPL mean KLD top-1
A vs A 39.362699 0.000000 100.000%
this branch vs A 39.362699 0.000000 100.000%
this branch + ggml-org master vs A 39.362699 0.000000 100.000%

Known next conflict

ggml-org#27258 (on master, in no tag yet) adds GGML_OP_SLEEP and bumps static_assert(GGML_OP_COUNT == 100) in ggml/src/ggml.c. This branch also bumps it to 100 for FLASH_ATTN_EXT_BANDED, so the text merges cleanly but does not compile: the real count is 101. When a tag with ggml-org#27258 ages in, merge it here and set both asserts to 101. The gate's master arm was built with exactly that change.

HIP warp mask (b12414+)

Upstream ggml-org#31617 enabled HIP's native warp sync builtins, which need a 64-bit lane mask. The banded FA kernel's __shfl_sync(0xffffffff, score, 0, WARP_SIZE) broke every ROCm leg of the prebuilt (fattn-banded.cu:125). It now uses ggml_cuda_shfl(score, 0, WARP_SIZE), the upstream helper. The CUDA SASS of fattn-banded.cu.o (sm_100, CUDA 12.8) is identical before and after, and ggml-hip builds for gfx90a and gfx1151. ggml-org#25731 carries the same line.

Quantized K cache, shared mask, cell offset (1ac4b1c)

  • 02b68e647: a quantized K cache (-ctk q8_0 -ctv f16) now takes the banded op wherever the layer's device supports it, checked once per device. A quantized V cache is still refused. F16/BF16 caches skip the check, so their path is unchanged. Inkling-Small UD-IQ1_S at 32K: peak 80430 -> 72984 MiB (F16 is 73222).
  • 1da4c9373: one banded mask per graph, shared by every banded layer, instead of a per-layer view the scheduler copied each time.
  • 1ac4b1c91: banded attention for a sequence stored at a cell offset, so slots that stay resident in a unified cache no longer fall back to dense.
  • Numeric gate (Inkling-Small UD-IQ1_S, old head vs new): PPL 39.362699 identical, KLD 0, top-1 100%.
  • Note: a quantized K cache is lossy on Inkling 1 whichever path runs (q8_0 K mean KLD about 0.19 vs F16), so it is not a recommended setting.

RPC op count (2c38e50)

Upstream b12635 added an op and set ggml-rpc.h to GGML_OP_COUNT == 101 with RPC_PROTO_PATCH_VERSION 2. This branch adds GGML_OP_FLASH_ATTN_EXT_BANDED on top, so the count is 102 and every GGML_RPC=ON build stopped at the static_assert (the 11-23 nightly failed on CPU linux/arm64, CPU windows x64/arm64 and Vulkan windows). The check is now 102 and the patch version 3. CPU builds with GGML_RPC=ON of the full pin set on b12648 and b12651 complete.

FA bias API cleanup and short-row soft_max (9dd84c2)

  • 13b53cf48 (Fix merge conflicts): merges upstream aa631e031e (ggml-org#33178, b12859), which renames the flash attention bias API to set_bias / set_sinks, derives the bias state from src[6] / src[7] and drops kq_b from build_attn_mha(). Upstream's side is kept verbatim; the branch's check that src[6] belongs to GGML_OP_FLASH_ATTN_EXT (it is the banded op's rel_logits) is kept on the renamed bias / bias_idxs.
  • eacd17dfc: upstream now casts a dense KQ bias to the mask type, which is F16 when flash attention is on. Inkling sends multi-sequence ubatches down that path, and the F16 bias moved Inkling-Small UD-IQ1_S by KLD 0.196. For LLM_ARCH_INKLING the mask is cast to F32 instead, so the bias stays F32 as before.
  • 874f2ae07, 9dd84c2ea: upstream moved soft_max rows of at most 8 columns to a one-thread-per-row kernel (CUDA ggml-org#33187 in b12878, also built for ROCm and MUSA; Vulkan ggml-org#33197 in b12916). It rounds differently from the block kernel by about an ulp, and the Inkling 1 router (6 routed + 2 shared experts, 8 wide) turns that into KLD 0.17 on Inkling-Small UD-IQ1_S. On those backends the router row gets a -inf column (width 9, block kernel) and the 8 real columns are taken back; exp(-inf) adds an exact 0, so the result has the same bits as before. CPU, Metal and other models are unchanged.
  • Numeric gate, Inkling-Small UD-IQ1_S against the shipped b12858-mix tree, on the full pin set at b12921 and b12927: PPL 39.362699 identical, KLD 0, top-1 100%, also at -b 512 -ub 3.

danielhanchen and others added 30 commits July 18, 2026 08:09
Hybrid attention model: 55 sliding-window plus 11 global layers, banded
content-dependent relative position bias instead of RoPE, per-layer short
convolution state, fine-grained MoE (256 experts top-6 plus 2 shared),
attention log-scaling past 128K, 1M context.

Includes the GGML_OP_FLASH_ATTN_EXT_BANDED operator (CPU and CUDA, fused
into the MMA flash attention kernel with an fp16 accumulator overflow
guard), HF to GGUF conversion, chat template with typed content block
parsing (interleaved thinking, narration and tool calls), mmproj vision
and audio support, and backend op tests at production shapes.
# Conflicts:
#	ggml/src/ggml-cuda/mmq.cuh
#	src/llama-model-saver.cpp
#	src/llama-vocab.h
Upstream 910196f renamed common_chat_params::thinking_end_tag to
thinking_end_tags and changed it from std::string to a vector, so
data.thinking_end_tag = END_MESSAGE no longer compiles.
# Conflicts:
#	src/llama-arch.cpp
# Conflicts:
#	ggml/include/ggml-rpc.h
#	ggml/src/ggml-backend-meta.cpp
#	ggml/src/ggml-cuda/ggml-cuda.cu
#	src/llama-model-saver.cpp
#	tests/test-llama-archs.cpp
# Conflicts:
#	ggml/src/ggml-rpc/ggml-rpc.cpp
Resolves the two conflicts left by upstream ggml-org#27764 (chat parsers split into
common/parsers) and ggml-org#26675 (ggml_prec rework):

- common_chat_params_init_inkling moves to common/parsers/inkling.cpp,
  registered in parsers.h and sources.cmake; chat.cpp keeps only the
  template detection branch.
- GGML_PREC_F32_PEDANTIC joins the new ranked ggml_prec scale at 5, below
  GGML_PREC_F32, since it is the stricter contract; ggml_flash_attn_ext_banded
  keeps its declaration next to the flash attention API.
…C_F32_PEDANTIC

Every caller of the deprecated ggml_mul_mat_set_prec /
ggml_flash_attn_ext_set_prec now uses ggml_prec_set_acc (the macOS prebuilt
leg builds with LLAMA_FATAL_WARNINGS, so the deprecation would be fatal
there), and ggml_prec_set_acc accepts GGML_OP_FLASH_ATTN_EXT_BANDED.

With the enum ranked, the CUDA cuBLAS compute-type gate and the CPU, spacemit
and Vulkan flash-attention accumulator checks compare by rank instead of
equality with GGML_PREC_F32, so a pedantic request never falls through to a
lower-precision path. The CUDA mul_mat_id slice carries the acc and src
precision slots, and ggml_cuda_mul_mat_id_needs_sync applies the same
pedantic gate as ggml_cuda_mul_mat_id so a pedantic F32 expert matmul cannot
trip its assertion.
Squash of the 56 commits since 3870aa4 (merges of master up to 8ca5a80, plus):
- chat : port the Inkling parser to the refactored chat API
- convert : check stacked ModelOpt NVFP4 experts after dequant
- inkling : trim comments
…own lines

Inkling shared its n_embd_r() check, the FALCON_H1 hybrid-memory branch and the
kv-cache context declaration with the line any new hybrid architecture also
edits, so every such PR (Inkling 2 in ggml-org#32217 among them) conflicts with this one.
Move each into its own block; behaviour is unchanged (RWKV never sets
n_embd_r_impl, and the Inkling branch is the FALCON_H1 body).
danielhanchen added a commit that referenced this pull request Nov 25, 2026
…, take #414 0cbe311, add #447 and #448, drop #427 and #428 (#451)

Upstream b12696..b12719 changed the Inkling 2 code the pins touch (DSpark
drafter, clip on ggml_l2_norm, depth mix weighted sum order, MMVF int64
offsets), so the old pins no longer merge. Each pin branch merged upstream
33aeb17 (b12720) and keeps upstream's code as is:

- #378: e1b2a33 -> ba3ad42
- #405: b5ed9f2 -> b14ca2b
- #386: a8ca6da -> 7280c5e
- #431: f44881a -> 5373aec

Also:
- #414: 74a0ffc -> 0cbe311 (HIP build of the depth mix fusion)
- add #447 0bc8e1c and #448 e148684, with their feature-checks.json entries
- drop #427 and #428: the base carries both CUDA changes

Every pin moves by fast-forward. Only for a base at or past b12720.
@danielhanchen
danielhanchen changed the base branch from base/upstream-33aeb17f8 to base/upstream-171527522 November 26, 2026 11:16
KyleAnthonyShepherd added a commit to KyleAnthonyShepherd/llama.cpp that referenced this pull request Nov 27, 2026
…t of unslothai#378, ggml-org#386)

FLASH_ATTN_EXT_BANDED with per-query sinks on CPU and CUDA. A sequence stored
as cells c0 + pos is viewed in place, a ring (the SWA cache once it wraps) is
gathered in position order; the dense fallback is chunked over query rows.

Assisted-by: Claude Opus 5.5
# Conflicts:
#	ggml/src/ggml-cuda/fattn-common.cuh
#	ggml/src/ggml-cuda/fattn-mma-f16.cuh
…o its CPU and CUDA paths do not assert

ggml-org#33063 asserts that the op is FLASH_ATTN_EXT in ggml_validate_flash_attn_ext_indexed_bias, which the CPU
flash attention and the CUDA FA alloc size call. FLASH_ATTN_EXT_BANDED shares both paths and never carries an
indexed bias, so Inkling (CUDA) and CPU-only Inkling 2 aborted at the first banded attention.
@danielhanchen
danielhanchen changed the base branch from base/upstream-171527522 to base/upstream-2a335259c November 28, 2026 05:06
@danielhanchen
danielhanchen changed the base branch from base/upstream-2a335259c to base/upstream-a38695013 November 28, 2026 07:03
@danielhanchen danielhanchen reopened this Nov 28, 2026
… path

Since the FA bias cleanup (b12859) a dense KQ bias is cast to the mask type
and added to the mask, and the mask is F16 whenever flash attention is
enabled. Inkling routes multi-sequence ubatches through this path with an
F32 bias, so rounding it to F16 moved its outputs (Inkling-Small wikitext-2
-c 512: KLD 0.196, top-1 83.5%). Cast the mask to F32 instead for Inkling,
which restores the previous numbers exactly.
From ggml-org b12878 (one thread per row for soft_max on short rows) CUDA
computes rows of up to 8 on a new kernel whose rounding differs from the
block kernel by an ulp. Inkling's router softmax over 6 routed + 2 shared
experts is 8 wide, and on Inkling-Small IQ1_S that ulp grows to KLD 0.17
over the layers. Append a -inf column on CUDA layers so the row stays on the
block kernel, which then returns the same bits as before; other backends
and models are unchanged.
…OCm, MUSA and Vulkan

ggml-org b12916 (ggml-org#33197) gave Vulkan the same one-thread-per-row soft_max for
rows of up to 8 that CUDA got in b12878, and the CUDA kernel is also built for
ROCm and MUSA. Pad the router row on those backends too, so their results stay
the same as before the short-row kernels.
@danielhanchen
danielhanchen changed the base branch from base/upstream-a38695013 to base/upstream-aa631e031 December 2, 2026 15:08
danielhanchen added a commit that referenced this pull request Dec 2, 2026
#378, #385, #386 and #431 merge upstream aa631e0 (FA bias API cleanup,
b12859); #378 also keeps the Inkling router soft_max off the new short-row
kernels (CUDA b12878, Vulkan b12916). #448 merges b12922 (few-row MMQ for
NVFP4 adds a dst argument to ggml_cuda_should_use_mmq_few).

feature-checks: add inkling2-expert-scales (MUL_MAT_ID with weight scales).
… b12878

ggml-org#33187 (b12878) also gave Metal a one-thread-per-row soft_max for rows
of up to 8 columns. Before it, Metal ran the 8-wide router row on its float4
kernel, which it only picks when the width is a multiple of 4, so a single
-inf column would move it to the scalar kernel and still change the sum
order. Pad to 12 on Metal (9 when the width is not a multiple of 4); the
other backends keep the single -inf column and an unchanged graph.
danielhanchen added a commit that referenced this pull request Dec 2, 2026
oobabooga pushed a commit to oobabooga/llama.cpp that referenced this pull request Dec 3, 2026
Inkling 2 (ggml-org#32217) and the Inkling 1 + 2 chat parser (ggml-org#32381) are upstream, so ggml-org#32187 (our Inkling 2 stacked on Inkling 1) no longer merges. Pin Inkling 1 as unslothai#378 (ggml-org#25731 merged with b12533) and the Inkling 2 per-expert scale patch as unslothai#377. Repin unslothai#61, ggml-org#304, ggml-org#332, ggml-org#320 (merged with b12532) and ggml-org#251 (merged with b12361). Drop unslothai#270 until its merge with ggml-org#31323 is fixed.
oobabooga pushed a commit to oobabooga/llama.cpp that referenced this pull request Dec 3, 2026
…aph dedupe and three CUDA speed pins (ggml-org#399)

* pr-set : repin unslothai#378 and ggml-org#386 for quantized K/V banded attention and a shared banded mask

* pr-set : add the Inkling 2 speed pins (unslothai#400, ggml-org#401, ggml-org#402) and the graph dedupe fold on ggml-org#386

* pr-set : repin ggml-org#32218 to its squashed head 0a9105d

The PR was force-pushed onto upstream e50c254 and the pinned commit
8ea4363 is no longer in it, so the nightly refused the pin.

* pr-set : repin for ggml-org#32669 (b12622) and retire ggml-org#32704

ggml-org#32669 applies the .scale tensors in build_lora_mm and
build_lora_mm_id and removes the build_moe_ffn scale arguments.

- unslothai#378, ggml-org#386: merge b12622, keep the explicit precision after
  prec_policy.apply in build_lora_mm (llama-graph.cpp conflict).
- ggml-org#24423: merge b12622, drop the scale arguments from the
  DiffusionGemma build_moe_ffn call as upstream did for gemma4.
- unslothai#396: merge b12622, give the per-visit host weight views their
  weight scales (inkling2_loop with --cpu-moe lost them: KLD 2.96).
- ggml-org#32704: upstream squash 690b87d is in b12611; drop the pin
  and its feature-checks.json entry.

* pr-set : pin Inkling 2 DSpark through unslothai#405 (ggml-org#32218 at 0a9105d)
@danielhanchen
danielhanchen changed the base branch from base/upstream-aa631e031 to base/upstream-0df40737c December 3, 2026 20:33
danielhanchen added a commit that referenced this pull request Dec 3, 2026
fix #396, pin #469 #470 (#473)

* pr-set : pin #464, default a missing NVFP4 / FP8 weight scale to 1.0

* pr-set : repin #378 #385 #386 #431 #448 for upstream b12859..b12927

#378, #385, #386 and #431 merge upstream aa631e0 (FA bias API cleanup,
b12859); #378 also keeps the Inkling router soft_max off the new short-row
kernels (CUDA b12878, Vulkan b12916). #448 merges b12922 (few-row MMQ for
NVFP4 adds a dst argument to ggml_cuda_should_use_mmq_few).

feature-checks: add inkling2-expert-scales (MUL_MAT_ID with weight scales).

* pr-set : repin #378 to keep the Inkling router soft_max on the pre-b12878 Metal kernel

* pr-set : repin #378 #386 #431 for b12939 (rpc SUPPORTS_OP, BF16 supports_op), comment-only repins of #241 #243

* pr-set : drop #462, upstream took the same short conv fusion in b12942

* pr-set : pin #469 (greedy argmax of the logits row)

* pr-set : repin #418 for the upstream flat CONCAT kernel in b12957

* pr-set : pin #470 (CPU multi-row MUL_MAT_ID for few-row experts)

* pr-set : repin #396 (the model saver writes a shared host weight once)

* feature-checks : keep cuda-short-conv-in-place with owner null, upstream b12942 carries it

* pr-set : pin upstream's Qwen4 model support until the aged base carries it (b12969)

This branch has not been deployed

No deployments
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.

2 participants