llama-quant : honor --tensor-type override when it matches the global ftype#22559
llama-quant : honor --tensor-type override when it matches the global ftype#22559Anai-Guo wants to merge 1 commit into
Conversation
…hes the global type (#22544) Fixes #22544. When a user supplies an explicit `--tensor-type` mapping that happens to match the requested global ftype, the previous code only set `manual = true` inside the `qtype != new_type` branch, so it was never flipped on the equal-type case. Control then fell through to `llama_tensor_get_type_impl`, which is free to override the user's choice via imatrix/heuristics — exactly what `--tensor-type` is meant to suppress. Set `manual = true` and break out of the pattern loop unconditionally once a pattern matches; only emit the override log line when the requested type actually differs from the current one.
|
Hi @Anai-Guo, thanks for your contribution! Per our contribution guidelines, the automated PR checker found the following issue(s) that need your attention:
Please note that maintainers reserve the right to make final decisions on PRs. If you believe there is a mistake, please comment below. |
|
Apologies — I missed the new-contributor 1-open-PR limit and the AI-disclosure policy. Closing this in favor of my older open PR (#21838). I'll wait for that one to land before opening anything else here. Thanks for the patience. |
…gml-org#22572) fix ggml-org#22544 (my fault!) Credit to @Anai-Guo, ref ggml-org#22559 - since that one was closed due to the new contributor policy I am taking the liberty of re-submitting that PR here.
…gml-org#22572) fix ggml-org#22544 (my fault!) Credit to @Anai-Guo, ref ggml-org#22559 - since that one was closed due to the new contributor policy I am taking the liberty of re-submitting that PR here.
…gml-org#22572) fix ggml-org#22544 (my fault!) Credit to @Anai-Guo, ref ggml-org#22559 - since that one was closed due to the new contributor policy I am taking the liberty of re-submitting that PR here.
…gml-org#22572) fix ggml-org#22544 (my fault!) Credit to @Anai-Guo, ref ggml-org#22559 - since that one was closed due to the new contributor policy I am taking the liberty of re-submitting that PR here. (cherry picked from commit b97ebdc)
…gml-org#22572) fix ggml-org#22544 (my fault!) Credit to @Anai-Guo, ref ggml-org#22559 - since that one was closed due to the new contributor policy I am taking the liberty of re-submitting that PR here. (cherry picked from commit b97ebdc)
…gml-org#22572) fix ggml-org#22544 (my fault!) Credit to @Anai-Guo, ref ggml-org#22559 - since that one was closed due to the new contributor policy I am taking the liberty of re-submitting that PR here.
…gml-org#22572) fix ggml-org#22544 (my fault!) Credit to @Anai-Guo, ref ggml-org#22559 - since that one was closed due to the new contributor policy I am taking the liberty of re-submitting that PR here.
Summary
Fixes #22544.
When a user supplies an explicit
--tensor-type "<pattern>=<type>"mapping that happens to match the requested global ftype, the user's intent (lock that tensor to that exact type) is silently dropped and the imatrix/heuristic path is allowed to override it.Root cause
llama_tensor_get_typeonly setmanual = truefrom inside theqtype != new_typebranch:So invoking
llama-quantizewith--tensor-type "^blk\.0\.attn_qkv\.weight$=iq4_xs"and global ftypeiq4_xsfalls through to the heuristic, which can pick a different type (e.g.q5_K) — exactly what--tensor-typeis meant to prevent.This was introduced by 1dab5f5 (refactor type selection), reported in #22544.
Fix
Set
manual = trueandbreakunconditionally once a pattern matches. Only emit the "applying manual override" log line when the requested type actually differs from the current one:A pattern match is the user pinning that tensor — it should suppress the heuristic regardless of whether it changes the type.
Test plan
./llama-quantize --imatrix model.imatrix.gguf --tensor-type "^blk\.0\.attn_qkv\.weight$=iq4_xs" model.gguf out.gguf iq4_xs 8—attn_qkvshould now be reported asiq4_xs(no longer redirected toq5_K).qtype != new_type) still emits the log line and switches type.--tensor-typeis not supplied (tensor_type_patterns.empty()→ unchanged path).🤖 Generated with Claude Code