Skip to content

perf: streaming I/O overlap — preadv coalescing, Inkling shadow prefetch + pipelined prefill - #21

Merged
NeelM0906 merged 6 commits into
mainfrom
claude/streaming-io-overlap
Aug 26, 2026
Merged

perf: streaming I/O overlap — preadv coalescing, Inkling shadow prefetch + pipelined prefill#21
NeelM0906 merged 6 commits into
mainfrom
claude/streaming-io-overlap

Conversation

@NeelM0906

Copy link
Copy Markdown
Owner

Phase B of the roadmap's Task 14 streaming workstream. Stacked on #20 (retarget to main once that merges).

Changes

  • Task 14e — read coalescing: expert misses whose blobs are exactly contiguous on disk (uniform stride or permuted `expertOffsets`) are grouped into runs and fetched with one scattered `preadv` per run — one syscall + one sequential NVMe read instead of a random `pread` per expert. Applies to the cache-plan path and the speculative/async fill path.
  • Inkling pilot/shadow speculative prefetch: `SpeculativeRouterInkling` mirrors the DSV4 pilot (layer L+1's sigmoid router on layer L's post-attention state, same kernels, bit-identical ranking) feeding the existing reserve/read/join/confirm machinery. Opt-in via `MFERENCE_SPEC_PREFETCH=shadow` until an install A/B accepts a default, matching how DSV4 earned its shadow default (+17.8% / +13.7% there).
  • Inkling prefill pipeline (depth 1): `prefillInklingChunk` no longer serializes fetch→encode→drain; expert e+1 is preaded while expert e's GLU runs, misses placed only in slots the in-flight buffer doesn't touch. Output byte-identical (serial queue + hazard tracking preserves accumulation order). Kill-switch: `MFERENCE_INKLING_PREFILL_PIPELINE=0`.

Tests

  • 6 new coalescing tests (run grouping, permuted offset tables, EOF mid-run, speculative fill) — all correctness paths of the new `preadv` reader.
  • `SpeculativeRouterInklingTests`: pilot prediction bit-identical to the real router readback on identical inputs.
  • Env-gated (`MFERENCE_INKLING_GTURBO`) off-vs-shadow greedy identity test for install hosts.
  • Full suite: 1086 tests, 175 suites, green.

TODO before defaulting Inkling shadow on

  • A/B on a host with the Inkling install (this machine no longer has the 148 GB payload)
  • DSV4 decode re-bench to size the preadv coalescing win

🤖 Generated with Claude Code

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5bd63627b8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Sources/Mference/Runtime/Inference/RealForwardRunner.swift
NeelM0906 added a commit that referenced this pull request Aug 21, 2026
Codex review on #21: a throw mid-pipeline (failed prefetch pread, drain
surfacing a GPU error) exited prefillInklingChunk with the pending
command buffer still running against the persistent act/acc scratch,
racing an immediate reset or retry. A scoped drain now waits it out on
every exit path.
NeelM0906 added a commit that referenced this pull request Aug 26, 2026
Codex review on #21: a throw mid-pipeline (failed prefetch pread, drain
surfacing a GPU error) exited prefillInklingChunk with the pending
command buffer still running against the persistent act/acc scratch,
racing an immediate reset or retry. A scoped drain now waits it out on
every exit path.
@NeelM0906
NeelM0906 force-pushed the claude/streaming-io-overlap branch from 6b950ba to b965e04 Compare August 26, 2026 17:36
Base automatically changed from claude/qwen38-longctx-ssd-kv to main August 26, 2026 18:15
Misses whose blobs are exactly contiguous on disk (uniform stride or a
permuted expertOffsets table) are grouped into runs and fetched with one
preadv per run — one syscall and one sequential NVMe read instead of a
random pread per expert. Applies to both the cache-plan path and the
speculative/async fill path. Roadmap Task 14e.
SpeculativeRouterInkling mirrors the DSV4 pilot: layer L+1's sigmoid
router run against layer L's post-attention state inside layer L's own
command buffer, read at the same router wake, feeding the existing
reserve/read/join/confirm machinery and the shadow issue budget. Same
kernels as the real router, so ranking is bit-identical (pinned by a
parity test); a real-install test pins off-vs-shadow greedy identity.
Mode stays opt-in (MFERENCE_SPEC_PREFETCH) until an A/B on the install
accepts a default, matching how DSV4 earned its shadow default.
prefillInklingChunk's routed loop serialized fetch->encode->drain, so
the SSD never overlapped GPU work (the deficiency documented in
docs/INKLING_SMALL.md). Now expert e+1 is planned and preaded while
expert e's GLU runs, with misses placed only in slots the in-flight
command buffer does not touch; accumulation order is unchanged (serial
queue + hazard tracking), so output stays byte-identical. Uses the same
PrefillRoutedTileScheduler contract as the other families.
MFERENCE_INKLING_PREFILL_PIPELINE=0 is the kill-switch.
Codex review on #21: a throw mid-pipeline (failed prefetch pread, drain
surfacing a GPU error) exited prefillInklingChunk with the pending
command buffer still running against the persistent act/acc scratch,
racing an immediate reset or retry. A scoped drain now waits it out on
every exit path.
@NeelM0906
NeelM0906 force-pushed the claude/streaming-io-overlap branch from b965e04 to 91da507 Compare August 26, 2026 18:15
@NeelM0906
NeelM0906 merged commit d5552a0 into main Aug 26, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant