pkg-s16 (51b36adf7), 9/30 requests: RING-REFUSE layer=46|47 check=stage.slot_not_gathered reserved=0
slots=384 sources=410..460. With prefetch hits the copies skip the hit sources, so once a layer's sources exceed
the ring the wrap reaches a slot holding an earlier source's copy that is not gathered yet; the stage_room
shortcut (reserved == 0) then let stage_one refuse.
- stage_target (leleka-cuda-model ring_prefetch) searches forward, wrapping, for the first slot that is not
reserved and free (never filled or gathered); without a prefetch it is stage_next itself (the literal ring:
copies and gathers in one order, lookahead one short of the ring).
- Ring::stage_room: no reserved shortcut; "no copy needed or stage_target finds a slot", so the walk waits for
a gather instead of refusing.
- Host tests: 200 seeds of 460 sources / 384 slots with random prefetch hits among the first 300, other sizes;
the model asserts no stage onto a reserved or unread slot and that stage_target refuses only when no
unreserved slot is free (both fail with the old stage_target). 18 tests.
Switch stays OFF by default. Not run on a GPU.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
PET.1 (3ba2a0e37, LELEKA_PREFILL_RING_PREFETCH=1): 5/12 requests failed with InvalidProjectionShape.
The slot bookkeeping the suspects named (prefetched source staged again, reserved slot reused, gather of an
empty / read slot) is now the pure SlotState / stage_needed / stage_target of leleka-cuda-model::ring_prefetch,
called by the driver's Ring and by the host tests: none of those paths is reachable. The unreviewed change was
the compute_drain background stream (process-wide: scoped drains that skip unregistered streams, memsets for
zero uploads, deferred frees in the small-chunk mixers/routers while copies are pending). It is now opt-in:
LELEKA_PREFILL_RING_PREFETCH_DETACH (policy field detach_drains, default off); by default the drains stay
context-wide.
- RING-REFUSE trace under LELEKA_TRACE_DRIVER_ERRORS / LELEKA_BRINGUP_TRACE (passed in with
set_ring_error_trace; no env read, no new global): one line naming the refused check (new.validate,
new.schedule_slots, layer.preflight, sources.spans, stream.*, stage.*, gather.*, enqueue.*) with layer,
source, stage_next, reserved, slots; RING-PREFETCH lines for issued / hits / wasted / dropped / cancelled.
- Host tests: 15 (prefetched source never staged again, reserved slot skipped until its gather then reused,
gather reads a slot exactly once, distinct refusal names, detach default off) plus a settings test row.
- Without the prefetch, stage_one / gather keep the literal checks and order (stage_target from stage_next).
Switch stays OFF by default. Not run on a GPU.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
After a layer's copy ring drained, the experts the next layer missed most often in its last N chunks (per-layer
miss history, top K <= ring/2, none on the 8-slot ring) are copied into the next ring's stage slots on the copy
stream, overlapping the combine and the next mixer. The next Ring::new adopts the set: a routed, non-resident
source with the same host bytes reads its prefetched slot (reserved until its gather, ordered by the slot's
copied event); the rest are dropped. stage_one skips reserved slots; the stage-ahead walk waits for a gather
when the next free slot is still live. Same experts, kernels and group order: bitwise neutral by construction.
A set no ring took is drained on end_prompt_stream / begin_prompt_stream / close.
- leleka-cuda-model ring_prefetch: policy, MissHistory ranking, match_prefetch, next_unreserved_slot (+ host
model of the reserved-slot ring walk), 10 tests
- driver: policy passed via OriginalMmqCopySchedule::set_ring_prefetch (no env read); counters
ring.prefetch_issued / _hit / _wasted / _failed (MB), span ring.prefetch_issue
- engine: ServeSettings::prefill_ring_prefetch (+ _WINDOW), settings test; issue from run_prompt_layer
- docs/experiments/ring-prefetch.md: design, switch, counters, GPU validation plan (R-hash identity, A/B by tail)
Not run on a GPU: no identity probe, no A/B, no speedup claimed.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>