Repository navigation
inkling2 : pin branch for the Inkling 2 support (unslothai#368 at 5f3eb91) - #372
danielhanchen wants to merge 75 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.
Resolves the conflicts with upstream ggml-org#29535 (K2 Horizon) and ggml-org#29442 (cuBLAS ldc and F16/BF16 src0 chunking): - Inkling and K2 Horizon both register: parser decl, parser source, model mapping case, EOG token, output tensor name. model.unembed moves a few lines up the OUTPUT tuple, away from upstream's embedding_projection, so pins that carry that line still merge. - LLAMA_VOCAB_PRE_TYPE_INKLING moves to 62, since upstream claimed 61 for K2_HORIZON. The id is internal; the GGUF carries tokenizer.ggml.pre as a string. - ggml_cuda_mul_mat_cublas_impl keeps the F32_PEDANTIC GemmEx path and passes upstream's ldc to both F32 branches; the pedantic compute-type override stays ahead of upstream's F16/BF16 src0 chunking, which it cannot overlap (pedantic only applies to F32 src0).
# Conflicts: # common/chat-peg-parser.cpp # tools/mtmd/clip.cpp
- ggml : per-token attention sinks for the banded flash attention op (CPU, CUDA) - CUDA : split-KV decode for the banded flash attention op - CUDA : tensor-core prefill for the banded flash attention op with per-row sinks - CUDA : keep the precision request on the MUL_MAT_ID per-expert fallback - inkling2 : model, GGUF constants, converter, chat template, tests - inkling2 : not supported by the tensor split mode - mtmd : add Inkling2 vision encoder
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Superseded: the pin set now pins Inkling through ggml-org#32187 (#370). |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5f3eb91cec
ℹ️ 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".
| {%- for ignored in range(source | length) -%} | ||
| {%- if not scan.done and state.pos < source | length -%} |
There was a problem hiding this comment.
Stop JSON scans once their terminating condition is reached
When rendering JSON-string tool-call arguments directly, such as through Transformers, setting scan.done does not terminate this loop: every whitespace scan still performs source | length iterations. The scalar and string scanners repeat the same pattern, making argument parsing quadratic. Rendering a single call with {"x": [0, ...]} took approximately 0.9 seconds for 200 elements and 14 seconds for 800 elements in a local Python/Jinja reproduction, despite the latter being only 2.4 KB. Larger tool-call histories can therefore stall prompt preparation before inference starts. Use terminating scans or native JSON parsing, and apply the same correction to the equivalent parser in Inkling.jinja.
Useful? React with 👍 / 👎.
| bool ggml_cuda_flash_attn_ext_banded_use_mma(const int device, const ggml_tensor * dst) { | ||
| if (dst->op != GGML_OP_FLASH_ATTN_EXT_BANDED) { |
There was a problem hiding this comment.
Honor compiled FlashAttention availability in the MMA selector
With GGML_CUDA_FA=OFF on a Turing-or-newer NVIDIA GPU, this selector can still return true for banded attention with F16/BF16 K/V, contiguous F32 relative logits, and no sinks, including Inkling's normal banded path. The banded backend advertises support and delegates execution to ggml_cuda_flash_attn_ext, but ggml_cuda_get_best_fattn_kernel unconditionally returns BEST_FATTN_KERNEL_NONE when FLASH_ATTN_AVAILABLE is undefined, causing that dispatcher to abort. Gate this selector on compiled FlashAttention availability so these builds use the standalone banded implementation or a supported fallback.
Useful? React with 👍 / 👎.
| // the MMA ABI indexes rel linearly and by Q's batch | ||
| if (rel->type != GGML_TYPE_F32 || !ggml_is_contiguous(rel) || | ||
| rel->ne[3] != Q->ne[3] || rel->ne[0] > (1 << 20)) { |
There was a problem hiding this comment.
Exclude per-head masks from the legacy banded MMA path
For banded attention without sinks on Turing-or-newer NVIDIA GPUs, this selector accepts masks with mask->ne[2] > 1, although the delegated flash_attn_ext_f16 kernel computes mask_h using only the batch offset and never applies the head stride nb32. Consequently every query head reads the first head's mask, silently producing incorrect attention when heads have different visibility or additive biases. The ordinary FlashAttention selector explicitly rejects this mask layout, but the new early MMA selection bypasses that check. Require a head-broadcast mask here and leave per-head masks to the standalone banded kernel.
Useful? React with 👍 / 👎.
| #define RPC_PROTO_MAJOR_VERSION 9 | ||
| #define RPC_PROTO_MINOR_VERSION 0 | ||
| #define RPC_PROTO_PATCH_VERSION 0 | ||
| #define RPC_PROTO_PATCH_VERSION 1 |
There was a problem hiding this comment.
Reject RPC peers with the old operation numbering
When this client connects to a pre-change RPC server advertising version 9.0.0, negotiate_hello accepts it because the handshake checks only major/minor versions, not this patch number. However, inserting GGML_OP_FLASH_ATTN_EXT_BANDED in the middle of ggml_op renumbers every subsequent operation, and RPC serializes/deserializes those numeric IDs directly. For example, the new GGML_OP_UNARY value is interpreted by the old server as GGML_OP_MAP_CUSTOM1, while the new GGML_OP_SSM_CONV becomes GGML_OP_SSM_SCAN. This can crash ordinary model inference even without using banded attention. Bump the incompatible protocol major version, or preserve the existing wire opcode values.
Useful? React with 👍 / 👎.
Pin branch for the Inkling 2 support used by the prebuilt pin set.
#368 now carries Inkling 2 directly on top of ggml-org#25731, which no longer merges onto the aged release tags the nightly builds from. This branch keeps the Inkling 2 commit the pin set has been verified with,
5f3eb91(single Inkling 2 commit on the Inkling 1 pinf5e241b), as a commit of a PR sopr-set.jsoncan point at it.5f3eb91cec4227d877686f958f588e1d72574f22); the Inkling 2 change is patch-identical to model : add Inkling 2 (inkling2 arch, banded attention sinks, vision projector) #368.