Skip to content

Drop the unused POOL_1D split-state handler left by the b11984 merge - #21

Merged
lukekim merged 1 commit into
spiceai-b11999from
lukim/b11999-drop-unused-pool-1d
Oct 30, 2026
Merged

lukekim merged 1 commit into
spiceai-b11999from
lukim/b11999-drop-unused-pool-1d

Conversation

@lukekim

@lukekim lukekim commented Oct 30, 2026

Copy link
Copy Markdown

What

Deletes the handle_pool_1d lambda from ggml_backend_meta_get_split_state. Nothing calls it on spiceai-b11999.

Why

Upstream removed this handler in ggml-org#31081. Mirroring a POOL_1D over an axis-0 split gives each device only a partial max. Upstream moved GGML_OP_POOL_1D into the generic scalar_only case and now refuses -sm tensor for the architectures that build the amax graph ([TAG_MOE_AMAX_SCALE]).

The b11984 merge kept upstream's case label and the arch denial, but also kept this fork's copy of the lambda. GCC's -Werror=unused-but-set-variable therefore fails the ubuntu job on every PR into spiceai-b11999, for example #20:

ggml/src/ggml-backend-meta.cpp:882:10: error: variable 'handle_pool_1d' set but not used [-Werror=unused-but-set-variable]

After this change, POOL_1D is handled exactly as upstream b11999 handles it.

Evidence

All results below are from macOS, Apple clang, on 2026-10-29. Each compile used the file's own command from compile_commands.json, plus -Wall -Wextra -Werror=unused-but-set-variable -Werror=unused-variable.

Before, base spiceai-b11999 at 2bedd1f:

ggml-backend-meta.cpp:882:10: error: unused variable 'handle_pool_1d' [-Werror,-Wunused-variable]
1 error generated.
exit 1

After, bc00c1c: exit 0. No diagnostic names a variable in this file. The only warnings are -Wunused-function warnings for static helpers in ggml-impl.h.

Tests at bc00c1c (Metal build):

  • test-llama-archs: Summary: all 547 test(s) passed
  • test-backend-ops -o POOL_1D: 216/216 tests passed

Not run: a GCC build. No GCC is installed on this Mac, so this PR's own ubuntu CI job is the GCC check.

Upstream removed handle_pool_1d in ggml-org#31081 (an axis-0 split gives each
device only a partial max) and moved GGML_OP_POOL_1D into the generic
scalar-only case. The b11984 merge kept the lambda but took upstream's
case, so it is never called and GCC's -Werror=unused-but-set-variable
fails the ubuntu build. POOL_1D is now handled exactly as upstream
b11999 handles it.
Copilot AI balanced review requested due to automatic review settings October 30, 2026 02:13
@github-actions github-actions Bot added the ggml label Oct 30, 2026

Copilot AI 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.

🟢 Approved

No active review issues remain for the removal of the unused POOL_1D handler.

No open issues 🎉

What changed in this PR

Removes an unused POOL_1D split-state handler left by the b11984 merge, addressing the unused-variable build failure without changing POOL_1D behavior.

Changes:

  • Deletes the unreferenced handle_pool_1d lambda.
  • Leaves POOL_1D handled by the existing generic scalar_only case, matching upstream b11999.
File Description
ggml/​src/​ggml-backend-meta.cpp Removes the obsolete POOL_1D split-state lambda.

Review effort: Balanced

@lukekim lukekim self-assigned this Oct 30, 2026
@lukekim
lukekim merged commit 1aa119b into spiceai-b11999 Oct 30, 2026
17 of 38 checks passed
lukekim added a commit to spiceai/spiceai that referenced this pull request Nov 8, 2026
…es (#16079)

* deps(llama-cpp): pin llama.cpp to spiceai-b11999 at the squash of spiceai/llama.cpp#23

Moves `llama-cpp-src` from 2bedd1f7 (tag b11999-spiceai.1) to 3a536dbf, the tip of
spiceai-b11999, three commits further on:
- spiceai/llama.cpp#21 deletes a POOL_1D split-state handler left unused by the b11984 merge.
- spiceai/llama.cpp#20 splits Mistral Large 4 and its DSpark drafter across devices.
- spiceai/llama.cpp#23 reads a DSpark draft token as the row's largest logit when the
  drafter's CPU chain is top-k alone.

`docs/dev/fork_patches.md` records the new pin and the three patches; #20 and #23 are
GAP rows, #21 needs no guard.

* deps(llama-cpp): move the llama.cpp pin to the squash of spiceai/llama.cpp#25

spiceai/llama.cpp#25 adds `llama_get_unsampled_logits_ith`, which reads an output's full
logits row after one synchronize, or returns NULL when a backend sampler sampled the row.
The DSpark drafter's pick now uses it. `docs/dev/fork_patches.md` records the new pin
and adds the patch's row.

* perf(llama-cpp): read a row's logits with one synchronize through llama_get_unsampled_logits_ith

* docs(fork-patches): measure Mistral Large 4's layer-split cost in the tensor-split row

The row said a layer split runs several times slower. Stock llama-server
at f68fea35 with the DSpark drafter across three DGX Sparks measured
7.68 tok/s split by layer against 13.19 split by tensor.

* deps(llama-cpp): pin llama.cpp to spiceai-b11999's tip, and keep the MTP head's state with the prompt cache (#16023)

* fix(llms): the MTP head's state follows the prompt cache

The MTP head pairs a prompt read's first token with the target's hidden state at the position
before it, and kept the last request's: a request after another one, or a turn that reuses the
previous turn's prompt, drafted differently from the same request on a fresh context (fewer
tokens accepted, and with batched verification, different tokens).

With the fork's state API (llama.cpp's common_speculative get/set state for its MTP head), the
prompt cache saves the head's state with each checkpoint and restores it with it. A cache that can
be cut anywhere stashes the head's state where a checkpoint would be, and reuses the cache up to
there or up to all of it, where the head's live state is; the debug line says how many shared
tokens it read again. Two integration tests on Qwen3.5-0.8B compare the drafts with a fresh
context's: a request after another, and a turn after the previous turn.

* test(llms): check the second request's drafts over eight requests, so the guard fails on Metal too

* style(llms): rustfmt the MTP head state change

* deps(llama-cpp): pin llama.cpp to spiceai-b11999 at the squash of spiceai/llama.cpp#31

The pin moves from the squash of spiceai/llama.cpp#25 to the branch's tip,
which adds #22 (carrying #18 and #19 over from spiceai-b11803), #24, #26,
#27, #29, #30 and #31. The ledger gets a row for each, #19's defaults go into
the levers row, and the MTP head-state guards from the previous commits guard
#31.

* style(llama-cpp): rustfmt the MTP state bindings

* fix(llms): keep the prompt cache's shared prefix for a DFlash or DSpark drafter

The head-state change treated every draft model behind the speculative shim as a head that carries
its state from one read to the next. A DFlash or DSpark drafter keeps none, so on a cache that can
be cut anywhere nothing was ever stashed, and every request whose prompt shared only part of the
cache read it all again from position 0. On Mistral Large 4 with its DSpark drafter split across
three nodes, each request reused 0 of its 35 prompt tokens instead of 34, which changed its prefill
batches and its replies. Only an MTP head now counts as one.

* deps(llama-cpp): pin llama.cpp to the squash of spiceai/llama.cpp#33 (#16049)

spiceai/llama.cpp#33 rebuilds a meta split a backend would reuse when another backend's rebuilds have reset the
containers holding its views. Since spiceai/llama.cpp#27 the DSpark drafter's graphs view the target's weights, and with
one graph slot (LLAMA_GRAPH_SLOTS=0) DeepSeek-V4.1 split by tensor aborted on its first or second request at
ggml-cuda/binbcast.cu:417. Spice's default of two graph slots builds splits from clones and did not reach it.

The ledger records the pin and a row for #33, a GAP covered by the fork's test-meta-shared-views, and the GAP count
moves from 58 to 59.

* test(llms-llamacpp): require at least one non-empty MTP draft in regression helpers

Copilot: generate/generate_after_read could pass with every draft empty.
Assert each helper produced at least one non-empty draft before returning.

* test(llms-llamacpp): compare whole replies when every MTP draft matches

The prompt-cache guards compared the two runs' replies only up to the shorter one. A reply grows by the step's token
and the drafts the target accepted, and the final step's next token is never appended, so two runs whose final steps
accepted different numbers of drafts give one reply that is a prefix of the other, and the prefix comparison passed.
With the same drafts at every step the runs take the same steps, so both guards now require the whole replies to be
equal once every draft matches.

Watched failing: with the final step's reply one token short in one run, both guards passed before this change, and
fail with it ("whose drafts match at every step").
mikemikimike pushed a commit to mikemikimike/spiceai that referenced this pull request Nov 8, 2026
…ceai/llama.cpp#33, and keep the MTP head's state with the prompt cache (spiceai#15922)

* deps(llama-cpp): pin llama.cpp to spiceai-b11999 at the squash of spiceai/llama.cpp#23

Moves `llama-cpp-src` from 2bedd1f7 (tag b11999-spiceai.1) to 3a536dbf, the tip of
spiceai-b11999, three commits further on:
- spiceai/llama.cpp#21 deletes a POOL_1D split-state handler left unused by the b11984 merge.
- spiceai/llama.cpp#20 splits Mistral Large 4 and its DSpark drafter across devices.
- spiceai/llama.cpp#23 reads a DSpark draft token as the row's largest logit when the
  drafter's CPU chain is top-k alone.

`docs/dev/fork_patches.md` records the new pin and the three patches; spiceai#20 and spiceai#23 are
GAP rows, spiceai#21 needs no guard.

* deps(llama-cpp): move the llama.cpp pin to the squash of spiceai/llama.cpp#25

spiceai/llama.cpp#25 adds `llama_get_unsampled_logits_ith`, which reads an output's full
logits row after one synchronize, or returns NULL when a backend sampler sampled the row.
The DSpark drafter's pick now uses it. `docs/dev/fork_patches.md` records the new pin
and adds the patch's row.

* perf(llama-cpp): read a row's logits with one synchronize through llama_get_unsampled_logits_ith

* docs(fork-patches): measure Mistral Large 4's layer-split cost in the tensor-split row

The row said a layer split runs several times slower. Stock llama-server
at f68fea35 with the DSpark drafter across three DGX Sparks measured
7.68 tok/s split by layer against 13.19 split by tensor.

* deps(llama-cpp): pin llama.cpp to spiceai-b11999's tip, and keep the MTP head's state with the prompt cache (spiceai#16023)

* fix(llms): the MTP head's state follows the prompt cache

The MTP head pairs a prompt read's first token with the target's hidden state at the position
before it, and kept the last request's: a request after another one, or a turn that reuses the
previous turn's prompt, drafted differently from the same request on a fresh context (fewer
tokens accepted, and with batched verification, different tokens).

With the fork's state API (llama.cpp's common_speculative get/set state for its MTP head), the
prompt cache saves the head's state with each checkpoint and restores it with it. A cache that can
be cut anywhere stashes the head's state where a checkpoint would be, and reuses the cache up to
there or up to all of it, where the head's live state is; the debug line says how many shared
tokens it read again. Two integration tests on Qwen3.5-0.8B compare the drafts with a fresh
context's: a request after another, and a turn after the previous turn.

* test(llms): check the second request's drafts over eight requests, so the guard fails on Metal too

* style(llms): rustfmt the MTP head state change

* deps(llama-cpp): pin llama.cpp to spiceai-b11999 at the squash of spiceai/llama.cpp#31

The pin moves from the squash of spiceai/llama.cpp#25 to the branch's tip,
which adds spiceai#22 (carrying spiceai#18 and spiceai#19 over from spiceai-b11803), spiceai#24, spiceai#26,
spiceai#27, spiceai#29, spiceai#30 and spiceai#31. The ledger gets a row for each, spiceai#19's defaults go into
the levers row, and the MTP head-state guards from the previous commits guard
spiceai#31.

* style(llama-cpp): rustfmt the MTP state bindings

* fix(llms): keep the prompt cache's shared prefix for a DFlash or DSpark drafter

The head-state change treated every draft model behind the speculative shim as a head that carries
its state from one read to the next. A DFlash or DSpark drafter keeps none, so on a cache that can
be cut anywhere nothing was ever stashed, and every request whose prompt shared only part of the
cache read it all again from position 0. On Mistral Large 4 with its DSpark drafter split across
three nodes, each request reused 0 of its 35 prompt tokens instead of 34, which changed its prefill
batches and its replies. Only an MTP head now counts as one.

* deps(llama-cpp): pin llama.cpp to the squash of spiceai/llama.cpp#33 (spiceai#16049)

spiceai/llama.cpp#33 rebuilds a meta split a backend would reuse when another backend's rebuilds have reset the
containers holding its views. Since spiceai/llama.cpp#27 the DSpark drafter's graphs view the target's weights, and with
one graph slot (LLAMA_GRAPH_SLOTS=0) DeepSeek-V4.1 split by tensor aborted on its first or second request at
ggml-cuda/binbcast.cu:417. Spice's default of two graph slots builds splits from clones and did not reach it.

The ledger records the pin and a row for spiceai#33, a GAP covered by the fork's test-meta-shared-views, and the GAP count
moves from 58 to 59.

* test(llms-llamacpp): require at least one non-empty MTP draft in regression helpers

Copilot: generate/generate_after_read could pass with every draft empty.
Assert each helper produced at least one non-empty draft before returning.
vatsalp2008 pushed a commit to vatsalp2008/spiceai that referenced this pull request Nov 9, 2026
…n sequence (spiceai#16106)

* feat(llama-cpp): decode and draft for several sequences in one context

A context can hold several sequences on one shared cache (`with_n_seq_max`, `with_kv_unified`),
and a batch can carry tokens of any of them (`Batch::add_seq`). Truncation and the partial state
a prompt checkpoint saves now take a sequence (`truncate_seq`, `partial_state_seq`,
`restore_partial_state_seq`), and refuse one the context does not hold instead of reaching the
llama.cpp assertion that ends the process.

The MTP shim drafts for every sequence of the target through the pinned fork's per-sequence
speculative API: `begin`, `accept` and the head's saved state take a sequence, and one
`draft_many` call drafts for several sequences in one pass of the head. It refuses an unknown
sequence, two requests for one sequence, and a batch whose sequences are interleaved.

The engine still decodes one request at a time in sequence 0; serving several requests together
is spiceai#15598.

* test(llms-llamacpp): a sequence's prompt checkpoint restores into that sequence beside another

Sequence 1 saves its recurrent and draft-head state at a split, reuses the prefix for the next turn, and drafts and replies exactly as the turn read whole into sequence 1 of a fresh context, while sequence 0 holds another prompt in both.

* feat(llms-llamacpp): decode several requests together, each in its own sequence (spiceai#16107)

* feat(llms-llamacpp): decode several requests together, each in its own sequence

The engine can serve up to `concurrent_requests` requests at once in one context: each step
decodes one batch holding every running request's next token, and with a draft head its draft
from one pass of the head, so the weights are read once for all of them. A request that arrives
while others run reads its prompt into the free sequence whose cache shares the most of it, and
decodes from the next step. It is admitted with room for its prompt and its whole possible
reply, so a running request never runs out of cache; one that does not fit waits, and idle
sequences' caches are emptied, longest unused first, to make room. A request whose client reads
slowly waits rather than holding the step, and one whose client leaves frees its sequence.

Each sequence keeps its own prompt cache, with checkpoints and the draft head's state saved and
restored per sequence.

`concurrent_requests` is an internal option that only tests set: the engine still serves one
request at a time until continuous batching is enabled (spiceai#15598).

* fix(llms-llamacpp): idle caches give up their room even when no request runs

A request admitted while every sequence was idle skipped making room, so the other sequences'
idle caches kept their cells and a prompt that needed them failed with "the context has no
room left for the batch". Admission now always empties the idle caches it does not reuse,
longest unused first, until the request fits; with nothing running the request is served as it
would be alone. `idle_caches_give_up_their_room_to_a_request_that_needs_it` failed with that
error before and passes now.

The decode thread also takes at most one queued request per sequence between steps, so requests
arriving faster than they are taken cannot hold off the running ones' steps, and the internal
ceiling is capped at 8 requests, which keeps a step's batch within the context's batch size.

* test(llms-llamacpp): show requests decode together, not one after another, in the overlap and leaving-client tests

The overlap test's first client now stops reading after its first chunk, and
its reply holds more tokens than a client buffers. One request at a time would
wait on that client and never reach the second request, which is as long, so a
step that waited on a paused client would stall it too. The leaving-client
test drops its client only once the other request has streamed more chunks
than a client buffers, so the leaving request is paused on its full buffer and
the closed-client cleanup runs while the other reply still decodes.

STREAM_BUFFER is public so the tests can size those replies against it.

* test(llms-llamacpp): compare whole replies when every MTP draft matches (spiceai#16079)

* deps(llama-cpp): pin llama.cpp to spiceai-b11999 at the squash of spiceai/llama.cpp#23

Moves `llama-cpp-src` from 2bedd1f7 (tag b11999-spiceai.1) to 3a536dbf, the tip of
spiceai-b11999, three commits further on:
- spiceai/llama.cpp#21 deletes a POOL_1D split-state handler left unused by the b11984 merge.
- spiceai/llama.cpp#20 splits Mistral Large 4 and its DSpark drafter across devices.
- spiceai/llama.cpp#23 reads a DSpark draft token as the row's largest logit when the
  drafter's CPU chain is top-k alone.

`docs/dev/fork_patches.md` records the new pin and the three patches; spiceai#20 and spiceai#23 are
GAP rows, spiceai#21 needs no guard.

* deps(llama-cpp): move the llama.cpp pin to the squash of spiceai/llama.cpp#25

spiceai/llama.cpp#25 adds `llama_get_unsampled_logits_ith`, which reads an output's full
logits row after one synchronize, or returns NULL when a backend sampler sampled the row.
The DSpark drafter's pick now uses it. `docs/dev/fork_patches.md` records the new pin
and adds the patch's row.

* perf(llama-cpp): read a row's logits with one synchronize through llama_get_unsampled_logits_ith

* docs(fork-patches): measure Mistral Large 4's layer-split cost in the tensor-split row

The row said a layer split runs several times slower. Stock llama-server
at f68fea35 with the DSpark drafter across three DGX Sparks measured
7.68 tok/s split by layer against 13.19 split by tensor.

* deps(llama-cpp): pin llama.cpp to spiceai-b11999's tip, and keep the MTP head's state with the prompt cache (spiceai#16023)

* fix(llms): the MTP head's state follows the prompt cache

The MTP head pairs a prompt read's first token with the target's hidden state at the position
before it, and kept the last request's: a request after another one, or a turn that reuses the
previous turn's prompt, drafted differently from the same request on a fresh context (fewer
tokens accepted, and with batched verification, different tokens).

With the fork's state API (llama.cpp's common_speculative get/set state for its MTP head), the
prompt cache saves the head's state with each checkpoint and restores it with it. A cache that can
be cut anywhere stashes the head's state where a checkpoint would be, and reuses the cache up to
there or up to all of it, where the head's live state is; the debug line says how many shared
tokens it read again. Two integration tests on Qwen3.5-0.8B compare the drafts with a fresh
context's: a request after another, and a turn after the previous turn.

* test(llms): check the second request's drafts over eight requests, so the guard fails on Metal too

* style(llms): rustfmt the MTP head state change

* deps(llama-cpp): pin llama.cpp to spiceai-b11999 at the squash of spiceai/llama.cpp#31

The pin moves from the squash of spiceai/llama.cpp#25 to the branch's tip,
which adds spiceai#22 (carrying spiceai#18 and spiceai#19 over from spiceai-b11803), spiceai#24, spiceai#26,
spiceai#27, spiceai#29, spiceai#30 and spiceai#31. The ledger gets a row for each, spiceai#19's defaults go into
the levers row, and the MTP head-state guards from the previous commits guard
spiceai#31.

* style(llama-cpp): rustfmt the MTP state bindings

* fix(llms): keep the prompt cache's shared prefix for a DFlash or DSpark drafter

The head-state change treated every draft model behind the speculative shim as a head that carries
its state from one read to the next. A DFlash or DSpark drafter keeps none, so on a cache that can
be cut anywhere nothing was ever stashed, and every request whose prompt shared only part of the
cache read it all again from position 0. On Mistral Large 4 with its DSpark drafter split across
three nodes, each request reused 0 of its 35 prompt tokens instead of 34, which changed its prefill
batches and its replies. Only an MTP head now counts as one.

* deps(llama-cpp): pin llama.cpp to the squash of spiceai/llama.cpp#33 (spiceai#16049)

spiceai/llama.cpp#33 rebuilds a meta split a backend would reuse when another backend's rebuilds have reset the
containers holding its views. Since spiceai/llama.cpp#27 the DSpark drafter's graphs view the target's weights, and with
one graph slot (LLAMA_GRAPH_SLOTS=0) DeepSeek-V4.1 split by tensor aborted on its first or second request at
ggml-cuda/binbcast.cu:417. Spice's default of two graph slots builds splits from clones and did not reach it.

The ledger records the pin and a row for spiceai#33, a GAP covered by the fork's test-meta-shared-views, and the GAP count
moves from 58 to 59.

* test(llms-llamacpp): require at least one non-empty MTP draft in regression helpers

Copilot: generate/generate_after_read could pass with every draft empty.
Assert each helper produced at least one non-empty draft before returning.

* test(llms-llamacpp): compare whole replies when every MTP draft matches

The prompt-cache guards compared the two runs' replies only up to the shorter one. A reply grows by the step's token
and the drafts the target accepted, and the final step's next token is never appended, so two runs whose final steps
accepted different numbers of drafts give one reply that is a prefix of the other, and the prefix comparison passed.
With the same drafts at every step the runs take the same steps, so both guards now require the whole replies to be
equal once every draft matches.

Watched failing: with the final step's reply one token short in one run, both guards passed before this change, and
fail with it ("whose drafts match at every step").
spiceemma pushed a commit to wangyusheng1985/spiceai that referenced this pull request Nov 10, 2026
… on a split model (spiceai#16172)

* feat(llama-cpp): decode and draft for several sequences in one context

A context can hold several sequences on one shared cache (`with_n_seq_max`, `with_kv_unified`),
and a batch can carry tokens of any of them (`Batch::add_seq`). Truncation and the partial state
a prompt checkpoint saves now take a sequence (`truncate_seq`, `partial_state_seq`,
`restore_partial_state_seq`), and refuse one the context does not hold instead of reaching the
llama.cpp assertion that ends the process.

The MTP shim drafts for every sequence of the target through the pinned fork's per-sequence
speculative API: `begin`, `accept` and the head's saved state take a sequence, and one
`draft_many` call drafts for several sequences in one pass of the head. It refuses an unknown
sequence, two requests for one sequence, and a batch whose sequences are interleaved.

The engine still decodes one request at a time in sequence 0; serving several requests together
is spiceai#15598.

* test(llms-llamacpp): a sequence's prompt checkpoint restores into that sequence beside another

Sequence 1 saves its recurrent and draft-head state at a split, reuses the prefix for the next turn, and drafts and replies exactly as the turn read whole into sequence 1 of a fresh context, while sequence 0 holds another prompt in both.

* feat(llms-llamacpp): decode several requests together, each in its own sequence (spiceai#16107)

* feat(llms-llamacpp): decode several requests together, each in its own sequence

The engine can serve up to `concurrent_requests` requests at once in one context: each step
decodes one batch holding every running request's next token, and with a draft head its draft
from one pass of the head, so the weights are read once for all of them. A request that arrives
while others run reads its prompt into the free sequence whose cache shares the most of it, and
decodes from the next step. It is admitted with room for its prompt and its whole possible
reply, so a running request never runs out of cache; one that does not fit waits, and idle
sequences' caches are emptied, longest unused first, to make room. A request whose client reads
slowly waits rather than holding the step, and one whose client leaves frees its sequence.

Each sequence keeps its own prompt cache, with checkpoints and the draft head's state saved and
restored per sequence.

`concurrent_requests` is an internal option that only tests set: the engine still serves one
request at a time until continuous batching is enabled (spiceai#15598).

* fix(llms-llamacpp): idle caches give up their room even when no request runs

A request admitted while every sequence was idle skipped making room, so the other sequences'
idle caches kept their cells and a prompt that needed them failed with "the context has no
room left for the batch". Admission now always empties the idle caches it does not reuse,
longest unused first, until the request fits; with nothing running the request is served as it
would be alone. `idle_caches_give_up_their_room_to_a_request_that_needs_it` failed with that
error before and passes now.

The decode thread also takes at most one queued request per sequence between steps, so requests
arriving faster than they are taken cannot hold off the running ones' steps, and the internal
ceiling is capped at 8 requests, which keeps a step's batch within the context's batch size.

* test(llms-llamacpp): show requests decode together, not one after another, in the overlap and leaving-client tests

The overlap test's first client now stops reading after its first chunk, and
its reply holds more tokens than a client buffers. One request at a time would
wait on that client and never reach the second request, which is as long, so a
step that waited on a paused client would stall it too. The leaving-client
test drops its client only once the other request has streamed more chunks
than a client buffers, so the leaving request is paused on its full buffer and
the closed-client cleanup runs while the other reply still decodes.

STREAM_BUFFER is public so the tests can size those replies against it.

* test(llms-llamacpp): compare whole replies when every MTP draft matches (spiceai#16079)

* deps(llama-cpp): pin llama.cpp to spiceai-b11999 at the squash of spiceai/llama.cpp#23

Moves `llama-cpp-src` from 2bedd1f7 (tag b11999-spiceai.1) to 3a536dbf, the tip of
spiceai-b11999, three commits further on:
- spiceai/llama.cpp#21 deletes a POOL_1D split-state handler left unused by the b11984 merge.
- spiceai/llama.cpp#20 splits Mistral Large 4 and its DSpark drafter across devices.
- spiceai/llama.cpp#23 reads a DSpark draft token as the row's largest logit when the
  drafter's CPU chain is top-k alone.

`docs/dev/fork_patches.md` records the new pin and the three patches; spiceai#20 and spiceai#23 are
GAP rows, spiceai#21 needs no guard.

* deps(llama-cpp): move the llama.cpp pin to the squash of spiceai/llama.cpp#25

spiceai/llama.cpp#25 adds `llama_get_unsampled_logits_ith`, which reads an output's full
logits row after one synchronize, or returns NULL when a backend sampler sampled the row.
The DSpark drafter's pick now uses it. `docs/dev/fork_patches.md` records the new pin
and adds the patch's row.

* perf(llama-cpp): read a row's logits with one synchronize through llama_get_unsampled_logits_ith

* docs(fork-patches): measure Mistral Large 4's layer-split cost in the tensor-split row

The row said a layer split runs several times slower. Stock llama-server
at f68fea35 with the DSpark drafter across three DGX Sparks measured
7.68 tok/s split by layer against 13.19 split by tensor.

* deps(llama-cpp): pin llama.cpp to spiceai-b11999's tip, and keep the MTP head's state with the prompt cache (spiceai#16023)

* fix(llms): the MTP head's state follows the prompt cache

The MTP head pairs a prompt read's first token with the target's hidden state at the position
before it, and kept the last request's: a request after another one, or a turn that reuses the
previous turn's prompt, drafted differently from the same request on a fresh context (fewer
tokens accepted, and with batched verification, different tokens).

With the fork's state API (llama.cpp's common_speculative get/set state for its MTP head), the
prompt cache saves the head's state with each checkpoint and restores it with it. A cache that can
be cut anywhere stashes the head's state where a checkpoint would be, and reuses the cache up to
there or up to all of it, where the head's live state is; the debug line says how many shared
tokens it read again. Two integration tests on Qwen3.5-0.8B compare the drafts with a fresh
context's: a request after another, and a turn after the previous turn.

* test(llms): check the second request's drafts over eight requests, so the guard fails on Metal too

* style(llms): rustfmt the MTP head state change

* deps(llama-cpp): pin llama.cpp to spiceai-b11999 at the squash of spiceai/llama.cpp#31

The pin moves from the squash of spiceai/llama.cpp#25 to the branch's tip,
which adds spiceai#22 (carrying spiceai#18 and spiceai#19 over from spiceai-b11803), spiceai#24, spiceai#26,
spiceai#27, spiceai#29, spiceai#30 and spiceai#31. The ledger gets a row for each, spiceai#19's defaults go into
the levers row, and the MTP head-state guards from the previous commits guard
spiceai#31.

* style(llama-cpp): rustfmt the MTP state bindings

* fix(llms): keep the prompt cache's shared prefix for a DFlash or DSpark drafter

The head-state change treated every draft model behind the speculative shim as a head that carries
its state from one read to the next. A DFlash or DSpark drafter keeps none, so on a cache that can
be cut anywhere nothing was ever stashed, and every request whose prompt shared only part of the
cache read it all again from position 0. On Mistral Large 4 with its DSpark drafter split across
three nodes, each request reused 0 of its 35 prompt tokens instead of 34, which changed its prefill
batches and its replies. Only an MTP head now counts as one.

* deps(llama-cpp): pin llama.cpp to the squash of spiceai/llama.cpp#33 (spiceai#16049)

spiceai/llama.cpp#33 rebuilds a meta split a backend would reuse when another backend's rebuilds have reset the
containers holding its views. Since spiceai/llama.cpp#27 the DSpark drafter's graphs view the target's weights, and with
one graph slot (LLAMA_GRAPH_SLOTS=0) DeepSeek-V4.1 split by tensor aborted on its first or second request at
ggml-cuda/binbcast.cu:417. Spice's default of two graph slots builds splits from clones and did not reach it.

The ledger records the pin and a row for spiceai#33, a GAP covered by the fork's test-meta-shared-views, and the GAP count
moves from 58 to 59.

* test(llms-llamacpp): require at least one non-empty MTP draft in regression helpers

Copilot: generate/generate_after_read could pass with every draft empty.
Assert each helper produced at least one non-empty draft before returning.

* test(llms-llamacpp): compare whole replies when every MTP draft matches

The prompt-cache guards compared the two runs' replies only up to the shorter one. A reply grows by the step's token
and the drafts the target accepted, and the final step's next token is never appended, so two runs whose final steps
accepted different numbers of drafts give one reply that is a prefix of the other, and the prefix comparison passed.
With the same drafts at every step the runs take the same steps, so both guards now require the whole replies to be
equal once every draft matches.

Watched failing: with the final step's reply one token short in one run, both guards passed before this change, and
fail with it ("whose drafts match at every step").

* perf(llama-cpp): take a greedy request's picks from the argmax output on a split model

On a model split across nodes, a request that picks greedily alone (no penalties, no
end-of-generation ban, no grammar) now decodes with the fork's argmax output on. A model whose
output head the split divides by rows, DeepSeek-V4.1 today, then computes each row's pick on the
devices that hold the head and sends back the picks instead of gathering every row's logits; any
other model computes its logits as before and llama.cpp takes their first maximum. The single
path sets the mode per request before its prompt is read; the batching path keeps it on while
every running request picks greedily alone. Changing the mode rebuilds the graph, so the context
calls llama.cpp only when it changes.

* test(llms-llamacpp): decode several requests together on a split model, against one node's replies

A model split across two ranks loads to decode two requests at once and runs two cases:

- Two greedy requests together, which take their picks from the argmax output.
- A penalized request that joins a greedy one after its first chunk and leaves before it, turning the
  argmax output off while it runs and on again after.

Each reply must equal one node's reply to the same request alone. The batching tests' helpers are
shared with the distributed tests for this, and two calls in batching.rs are formatted as rustfmt
writes them.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants