Commit Graph
441 Commits
Author SHA1 Message Date
Pavlo RatushnyiandClaude Sonnet 5.5 1af2d4e2db perf(prefill): deferred guard status is on by default
Job 971 (ABBA, separate processes, 16,000 tokens, chunk 8192, stream + aligned copies): 4,349-4,363 -> 4,553-4,571 tok/s
(+4.8%); final residual R hashes of both chunks and the greedy ids are identical to the immediate guards.
LELEKA_PREFILL_DEFER_GUARDS=0 restores the immediate guards.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-24 00:04:26 +02:00
Pavlo Ratushnyi 1823923fba Merge branch 'claude/prefill-overlap' into claude/port-gpu-bringup 2026-10-23 21:07:52 +02:00
Pavlo Ratushnyi 889a5f96ce Merge branch 'claude/e2e' into claude/port-gpu-bringup 2026-10-23 20:22:04 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 e08eab5fad feat(deploy,e2e): bind the MTP draft vocabulary (--mtp-rt-dir = the MTP pack) in the generated engine command, the e2e runner and the replay
The Original drafts over the 106k-row draft_vocab.bin of data/mtp-rt; the daemon default (rt_directory None) and the smokes drafted over
the full 248k-row head (+0.18 ms per draft step, ledger agent). Jobs 943b/945 ran without it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-23 19:42:01 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 904ac58d3a fix(cuda-driver): fence the staged residual rows (cuStreamSynchronize(0)) before the draft graph reads them; budget: reserve 2 GiB, admit floor soft+reserve, resident fixed footprint measured, plan-vs-actual check; leak scenario, slope fit, heap stats
- stage_first_residual_direct: cuMemcpy D2D is ordered on the legacy stream only; the draft graph runs on a non-blocking stream. The copies are now followed by a legacy-stream
  synchronize (not a context synchronize). Model-free ordering tests.
- memory budget from the real Codex CRM session (e2e job 945): plan constant for the resident bank corrected (+1.1 GiB), reserve 2 GiB, prefix insertions stop at soft+reserve,
  note_post_load compares the plan with the host after the stack opened.
- smoke: leak scenario (30 s RSS anon/file/shmem, meminfo, VRAM, prefix store, mallinfo2) with OLS and Theil-Sen slopes; LELEKA_MEMORY_NO_TRIM A/B knob.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-23 16:17:44 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 242d54a503 perf(prefill): deferred guard status for the prompt producer's run (LELEKA_PREFILL_DEFER_GUARDS=1, experimental, default off): stream-ordered zero + DtoH into a pinned ring, cross-stream event ordering instead of the context drain, evaluated in order before results leave the device
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-23 16:14:53 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 cb843dd7b7 perf(prefill): page-aligned expert supersets in the chunk stream (merged with claude/ledger's ring change)
The stream entries carry the 4 KiB-aligned supersets, their slot offsets and the offsets of the exact pieces; the
gather reads the exact pieces at those offsets (same bytes reach the MMQ slot). LELEKA_PREFILL_ALIGNED_COPY=0 restores
the literal layout in both paths.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-23 16:14:46 +02:00
Pavlo Ratushnyi a6be2e2106 Merge branch 'claude/ledger' into claude/prefill-overlap 2026-10-23 16:09:03 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 9c18bed1a1 Merge claude/port-gpu-bringup into claude/prefill-overlap
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-23 16:08:55 +02:00
Pavlo Ratushnyi 34436ac9c1 perf(prefill): the resident and device QSA attention paths launch the guards with the same full grid 2026-10-23 16:08:09 +02:00
Pavlo Ratushnyi 4f7c4618d3 Merge branch 'claude/quality-gate' into claude/port-gpu-bringup 2026-10-18 05:30:48 +02:00
Pavlo Ratushnyi 0790ba6ec9 Merge branch 'claude/memory-safety' into claude/port-gpu-bringup 2026-10-18 05:09:13 +02:00
Pavlo Ratushnyi 8896b458b4 docs(memory): inventory, tests and laptop results; soak session length bounded by the context 2026-10-18 04:47:02 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 505f3ee70f fix(runtime): output cap 4096 -> 32768 (one shared constant); /v1/status omits a null prefix_cache
The Codex tic-tac-toe run (job 943) ended after 4 minutes: the model wrote the whole index.html in one tool call, hit the
runtime's 4096-token output cap three times (tool call unterminated -> response.failed 'tool parameter is incomplete', then
'incomplete: max_output_tokens' -> turn.failed -> Codex exit 1). The Original server has no such cap (max_tokens 0 = the rest
of the context). RuntimeServer, the engine request check, strata-next's runtime default, the leleka-deploy generated config
and the examples now use leleka_backend_api::MAX_OUTPUT_TOKENS = 32768. /v1/status keeps the Python server's key set when no
prefix cache exists (http_surface golden regressed with the prefix-cache merge).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-18 04:36:37 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 82d7734dde test(memory): reader scenario decodes a fixed number of tokens and lasts until the reader has streamed its volume
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-18 03:57:43 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 e345a7fe56 test(memory): shed smoke re-centres the floors before the recovery phase
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-18 03:50:33 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 052a2fcc22 feat(memory): reserve the hot part of a file-mapped expert bank out of the elastic budget; measured fixed-footprint constant
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-18 03:12:02 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 d561af5f4a perf(prefill): QSA prompt guards launch a full grid (64 blocks left the GPU idle, 2.8 ms per layer)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-18 03:00:21 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 3319a7c10c feat(bank): expert_pieces_aligned helper for the chunk stream issuer
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-18 02:56:35 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 81137d53fc perf(prefill): ring expert copies as page-aligned supersets (LELEKA_PREFILL_ALIGNED_COPY, default on)
The CUPTI ledger shows the ring's three 0.5-0.9 MB expert pieces run at 36 GB/s while the Original's single blobs run at 49.5; pieces start at
expert*piece_bytes (arbitrary offsets) and the roofline probes measure 40.3 GB/s unaligned against 47.7 aligned. Each piece is now copied as the
4 KiB-aligned superset (clamped to the registered tensor) into page offsets of the ring slot (slot +24 KiB), and the gather kernel reads the three
pieces at their lead offsets; same bytes reach the MMQ slot. Not yet measured: job 9002 (hash gate + ABAB).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-18 02:54:57 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 1255374c2a fix(memory): PSI only counts while available memory is below 3x the soft floor (a page-cache reader raised PSI full to 5.2% with 68 GiB free in job 910)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-18 02:42:00 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 51c82250f1 feat(memory): inventory totals separate file-mapped bytes from RAM; swap-out and PSI thresholds are tunable (LELEKA_MEMORY_SWAPOUT_PAGES_PER_S, _PSI_SOME_SHED, _PSI_FULL_REJECT)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-18 02:19:52 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 97227d8c8e fix(serve): the Original serve path stops on <|endoftext|> as the Original does; quality-gate retrieval and ladder jobs
generate.cpp stops on {248044, 248046}; the GGUF eos_token_id is only 248046, so the port ran on
past an <|endoftext|> (up to max_new, emitting <|im_start|> loops). The stop set is now the model's EOS
plus <|endoftext|> in the serve backend, the smokes and the laptop probe.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-18 02:12:54 +02:00
Pavlo Ratushnyi ed389d4de8 Merge branch 'claude/memory-safety-unsafe' into claude/memory-safety 2026-10-18 02:03:00 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 95475335be docs(native-cpu-expert): SAFETY invariants, bounds asserts at the unsafe leaves, pool lifecycle tests
Documents the epoch-claim protocol behind the Shared Send/Sync impls, adds row-length, destination and alignment
asserts at the SIMD leaves and quantize_raw/float_dot/convert_bf16, and tests pool Drop joining and idle-gap stability.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-18 02:01:05 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 218afcda94 docs(cuda-driver): SAFETY invariants for FFI, mapped-host owners, file maps; checked_add in index import; audit tests
Comments only, plus: CUDA_MEMCPY2D layout asserts, checked_add in OriginalQsaResidentIndex::import span validation,
and model-free tests (mapped_audit_*, Records bounds, stager copy-job and file-map bounds, arena bounds, resident
span bounds after truncation).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-18 02:01:05 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 74f4ee07dd fix(cuda-driver): fence the cuMemsetD8 of the full-forward scratch before the first launch
cuMemsetD8_v2 is asynchronous with respect to the host and only ordered on the legacy default stream; the original=false
construction path had no later synchronous copy, so a kernel on a non-blocking stream could race the zeroing.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-18 02:01:04 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 3d9af8a0eb fix(cuda-driver): store-buffering races in the expert stager stop and MMQ host-stage finish, bound host-stage wait
stop/finish stored 'head' then loaded 'active' while a worker raised 'active' then claimed from 'head'; on x86 the
fence could return while a worker still copied from a source the caller then released. SeqCst on the four accesses.
HostStage::finish also let a helper waiting on 'released' overwrite a ring buffer still being read (re-check head after
the wait), and wait() now refuses a length beyond the bytes the job copied (page-locked buffers are uninitialised).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-18 02:01:04 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 0af0bfaed4 feat(memory): return evicted heap to the OS after a shed, planned-vs-measured column in the inventory table, docs draft
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-18 01:57:55 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 b3f2e85ea9 test(memory): prefix serve shed/restore and a churn test under random shed directives (exact resumes, store inside its budget)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-18 01:53:11 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 713235d8ed feat(memory): residency guard on its own thread, read-only remap of the archive, dead-sampler recovery, cgroup v1, swap A/B tool, lint fixes
- guard_archive maps a private read-only reopen of the descriptor (a write-sealed memfd refuses a shared mapping that could become writable on
  kernels up to 5.15); the residency read runs on its own thread; the sampler survives a panic and a stale level is re-evaluated by the
  requests themselves; cgroup v1 memory controller limits (WSL2 hybrid, old container hosts) are honoured.
- examples/swap_ab + scripts/memory/swap_ab.sh: A/B (unlocked, heal, mlock) of the memfd under real pressure fenced into one cgroup.
- Miri: procfs/host/plan/pressure/inventory/census/ledger/governor run clean (61 tests).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-18 01:51:29 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 eead818051 feat(memory): real-model memory smoke (inventory, soak, shed, reader), deploy profiles carry the memory budget
- backend_original_serve_memory_smoke.rs: scenarios inventory / soak / shed / reader and a model-free archive guard probe; floors
  moved next to the memory the host has now so the shed path runs far from the real limit; abort guard at 15 GiB.
- Governor::set_floors; stack prefix_bytes / prefix_budget_bytes accessors.
- leleka-deploy: Profile.memory (prefix_cache_mib, floors, reserve, share, lock, heal, resident budget) -> engine args and
  LELEKA_MEMORY_* environment; built-in profiles carry it; tests.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-18 01:40:43 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 5ebd939b6f feat(memory): wire the governor into the runtime, the gRPC status and the control plane
- leleka-runtime: memory_governor glue (startup plan with refusal, KAR memfd lock/residency guard, VRAM check, load-ledger stages,
  inventory classes), prefix budget from the governor (auto/explicit clamped), shed directive applied per request and per prefill chunk,
  engine-side admission (503 memory_pressure text), page-cache release of the shards after the resident bank load, cgroup-aware
  available_memory.
- backend-api: Backend::memory_report (default None) and ScriptedEngine support; proto Snapshot.memory_json; desktop-core runtime_rpc and
  runtime-client carry it.
- control-plane: MemoryView, /v1/status `memory`, /metrics `memory`, 503 memory_pressure + Retry-After gate before queueing, engine-side
  refusal text mapped to the same 503; tests incl. a 600-request model-free soak (threads/fds/RSS flat).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-18 01:33:34 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 2ecfd42001 e2e: engine request capture (LELEKA_CAPTURE_DIR), offline replay smoke, session analysis headline, CUPTI trigger helper
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-18 01:28:02 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 7da6a63e61 feat(memory): leleka-memory crate: procfs/cgroup/PSI facts, inventory, load ledger, budget planner, pressure monitor, governor, memfd lock/residency guard, census
Model-free and CUDA-free. 64 unit tests (parsers, planner refusals with numbers, shed order and hysteresis, admission, sampler thread,
mlock/mincore/madvise over a descriptor, flatness check).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-18 01:20:21 +02:00
Pavlo Ratushnyi 1cd52bc388 Merge branch 'claude/port-gpu-bringup' into claude/e2e 2026-10-18 00:59:49 +02:00
Pavlo Ratushnyi 7330ddb6d5 Merge branch 'claude/prefix-cache' into claude/port-gpu-bringup 2026-10-18 00:57:29 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 e9d7db4392 perf(prefill): the expert stream starts at 4096-row chunks (2048-row chunks copy ~40% unrouted experts and lose 20%)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-18 00:43:05 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 6ed9763278 perf(prefill): the chunk expert stream is on by default (issuer depth 2, zero uploads as memsets)
Paired A/B in one process (job 958): 16,000 tokens, chunk 8192: 4,805-4,811 tok/s with depth 2 vs 3,795-3,799 with the
per-layer ring, identical greedy ids. LELEKA_PREFILL_STREAM=0 restores the per-layer ring.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-18 00:35:38 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 25538a8300 docs(prefix-cache): design, protocol, knobs, results (5090 jobs 921-926, laptop), remaining; 180k policy simulation; port-status row
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-17 23:54:47 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 9fdc1f4919 test(prefill): scoped drain stream selection
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-17 22:33:35 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 8e2d534791 perf(prefill): zero uploads become memsets while the expert stream runs (default), issuer depth override for sweeps
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-17 22:32:17 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 dba10288dc fix(prefix-cache): a hit counts as shared evidence only on a branch point (histories fork below it), not because another session ran in between
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-17 22:12:25 +02:00
Pavlo Ratushnyi 8daba240d7 Merge branch 'claude/port-gpu-bringup' into claude/decode-parity
# Conflicts:
#	crates/leleka-runtime/src/qwen_forward/original_serve_residency.rs
2026-10-17 21:31:37 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 b3da9af763 feat(prefix-cache): default block/grid = prefill capacity (prefill at the chosen chunk speed)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-17 21:19:50 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 42f1edaf70 perf(serve): CPU leg: validated spans of admitted experts are reused without the per-expert source scope (LELEKA_OPEN_CACHE=off controls); spans inside the CPU leg
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-17 20:49:43 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 0ac97bf63a test(quality): long-context retrieval check (100k/180k) with teacher forcing in the long smoke
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-17 20:47:02 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 c32cfed135 fix(prefix-cache): a miss clears the live claim (the empty-prompt reset rewrites the first index row), budget profiles for the real RAM picture, import profiling spans
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-17 20:34:53 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 8af18396b8 feat(prefix-cache): pool protocol (summary through runtime gRPC, /v1/status, /v1/prefix_match), --prefix-cache-mib/--prefix-cache-block, laptop profile in the smoke, docs
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-17 19:47:53 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 d53db650fd test(prefix-cache): GPU smoke harness for interleaved agent sessions, model-free GPU round-trip of the K/V and index transfer
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-17 19:12:17 +02:00