fix(gguf): correct the Q8_0 / Q5_0 / Q5_1 quantization labels - #2516
Open
Hoang130203 wants to merge 1 commit into
Open
fix(gguf): correct the Q8_0 / Q5_0 / Q5_1 quantization labels#2516Hoang130203 wants to merge 1 commit into
Hoang130203 wants to merge 1 commit into
Conversation
llama.cpp's llama_ftype enum leaves 4, 5 and 6 unused — Q4_1_SOME_F16,
Q4_2 and Q4_3 were removed — and resumes at 7 with Q8_0, 8 Q5_0, 9 Q5_1.
_FILE_TYPE_LABELS closed that gap, shifting three codes down by one:
ftype llama.cpp ODS reported
6 (removed) Q5_0 label for a code llama.cpp never emits
7 Q8_0 Q5_1 wrong
8 Q5_0 Q8_0 wrong
9 Q5_1 9 missing, falls through to the raw int
So a Q8_0 model is shown as Q5_1, a Q5_0 model as Q8_0, and a Q5_1 model
as the bare number 9.
That the rest of the table is right is the evidence this is a
transcription slip rather than a different convention: every code from 10
to 34 matches the enum exactly, and the three that do not are precisely
the ones straddling the removed-type gap.
The bundled tiers all ship Q4_K_M (ftype 15), which is mapped correctly,
so this only shows up for users who bring their own Q8_0, Q5_0 or Q5_1
GGUF — exactly the people most likely to care which quantization they
are running.
Adds 16 assertions pinning the enum either side of the gap, and that the
removed codes 4, 5 and 6 report no label rather than borrowing a
neighbour's.
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
gguf_inspector._FILE_TYPE_LABELSmaps a GGUF'sgeneral.file_typeto aquantization name. llama.cpp's
llama_ftypeenum leaves 4, 5 and 6 unused —Q4_1_SOME_F16,Q4_2andQ4_3were removed — and resumes at 7. The tableclosed that gap, shifting three codes down by one:
Built synthetic GGUFs with each
file_typeand ran the shipped parser overthem:
A Q8_0 model is displayed as Q5_1, a Q5_0 model as Q8_0, and a Q5_1
model as the bare number
9. Code 6 gets a label for a type llama.cpp neveremits.
Why this is a transcription slip and not a different convention
The rest of the table is exactly right. Checked every remaining row against the
enum:
25 consecutive rows agree; the only three that do not are precisely the ones
straddling the removed-type gap. Someone transcribed the enum and closed a hole
that was meant to stay open.
Impact
Every bundled tier ships Q4_K_M (ftype 15), which maps correctly — so this
is invisible on a default install and only surfaces for users who bring their
own Q8_0 / Q5_0 / Q5_1 GGUF. Those are exactly the people who chose a
quantization deliberately and are most likely to care that the dashboard names
it wrong.
performance_oracleconsumes this parser's output for fit reporting.Fix
Move the three rows to their real codes and drop the invented
6. One-linecomment recording why the gap exists, so it does not get closed again.
AI Assistance
AI assisted with drafting the tests and wording this description. I found the
shift by running the shipped table against synthetic GGUFs for each code and
diffing the whole table against the enum — that comparison is what showed only
the three gap-adjacent rows disagree.
Release Lane
release/2.6.xmainStable hotfix reason:
Changed Surface
(Three entries in a lookup table in
gguf_inspector.py, and its tests.)Risk And Validation
git diff --checkrelease/2.6.xCommands/results:
Caveat — what I verified and what I am citing. I proved the behaviour
above by running the parser over GGUFs I built byte by byte, and I proved the
internal inconsistency by diffing the whole table against the enum. What I did
not do is read a real Q8_0 GGUF produced by
llama-quantize, because I have nosuch file here and no network access to fetch one. The claim that 7/8/9 are
Q8_0/Q5_0/Q5_1 comes from llama.cpp's
llama_ftypeinllama.h. If you have aQ8_0 GGUF handy,
python3 -c "import gguf_inspector; print(gguf_inspector.inspect_gguf('...')['quantization'])"settles it in one command — worth doing before merge, since I am asserting an
external constant.
Operational Change Check
inspect_gguf()is a read-only metadata parser behind model fit/performancereporting. The change alters three entries in a display-label lookup. It reads
no more of the file, changes no parsing logic, and nothing branches on the
label —
performance_oracleconsumes the numeric fields. The visible effect isthat three quantization names are now the ones llama.cpp uses.
Notes For Reviewers
Codes 4, 5 and 6 now report the raw integer, which is what the existing
test_unknown_file_type_falls_back_to_stringified_intbehaviour already doesfor anything unmapped. That is the honest answer for a type llama.cpp cannot
produce. If you would rather they say something like
"removed", that is aone-line change — but I would keep them unmapped so a future enum addition at
those codes is not silently mislabelled again.
Ftype 33/34 are
TQ1_0/TQ2_0in the table and I left them alone; theymatch the enum. Older llama.cpp builds briefly used 33/34 for the
Q4_0_4_4-family repacking types before those were removed, so if you ever seea very old GGUF report
TQ1_0, that is the reason — not something this PRintroduces.