Repository navigation
Remove SafeTensors source weights after a converted GGUF loads - #225
Merged
Merged
Conversation
Once a model converted from SafeTensors loads in llama-server, delete the model*.safetensors shards and their index the converter consumed, so the checkpoint is not stored twice. Companion files such as head.safetensors and adapters stay, and a vision model keeps its weights until its mmproj exists. The manifest is refreshed to list the GGUF so cluster sync ships it as a regular file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ganisback
commented
Oct 19, 2026
ganisback
left a comment
Collaborator
Author
There was a problem hiding this comment.
Three blocking issues with deleting the SafeTensors source after a converted GGUF loads. See the inline comments.
Record the deleted source weights in the manifest before removing them, so a dtype request the model can no longer convert fails with a clear error instead of quietly serving the GGUF that is left. Leftover companions such as head.safetensors no longer make the model look convertible, and removal waits for conversions reading the same directory. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
Author
|
Addressed the three blocking review comments in 8663096:
Tests: |
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.
Summary
model*.safetensorsshards andmodel.safetensors.index.jsonthe converter consumed, so the checkpoint is not stored twice (e.g. JEV-9B kept ~18 GB of shards next to its 9.5 GB GGUF).head.safetensorsand adapter directories are kept; a vision model keeps its weights until its mmproj GGUF exists.loadEngineWithProgressModeinto one closure.Trade-off: converting the same model to a different dtype later needs a fresh download.
Testing
make lint;go test ./internal/{convert,model,inference,server}.laya-typed-decisionswithout its GGUF: conversion, load, 843 MB of SafeTensors removed, manifest switched to gguf, and a reload served the GGUF.Review fixes (8663096)
manifest.jsonasremoved_source_weightsbefore deletion. A dtype request with no matching GGUF then fails withErrSourceWeightsRemovedinstead of serving the GGUF that is left..safetensorscompanions no longer make the model look convertible. Removal waits for any conversion of the same directory, using a per-directoryRWMutex.go test ./...passes, and the new tests also pass under-race.End to end:
Qwen/Qwen3.5-4B(vision, 2 shards, 8.7 GB) on the:11435previewPOST /api/loadwithdtype=f16Qwen3.5-4B-f16.gguf(8.7 GB) andmmproj-Qwen3.5-4b-F16.ggufin ~31s, loadedready. A chat completion answered correctly.format=gguf,removed_source_weightslists the 3 files, and only the 2 GGUFs remain.POST /api/loadwithdtype=q8_0model Qwen/Qwen3.5-4B has no q8_0 GGUF: SafeTensors source weights were removed after an earlier GGUF conversion; pull the model again to convert another dtype. No conversion ran and the f16 GGUF was not served.PUT /api/models/Qwen/Qwen3.5-4B/configdtype=q8_0was rejected with 400 (no q8_0 build and no weights to convert into one).dtype=f16was accepted with 200. A default load afterwards wasready.No panics and no data race reports in the server log.
🤖 Generated with Claude Code