Repository navigation
hrx: bound the graph program cache (GGML_HRX_GRAPH_PROGRAM_CACHE, default 64) - #63
Merged
bong-water-water-bong merged 1 commit intoOct 2, 2026
Conversation
…ault 64) GraphProgramCache kept every program it built and never evicted. A new graph shape (each new prompt or ubatch length, and decode as n_kv grows) builds a GraphProgram that retains HRX buffers, its recorded graph and a transient arena binding, so a llama-server answering prompts of varying length grew GTT without bound: ZAYA1-8B Q4_K_M on HRX0 grew about 1 GiB per request (about 34 programs of about 130 MiB) and ran a 128 GB Strix Halo out of memory; 60 requests of one length plateau at 4.35 GiB. Since engine ggml-org#270 makes HRX the default GPU route of `1bit serve`, any long-running server hits this. runtime/graph-program-cache-limit.{h,cpp} (new): after a lookup that built a new program, if the cache holds more than GGML_HRX_GRAPH_PROGRAM_CACHE programs (default 64; 0 = unbounded, the old behaviour), wait for the stream so no command of a dropped program is still running, mark it synchronized, then drop every program except the current one, and the prepared programs. A lookup that reused a program (by uid or by structure) drops nothing, so steady decode does not churn. Each flush logs one WARN line with a running count. Hookups in AMD's files: GraphProgramCache::size() and retain_only(keep), one call in GraphExecutor::execute, CMake sources. ZAYA1-8B Q4_K_M, llama-server on HRX0, balanced power, 40 greedy requests of varying length (the same 20 lengths twice), GTT from mem_info_gtt_used: - cap 0 (old): 24.6 GiB, watchdog stop at request 28 - cap 64: 8.7 GiB, 7 flushes; cap 128: 15.9 GiB, 3 flushes - cold request median 1.74 s (cap 0) vs 1.84 s (cap 64); a repeated length is 1.12 s unbounded vs 1.75 s after a flush (the flush drops the warm set) - greedy answers identical to cap 0 at caps 4, 16 and 32 (23/23) - llama-bench pp512/tg128 unchanged (cap 32: 1979/1888 and 93.4 vs cap 0 1943/1981 and 94.2); no flush during tg128 - GGML_HRX_DISABLE_GRAPH_REPLAY=1 does not stop the growth (24.6 GiB) and costs decode (88.6 +- 10 vs 94.2) Qwen3.8-27B UD-Q4_K_XL with --spec-type draft-mtp (cap 16, 30 requests): 3.4 GiB, drafting active (draft_n 15-19). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
|
Review (PR-Agent duty): approve.
Merging after #62, once the hosted Linux/Windows jobs pass. The self-hosted cpu-/gpu- jobs never get a runner on this fork, and the branch is unprotected, so no admin merge is needed. |
bong-water-water-bong
merged commit Oct 2, 2026
d60cc4f
into
1bit/hrx-vulkan-patched
10 of 24 checks passed
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.
HRX's
GraphProgramCachekept every program it built and never evicted any. A long-running llama-server on HRX therefore grew GPU memory (GTT) without bound. Since engine ggml-org#270 made HRX the default GPU route, this blocks the release: on 2026-10-01 it ran strixhalo out of memory.Cause
Every new graph shape builds a
GraphProgram: each new prompt or ubatch length, and decode shapes asn_kvgrows. Each program holds its HRX buffers, its recorded graph and a transient-arena binding.With ZAYA1-8B that's about 34 programs per request at about 130 MiB each, so roughly +1 GiB per request when prompt lengths vary. Sixty requests of a single length level off at 4.35 GiB.
Fix
New file
runtime/graph-program-cache-limit.{h,cpp}. After a lookup that built a new program, if the cache holds more thanGGML_HRX_GRAPH_PROGRAM_CACHEprograms (default 64;0= unbounded, the old behaviour), it:stream_synchronize_sleeping, so no command of a dropped program is still running;A lookup that reused a program, by uid or by structure, drops nothing, so steady decode never triggers a flush. Each flush logs one WARN line with a running count. (llama-server hides HRX's INFO logs.)
Hookups in AMD's files:
GraphProgramCache::size()andretain_only(keep)GraphExecutor::executeMeasured
ZAYA1-8B Q4_K_M, llama-server on HRX0, balanced power mode. 40 greedy requests of varying length (the same 20 lengths sent twice). GTT read from
mem_info_gtt_used.--spec-type draft-mtp -md mtp-Qwen3.8-27B-Q4_0.ggufat cap 16, 30 requests: 3.4 GiB, drafting active (draft_n15–19).GGML_HRX_DISABLE_GRAPH_REPLAY=1is not a workaround: it still grows to 24.6 GiB, and decode drops to 88.6 ± 10 tok/s.Not in this PR
get_or_buildcompares each new uid against every cached program. With many cached programs that's a likely cause of a slow first decode after a prefill. The cap bounds this cost but doesn't remove it.🤖 Generated with Claude Code