Skip to content

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

Open
danielhanchen wants to merge 53 commits into
base/upstream-239242322from
inkling1-b12533
Open

danielhanchen wants to merge 53 commits into
base/upstream-239242322from
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.

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).
std::max drops NaN, so an output full of NaN reported max_abs 0 and passed.
Count a non-finite value as an infinite error.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 7cbffd2643

ℹ️ 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".

… compiled out

With GGML_CUDA_FA=OFF ggml_cuda_get_best_fattn_kernel() always returns
BEST_FATTN_KERNEL_NONE, so delegating aborted. Return false from the MMA
helper so the standalone banded kernel runs instead.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 68df508279

ℹ️ 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".

Upstream b12635 added an op and moved the RPC check 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 GGML_RPC=ON builds stop at the static_assert. Bump the check to 102 and
the patch version to 3.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

danielhanchen added a commit that referenced this pull request Nov 23, 2026
pr-set : repin #378 so GGML_RPC=ON builds count the banded attention op

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2c38e50c15

ℹ️ 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".

Comment thread ggml/include/ggml.h
GGML_OP_FILL,

GGML_OP_FLASH_ATTN_EXT,
GGML_OP_FLASH_ATTN_EXT_BANDED,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve existing operation numbers used by RPC

When this build connects to an existing RPC server, inserting the new operation here changes the wire IDs of every subsequent operation. For example, SSM_CONV changes from 73 to 74, which the previous server interprets as SSM_SCAN. RPC serializes tensor->op directly, and negotiate_hello() ignores the patch version, so the patch-version bump does not reject these incompatible peers. This can execute the wrong kernels or abort inference, including for models unrelated to Inkling. Append the new operation without renumbering existing ones, or change protocol negotiation to reject incompatible builds.

Useful? React with 👍 / 👎.

@danielhanchen
danielhanchen changed the base branch from base/upstream-ad50351f5 to base/upstream-239242322 November 24, 2026 09:08
@danielhanchen

Copy link
Copy Markdown
Member Author

Repinned to 6e32059ba, a fast-forward of 2c38e50c1 (no force push): Fix merge conflicts with b12670.

Upstream ggml-org#32740 (b12670, compact bias on FLASH_ATTN_EXT) uses src[6] and src[7] of FLASH_ATTN_EXT for the bias table and indices. src[6] is also where FLASH_ATTN_EXT_BANDED keeps rel_logits. The text merge is clean, but the shared CPU flash attention code read src[6] for both ops. The fix keeps upstream as is and picks the tensors by op type: rel only for the banded op, the bias table and indices only for FLASH_ATTN_EXT. The PR base moves to base/upstream-239242322, so the diff stays this PR's own change.

Numeric gate (Inkling-Small UD-IQ1_S, wikitext-2, -c 512 --chunks 20, B200):

arm PPL mean KLD vs A top-1
A 2c38e50c1 (old head) 39.3627 - -
A again 39.362699 0.000000 100%
B 6e32059ba (new head) 39.362699 0.000000 100%
C 6e32059ba + ggml-org master 39.362699 0.000000 100%

The pin set with this commit merges, passes the contract and merge checks on b12670 and b12671, and passes verify --cuda on b12670 and b12671 (CPU gate, CUDA build, test-chat, MUL_MAT/MUL_MAT_ID/PAD/GET_ROWS, all 31 features on GPU, including inkling 71/71 and inkling2-banded-attn 54/54).

ggml_prec_set_acc() stores the accumulator precision of GGML_OP_FLASH_ATTN_EXT_BANDED in op param 3 and
ggml_flash_attn_ext_get_prec() reads it, but the generic getter returned GGML_PREC_UNDEFINED for the banded op.
test-flash-attn-bias checks the round trip.
…h with the main label

Both were plain add_test() entries without a label, so ctest -L main skipped them.
…_bias

The banded op reuses the FA MMA kernel and tagged it with max_bias < 0, but ggml_flash_attn_ext() accepts a
negative max_bias (no ALiBi), so an ordinary call with max_bias < 0 read the sinks as a relative-bias table.
m0 of an ordinary call is a power of 2 and never negative. Add FLASH_ATTN_EXT cases with max_bias = -2.
A row without a visible cell has a zero rowsum, the MMA kernel and the stream-k fixups divided 0 by 0. The
CPU and the other banded CUDA kernels return 0. Let the banded test mask a whole query (mask_kind 4).
… early return

A pure NVFP4 checkpoint returned from dequant_model() before the check, keeping the packed experts.
…probe every cache type

The reserve context reports the full span as contiguous, so the reserved graph of a unified multi-sequence context
was banded while such ubatches run dense. Take the banded op for one-sequence ubatches only, as inkling2 does,
and ask the layer's device for F32 / F16 / BF16 caches too, not only for quantized ones.
The FA kernels read F16 K/V in place with 16-byte loads, so a K/V view whose rows are padded off that boundary
(a 129-wide backing tensor) was mis-addressed. Keep such ops on the banded kernels, which read any row stride.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: e1b2a332f4

ℹ️ 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".

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