Archived
core/format: an imatrix entry is found under llama.cpp's spelling, .weight and all
llama.cpp names each imatrix entry by its tensor (blk.0.attn_q.weight.in_sum2); importance_for stripped .weight from the weight's name and looked up only the bare stem, so --imatrix matched no weight from a llama.cpp file: the codebook types that need it (iq1_s, iq2_xxs, iq2_xs) were refused and every other type was quantised without its importances. Both spellings are found now, per-expert rows included, and the row is read under the entry's own name. Tests: format_test a_converter_weight_name_finds_llama_cpps_spelling (a dense and a stacked expert entry spelled .weight.in_sum2, a missing expert, a wrong width) fails without the change and passes with it; a_converter_weight_name_finds_its_imatrix_row (the bare spelling) is unchanged.
This commit is contained in:
1 parent
b56139a96a
commit
fa8c746497
2 files changed
+36
-5
No files matched your search
@@ -2015,6 +2015,30 @@ TEST(a_converter_weight_name_finds_its_imatrix_row) {
|
||||
CHECK(!im.importance_for("blk.0.attn_k.weight", 4, &w));
|
||||
}
|
||||
|
||||
/* llama.cpp's imatrix (tools/imatrix, "%s.in_sum2" of the tensor's name) keeps `.weight` in every
|
||||
* entry's name; a converter weight finds that spelling too, dense or an expert of a stack. */
|
||||
TEST(a_converter_weight_name_finds_llama_cpps_spelling) {
|
||||
const std::string path = write_tmp("names-llama.imatrix", gguf_bytes(
|
||||
{
|
||||
{ "blk.0.attn_q.weight.in_sum2", { 4 }, { 1.0f, 2.0f, 3.0f, 6.0f } },
|
||||
{ "blk.5.ffn_down_exps.weight.in_sum2", { 4, 2 },
|
||||
{ 1.0f, 1.0f, 1.0f, 1.0f, 8.0f, 4.0f, 2.0f, 2.0f } },
|
||||
{ "blk.5.ffn_down_exps.weight.counts", { 1, 2 }, { 10.0f, 3.0f } },
|
||||
},
|
||||
{}));
|
||||
ImatrixFile im;
|
||||
REQUIRE(im.open(path) == RAD_OK);
|
||||
std::vector<float> w;
|
||||
REQUIRE(im.importance_for("blk.0.attn_q.weight", 4, &w));
|
||||
CHECK_NEAR(w[0], 1.0 / 3.0, 1e-6);
|
||||
CHECK_NEAR(w[3], 2.0, 1e-6);
|
||||
REQUIRE(im.importance_for("blk.5.ffn_down_exps.1.weight", 4, &w));
|
||||
CHECK_NEAR(w[0], 2.0, 1e-6); /* expert 1's own row, mean 4 */
|
||||
CHECK_NEAR(w[2], 0.5, 1e-6);
|
||||
CHECK(!im.importance_for("blk.5.ffn_down_exps.2.weight", 4, &w)); /* no expert 2 */
|
||||
CHECK(!im.importance_for("blk.0.attn_q.weight", 5, &w));
|
||||
}
|
||||
|
||||
/* With general.alignment 1 every float of a payload may sit at an odd address; the importance is
|
||||
* read by memcpy, so its values are those the file holds. */
|
||||
TEST(an_importance_at_an_odd_offset_reads_the_values_the_file_holds) {
|
||||
|
||||
Reference in new issue
Block a user