Files
leleka/docs/port-status.md
T
Pavlo RatushnyiandClaude Sonnet 5.5 d2701dbc65 docs: feasibility decisions for KAR routed/prefill experts and the multi-GPU handoff; bring-up print review with a source-scan guard
Item 5: the patch source is not in the tree but is in the git objects of the codex KAR branch; recorded what it is, what can be recovered and why it is not ported. Item 6: scope of set_stage/set_next and what a layer split needs; nothing implemented. Item 8: every production DBG/PROBE print is behind LELEKA_BRINGUP_TRACE or a switch of its own; crates/leleka-runtime/tests/bringup_prints_gated.rs keeps it so.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-25 12:36:50 +01:00

20 KiB

Rust port status by module

Branch claude/port-main, reviewed 2026-10-14. "Original" is the C++/CUDA/Python Strata under engine/strata/ (commit in docs/upstream.md). This page records what exists and how it was checked. It makes no performance or model-quality claim, and no row has run on a GPU.

Sources of the rows: the gap audits of 2026-10-14 (forward, serving, offline), PORT-GAPS-MODE17.md, docs/offline-port.md, docs/rope-and-memory-plan.md, docs/sampler-reference.md, docs/experiments/2026-10-14-*.md and the docs/cuda-seal-plan-additions*.json files. Where a row disagrees with an older audit, the code on the branch wins; re-check the code before relying on a row.

Reading the table

Completeness:

  • full: every behavior of the Original unit has a Rust owner.
  • partial: a stated subset.
  • planner: only the host-side planning, layout or admission half is ported.
  • absent: no counterpart.
  • different: a deliberate redesign, not a port.

Verification level (the highest level reached, never a claim about correctness beyond it):

Level Meaning
O Executed on macOS CPU against an oracle built from the unmodified Original (Python tool or the Original's own C++ host code compiled on the dev machine), committed as goldens or run live.
T Rust unit or integration tests executed on macOS with no Original oracle (self-consistency, invariants, hand-derived values).
L Type-checked for x86_64-unknown-linux-gnu (cargo check --all-targets, leleka-cuda-driver with --features cuda-driver, leleka-runtime); the tests compile but were not run.
S Source only: no GPU run and no numerical check. Thirty .cu files were compiled with nvcc 13.2.86 and their PTX sealed on 2026-10-15 (pin = checked-in bytes); that is a build and provenance fact, not evidence of correct output.
G Run on a GPU. No row in this table has this level.

A .cu file may sit at S while its Rust host side sits at L or O; both are named when they differ. A committed .ptx file is evidence of a build only where its pin is frozen (30 assets sealed 2026-10-15; six placeholders remain, see the end of this page); GPU load is verified separately by the host smokes.

Offline tooling (Python oracle, engine/strata/tools, setup.py, serve/)

Original unit Rust file(s) Completeness Verification
iq_pack.py dense and expert paths, --compat-bf16, --base, experts.bin control-plane/src/native_pack.rs full for the default and optional paths; documented divergences in docs/offline-port.md O: live scripts/offline/diff_native_pack.py (2755 cases + 12 CLI cases), six real golden expert tables as unit tests
gguf_reader.py header, tensor directory, geometry crates/model-format/src/gguf.rs, control-plane/src/gguf_json.rs full for the header; stricter on alignment O: diff_gguf_header.py (400 cases), gguf_headers.json
strata_tokenizer.py crates/tokenizer, control-plane/src/tokenizer_assets.rs full for gpt2/qwen35 O: diff_tokenizer.py (all five assets, ids, every Unicode scalar x 13 contexts), committed tokenizer_oracle.json
gguf-py / iq_fixture.py dequantization control-plane/src/ggml_bridge.c, crates/quant-core full for 23 block types O: diff_dequant.py (69 fixtures, bit-exact f32); Q3_K, Q4_0 and Q5_0 are not in quant-core (covered by the pinned ggml bridge)
embd_bf16_pack.py, ple_fp8_pack.py, draft_vocab.py, make_profile.py crates/offline-tools full O: diff_tools.py, tools_oracle.json
mtp_rt.py crates/offline-tools/src/mtp_rt.rs full O: diff_tools.py
mtp_fetch.py control-plane/src/mtp_fetch.rs full O: diff_mtp_fetch.py and tests/mtp_fetch.rs against a local HTTP mirror
mtp_pack.py (BF16 to Q2_0/Q4_0/Q8_0 experts GGUF) control-plane/src/mtp_pack.rs is a structural validator of the output only partial: validator only, producer absent T
setup.py RoPE and RAM/context policy crates/context/src/setup_policy.rs full for the pure policy functions O: setup_policy_oracle.json
serve/frontend.py ChatTemplate control-plane/src/prompt.rs (minijinja 2.24.0) full for the pinned template O: diff_chat_template.py (3000 cases), chat_golden.json (10 cases)
Service.reasoning_budget / Service.run control-plane/src/reasoning_budget.rs, crates/serving-policy/src/reasoning.rs full as a pure loop; not wired into the live worker O: 247 budget lookups, 400 generations of the real Service.run
pack_index.py, strata_pack.py, pack_layer.py, canonical_xcheck.py none absent by decision (Q2_0/AVX-512 path only) not applicable
setup.py hardware probing, installer, AMD/HIP/Windows parts none different (doctor.rs, cuda_memory.rs, preflight.rs, service_*.rs) T

Serving, API and policy

Original unit Rust file(s) Completeness Verification
serve/server.py operational routes (/props, /slots, /v1/status, /settings, /load, /unload, aliases, CORS, idle unload, reload gates, stall watchdog) control-plane/src/{app,server_api,worker,config,models_api}.rs, crates/serving-policy partial: web UI, telemetry (NVML/sysfs) and vision are absent O: replayed against the real Python handlers (tests/fixtures/golden/http_surface.json), serving-policy goldens built from Original host code
/v1/chat/completions, /v1/messages, /v1/responses, SSE, tools, schema validation control-plane/src/{chat,messages,responses,response_tools,tool_output,stream_parts}.rs full for the text and function subset; stop sequences and some penalties are rejected T: mock worker and recorded fixtures; no comparison against the upstream server
MCP hub (serve/mcp.py) control-plane/src/mcp.rs stdio and Streamable HTTP T: tests/mcp_hub.rs
Sampling request keys (sampling_keys, GEN grammar) control-plane/src/{sampling,wire}.rs, crates/sampler-ref/src/params.rs full O: golden GEN strings lifted from server.py by AST
serve/structured.py responses.rs, response_tools.rs full parity (validation only, no grammar decoding) T
core/conversation_{cache,buffer,memory,state,snapshot}, program/conv_cache.hpp, parking, checkpoint chain crates/leleka-runtime/src/conversation/ full for policy and accounting; GPU snapshot bound through the session owners O for cache and manager (conversation/golden); L for the CUDA-bound snapshot
(not in the Original) memory governor: startup budget that refuses what cannot fit and sizes the caches from what is left, pressure monitor (shed, then 503 memory_pressure + Retry-After), allocation inventory and load ledger, sealed-memfd lock / swap detection / heal crates/leleka-memory, crates/leleka-runtime/src/memory_governor.rs, control-plane/src/memory_view.rs; docs/memory-safety.md new in the port; model-free policy, state machine, planner, mapping and soak tested (Miri clean on the pure modules) L: see docs/memory-safety.md for the 5090 jobs 910-917 and the WSL2 swap A/B
(not in the Original) cross-session prefix cache: content-addressed blocks and checkpoints in host RAM, pool summary / prefix_match crates/leleka-runtime/src/prefix_cache/, qwen_forward/original_serve_prefix.rs, control-plane/src/prefix_view.rs; docs/prefix-cache.md new in the port; model-free policy and store tested, bound to the real model on the 5090 and the laptop L: greedy ids of every cached request equal a full read on the same chunk grid (jobs 921-927)
cvec.{hpp,cu} host loader, SVE1 embedding files, M-RoPE positions crates/serving-policy/src/{cvec,vision}.rs, crates/experimental-ref/src/cvec.rs host side full; device apply is the experimental program below O (gen_cvec_fixtures.cpp, gen_vision_fixtures.cpp)
program/logits_selection.hpp, core/progress.hpp crates/serving-policy/src/{stride,watchdog}.rs full O (golden vs the C++ header)
platform/direct_file, ngram/ple_reader (async O_DIRECT row reader) crates/model-format/src/ple_reader*, leleka-runtime/.../qwen4exp_ple_reader.rs partial: async reader with page dedup and row cache; O_DIRECT is Linux-only T (macOS), L
platform/memory.cpp mlock, DXGI none absent (Windows branch out of scope) not applicable

Sampling and speculation policy

Original unit Rust file(s) Completeness Verification
sampler.hpp, host reference of sampler_parity.cpp (Philox, penalties, top-k/top-p/min-p, temperature, pick) crates/sampler-ref full O: 322 cases from the unmodified Original host reference, bitwise; mutation checks fail the suite
coupled_draft.hpp counter and ring arithmetic crates/sampler-ref/src/coupled.rs full O (cross-checked against mirror_pick; the kernels have no host twin)
sampler.cu kernels crates/cuda-driver/src/original_sampler{,_params,_ffi,_mapped}.rs, original_sampler.cu, native_head_sampler.cu full source; SamplerParams ABI checked O for the 64-byte ABI and helpers; S for the kernels; PTX sealed with nvcc 13.2.86 on 2026-10-15 (no GPU run)
Per-request host sampler on the plain decode path leleka-runtime/src/qwen_forward/step_sampler.rs, output.rs full O (shim crate, oracle/run_port_host_tests.sh), L
spec/{suffix_drafter,draft_policy,controller} leleka-runtime/src/qwen_forward/original_spec_{policy,suffix,controller,draft}.rs full; the controller is unused by the Original's production path T: fake-engine state-machine tests; L
generate.cpp serve loop (draft, verify, commit, rollback) original_serve_engine.rs, original_serve_native.rs, cuda-driver/.../original_spec bindings, original_mtp_verified_adapter.rs partial: concrete engine over a verifier/session/draft port; selection in the actual serving owner open T with a fake engine; L
reasoning_budget wrap-up see offline table full, not wired O

Memory, context and RoPE

Original unit Rust file(s) Completeness Verification
rope_scaling.hpp, rope.cu build_rope_table, rope knobs crates/context/src/rope_scaling.rs full O: 16 table configs bit-for-bit (FNV over 524288 rows), 9 invalid configs
plan.hpp, plan_main.cpp, kv_pool_bytes, kv_q8.hpp, kv_q4.hpp crates/context/src/memory_plan.rs full O: 78 planner runs byte-for-byte, 80 kv_pool_bytes rows
Context policy, geometry of the native QSA stack, PTX ABI detection crates/context/src/{context_policy,geometry,ptx_abi}.rs Leleka-own policy (not an Original unit) T: default unchanged, 2x256K, 1x512K YaRN, refusals, boundaries
262144 pin lift in the driver and runtime cuda-driver/src/serving_context.rs, leleka-runtime/src/serving.rs and threaded call sites applied; four .cu sources edited, committed PTX not regenerated L; default context is asserted equal to the frozen literals
Planner under-reports indexer keys by 96 bytes per token and layer preserved literally n/a documented in docs/rope-and-memory-plan.md

Model forward leaves (CUDA sources plus Rust owners)

Original unit Rust file(s) Completeness Verification
Embedding, native head, NativeEmbed (layer.cpp, native_head.cpp) cuda-driver/src/native_head*.rs, native_head_{iq,native,sampler}.cu, leleka-runtime/.../output_native*.rs partial: head banks complete; native_dense.cpp has the planner half only S, L; head assets sealed with nvcc 13.2.86 on 2026-10-15 (no GPU run); model-format/src/native_dense_plan.rs is T
PLE hash, gather, post-ops, batch, KAR PLE cache qwen_forward/{input_hash,kar_ple_cache}.rs, ple_native_batch.cu, ple_prompt_device.cu, offline_ple_kernel.cu hash full; post-ops partial (prompt batch path) hash T; kernels S, host L; KAR PLE cache is an independent Leleka implementation, not a port
GR / hyper-connection (gr.cu, fused_gr.cu, native GR, prefill gr_*) mtp_original_full_*gr*.cu, gr_native_batch.cu, gr_prompt_device.cu, gr_*.rs partial: all variants present as source for MTP and prompt; target-decode fused GR is wired only through the window planner S, L; window planner T
GDN (4 variants) gdn_*.rs, offline_gdn_*_kernel.cu, original_verify.cu partial: fused T1, prefill option B and verify-multi are literal or adapted; legacy gdn.cu and native_gdn.cu are re-derived S, L; scalar helpers T
QSA decode / prompt / select / indexer / post-ops qsa_native_decode.cu, qsa_prompt_{attention,select,indexer,postops,kv}.cu, qsa_*.rs partial: INT8 split-K decode, prompt INT8 v2, select and indexer present; FP16 and WMMA prompt kernels and native_qsa_score absent S, L; kernel model pieces T
Dense GEMV (native_mmvq, iq_kernels, BF16, S-forms) native_head_native.cu, native_head_iq.cu, mtp_original_full_{bf16,head_*}.cu, s_gemv_legacy.cu, cuda-driver/src/s_gemv_legacy.rs partial: native and IQ present; legacy S-forms have a planner and summation-order model with a host-executed oracle S; S-form oracle T
Prefill MMQ / grouped MoE (moe_mmq.cu, vendored ggml-cuda), copy1/strata_q2/iota mmq_original_*.rs/.cu, third_party/llamacpp, mmq_original_prefill_misc.cu partial: native IQ MMQ path; Q2 kernels added with host-executed goldens S, L; goldens T
MoE router, shared expert, combine, grouped expert mtp_original_full_{router,shared,combine,s2}.cu, moe_route_top10.cu, moe_*.rs full source S, L
Elementwise, quantize_act, device poison mtp_original_full_{element,quant80}.cu, device_poison.cu, device_arena.rs full S; arena T
Short-context FlashAttention native_flash_attn.cu, native_flash_attn.rs (admission model) full source (opt-in in the Original) S; admission model T with a host-executed oracle
CPU expert pool crates/native-cpu-expert full source, Linux x86-64 only L; parity binary exists, not run
Expert cache, slots, stager, file source, STRP profile, adaptive policy cuda-driver/src/original_{expert_cache,expert_slots,expert_stager,file_expert_source}*.rs, leleka-runtime/.../cache_*.rs, original_cache_startup.rs full for the host owners; RAM-source and non-Linux paths absent L, T for pure policy
pinned.cu shared-file arena model-format/src/pinned_arena_plan.rs planner (header, registration plan, parallel load) T
Layer split, remote experts, set_stage handoff experimental-ref/src/remote_experts.rs (planner only) planner; second-GPU context, staging and launches absent; handoff not done by decision (docs/port-remaining.md section 6) O for selection, grouping, metadata, scatter

MTP, verifier, prefill and session

Original unit Rust file(s) Completeness Verification
MtpDrafter::load/bind/kv_restore cuda-driver/src/original_mtp_{rt,bank,loader,draft_head,actor_loaded,coupled,round_lifecycle}.rs, leleka-runtime/.../original_mtp_* source-complete (branch claude/port-mtp-loader) T for loader planning, L; GPU proofs are #[ignore] (original_mtp_bank_gpu)
MTP forward, prefill, INT8, ring (mtp.cpp record/capture/draft) mtp_original_*.rs, mtp_original_*.cu partial to full literal source S, L
Verifier arena, schedule, journals, accepted-prefix commit original_verify{,_layout,_schedule,_logits,_diag,_profile,_mapped}.rs, original_gpu_schedule.rs, qsa_verification_commit.rs, original_verify.cu, original_verify_qsa.cu partial: public release/diag/profile/logit readout added; multi-GPU stage handoff absent S, L
record_window window recorder original_verify_window_{ops,plan,planner,proj,gr,qsa,moe,record,kernels,gpu}.rs planners complete for every producer; whole-window planner harness covers every T, both splits and PLE T (planner order against verify.cpp), L; original_verify_window_moe_experts and ..._qsa_gate unsealed, so the window fails closed
Runtime wiring of the window (weights, journals, CPU pool callbacks, graph registration) not done absent not applicable
Prefill::run scheduling original_prefill_{layout,arena,schedule,schedule_crosscheck}.rs, original_{moe_prompt_device,expert_stager,stream_all}.rs scheduling model plus extracted-C++ golden traces, prompt scheduler caller O for the scheduling traces, L
Session state, carve, RoPE registration, checkpoint original_session_{state,qsa_init,rope}.rs, session_checkpoint.rs, original_conversation_state.rs partial: optional session.cpp graphs not certified T, L

KAR and experimental modes (Leleka and optional Original features)

Original unit Rust file(s) Completeness Verification
KAR-2 writer, codec, overlay, CPU decode oracle control-plane/src/kar*.rs, crates/model-format/src/kar*.rs full (Leleka-own; oracle is the external koference tool) O against koference constants; archives verified on real shards earlier (Linux)
KAR level 2..5 decode on CUDA, routed-expert source model-format/src/{kar_nested,kar_kernel_model,kar_levels}.rs, cuda-driver/src/kar_decode_levels*.rs/.cu, leleka-runtime/.../kar_expert_source.rs source-complete, wired behind NativeBackendConfig::kar_expert_source O-like: kernel model bit-for-bit against kar_codec::decode_range over randomized records; PTX placeholder with zero pin; smoke #[ignore]
KAR PLE GPU cache kar_ple_cache.rs, offline_kar_ple_kernel.cu full (independent implementation) the earlier GPU experiments in docs/experiments/2026-10-03-*ple*.md predate the port and are not repeated on it; no oracle here beyond T
Q4_0, K8V4, rotated-INT8 KV, FWHT-256 crates/experimental-ref/src/{fwht,q4_0,kv_q8,layout,cache}.rs, experimental_kv_{q4,q8}.cu references full; forward pass does not consume the formats O (goldens from the Original's host C++, Separate and Fused FMA models); the literal .cu is run by a CPU thread emulator and compared bit for bit
Keyless V-only, query routing experimental-ref/src/{keyless,attn}.rs, experimental_{keyless,qsa_attn}.cu references full; quality gate previously failed, opt-in only O (emulator), S
KV streaming planner and CLOCK resolver experimental-ref/src/kv_stream.rs, experimental_kv_stream.cu references full O (480 plan cases + resolver)
kv_q8.cu INT8 append, kv_stream.cu resolve/copy/reset/stage, --kv-resident (serve path) qsa_prompt_kv.cu, mtp_original_kv.cu, qsa_prompt_resolver.{cu,rs}, qsa_resident_transport.rs, serving_context::configure_kv_resident, StackConfig::{kv_format, kv_resident} full for INT8; fp16/q4_0/k8v4 excluded on the serve path (docs/kv-streaming.md) G: kv_stream_gpu model-free proofs on the RTX 5090 (2026-10-16); real-model long-context run pending
Experimental driver facade, opt-in, pins cuda-driver/src/experimental{,_gpu,_gpu_smoke}.rs, leleka-runtime/src/experimental.rs full; every mode refuses at Load until the consumer is wired (FORWARD_CONSUMER_WIRED) L; entry signatures cross-checked against the .cu text (T)
experimental_routed.hpp, experimental_experts.hpp prefill patches none absent from the imported tree; the patch source is in the git objects of origin/codex/stra10-bounded-kar-cache-gitea (b6563e3); decision: not ported (docs/port-remaining.md section 5) not applicable

What is open for every row

  1. PTX build and seal. Done 2026-10-15 with nvcc 13.2.86 (30 assets, including the four RoPE/stream PTX, original_verify_window_moe_experts, original_verify_window_qsa_gate and experimental::PINS; GPU load is verified separately by the host smokes, no numerical claim). Still open: seal the six remaining placeholder PTX (mmq_original_group_*, mtp_original_scalar_{gr,norm}, native_parity) and resolve the fast-math question in docs/cuda-seal-plan-additions-window.json. The seal-plan JSON files in docs/ list the recipes.
  2. Linking and wiring. Window recorder runtime wiring, the serving owner that selects OriginalSpecController, the multi-GPU stage handoff, and the consumers for the experimental formats.
  3. Linux execution. Run the Linux-gated tests of leleka-cuda-driver and leleka-runtime, then the #[ignore] GPU smokes on the GPU host.
  4. Original17 parity. Greedy token-id equality against the Original on shared prompts, then seeded sampled-path parity.
  5. Gates. Performance and quality gates from PROJECT_CHARTER.md; docs/performance-ledger.md has no entries.