Skip to content

llama-quant : fix --tensor-type when default qtype is overriden#22572

Merged
pwilkin merged 1 commit into
ggml-org:masterfrom
ddh0:honor-tensor-type-override
May 1, 2026
Merged

llama-quant : fix --tensor-type when default qtype is overriden#22572
pwilkin merged 1 commit into
ggml-org:masterfrom
ddh0:honor-tensor-type-override

Conversation

@ddh0

@ddh0 ddh0 commented May 1, 2026

Copy link
Copy Markdown
Contributor

fix #22544 (my fault!)

Overview

Currently, when using --tensor-type "<regex>=GGML_TYPE", if the GGML_TYPE override matches the default type for the chosen output ftype, the internal heuristics in llama_tensor_get_type_impl may still take effect, rather than being locked to the specified GGML_TYPE.

This is my own mistake that I introduced in #19770.

    ggml_type new_type = default_type;

    // get more optimal quantization type based on the tensor shape, layer, etc.
    if (!params->pure && ggml_is_quantized(default_type)) {
        // if the user provided tensor types - use those
        bool manual = false;
        if (!qs.tensor_type_patterns.empty()) {
            const std::string tensor_name(tensor->name);
            for (const auto & [pattern, qtype] : qs.tensor_type_patterns) {
                if (std::regex_search(tensor_name, pattern)) {
                    if (qtype != new_type) {
                        LLAMA_LOG_WARN("%s: %-36s - applying manual override: %s -> %s\n",
                                       __func__, tensor_name.c_str(), ggml_type_name(new_type), ggml_type_name(qtype));
                        new_type = qtype;
                        manual = true; // THIS IS WRONG
                        break;         // THIS IS WRONG
                    }
                // MOVED TO HERE!
                // MOVED TO HERE!
                }
            }
        }

        // if not manual - use the standard logic for choosing the quantization type based on the selected mixture
        if (!manual) {
            new_type = llama_tensor_get_type_impl(qs, new_type, tensor, params->ftype, tm.category);
        }

Additional information

Credit to @Anai-Guo, ref #22559 - since that one was closed due to the new contributor policy I am taking the liberty of re-submitting that PR here.

Requirements

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.
@pwilkin pwilkin merged commit b97ebdc into ggml-org:master May 1, 2026
45 of 46 checks passed
samuraieng pushed a commit to samuraieng/llama.cpp that referenced this pull request May 6, 2026
…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.
ljubomirj pushed a commit to ljubomirj/llama.cpp that referenced this pull request May 6, 2026
…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.
@ddh0 ddh0 deleted the honor-tensor-type-override branch May 6, 2026 21:42
meh pushed a commit to meh/llama.cpp that referenced this pull request May 10, 2026
…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.
baramofme pushed a commit to baramofme/llama-cpp-turboquant that referenced this pull request May 23, 2026
…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)
carlosfundora pushed a commit to carlosfundora/llama.cpp-1-bit-turbo that referenced this pull request May 24, 2026
…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)
winstonma pushed a commit to winstonma/llama.cpp that referenced this pull request May 27, 2026
…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.
fewtarius pushed a commit to fewtarius/CachyLLama that referenced this pull request May 30, 2026
…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.
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.

Misc. bug: Regression: --tensor-type is ignored when it matches the global quantization type (commit 1dab5f5)

4 participants