Skip to content

feat(engine): DSpark under continuous batching + load-aware verify length (spec Phases 5/6 remainder) #427

Description

@pekkah

Follow-up to PR #426 (DSpark Phases 0-4 + single-user server) and the docs/dspark-plan.md spec (#413).

What's missing

DSpark currently requires the single-user InferenceEngine (MaxBatchSize=1); the loader rejects continuous batching because the tap/draft state is single-sequence:

  1. Per-sequence hidden-tap buffers. HiddenTapBuffer is one position-indexed buffer per pass; ContinuousBatchingEngine interleaves sequences with per-sequence KV caches, so capture must be keyed by cache/sequence (the RunBatchedTrunk capture site already guards on the owned cache view — that guard becomes a routing decision instead).
  2. Per-sequence draft contexts. IDSparkDraft holds one context (ctx K/V + append cursor). Multi-user needs one draft MODEL (weights shared) with N contexts — likely a CreateContext() handle API, restructuring DSparkDraftModel/CudaDSparkDraftModel state.
  3. Batched drafting + packed verify. Per decode step: propose a block per eligible greedy sequence (GPU draft amortizes well; CPU draft per-user is prohibitive), then verify all users' segments in one packed pass — BatchForwardMulti already accepts repeated caches with consecutive positions per user (that's exactly what BatchVerify does single-user), so the trunk machinery may already suffice; per-user accept/rollback via per-sequence TruncateTo.
  4. Load-aware verify length (spec §7's server half). Trim each user's verified prefix by confidence AND batch occupancy — the paper's scheduler: under load, shorter verifies keep step latency bounded; when idle, full blocks. The threshold trim already resolves from SHARPI_DSPARK_*; the occupancy signal comes from the batcher.

Why deferred

The payoff only exists where DSpark already wins single-user — which per the Phase-4 measurements means desktop-scale targets (see the companion validation issue). Building the engine's most concurrency-sensitive extension before the single-user win condition is demonstrated would be effort at the wrong altitude.

🤖 Generated with Claude Code

https://claude.ai/code/session_018EWo1niax1g8A5E79RSALJ

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions