From 1b5a849135b84ed29322d13612bcde030bf74f33 Mon Sep 17 00:00:00 2001 From: bong-water-water-bong Date: Fri, 13 Nov 2026 21:31:52 -0400 Subject: [PATCH] hrx: HostWeightCache::clear() resets the live gauges only, as AMD's does (engine#2393) clear() zeroed every stat. AMD's clear() (9bf5871) zeroes only allocation_count and resident_bytes, which follow the entries it drops. Hits, misses, evictions, materialized bytes and duplicate warnings count over the cache's life. hrx-buffer-test's host_weight_cache case asserts exactly that (hits == 1 after clear()). The #327 merge kept this branch's older body, so the case failed at tests/hrx-buffer-test.cpp:569. The only production caller is the backend release, which logs the stats before it clears, so nothing else reads them after a clear. Co-Authored-By: Claude Opus 5.5 --- ggml/src/ggml-hrx/runtime/host-memory.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ggml/src/ggml-hrx/runtime/host-memory.cpp b/ggml/src/ggml-hrx/runtime/host-memory.cpp index b3281477f33f..23bd8913f1f3 100644 --- a/ggml/src/ggml-hrx/runtime/host-memory.cpp +++ b/ggml/src/ggml-hrx/runtime/host-memory.cpp @@ -2184,7 +2184,11 @@ void HostWeightCache::clear() { resident_bytes_ = 0; available_at_first_weight_ = 0; oversize_warned_ = false; - stats_ = {}; + // engine#2393: the live gauges follow the entries just dropped; hits, misses, evictions, materialized bytes and + // duplicate warnings are counts over the cache's life, which is what AMD's clear() keeps (9bf5871) and what + // tests/hrx-buffer-test.cpp asserts. The #327 merge had kept this branch's older `stats_ = {}`. + stats_.allocation_count = 0; + stats_.resident_bytes = 0; if (arena_ != nullptr) { hrx_buffer_release(arena_); arena_ = nullptr;