You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(MAD-186): port hipfire weight-pager intelligence (7 stories)
Implements seven hipfire-style pager features on top of the WeightPager
runtime, all gated by env vars so default behaviour is byte-identical
to the pre-MAD-186 path:
MAD-231 slot pin/refcount wp-pool, wp-pager
Protect in-flight slots from eviction during ops. Refcounted
via PoolAllocator pin_slot/unpin_slot. Conservative window
spanning ensure -> next-eval-cb covers compute-stream reads.
Diagnostic: lru_walk_pinned_skips.
MAD-232 posix_fadvise K-layer lookahead wp-file-io, wp-pager
One advise call per upcoming paged tensor in
[block+1, block+k]. WP_FADVISE_LOOKAHEAD env-gated. Walks the
catalog via compute_advise_ranges (pure, unit-testable).
MAD-233 cross-layer N+K MoE prefetch wp-eval-cb
Sister-prefetch the current layer's expert set, plus a
cross-layer block looking K layers ahead. WP_NEXT_LAYER_PREFETCH_K
env-gated. Composes with MAD-235 batched submit.
MAD-234 UMA/APU MemAvailable pre-flight wp-pool
Refuse-with-actionable-error policy. is_uma_device combines
hipDeviceAttributeIntegrated with a gfx-string prefix fallback
for gfx115x / gfx1103 / gfx1102 / gfx1100 / gfx90c / gfx940.
Pre-flight clamp: pool > MemAvailable - 2 GiB -> hard error.
MAD-235 batched io_uring submit wp-file-io, wp-prefetch
Submit N SQEs and one io_uring_submit. All-or-nothing
semantics: any sub-request failure rolls back every reservation.
WP_BATCH_PREFETCH env-gated; falls back to per-page on false.
MAD-236 always-resident pinning wp-page-catalog, wp-pager
register_pinned + add_pinned: tensors whose bytes already
live in caller-owned VRAM (e.g. token_embd) are first-class
catalog entries. ensure() short-circuits to resident_ptr;
no slot allocation, no disk read. Telemetry counters for
pinned bytes + page count.
MAD-237 popularity counter + hot-set wp-pool
Two-pass LRU walk under WP_HOT_HIT_THRESHOLD > 0:
A) evict LRU among unpinned AND hit_count <= threshold
B) if A empty, fall through to unpinned LRU.
Periodic decay (halve hit counts every 1024 evictions) keeps
counters bounded and lets cold-becomes-hot demote over time.
Default threshold=0 -> pure LRU, byte-identical to pre-237.
Tests: 19 new unit tests covering algorithm correctness on the CPU
buffer-type (PoolAllocator pin/eviction-skip/hot-protection, FileIOLayer
advise + batched submit + rollback, PageCatalog pinned mixing, UMA
prefix table). Real-HIP integration validation deferred to a follow-up
R9700 run.
Bug discovered during test validation: compute_advise_ranges filtered
consolidated parents by `m.size == 0` based on a stale assumption -
add_consolidated_experts stores total_size on the parent (it's load-
bearing for other consumers' name lookups). Switched filter to the
authoritative `is_consolidated` flag; defence-in-depth size==0 guard
kept for malformed catalog entries.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
0 commit comments