Skip to content

research/load_templates: weight-loading IO templates with pipelined pre-warm (PPC/MAIO FAST '26, engine#87, HIP-1345 §2.4) - #111

Closed
breezesamuel wants to merge 1 commit into
hanzoai:mainfrom
breezesamuel:load-templates-research
Closed

breezesamuel wants to merge 1 commit into
hanzoai:mainfrom
breezesamuel:load-templates-research

Conversation

@breezesamuel

@breezesamuel breezesamuel commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Research deliverable for #87 ([Bounty #14] Model-loading IO templates, PPC/MAIO FAST '26, HIP-1345 §2.4): a bounded clean-room implementation of the record-once/replay-pipelined load-template mechanism in hanzo-bench (load_templates module), with the synchronous serial demand baseline, a head pre-warm policy, raw measurements across three checkpoint layouts × three storage/link scenarios, the HIP-1345 §2.4 status update, and an explicit out-of-scope statement.

Contract coverage (6-point)

  1. Paper & license audit — PPC/MAIO (Liu et al.; FAST '26): learn model weight-loading access sequences and pre-warm pages across NVMe/host/device before serving; the authors' up-to-79% load-latency reduction is their environment's number, not a Hanzo expectation (per the bounty's own caveat). No public reference code exists to our knowledge; nothing was ported — clean-room from the objective. Module is stdlib-only, MIT OR Apache-2.0 dual license.
  2. Matched baselines — demand load (synchronous serial NVMe→host→device) vs template pipeline (two-channel replay with a bounded host staging window) vs head pre-warm + pipeline, on the identical 512-page/8 GiB page set and recorded order. Three layouts (contiguous / 4-shard strided / mmap-random deterministic permutation) × three scenarios (NVMe 7 GB/s + PCIe 12; SATA 500 MB/s + PCIe 8; NVMe 7 + PCIe 3 link-bound). Raw rows committed in hanzo-bench/results/load-templates-results.json.
  3. Falsifiable hypotheses (pre-declared) — L1: pipelining converts Σ(read+copy) into max(Σread, Σcopy)+startup, collapsing to ~1.0× in the storage-bound regime; L2: layout access patterns dominate absolute latency more than policy dominates the ratio; L3: a budget-sized head pre-warm breaks even after one replayed session; L4: the staging-window gate bounds host occupancy and the occupancy column honestly reports when it binds. Observed values for all four in the results file.
  4. Deliverable — hanzo-bench/src/load_templates.rs (page identity, layout orders + configured NVMe layout penalties, LoadTemplate recording, demand/pipeline/head-prewarm policies with the gated two-channel recurrence, break-even metric, 8 tests) + hanzo-bench/examples/load_templates_bench.rs + results JSON + HIP update. Bounded: one module, one example, no engine changes.
  5. Evidence — 8 tests: layout orders are permutations, demand identity (exact serial sum), pipelined ≤ demand, staging-window producer-lead bound, head-prewarm monotonicity, head=0 ≡ streaming pipeline, empty-template zeroing, zero-savings break-even. cargo test green on windows/amd64; module is stdlib-only.
  6. Measurements + HIP update — raw numbers in results/load-templates-results.json; results/HIP-1345-update.md proposes the §2.4 addendum (weight-loading half; the LoRA paging half is engine PR hanzo-kv-fabric: multi-tenant LoRA adapter paging (S-LoRA / HIP-1345 s2.3, Bounty #15) #104) and carries the out-of-scope statement.

Key results

scenario / layout demand pipeline head pre-warm + pipeline
1 balanced, contiguous 1.94 s 1.23 s (1.58×) 0.92 s (2.11×)
1 balanced, mmap-random 5.62 s 4.91 s (1.15×) 3.68 s (1.53×)
2 storage-bound, contiguous 18.25 s 17.18 s (1.06×) 12.89 s (1.42×)
3 link-bound, contiguous 4.09 s 2.87 s (1.43×, window pinned at 2 GiB) 2.86 s (1.43×)
3 link-bound, sharded 5.32 s 2.87 s (1.85×) 2.86 s (1.86×)

Findings worth the maintainers' time

  • The pipeline buys overlap, not bandwidth: in the storage-bound (SATA) scenario the streaming win collapses to 1.02×–1.06×; it peaks when the two channel times are comparable. Head pre-warm is what still pays in the storage-bound regime (1.35×–1.42×) because it moves 2 GiB off the critical path entirely.
  • Layout beats pipelining for random-order formats: the mmap-random layout's effective NVMe rate (configured 1/4) costs 4× more than the pipeline saves — cold-load latency across weight formats spans 1.94 s–69.79 s while pipeline ratios vary only 1.02×–1.58×.
  • Occupancy is measured, not asserted: the staging window binds only when it must — pinned at the 2 GiB budget (link-bound contiguous), a natural 74-page (1.2 GiB) lead under budget (link-bound sharded), one page (consumer drains faster than the producer stages).
  • Pre-warm amortizes immediately: break-even for the 2 GiB head window is ONE replayed serving session in all nine scenario×layout pairs measured.

Honesty boundaries

  • All rates are configured (7/0.5 GB/s NVMe sequential, 1/2 strided and 1/4 random layout penalties, 12/8/3 GB/s PCIe, 2 GiB staging), not measured Hanzo hardware — the HIP update lists the hardware rerun as the follow-up.
  • The template's access order comes from the layout's canonical order, standing in for a recorded cold-load run; the replay mechanism is identical either way.
  • Upstream 79% figure stays with its authors.

Draft PR — happy to rebase or restructure per maintainer preference. (Note: #100/#104/#105/#108/#110 touch hanzo-kv-fabric; this one touches hanzo-bench only, so it is merge-independent.)

…re-warm (PPC/MAIO FAST '26, engine#95, HIP-1345 §2.4)

Bounded clean-room implementation of the record-once/replay-pipelined
load-template mechanism in hanzo-bench:

- 16 MiB weight-page identity; canonical page access orders for three
  checkpoint layouts (contiguous / 4-shard strided / mmap-random
  deterministic permutation) with configured layout NVMe penalties
  (1/2 strided, 1/4 random)
- LoadTemplate recording (record-once) + two replay policies: demand
  (synchronous serial NVMe->host->device baseline) and the two-channel
  pipelined replay — NVMe producer stages into a bounded host RAM
  window while the PCIe consumer streams pages to device; producer
  gated so staged-but-not-copied pages stay within the window
- head_prewarm: stage the first 2 GiB of the learned order in the idle
  window before serving (head capped by the staging budget) + pipeline
  the tail; break_even_turns amortization metric
- 8 tests: layout orders are permutations, demand identity, pipelined
  <= demand, window producer-lead bound, head monotonicity, head=0 ==
  streaming pipeline, empty-template zeroing, zero-savings break-even;
  stdlib-only module
- results/load-templates-results.json: demand vs pipeline vs head
  pre-warm on the identical 512-page/8 GiB set, three layouts x three
  scenarios. Streaming pipeline 1.02x-1.85x, head pre-warm 1.35x-2.11x
  vs demand; break-even for the window = ONE replayed session in all
  nine pairs. Occupancy column reports when the window actually binds
  (pinned 2 GiB link-bound contiguous; natural 74-page lead sharded;
  one page consumer-drains)
- findings: the pipeline buys OVERLAP not bandwidth (storage-bound
  regime collapses to 1.0x); layout access patterns dominate absolute
  cold-load latency (1.94s-69.79s demand span) more than policy
  affects the ratio
- results/HIP-1345-update.md: proposed §2.4 addendum (weight-loading
  half; LoRA paging half = PR hanzoai#104) + explicit out-of-scope statement
  (no io_uring/CUDA staging/mmap syscalls; no learned predictors;
  configured rates until the Hanzo-hardware rerun)
- Upstream 79% load-latency-reduction figure remains the authors' own
  per the bounty caveat; no reference code exists to port - clean-room
  from the objective
@zeekay zeekay changed the title research/load_templates: weight-loading IO templates with pipelined pre-warm (PPC/MAIO FAST '26, engine#95, HIP-1345 §2.4) research/load_templates: weight-loading IO templates with pipelined pre-warm (PPC/MAIO FAST '26, engine#87, HIP-1345 §2.4) Nov 21, 2026
@zeekay

zeekay commented Nov 21, 2026

Copy link
Copy Markdown
Member

Not merged. #87 asks for cold-load latency across NVMe, host RAM and device memory; here every rate is configured (7 and 0.5 GB/s NVMe, PCIe links, layout penalties) and the template order stands in for a recorded load, so the table restates sum against max of those constants and nothing is loaded. Missing: a cold load of a real checkpoint through the engine's loader as the baseline, the access order recorded from that run, the pipelined or head-warmed load timed against it on the same files, and the loader calling the module (it sits in hanzo-bench and nothing uses it). I did not build it here: hanzo-bench pulls hanzo-engine, and fork PRs get no CI.

@zeekay

zeekay commented Nov 25, 2026

Copy link
Copy Markdown
Member

Closing stale draft simulation harness (last commit 2026-11-18, no follow-up since the 2026-11-21 review).

Remaining acceptance criteria for #87:

  1. Measure real cold-load latency of an actual checkpoint through hanzo-engine's model loader as baseline (not hand-configured NVMe/PCIe throughput constants).
  2. Record real page access order from that cold run and time the pipelined / head-pre-warmed replay against the same files.
  3. Wire the module into the engine loader rather than leaving an unused standalone module in hanzo-bench.

Feel free to reopen or file a fresh PR once those real-loader measurements and wiring are in place.

@zeekay zeekay closed this Nov 25, 2026
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.

2 participants