Repository navigation
llama : Inkling 2 DSpark with both drafter layouts (ggml-org#32218 head e4b1cb531 plus the 0a9105de4 fused path) - #405
Conversation
Assisted-by: Codex
Assisted-by: Claude Opus 5.5
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. |
## Summary Studio's Auto speculative decoding launches DSpark with `--spec-draft-n-max 3` when nothing names a depth. For Inkling 2 on the current prebuilt, depth 2 is faster under both sampling defaults Studio uses, because the third draft token is rarely accepted and costs a wider verify step. This makes Inkling 2 (both GGUF layouts, `inkling2` and `inkling2_loop`) default to depth 2: - The launch (`_emit_dspark`) and the fit pricing (the draft depth used to size verify rows) share one helper, so the reserve matches what the child runs. - A depth the user sets (the settings field, extras or env) still wins. - Every other DSpark model, for example DeepSeek-V4-Flash, keeps depth 3. - MTP, DFlash and EAGLE-3 are untouched. ## Measurements Inkling-2-Mini, current DSpark pin (ggml-org#32218 at 0a9105de4 via unslothai/llama.cpp#405), `dspark-Inkling-2-Mini-Q8_0.gguf` drafter, llama-server, exclusive B200, greedy draft (server default), 4 prompts x 384 tokens, seed 1234. Each arm was run twice with the arms interleaved; the A/A spread is 3.4% or less in every arm. Studio's Inkling 2 defaults on main (`inference_defaults.json`: temperature 1.0, top_p 1.0, top_k -1, min_p 0): | target | no draft tok/s | depth 2 tok/s | depth 3 tok/s | |---|---|---|---| | UD-Q4_K_XL | 73.2, 73.6 | 84.1, 85.3 (1.15x) | 79.0, 80.3 (1.09x) | | UD-IQ1_S | 76.9, 75.7 | 91.7, 89.8 (1.19x) | 80.3, 78.9 (1.04x) | Studio's generic defaults (temperature 0.6, top_p 0.95, top_k 20, min_p 0.01): | target | no draft tok/s | depth 2 tok/s | depth 3 tok/s | |---|---|---|---| | UD-Q4_K_XL | 82.1, 81.9 | 103.6, 104.0 (1.27x) | 85.8, 85.9 (1.05x) | | UD-IQ1_S | 84.6, 85.0 | 106.5, 110.2 (1.28x) | 96.2, 96.2 (1.13x) | Greedy (temperature 0), UD-IQ1_S: depth 2 1.28x, depth 3 1.19x, depth 5 1.15x, depth 7 1.08x. ## Tests - New parametrized case in `test_llama_cpp_mtp_detection.py`: Inkling 2 in both layouts emits depth 2, a requested depth 3 stays 3, and `deepseek4` and an unknown architecture stay at 3. The existing DeepSeek-V4-Flash case is unchanged. - `test_llama_cpp_mtp_detection.py`, `test_spec_sidecar_fit_reserve.py`, `test_mtp_drafter_companion.py` and `test_llama_cpp_placement.py`: 1458 passed. The placement file has teardown errors on a host with visible GPUs (CUDA device queries in CPU tests); the same test IDs error on main, and CI runners have no GPU. ## Not covered - GPUs other than B200. The depth trade-off comes from acceptance (the third token is rarely kept), which does not depend on the GPU, but the speed ratio was only measured on B200. - A future DSpark pin. On the newer upstream head (e4b1cb531) the drafter decodes its full 8-token block every round and depth 2 is the slowest setting there, so this default should be revisited when the pin moves.
The drafters published with unsloth/Inkling-2-Mini-GGUF before the f_rnn layout (dspark_fuse, dspark_hidden_out, padded markov_w1) keep their own head: a draft with dspark_hidden_out.weight takes the 0a9105d loader, graph and speculative loop, a draft with markov_ctx_norm takes the f_rnn path above, and every other DSpark draft is unchanged. A draft mixing both layouts is refused at load.
- reject a fused draft that also carries f_rnn (markov_ctx_*, blk.N.ctx_mix/ctx_norm, token_embd_norm) or fc-based DFlash tensors, and one without any SWA layer, at load - reuse the upstream DFLASH_ATTN_*_CTX tensors and layer fields for attn_k_ctx/attn_v_ctx - equal-size block check in build_inkling2_embd, as in the markov head - no dummy state on probe and warmup decodes of the fused draft (its state is 3*n_embd) - keep upstream's test_logit_bias
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b5ed9f2845
ℹ️ 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_tensor * llama_model_dflash::graph_base::mix_target_features(ggml_tensor * features, int row, ggml_tensor * norm) { | ||
| const int64_t count = model.target_layer_ids.size(); | ||
| auto * weights = ggml_soft_max(ctx0, ggml_view_1d(ctx0, model.dspark_fuse, count, row*model.dspark_fuse->nb[1])); |
There was a problem hiding this comment.
Convert fused mixing weights to F32 before softmax
When a fused-layout drafter is converted with llama-quantize, dspark_fuse.weight is eligible for conversion because it is a 2D weight and has no exclusion in tensor_allows_quantization(). An F16/BF16 conversion changes its type directly, and quantized formats fall back to F16 when the target-layer count is not block-aligned. This view preserves that type, but the CPU softmax implementation in ggml/src/ggml-cpu/ops.cpp only handles F32 and aborts otherwise, so the converted drafter cannot process its context features. Cast the mixing row to F32 before softmax, or preserve this tensor as F32 during quantization.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Already covered in the pin set: #397 keeps dspark_fuse.weight unquantized in llama-quantize (src/llama-quant.cpp, quantize &= name.find("dspark_fuse.weight") == std::string::npos), and #397 is merged before #405 in pr-set.json, so a fused drafter quantized with the prebuilt keeps an F32 fuse. The published drafters also store it as F32. Keeping that fix in #397 where it was born rather than duplicating it here.
| // the block attention is non-causal: a draft with a markov context decodes the full trained block, then reads n_max of it | ||
| const int32_t n_draft = params.n_max; | ||
| const int32_t n_block_tokens = n_draft + (sample_from_anchor ? 0 : 1); | ||
| const int32_t n_block_tokens = has_markov_context ? block_size : n_draft + (sample_from_anchor ? 0 : 1); |
There was a problem hiding this comment.
Bound full-block draft batches by the context capacity
For the new Markov-context layout, each drafting sequence now contributes the entire trained block, but all sequences are still passed to one decode without checking the batch or microbatch capacity. For example, two active sequences with an 8-token block, n_max = 3, and a draft microbatch capacity of 8 produce a 16-token non-causal decode. llama_context::decode() asserts that a non-causal batch fits entirely in n_ubatch (src/llama-context.cpp:2254), terminating the process rather than returning the error handled below. The initialization change only enlarges output limits, not these capacities. Decode groups of complete blocks that fit the configured capacities, and reject configurations where even one block cannot fit.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
This line is upstream's code from ggml-org#32218 (8ccecab, the f_rnn path), which this pin carries verbatim so the new layout behaves exactly like upstream. Changing how the markov-context path sizes its batches belongs in ggml-org#32218 itself; for the prebuilt the default is the fused drafter, and the multi-slot server checks (-np 2 / -np 4, 4 concurrent requests) passed on this head.
|
@codex review |
|
Codex Review: Didn't find any major issues. More of your lovely PRs 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". |
…7059d6) Registra a config validada em hardware real (RTX 5060 Ti 16GB): - ctx 102400 (100k), KV f16/q8_0, batch 512 / ubatch 128 - DSpark n-max 2 (n-min 0, p-min 0), sem --spec-draft-device - 15684-15721 MiB usados / 590-627 MiB livres (96.2-96.4%) - prompt 243.5-256.9 t/s, geracao 58.9-63.6 t/s, aceitacao 46.7-52.3% - escada de KV a 122880: f16/f16 = 344 MiB livres (reprovado) -> f16/q8_0 = 421 MiB (aprovado) - 120k com DSpark colapsa para 24.9 t/s; curva 16K/32K/100K/120K documentada - com ~59k de prompt preenchido: 26.6 t/s (DSpark n=2) vs 34.0 t/s sem drafter Novo docs/inkling-2-mini.md com versoes exatas: llama.cpp b12651 (commit d426a3774), release Unsloth b12651-mix-c7059d6, sha256 do zip, CUDA 13.3 do build + runtime 13.5 (cudart 6.14.11.13050 / cublas 6.14.11.13100), driver 621.24, quant UD-IQ3_XXS e drafter Q8_0 com bytes e sha256 do HF, fix antecipado do DSpark (unslothai/llama.cpp#405, b5ed9f2) e o script completo. Novo scripts/start-inkling2-mini-ud-iq3xxs-100k-q8.bat (CRLF, auto-download, args ctx/ctk/ctv/ubatch/nmax).
|
Tested the On a coding/prose head-to-head test (
In multi-hit server benchmarks at Also needed two extra fixes for Vulkan
|
Inkling 2 DSpark drafter support that loads both drafter layouts: the current upstream one from ggml-org#32218 (head e4b1cb5, by @pwilkin and @ngxson) and the older padded-vocab one that the drafters already published with unsloth/Inkling-2-Mini-GGUF use (0a9105d).
Why
markov_w1at the real vocab size (200058 rows) and adds themarkov_ctx_*context head, while the published drafters (dspark-Inkling-2-Mini-Q8_0.ggufand thedspark/copies) use the padded layout (dspark_fuse,dspark_hidden_out, 201024 rows).joint_proj.weight has wrong shape; expected 2816, 768, got 5120, 768markov_w1.weight has wrong shape; expected 256, 200058, got 256, 201024Mainline_Support/) should load in the prebuilt too.What changed
The branch fast-forwards from 0a9105d and now has three commits on top:
dspark_hidden_out.weight: the 0a9105d loader, graph and speculative loop.markov_ctx_norm(f_rnn): upstream's path.DFLASH_ATTN_*_CTXtensors instead of duplicates;test_logit_biasis kept as is.The base branch moves to
base/upstream-cbb1c1c50, the upstream base of e4b1cb5 (in b12625).Checks
All on B200, 4 prompts x 384 tokens, greedy and temp 1.0 (seed 1234), root and Mainline_Support UD-Q4_K_XL targets.
llama-server -np 2and-np 4with the fused drafter, 4 concurrent requestsverify --cudaon b12648 and b12651Speed on one exclusive B200 with this build (root UD-Q4_K_XL, 3 rounds after a warm-up, tok/s and ratio to no drafter):
Acceptance is the same for both layouts at the same n_max, so the gap is per-round cost: upstream's path decodes the full 8-token block every round.
Not covered