Skip to content

ggml : fix MUL_MAT_ID repack with Q8_K#12544

Merged
ggerganov merged 2 commits into
masterfrom
gg/repack-fix-mul-mat-id
Mar 26, 2025
Merged

ggml : fix MUL_MAT_ID repack with Q8_K#12544
ggerganov merged 2 commits into
masterfrom
gg/repack-fix-mul-mat-id

Conversation

@ggerganov

Copy link
Copy Markdown
Member

fix #12528

  • The mul_mat_id assumed Q8_0 type for the src1
  • Fix IQ4_NL param type to by Q8_0 instead of IQ4_NL
  • Code indentations

@ggerganov

Copy link
Copy Markdown
Member Author

@Djip007 Could you take a look at these fixes?

@github-actions github-actions Bot added the ggml changes relating to the ggml tensor library for machine learning label Mar 24, 2025

@Djip007 Djip007 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a very quick review...

Comment thread ggml/src/ggml-cpu/ggml-cpu-aarch64.cpp Outdated
INTER_SIZE);
}
} else {
GGML_ASSERT(PARAM_TYPE == GGML_TYPE_Q8_0);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For C++ I'll use in this case

        if constexpr (PARAM_TYPE == GGML_TYPE_Q8_0) { ... }
        if constexpr (PARAM_TYPE == GGML_TYPE_Q8_K) { ... }

and if this is the only to possible may may be some

  static_assert( (PARAM_TYPE == GGML_TYPE_Q8_K) || (PARAM_TYPE == GGML_TYPE_Q8_0), "comment");

but it may be trap by adding gem[v/m] PARAM_TYPE as template param

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may be remove the if and change (transforme) the quantize_mat_q8_K/quantize_mat_q8_0 to template quantize_mat<PARAM_TYPE>

template <ggml_type PARAM_TYPE>
void quantize_mat(...);

tempate<> quantize_mat<GGML_TYPE_Q8_0>(...) {
    quantize_mat_q8_0(...);  // or "inline" it.
}
tempate<> quantize_mat<GGML_TYPE_Q8_0>(...) {
    quantize_mat_q8_K(...);
}


// instance for IQ4
static const tensor_traits<block_iq4_nl, 4, 4, GGML_TYPE_IQ4_NL> iq4_nl_4x4_q8_0;
static const tensor_traits<block_iq4_nl, 4, 4, GGML_TYPE_Q8_0> iq4_nl_4x4_q8_0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with the static_assert it will be catch a build time.

Comment thread ggml/src/ggml-cpu/ggml-cpu-aarch64.cpp Outdated

template <>
void gemv<block_iq4_nl, 4, 4>(int n, float * s, size_t bs, const void * vx, const void * vy, int nr, int nc) {
template <> void gemv<block_iq4_nl, 4, 4>(int n, float * s, size_t bs, const void * vx, const void * vy, int nr, int nc) {

@Djip007 Djip007 Mar 24, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may be add the PARAM_TYPE on this template to

template <typename BLOC_TYPE, int64_t INTER_SIZE, int64_t NB_COLS, ggml_type PARAM_TYPE>
void gem[m,v]....

@ggerganov

Copy link
Copy Markdown
Member Author

@Djip007 Thanks. Let me know if you have any other suggestions.

@ggerganov

Copy link
Copy Markdown
Member Author

Merging this for now and happy to hear if you have any additional suggestions.

Seunghhon pushed a commit to Seunghhon/llama.cpp that referenced this pull request Apr 26, 2026
* ggml : fix MUL_MAT_ID repack with Q8_K

ggml-ci

* ggml : improve repack templates

ggml-ci
ljubomirj pushed a commit to ljubomirj/llama.cpp that referenced this pull request May 6, 2026
* ggml : fix MUL_MAT_ID repack with Q8_K

ggml-ci

* ggml : improve repack templates

ggml-ci
my-other-github-account pushed a commit to my-other-github-account/llama.cpp that referenced this pull request May 15, 2026
* ggml : fix MUL_MAT_ID repack with Q8_K

ggml-ci

* ggml : improve repack templates

ggml-ci
my-other-github-account pushed a commit to my-other-github-account/llama.cpp that referenced this pull request May 15, 2026
* ggml : fix MUL_MAT_ID repack with Q8_K

ggml-ci

* ggml : improve repack templates

ggml-ci
phibya pushed a commit to ziee-ai/llama.cpp that referenced this pull request May 29, 2026
* ggml : fix MUL_MAT_ID repack with Q8_K

ggml-ci

* ggml : improve repack templates

ggml-ci
AlexiAlp pushed a commit to minghaop/llama.cpp that referenced this pull request Jun 2, 2026
* ggml : fix MUL_MAT_ID repack with Q8_K

ggml-ci

* ggml : improve repack templates

ggml-ci
AlexiAlp pushed a commit to minghaop/llama.cpp that referenced this pull request Jun 2, 2026
* ggml : fix MUL_MAT_ID repack with Q8_K

ggml-ci

* ggml : improve repack templates

ggml-ci
fukuro-kun pushed a commit to fukuro-kun/fukuro-llama-cpp-turboquant that referenced this pull request Jul 5, 2026
* ggml : fix MUL_MAT_ID repack with Q8_K

ggml-ci

* ggml : improve repack templates

ggml-ci
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ggml changes relating to the ggml tensor library for machine learning

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Eval bug: Program not working properly due to new features of "repack Q4_K tensor"

2 participants