Skip to content

cleanup: VRAM-layer audit — dead modules, staging gate, one reserve floor, honest budget logs#877

Merged
kekzl merged 1 commit into
mainfrom
cleanup/vram-audit-2026-07-07
Jul 7, 2026
Merged

cleanup: VRAM-layer audit — dead modules, staging gate, one reserve floor, honest budget logs#877
kekzl merged 1 commit into
mainfrom
cleanup/vram-audit-2026-07-07

Conversation

@kekzl

@kekzl kekzl commented Jul 7, 2026

Copy link
Copy Markdown
Owner

What

Verified findings from the 2026-07-07 VRAM management audit — full write-up with per-finding evidence, the deliberate-design list, and measurement-gated follow-ups in docs/audit/vram_audit_2026_07_07.md. Net: −757 LOC, one real allocation-gate fix, the rest is dead scaffolding and diagnostic honesty.

Dead code removed

  • GDNState module: init() never called, Engine::gdn_state_ never assigned (always null, every read guarded); GDN models run recurrent state through SSMState. Also removes the dead InferenceState::gdn_state/gdn_seq_id fields and the never-read gdn_layer_map_.
  • DeviceAllocator + PinnedAllocator: zero runtime callers (unit tests only); the async default pool is tuned directly and prefill pinned staging uses raw cudaHostAlloc.
  • MemoryManager facade collapsed: its remaining job was holding a VRAMAllocator — Engine now holds it directly; the single compute_budget caller uses the free function.
  • Stranded plan_tier_of() wrapper (comment-only references), Phase-4b constexpr actually_free = true bisect leftover with dead branches.

Real fix

  • moe_.raw_staging_buf gated on any_host_packed_experts: its only consumers are the !packed.on_device branches of the legacy MoE forward, but it was allocated whenever packed experts existed — dead weight (1 expert raw, MiB-range) on every all-on-device GGUF-MoE load. Deliberately NOT using the LRU predicate with its gpt-oss exemption — gpt-oss' transiently host-resident experts keep the staging fallback.

Consolidation / honesty

  • nvfp4_beneficial() hoisted to core/qtype.h as single policy source (the budget re-derived it as a local lambda — the G1 duplication class, in sync today, drift waiting to happen).
  • New vram_reserve_floor() helper replaces the 6 true max(total/10, 256 MiB) derivations; normalizes one copy that had drifted to a 1 MiB floor. Semantically distinct reserves (kv-floor clamps, additive safeties) intentionally untouched.
  • Budget log no longer reports a phantom fp8= reservation when FP8 prefill is resolved off (the sm_120 default): fp8_cache_bytes had zero consumers in that state. Strategy line now reads NVFP4_DECODE (fp8 prefill off). KV sizing math unchanged.
  • Removed the vacuous !plan.failed guard on the fix: capture-poisoned engine wedge + planner-driven KV pool sizing #875 GGUF reserve branch (the budget-side plan runs unconstrained → failed unreachable there) and documented the deliberate two-plan design at both sites.
  • MemAccount per-pool notes wired for weight-cache build totals + executor workspaces; the header now promises exactly what is wired.

Perf

Perf-neutral by design — no hot-path changes, no baseline refresh needed.

  • verify-fast: tests PASS, smoke PASS, pp512 +5.3% / pp4096 +73% vs baseline (above, FA2).
  • decode tg128 read −20.7% with the depressed-host signature (mem 405 MHz median during bench; script auto-degraded to WARN per Q8_0 GGUF perf drift since 2026-05-29 baseline: tg128 259->238 (-8%), pp512 8260->7150 (-13%) #526).
  • graphs on/off gate re-measured on warmed clocks: 2.58× (threshold 1.3×) — the scripted 1.26× run was the same cold-clock artifact.
  • MoE smokes: GGUF Q4_K_M 30B logs MoE staging buffer: skipped (all packed experts on device), output coherent; Coder-30B-FP4 292 tok/s decode, VramBudgetReserve 2/2 green.

🤖 Generated with Claude Code

…loor, honest budget logs

Verified findings from the 2026-07-07 VRAM audit (docs/audit/vram_audit_2026_07_07.md):

- Delete dead GDNState module (init never called, gdn_state_ always null;
  GDN recurrent state runs through SSMState) incl. InferenceState fields
  and the never-read gdn_layer_map_.
- Delete DeviceAllocator/PinnedAllocator (zero runtime callers) and
  collapse the MemoryManager facade — Engine holds VRAMAllocator directly.
- Delete stranded plan_tier_of() wrapper and the hardcoded Phase-4b
  bisect constant with its dead branches.
- Gate moe raw_staging_buf on any_host_packed_experts (its only consumers
  are the host-expert branches of the legacy MoE forward) — no longer
  allocated on all-on-device loads.
- Hoist nvfp4_beneficial() to core/qtype.h as the single policy source
  (was re-derived as a lambda in vram_budget.cpp — G1 regression class).
- Add vram_reserve_floor() helper; convert the 6 true max(total/10,256MiB)
  sites and normalize the drifted 1 MiB floor in phase3_nvfp4_decode.
- Stop logging a phantom fp8= reservation when FP8 prefill is resolved
  off (sm_120 default); KV sizing math unchanged.
- Remove the vacuous !plan.failed guard on the #875 GGUF reserve branch
  (the budget-side plan runs unconstrained, failed is unreachable there)
  and document the deliberate two-plan design.
- Wire MemAccount notes for the weight-cache build totals and executor
  workspaces; header now states exactly which pools are attributed.

Perf-neutral by design: no hot-path changes; verify-fast tests green,
prefill gates pass, graphs on/off re-measured 2.58x on warmed clocks
(the scripted 1.26x run carried the depressed-host signature, #526).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@kekzl kekzl enabled auto-merge (squash) July 7, 2026 10:34
@kekzl kekzl merged commit 15a3ba7 into main Jul 7, 2026
7 checks passed
@kekzl kekzl deleted the cleanup/vram-audit-2026-07-07 branch July 7, 2026 10:45
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