Repository navigation
Open
Labels
enhancementNew feature or requestNew feature or requestmodel managertechdebtToil to reduce technical debtToil to reduce technical debt
Description
What should this feature add?
Reading a GGUF header is expensive for large-vocabulary encoders, and the same header is parsed several times per install and per load.
Cost per open (gguf-py GGUFReader, which builds a numpy view per array element, ~1M of them for a 256k vocabulary):
| File | Header parse |
|---|---|
| city96 UMT5-XXL Q8_0 | ~10 s |
| Qwen2.5-VL-7B | ~6 s |
| T5 v1.1, 32k vocab | ~3 s |
Opens:
- Install: one for
load_state_dict, one forModelOnDisk.metadata(). - First load: one per submodel; UMT5 GGUF builds its tokenizer from the header, another ~11 s.
- After eviction, every reload pays again.
- With feat(qwen-image): load the Qwen2.5-VL text encoder from GGUF builds #9969, identifying a
qwen2vlfile reads the header once more for its context length, becausemetadata()keeps only string fields onmain. feat(wan): load the UMT5 text encoder from GGUF builds #9967 makes it return typed scalars.
WrappedGGUFReader.close() calls gc.collect() on every read, which shows up on loads under the model-load lock. A reviewer measured at the existing call sites that the caller's with … as reader binding keeps the reader alive until return. So the collect can't release the memmap early; the map is released on return anyway.
Proposals, independent of each other:
- A header reader that skips array payloads, or reads them lazily. This helps every large-vocabulary GGUF encoder.
- Let
ModelOnDiskfill its metadata cache from the reader thatload_state_dictalready opens, saving one parse per GGUF identification. - Drop the
gc.collect()fromWrappedGGUFReader.close()if it is confirmed unnecessary on Windows. - Once feat(wan): load the UMT5 text encoder from GGUF builds #9967 has landed, read the
qwen2vl.context_lengthcheck in feat(qwen-image): load the Qwen2.5-VL text encoder from GGUF builds #9969's config frommod.metadata()instead of a second reader. - Once feat(anima): load the Anima transformer from GGUF builds #9970 has landed, size stable-diffusion.cpp whole-pipeline SD 3 GGUFs (feat(sd3): load SD 3.5 transformers from GGUF builds #9972) by their transformer tensors via
gguf_tensor_bytes, as Anima all-in-one files are.
Additional Content
Collected from the reviews of #9967, #9969, #9970 and #9972.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestmodel managertechdebtToil to reduce technical debtToil to reduce technical debt
Activity