Repository navigation
model : Inkling 1 (ggml-org#25731) on b12533 for the prebuilt - #378
danielhanchen wants to merge 53 commits into
Conversation
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: # src/llama-model.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.
…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.
|
@codex review |
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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.
|
@codex review |
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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.
|
@codex review |
pr-set : repin #378 so GGML_RPC=ON builds count the banded attention op
There was a problem hiding this comment.
💡 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".
| GGML_OP_FILL, | ||
|
|
||
| GGML_OP_FLASH_ATTN_EXT, | ||
| GGML_OP_FLASH_ATTN_EXT_BANDED, |
There was a problem hiding this comment.
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 👍 / 👎.
|
Repinned to Upstream ggml-org#32740 (b12670, compact bias on FLASH_ATTN_EXT) uses Numeric gate (Inkling-Small UD-IQ1_S, wikitext-2,
The pin set with this commit merges, passes the contract and merge checks on b12670 and b12671, and passes |
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.
|
@codex review |
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
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 inscripts/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:common/parsers/inkling.cpp,parsers.h,common/chat.cpp,common/chat-peg-parser.*models/templates/Inkling.jinjaand upstream'sis_inkling_templatedetects ittests/test-chat.cppggml/src/ggml-cuda/fattn-mma-f16.cuhkb0_next,kb0_max, newnstages > 1loop)k_VKQ_0 = kb0 * nbatch_fa, the real block index, so the rotated order stays correctggml/src/ggml-cuda/mmq.cuh(int64_t) ids_dst[j]*stridecasts in the MoE write-back that upstream lackssrc/llama-vocab.hLLAMA_VOCAB_PRE_TYPE_ZONOS3 = 67INKLINGmoves to 68 (the GGUF stores the pre-tokenizer as the stringinkling)gguf-py/gguf/tensor_mapping.pymodel.embed_normmapped for inkling2conversion/*,src/llama-arch.cpp,src/llama-hparams.cpp,src/llama-kv-cache.cpp,src/llama-vocab.cppb12533 rather than b12532 because b12533 (ggml-org#32374) is the oldest tag that leaves the branch conflict-free against ggml-org master.
Evidence
test-llama-archs -a inklingand-a inkling2pass,test-chatpasses from the tree root,test-backend-ops -o FLASH_ATTN_EXT -b CPUpasses.git merge-treeagainst b12532, b12542 and ggml-org master: no conflicts.unsloth/Inkling-Small-GGUFUD-IQ1_S, wikitext-2-c 512 --chunks 20, B200), arm A = eeac951, the KLD base:Known next conflict
ggml-org#27258 (on master, in no tag yet) adds
GGML_OP_SLEEPand bumpsstatic_assert(GGML_OP_COUNT == 100)inggml/src/ggml.c. This branch also bumps it to 100 forFLASH_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 usesggml_cuda_shfl(score, 0, WARP_SIZE), the upstream helper. The CUDA SASS offattn-banded.cu.o(sm_100, CUDA 12.8) is identical before and after, andggml-hipbuilds 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.RPC op count (2c38e50)
Upstream b12635 added an op and set
ggml-rpc.htoGGML_OP_COUNT == 101withRPC_PROTO_PATCH_VERSION 2. This branch addsGGML_OP_FLASH_ATTN_EXT_BANDEDon top, so the count is 102 and everyGGML_RPC=ONbuild 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 withGGML_RPC=ONof the full pin set on b12648 and b12651 complete.