Skip to content

server, speculative-simple: wire dspark tap capture - #67

Merged
khosravipasha merged 2 commits into
prismfrom
dspark-capture-wiring
Jul 14, 2026
Merged

server, speculative-simple: wire dspark tap capture#67
khosravipasha merged 2 commits into
prismfrom
dspark-capture-wiring

Conversation

@khosravipasha

Copy link
Copy Markdown
Collaborator

Wire dspark tap capture into tools/server and examples/speculative-simple so --spec-type draft-dspark works outside the test harness.

  • engage llama_set_capture_layers(..., masked=false); layer ids read from the drafter GGUF
  • common_speculative_begin() before prompt decode; capture rows staged via common_speculative_process() on prefill/verify batches
  • prompt-cache prefix reuse disabled in capture mode
  • draft context sized for block drafting (n_outputs_max, n_batch >= n_ctx)

--spec-draft-n-max must equal the drafter's block_size. Validated single-slot; greedy output identical with/without the drafter.

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.

Pull request overview

Wires dspark capture-based speculative decoding into the server and speculative example.

Changes:

  • Reads dspark metadata and enables target-layer capture.
  • Stages prompt and verification capture rows.
  • Adjusts draft context sizing and disables prompt-prefix reuse.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
tools/server/server-context.cpp Integrates dspark capture into server request processing.
examples/speculative-simple/speculative-simple.cpp Adds a dspark-specific speculative decoding flow.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tools/server/server-context.cpp Outdated
Comment on lines +1043 to +1046
if (cparams.n_batch < cparams.n_ctx) {
SRV_INF("draft-dspark: raising draft ctx n_batch %u -> %u (full-context staging)\n",
cparams.n_batch, cparams.n_ctx);
cparams.n_batch = cparams.n_ctx;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 2fc57d2 — draft ctx batch is now sized n_ctx + block_size (block_size from the drafter GGUF; +64 fallback if the KV is missing), so a full round fits even at the context limit.

Comment on lines +125 to +127
if (spec_dspark) {
cparams.n_batch = std::max(cparams.n_batch, cparams.n_ctx);
cparams.n_ubatch = std::max(cparams.n_ubatch, cparams.n_batch);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 2fc57d2 — same n_ctx + block_size sizing here, using a local block_size reader.

Comment on lines +1023 to +1025
const bool spec_dspark = std::find(params_base.speculative.types.begin(),
params_base.speculative.types.end(),
COMMON_SPECULATIVE_TYPE_DRAFT_DSPARK) != params_base.speculative.types.end();

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 2fc57d2ctx_shift is now force-disabled when capture-mode speculation initializes (same pattern as the existing mtmd/context checks), with a warning. Proper shift support (reset + recapture) left as future work.

Comment on lines +3493 to +3496
// capture-type drafters already ran begin() before prompt decode (see
// SLOT_STATE_STARTED) -- running it again here would wipe the prompt's
// staged capture rows.
if (slot.can_speculate() && !common_speculative_need_embd_capture(spec.get())) {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 2fc57d2 — added server_slot::spec_disabled, set at launch for is_child() slots when the spec needs capture; can_speculate() respects it, so n_cmpl children run plain AR instead of erroring every round. Copying per-sequence speculative state on clone left as future work.

Comment on lines +1027 to +1029
const uint32_t block_size = server_read_dspark_block_size(params_spec.mparams.path);
if (block_size > 0) {
const uint32_t n_out_dspark = params_base.n_parallel * (1 + block_size);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 2fc57d2 — init now validates --spec-draft-n-max == block_size (read from the drafter GGUF) and fails model load with a clear error on mismatch. Verified: --spec-draft-n-max 6 against a block-4 drafter now exits with draft-dspark: --spec-draft-n-max (6) must equal the drafter's block_size (4).

@bri-prism
bri-prism self-requested a review July 14, 2026 04:47
@khosravipasha
khosravipasha merged commit c024aa2 into prism Jul 14, 2026
14 of 28 checks passed
@khosravipasha
khosravipasha deleted the dspark-capture-wiring branch July 14, 2026 04:50
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.

3 participants