feat(neuron): continuous batching — batched decode + engine (#98, slices 1–3b) #121
Reference in New Issue
Block a user
Delete Branch "feat/98-batched-decode"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
First four slices of F4d continuous batching (#98, epic #84): gang batching with lockstep decode and cat-based rebatch — no scatter kernels, no paged attention, no CUDA kernel changes.
Arch groundwork (qwen3_5) — per-row RoPE positions (
batch_cos_sin+ rank-dispatched apply),assemble_batch(right-pad per-seq snapshot KV to the batch max, cat on dim 0; GDN states cat on dim 0),forward_batch_decode((B,1), positions, mask),batch_decode_mask(one padding gap per row). Keys are stored post-RoPE, so padding is position-inert.Worker jobs —
AssembleKvBatch,ForwardLogitsBatch(per-row CPU[vocab]logits),ExtractKvRows(slice a live batch row back to a contiguous B=1 snapshot — the join/leave rebatch primitive). Fix en route: dense safetensors loads pick f32 on non-CUDA devices (candle CPU has no bf16 matmul).Engine (
harness/engine.rs) — per-model task multiplexing concurrent text chat streams through one(B,1)forward per step. Joins prefill at B=1 through the existing chunked-prefill + prefix-cache paths; per-slot router tasks own the detokenizer + reasoning/tool-call state machine; the engine holdsinference_lockwhile active so vision/non-streaming requests stay safe. Default-off: activates only when[admission] max_in_flight > 1on a snapshot-capable worker-path model;NEURON_BATCHING=0kill switch. No production config changes in this PR — behaviour is unchanged everywhere until an operator raises the knob.Parity tests on the committed qwen3_next-tiny fixture at three levels: arch (ragged lockstep == sequential, hidden-for-hidden), worker (end-to-end jobs incl. a leave-path rebatch), engine (concurrent == sequential byte-identical, with mid-flight joins).
Remaining slices tracked in #98: TP batched GenerateStep (the payoff — 27B/Coder-Next are TP-2) and the O5 bench gate.
🤖 Generated with Claude Code
https://claude.ai/code/session_01TczcGF7JSjJs8r15RSSGpx