Skip to content

feat: show model cache size, delete other models from Set Model, drop superseded preset copies - #48

Merged
MattDHill merged 2 commits into
masterfrom
feat/model-cache-cleanup
Nov 22, 2026
Merged

MattDHill merged 2 commits into
masterfrom
feat/model-cache-cleanup

Conversation

@MattDHill

@MattDHill MattDHill commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #47. Downloaded models stay cached on purpose, so switching back is instant, but nothing showed how much disk they take or offered a way to reclaim it short of Delete Model Cache one repo at a time. #47 also made one case invisible: once a preset's current repo is cached, a copy from its former repo is never used again and Set Model doesn't list it.

  • Cache size. Set Model's model list ends with "Downloaded models use N GB of disk."
  • Delete other downloaded models, a Set Model toggle, off by default. After saving the selection it removes every cache entry the selection doesn't use: its main and draft repos stay, and a selected preset keeps all its cached repos. That set is cacheEntriesInUse in utils.ts, which Delete Model Cache's protection now uses too.
  • Superseded preset copies are removed at start. Once a selected preset's current repo is cached, main.ts deletes its former repos' folders before launching, and logs each one. A folder that also holds another quant, or that llama-server will load anyway as the main or draft model (an -hf override in the extra arguments counts, since the last flag wins), is kept. The old repo is withdrawn, so this only removes weights nothing resolves to.
  • A split model counts as cached only with every part on disk. Without this, an interrupted download of the current repo's first part would make a preset switch off a complete former copy, and then delete it.

No version bump: the release notes go into the unreleased 12110:1.

Verified on demo.local (generic, x86_64), with placeholder cache folders standing in for real weights:

  • Both Qwen2.5 7B copies complete: start logged Removed unsloth/Qwen2.5-7B-Instruct-GGUF, which the selected preset no longer uses. and the folder was gone.

  • Qwen's split missing part 2: no removal, and the server loaded unsloth/Qwen2.5-7B-Instruct-GGUF:Q4_K_M.

  • The form showed the cache total, which also counts partial downloads in progress, and the toggle defaulted off.

  • Submitting the Qwen2.5 14B preset with the toggle on removed both 7B folders and kept both 14B ones. The next start kept the unsloth 14B folder because it also holds a Q8_0 file.

  • After review: with a former 14B folder holding only the preset's quant, it survived start with extra arguments -hf unsloth/Qwen2.5-14B-Instruct-GGUF:Q4_K_M, and again with --hf_repo_draft naming it. llama-server rewrites _ to - in long options (common/arg.cpp, b12110), and the option reader now does the same. With no extra arguments, start removed the folder.

Not tested: the delete-others toggle while a draft model is set.

review effort: 'high'

🤖 Generated with Claude Code

… superseded preset copies

Downloaded models accumulate by design (switching back is instant), but
nothing showed the space they take or offered a way to reclaim it short
of Delete Model Cache one repo at a time, and a preset's former-repo
copy became invisible dead weight once its current repo was cached.

- Set Model's model list ends with the total size of the cache.
- Set Model's "Delete other downloaded models" toggle (off by default)
  removes every cache entry outside cacheEntriesInUse for the submitted
  selection: its main and draft repos, plus every cached repo of a
  selected preset. Delete Model Cache now uses the same function.
- main.ts deletes a selected preset's former-repo folders before start
  once its current repo is cached. A folder holding another quant, or
  serving as the draft repo, is kept; the old repo can't be downloaded
  again, so only weights nothing resolves to are removed.
- A split model counts as cached only with every part on disk, so an
  interrupted download of the current repo neither displaces a complete
  former copy nor triggers its removal.

Release notes are added to the unreleased 12110:1.

Verified on demo.local (generic x86_64) with placeholder caches: with
both Qwen2.5 7B copies complete, start logged the removal of the unsloth
folder; with the Qwen split missing a part, the unsloth copy was kept and
served; the form showed the cache total and the toggle off; submitting
the 14B preset with the toggle removed both 7B folders and kept both 14B
ones, and the next start kept the unsloth 14B folder because it also
holds a Q8_0 file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
helix-white added a commit that referenced this pull request Nov 22, 2026
Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol

@helix-white helix-white left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two deletion-safety fixes are needed in startos/utils.ts:

  • [P2] Preserve an overridden main repo in supersededCopies. With both Qwen2.5 7B Q4_K_M copies cached, select the preset and set Extra arguments to -hf unsloth/Qwen2.5-7B-Instruct-GGUF:Q4_K_M. serveArgsOf puts that override last, so llama-server still uses unsloth, but supersededCopies protects only the draft repo and deletes unsloth before launch. Because that repo was withdrawn, this destroys the cached copy needed for startup. The proposal extracts effective main/draft repo protection and shares it with both cleanup policies, records the preservation contract at that owner, and corrects the README.
  • [P2] Recognize upstream's underscore spellings in the option reader. For example, --hf_repo_draft unsloth/Qwen2.5-7B-Instruct-GGUF:Q4_K_M is valid: b12110's common/arg.cpp normalizes underscores in long option names before dispatch. lastOptionValue does not, so the new startup cleanup deletes that active draft repo despite the draft guard. The proposal applies the same normalization in the shared reader, also fixing the analogous manual/bulk-delete protection.

Mergeability against origin/master is clean. This is a code-only review; I did not build, typecheck, or run the changes. Please verify the proposal, including both main/draft overrides, repeated flags, and the underscore spellings, before adopting it.

Proposed changes: c8e112b...proposal/48

Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol

…ng the cache

Adopts helix-white's proposal on #48.

- supersededCopies now keeps every repo the effective serve args load,
  so a former repo named by -hf in the extra arguments (last flag wins)
  survives, not only the draft. Delete Model Cache and Set Model's
  delete-others share the same effective-repo set.
- lastOptionValue normalizes underscores in long options, as
  llama-server does before dispatch (common/arg.cpp, b12110), so
  --hf_repo_draft and friends are recognized.

Verified on demo.local with a former Qwen2.5 14B folder holding only the
preset's quant and the current repo cached: with extra arguments
-hf unsloth/Qwen2.5-14B-Instruct-GGUF:Q4_K_M, and separately with
--hf_repo_draft naming it, the folder survived start; with no extra
arguments, start removed it and logged the removal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@helix-white helix-white left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 6e1141a against the previous review and proposal. Both findings are addressed: automatic cleanup now preserves the effective main and draft repos through the shared helper, and the option reader normalizes long-option underscores like llama-server. The README records the preservation guarantee. No further blocking findings; mergeability against origin/master is clean.

Code-only review; no builds or tests run. The four variant builds are still pending.

Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol

@MattDHill
MattDHill merged commit ee93e54 into master Nov 22, 2026
6 checks passed
@MattDHill
MattDHill deleted the feat/model-cache-cleanup branch November 22, 2026 16:54
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.

2 participants