Spaces:
Running
Running
Commit
·
73547ad
1
Parent(s):
a2e9ccb
gguf: fix failure on version == 0 (llama/13956)
Browse files- ggml/src/gguf.cpp +9 -6
ggml/src/gguf.cpp
CHANGED
|
@@ -347,6 +347,11 @@ struct gguf_context * gguf_init_from_file_impl(FILE * file, struct gguf_init_par
|
|
| 347 |
int64_t n_tensors = 0;
|
| 348 |
|
| 349 |
if (ok && gr.read(ctx->version)) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 350 |
/*
|
| 351 |
* bit layout is different when reading non-native endian models.
|
| 352 |
* assuming that the GGUF version is 3, the non-native endian model
|
|
@@ -354,18 +359,16 @@ struct gguf_context * gguf_init_from_file_impl(FILE * file, struct gguf_init_par
|
|
| 354 |
* the last 4 hexadecimal digits to check if the model is the same
|
| 355 |
* endianness as the host system.
|
| 356 |
*/
|
| 357 |
-
if ((ctx->version & 0x0000FFFF) == 0x00000000) {
|
| 358 |
GGML_LOG_ERROR("%s: failed to load model: this GGUF file version %" PRIu32 " is extremely large, is there a mismatch between the host and model endianness?\n", __func__, ctx->version);
|
| 359 |
-
|
| 360 |
-
return nullptr;
|
| 361 |
}
|
| 362 |
|
| 363 |
-
|
| 364 |
-
if (ctx->version == 1) {
|
| 365 |
GGML_LOG_ERROR("%s: GGUFv1 is no longer supported, please use a more up-to-date version\n", __func__);
|
| 366 |
ok = false;
|
| 367 |
}
|
| 368 |
-
if (ctx->version > GGUF_VERSION) {
|
| 369 |
GGML_LOG_ERROR("%s: this GGUF file is version %" PRIu32 " but this software only supports up to version %d\n",
|
| 370 |
__func__, ctx->version, GGUF_VERSION);
|
| 371 |
ok = false;
|
|
|
|
| 347 |
int64_t n_tensors = 0;
|
| 348 |
|
| 349 |
if (ok && gr.read(ctx->version)) {
|
| 350 |
+
if (ok && ctx->version == 0) {
|
| 351 |
+
GGML_LOG_ERROR("%s: bad GGUF version: %" PRIu32 "\n", __func__, ctx->version);
|
| 352 |
+
ok = false;
|
| 353 |
+
}
|
| 354 |
+
|
| 355 |
/*
|
| 356 |
* bit layout is different when reading non-native endian models.
|
| 357 |
* assuming that the GGUF version is 3, the non-native endian model
|
|
|
|
| 359 |
* the last 4 hexadecimal digits to check if the model is the same
|
| 360 |
* endianness as the host system.
|
| 361 |
*/
|
| 362 |
+
if (ok && (ctx->version & 0x0000FFFF) == 0x00000000) {
|
| 363 |
GGML_LOG_ERROR("%s: failed to load model: this GGUF file version %" PRIu32 " is extremely large, is there a mismatch between the host and model endianness?\n", __func__, ctx->version);
|
| 364 |
+
ok = false;
|
|
|
|
| 365 |
}
|
| 366 |
|
| 367 |
+
if (ok && ctx->version == 1) {
|
|
|
|
| 368 |
GGML_LOG_ERROR("%s: GGUFv1 is no longer supported, please use a more up-to-date version\n", __func__);
|
| 369 |
ok = false;
|
| 370 |
}
|
| 371 |
+
if (ok && ctx->version > GGUF_VERSION) {
|
| 372 |
GGML_LOG_ERROR("%s: this GGUF file is version %" PRIu32 " but this software only supports up to version %d\n",
|
| 373 |
__func__, ctx->version, GGUF_VERSION);
|
| 374 |
ok = false;
|