File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -4284,7 +4284,21 @@ struct llama_model_loader {
42844284 }
42854285 };
42864286
4287- std::unordered_map<std::string, struct llama_tensor_weight> weights_map;
4287+ // custom comparator to sort weights more nicely by layer
4288+ struct weight_name_comparer {
4289+ bool operator()(const std::string & a, const std::string & b) const {
4290+ int a_layer = -1;
4291+ int b_layer = -1;
4292+ sscanf(a.c_str(), "blk.%d.", &a_layer);
4293+ sscanf(b.c_str(), "blk.%d.", &b_layer);
4294+ if (a_layer != b_layer) {
4295+ return a_layer < b_layer;
4296+ }
4297+ return a < b;
4298+ }
4299+ };
4300+
4301+ std::map<std::string, struct llama_tensor_weight, weight_name_comparer> weights_map;
42884302 std::unordered_map<std::string, struct llama_model_kv_override> kv_overrides;
42894303
42904304 struct gguf_context * meta = NULL;
You can’t perform that action at this time.
0 commit comments