cleanup: VRAM-layer audit — dead modules, staging gate, one reserve floor, honest budget logs#877
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
init()never called,Engine::gdn_state_never assigned (always null, every read guarded); GDN models run recurrent state throughSSMState. Also removes the deadInferenceState::gdn_state/gdn_seq_idfields and the never-readgdn_layer_map_.cudaHostAlloc.VRAMAllocator— Engine now holds it directly; the singlecompute_budgetcaller uses the free function.plan_tier_of()wrapper (comment-only references), Phase-4bconstexpr actually_free = truebisect leftover with dead branches.Real fix
moe_.raw_staging_bufgated onany_host_packed_experts: its only consumers are the!packed.on_devicebranches 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 tocore/qtype.has single policy source (the budget re-derived it as a local lambda — the G1 duplication class, in sync today, drift waiting to happen).vram_reserve_floor()helper replaces the 6 truemax(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.fp8=reservation when FP8 prefill is resolved off (the sm_120 default):fp8_cache_byteshad zero consumers in that state. Strategy line now readsNVFP4_DECODE (fp8 prefill off). KV sizing math unchanged.!plan.failedguard on the fix: capture-poisoned engine wedge + planner-driven KV pool sizing #875 GGUF reserve branch (the budget-side plan runs unconstrained →failedunreachable there) and documented the deliberate two-plan design at both sites.Perf
Perf-neutral by design — no hot-path changes, no baseline refresh needed.
MoE staging buffer: skipped (all packed experts on device), output coherent; Coder-30B-FP4 292 tok/s decode,VramBudgetReserve2/2 green.🤖 Generated with Claude Code