Files
leleka/docs/original-serve.md
T
Pavlo RatushnyiandClaude Sonnet 5.5 6d3ad69d3d
Rust port / port-fast (push) Failing after 7s
Rust port / port-typecheck (push) Failing after 7s
Rust port / port-oracles (push) Failing after 10s
Rust port / port-linux-tests (push) Failing after 22s
docs: sealed with nvcc 13.2.86 on 2026-10-15, GPU load verified separately, no numerical claim
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-15 07:26:47 +02:00

7.4 KiB

Original mode17 serve path

Status: source-complete at the wiring level, not GPU-run (no device was available when this was written). Nothing here certifies quality or speed; selection is an operator choice, as for the other experimental modes.

What it is

generate.cpp's serve loop as a backend: the Original batched prompt read, then OriginalSpecController (spec 4, suffix draft 3, verify windows up to 6) over the native OriginalVerifier with MTP drafting and accepted-prefix commit. The preview path (the Rust-native decoder chain) is unchanged.

piece file
backend selection and owner loop crates/leleka-runtime/src/backend_original_serve.rs
per-request flow (admit, reset, prefill, decode) qwen_forward/original_serve_request.rs, original_serve_stack.rs
verifier assembly per decode phase qwen_forward/original_serve_verifier.rs
the owners behind the serve port qwen_forward/original_serve_host.rs, original_serve_native.rs
expert tier, lineage ledger, mode17 constants original_serve_pool.rs, original_serve_ledger.rs, original_serve_config.rs
verified-window publication into QwenSession qwen_forward/session_original_verified.rs

Selecting it

leleka-inference ... [--backend-mode auto|original|preview] [--original-prefill-capacity N] [--mtp-rt-dir PATH] [--spec-min-p F]

  • auto (default): the Original path when every compiled asset and every verifier window asset/producer it needs is present in the build (leleka_cuda_driver::unsealed_original_serve_assets(): native head, sampler, verifier and MTP-session PTX, the window kernels unsealed_window_assets(), and any producer in UNBOUND_PRODUCERS) and the configuration can feed it (inherited sealed KAR archive, MTP pack, no KAR expert source, no experimental mode, context within the trained size); otherwise the preview path, with the reason on stderr. An --experimental-* flag selects preview unless the mode is given explicitly.
  • original: never falls back. Refuses naming what is missing, e.g. the unbound window producers or an unsealed PTX; refuses a KAR expert source (the Original executors read the pinned model's own mapped routed experts, not a KAR level decode).
  • preview: never starts the Original path.

The load must be the explicit KAR PLE MTP load, as for the windowed256 modes.

Request plumbing

  • Admission: n + max_new + 8 <= context_tokens (generate.cpp), before any work.
  • Sampling: the request's SamplingParams map field for field to the driver SamplerParams (driver_sampler_params); a greedy request without penalties takes the plain argmax. Unseeded requests take a clock seed. Penalty history is the literal per-row window (tail of the committed tokens + the window prefix), uploaded per window.
  • Rope / context: RopeConstants::from_serving_context() (the analytic RoPE form of the process serving context) feeds both the verifier's QSA append and the draft K/V policy.
  • MTP: the digest-pinned pack of the binding, or the Original --mtp DIR bank (--mtp-rt-dir); coupled draft sampling only with STRATA_SPEC_COUPLED as in the Original.
  • Every request starts at position 0 (no conversation cache is merged): the session, the draft ring and the twelve resident QSA layers are rolled back to the empty-prompt checkpoints taken at load.

Verified-window publication

The verifier owns the canonical GDN image, the PLE history and the twelve QSA index/K-V journals for a decode phase. After each commit event the host publishes the accepted rows (position, predecessors and the twelve resident QSA witnesses, read from the verifier's own journal) to the session. The recurrent GDN/PLE state lags and is read back once at the end of the phase when a consumer needs it (StackConfig::settle_state); while it lags the session refuses prompt transactions and checkpoints. Commit and draft are serialized: the commit event completes and the session is published before the draft launches.

Running the GPU smoke

LELEKA_ORIGINAL_SERVE_SMOKE=yes \
LELEKA_STRA169_KAR_FD=… LELEKA_STRA169_KAR_PROVENANCE=… \
LELEKA_STRA169_IQ3S_SHARD0=… LELEKA_STRA169_IQ3S_SHARD1=… \
LELEKA_STRA169_MTP_PACK=… LELEKA_STRA169_MTP_STAGING=… \
[LELEKA_ORIGINAL_SERVE_RT_DIR=…] [LELEKA_ORIGINAL_SERVE_CAPACITY=1024] [LELEKA_ORIGINAL_SERVE_BUDGET_GIB=28] \
cargo test -p leleka-runtime --features cuda-driver -- --ignored original_serve_smoke

It opens the stack, serves a greedy request twice (the second must reproduce the first across a reset), a sampled request with penalties, a request cancelled after its first committed round, and a final request that must reproduce the first. While UNBOUND_PRODUCERS is non-empty the stack refuses to open with the first missing producer's name; that is the expected result until they are bound.

Open items

  • The compiled assets the probe lists as unsealed: the native head, sampler, MTP session PTX and the two window kernels (original_verify_window_moe_experts.ptx, original_verify_window_qsa_gate.ptx) were sealed with nvcc 13.2.86 on 2026-10-15 (GPU load is verified separately by the host smokes; no numerical claim). A window asset whose bytes stop matching its pin fails the whole window before capture. Remaining placeholders (mmq_original_group_*, mtp_original_scalar_{gr,norm}, native_parity) are still reported as unsealed. All 21 former window producers are bound by the planner; the runtime attaches projections, hyper-connection/PLE, QSA and router/shared-expert operands (dense_original_verify.rs, cache_original_verify.rs) to every window graph.
  • A new OriginalVerifier is assembled and its graphs captured for every request (the QSA owners move one way into its journal); keeping one alive across requests needs a re-seed path.
  • Routed experts run on the all-CPU pool; there is no GPU expert residency or PCIe plan (the driver publishes the empty plan). The prefill chunk is an operator choice (default 2048) instead of the Original's slot-derived ladder.
  • Short prompts also take the batched prefill (the Original reads <= 64 tokens through verify windows).
  • Commit/draft overlap of the Original is traded for exactness (see above).
  • draft_first (CLI only), scaled RoPE tables (STRATA_ROPE_TABLE), multi-stage and vision requests are not supported.
  • Conversation cache (resume / checkpoints / parked snapshots) is merged (conversation/) but not bound to this stack, deliberately: its device side (OriginalDevice<T: OriginalSessionBytes + OriginalSessionControl>) addresses the driver's OriginalSessionState arena (GDN image, PLE history, per-layer idx/K-V regions, host K/V owner), whereas the serve stack drives a QwenSession whose recurrent state, PLE history and QSA index/K-V live in the verifier journals and the twelve resident QSA witnesses. No OriginalSessionState is constructed outside the driver and OriginalConversationAccess is crate-private. Binding needs a QwenSession-backed SessionDevice (byte regions over those owners, restore_draft(resume) as a partial ring rollback instead of reset_to_empty) plus settle_state on, so every request would end with session and verifier in step. Until then every request resets to the empty prompt (begin_request/finish_request are not called).
  • Host-side rolling costs not measured: 12 small device checkpoints per committed round, one GDN readback per request when settle_state is on.