Skip to content

docs: les-plan.md — LES ideas on the NVMe/host tier's decode (design + experiment plan) - #112

Merged
midagedev merged 3 commits into
mainfrom
cursor/les-plan-bb9a
Oct 13, 2026
Merged

midagedev merged 3 commits into
mainfrom
cursor/les-plan-bb9a

Conversation

@midagedev

Copy link
Copy Markdown
Owner

What and why

This PR adds docs/research/les-plan.md, a design and experiment plan with no engine code. It covers which ideas from LES (Lookahead Expert Scheduling) give a measurable decode speedup on the paged-expert path in 0.3.3, and how a separate worker builds and measures each one.

Current state on main d90151ed:

  • Plain one-column decode (Chain::Step, draft off) still waits for every miss before computing. It fills synchronously on the compute pool (moe.rs:2600-2610 → nvtier.rs:2211-2266).
  • Multi-column steps (the draft's verify columns, Chain::Cols) already compute resident experts first. Their misses go to the reader at a step rank (4d6dbeb2, moe.rs:1850-1939).
  • Gate lookahead exists only as a plan (tierengine S5). There is no predictor and no Kind::Prefetch.
  • Reads per expert: three serial 4 KiB-aligned O_DIRECT preads, one per stacked tensor (nvtier.rs:1409-1418, :2354-2373). A single miss therefore reads at QD 1.

Ranked levers. Bands are derived from the refill card's admissible 42.21 tok/s shape and the gate plan:

  1. C2, part units: read a fill's three parts at once.
  2. C1, resident-first on the one-column step: the code exists; route the step to it.
  3. C3, cross-layer prefetch: opened only if the replay gives a miss recall of at least 0.34 and an oracle-prefetch ceiling run clears the ruler.

Contiguous repacking and GPU-visible writes predict about 0 on the discrete box. Mixed precision and the draft stage are maintainer questions.

The doc also gives the counters to add, the ablation order, pass/fail per experiment, how outputs stay bit-identical, tasks T0–T8 with the files each touches, and six questions for the maintainer. Nothing in it touches a release, a default or a public API.

Code shape

  • No second copy. C1 reuses serve_step_split rather than adding a one-column copy.
  • Model code holds only architecture facts. Not applicable (doc only).
  • Dead code is gone. Not applicable.
  • No silent failure. Not applicable.
  • Comments state what is true now. Not applicable.
  • No relaxed gate.
  • cargo fmt and cargo clippy are clean on what I touched: no Rust was touched.

Duplication found or removed: none.

What I ran

Read-only code analysis and arithmetic. No build, gate or box run; every number is tagged [measured, source], [derived] or [assumption].

Hardware (if the change is for a machine)

None.

Open in Web Open in Cursor 

…e, ranked levers with derived bands, experiment design and worker tasks

Co-authored-by: midagedev <[email protected]>
@midagedev
midagedev marked this pull request as ready for review October 13, 2026 21:17

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Verdict: MUST_FIX: The plan names the wrong gate for its split-path FAIL-first and contains an incorrect derivation.

Must fix

1. Name the gate that exercises the split path (kind B)

docs/research/les-plan.md:236 says a landing-order sum in the split path makes gate-union red. That recipe runs only --test union, whose calls use experts_union_into; it never enters serve_step_split.
The existing split-path bit-identity test calls experts_step_union_into at crates/model/src/moe.rs:4391. justfile:832 runs it under gate-ops via --lib.
Correct the attribution now so the implementation plan uses the gate that reaches the mutant. Replace the FAIL-first bullet with:

- Sum the split path in landing order: run `gate-ops`'s existing split-path bit-identity test and confirm it goes red.

Also attribute the split-path contract at line 228 to gate-ops. Keep gate-union for the ordinary union contract; no additional split-path test is needed for this correction.

2. Correct the miss-layer derivation (kind B)

docs/research/les-plan.md:103 evaluates 48 × (1 − exp(−4/48)) as 3.5. It is 3.837868. The value feeds the gain bands and the replay's open/close threshold at line 139.
Correcting the arithmetic before the experiments prevents judging a replay against a threshold derived from the wrong value. Use:

L = 48 × (1 − exp(−f/48)) ≈ 3.84 at f = 4 [derived].
The recall bar is r ≥ 0.58 / (3.837868 × 0.49) ≈ 0.3084; round up to 0.31 [derived].

Propagate this L through the dependent bands and use the corrected recall bar consistently in the candidate and experiment tables. Alternatively, retain 3.5 only as a separately stated assumption, without claiming it evaluates the printed formula.

Non-blocking

⚠ Charge C1's handoff per miss layer: docs/research/les-plan.md:115.
The assumed 0.05–0.15 ms/job costs 1.48–4.43 ms/token at G's 29.5 miss layers. The +7..+9 % band omits that cost.
Use gain = L × (min(t_hits, t_fill) − t_handoff) and recompute E3's band before using it to judge a run.

Checked

Duplicates: 0 new implementation items; no dryer pairs. The split-path test already exists.
Complexity: no functions changed.
Silent failure: no executable code added.
Tests: none changed; static tracing confirms gate-union misses the split path and gate-ops includes its bit-identity test. No mutant was executed.
Gates: no existing pins, thresholds or cases changed.
Performance: documentation only; no hot path changed.
Escape catalog: C1–C4 do not match this diff.

Notes

dryer and crapper did not run because no Rust file changed. No build or gate was run.

🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since the last review:

Verdict: CLEAN: The earlier findings are resolved, and the documentation changes introduce no blocking defect.

Checked

Duplicates: 0 new implementation items checked; no dryer pairs. The plan reuses the existing split-path test.
Complexity: no functions changed; no crapper results.
Silent failure: 0 new executable sites; no error handling changed.
Tests: none changed. gate-ops includes the existing split-path test, which calls experts_step_union_into and compares output bits against experts_into at crates/model/src/moe.rs:4394. The split path sums at moe.rs:1937. No mutant was executed.
Gates: planned replay cutoff corrected from 0.34 to 0.31; no executable gate or pin changed. At recall 0.31, predicted hidden time is 0.583 ms, above the stated 0.58 ms ruler.
Performance: documentation only; no hot path changed.
Escape catalog: C1–C4 do not match the diff.

Notes

dryer and crapper did not run because no Rust file changed. No build or gate was run; the PR supplies no new GPU gate evidence.

🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)

@midagedev
midagedev merged commit 45836b1 into main Oct 13, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants