Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc. bug: Unable to load model #10696

Closed
VJHack opened this issue Dec 6, 2024 · 13 comments
Closed

Misc. bug: Unable to load model #10696

VJHack opened this issue Dec 6, 2024 · 13 comments

Comments

@VJHack
Copy link
Contributor

VJHack commented Dec 6, 2024

Name and Version

./build/bin/llama-cli --version
register_backend: registered backend Metal (1 devices)
register_device: registered device Metal (Intel(R) Iris(TM) Plus Graphics 655)
register_backend: registered backend BLAS (1 devices)
register_device: registered device BLAS (Accelerate)
register_backend: registered backend CPU (1 devices)
register_device: registered device CPU (Intel(R) Core(TM) i5-8279U CPU @ 2.40GHz)
version: 4233 (f68367d2)
built with Apple clang version 14.0.0 (clang-1400.0.29.202) for x86_64-apple-darwin21.6.0

Operating systems

Mac

Which llama.cpp modules do you know to be affected?

Other (Please specify in the next section)

Problem description & steps to reproduce

I am unable to load and run inference on any model. Previously with the make build system, I didn't have any issues. But now that our build system has switched to cmake I've been having this issue shown below. I'm not able to use either llama-cli or llama-server.

I'm running on MacOS with 16 GB of memory and Intel Core i5 processor.

How I'm building:
cmake -B build
cmake --build build --config Release

command:
./build/bin/llama-server -m models/tinyllama-1.1b-chat-v1.0.Q2_K.gguf

Any help would be appreciated!

First Bad Commit

No response

Relevant log output

$ ./build/bin/llama-server -m models/tinyllama-1.1b-chat-v1.0.Q2_K.gguf

register_backend: registered backend Metal (1 devices)
register_device: registered device Metal (Intel(R) Iris(TM) Plus Graphics 655)
register_backend: registered backend BLAS (1 devices)
register_device: registered device BLAS (Accelerate)
register_backend: registered backend CPU (1 devices)
register_device: registered device CPU (Intel(R) Core(TM) i5-8279U CPU @ 2.40GHz)
build: 4180 (c6807b3f) with Apple clang version 14.0.0 (clang-1400.0.29.202) for x86_64-apple-darwin21.6.0 (debug)
system info: n_threads = 4, n_threads_batch = 4, total_threads = 8

system_info: n_threads = 4 (n_threads_batch = 4) / 8 | Metal : EMBED_LIBRARY = 1 | CPU : SSE3 = 1 | SSSE3 = 1 | AVX = 1 | AVX2 = 1 | F16C = 1 | FMA = 1 | LLAMAFILE = 1 | AARCH64_REPACK = 1 | 

main: HTTP server is listening, hostname: 127.0.0.1, port: 8080, http threads: 7
main: loading model
srv    load_model: loading model 'models/tinyllama-1.1b-chat-v1.0.Q2_K.gguf'
llama_load_model_from_file: using device Metal (Intel(R) Iris(TM) Plus Graphics 655) - 1531 MiB free
llama_model_loader: loaded meta data with 23 key-value pairs and 201 tensors from models/tinyllama-1.1b-chat-v1.0.Q2_K.gguf (version GGUF V3 (latest))
llama_model_loader: Dumping metadata keys/values. Note: KV overrides do not apply in this output.
llama_model_loader: - kv   0:                       general.architecture str              = llama
llama_model_loader: - kv   1:                               general.name str              = tinyllama_tinyllama-1.1b-chat-v1.0
llama_model_loader: - kv   2:                       llama.context_length u32              = 2048
llama_model_loader: - kv   3:                     llama.embedding_length u32              = 2048
llama_model_loader: - kv   4:                          llama.block_count u32              = 22
llama_model_loader: - kv   5:                  llama.feed_forward_length u32              = 5632
llama_model_loader: - kv   6:                 llama.rope.dimension_count u32              = 64
llama_model_loader: - kv   7:                 llama.attention.head_count u32              = 32
llama_model_loader: - kv   8:              llama.attention.head_count_kv u32              = 4
llama_model_loader: - kv   9:     llama.attention.layer_norm_rms_epsilon f32              = 0.000010
llama_model_loader: - kv  10:                       llama.rope.freq_base f32              = 10000.000000
llama_model_loader: - kv  11:                          general.file_type u32              = 10
llama_model_loader: - kv  12:                       tokenizer.ggml.model str              = llama
llama_model_loader: - kv  13:                      tokenizer.ggml.tokens arr[str,32000]   = ["<unk>", "<s>", "</s>", "<0x00>", "<...
llama_model_loader: - kv  14:                      tokenizer.ggml.scores arr[f32,32000]   = [0.000000, 0.000000, 0.000000, 0.0000...
llama_model_loader: - kv  15:                  tokenizer.ggml.token_type arr[i32,32000]   = [2, 3, 3, 6, 6, 6, 6, 6, 6, 6, 6, 6, ...
llama_model_loader: - kv  16:                      tokenizer.ggml.merges arr[str,61249]   = ["▁ t", "e r", "i n", "▁ a", "e n...
llama_model_loader: - kv  17:                tokenizer.ggml.bos_token_id u32              = 1
llama_model_loader: - kv  18:                tokenizer.ggml.eos_token_id u32              = 2
llama_model_loader: - kv  19:            tokenizer.ggml.unknown_token_id u32              = 0
llama_model_loader: - kv  20:            tokenizer.ggml.padding_token_id u32              = 2
llama_model_loader: - kv  21:                    tokenizer.chat_template str              = {% for message in messages %}\n{% if m...
llama_model_loader: - kv  22:               general.quantization_version u32              = 2
llama_model_loader: - type  f32:   45 tensors
llama_model_loader: - type q2_K:   45 tensors
llama_model_loader: - type q3_K:  110 tensors
llama_model_loader: - type q6_K:    1 tensors
llm_load_vocab: special_eos_id is not in special_eog_ids - the tokenizer config may be incorrect
llm_load_vocab: special tokens cache size = 3
llm_load_vocab: token to piece cache size = 0.1684 MB
llm_load_print_meta: format           = GGUF V3 (latest)
llm_load_print_meta: arch             = llama
llm_load_print_meta: vocab type       = SPM
llm_load_print_meta: n_vocab          = 32000
llm_load_print_meta: n_merges         = 0
llm_load_print_meta: vocab_only       = 0
llm_load_print_meta: n_ctx_train      = 2048
llm_load_print_meta: n_embd           = 2048
llm_load_print_meta: n_layer          = 22
llm_load_print_meta: n_head           = 32
llm_load_print_meta: n_head_kv        = 4
llm_load_print_meta: n_rot            = 64
llm_load_print_meta: n_swa            = 0
llm_load_print_meta: n_embd_head_k    = 64
llm_load_print_meta: n_embd_head_v    = 64
llm_load_print_meta: n_gqa            = 8
llm_load_print_meta: n_embd_k_gqa     = 256
llm_load_print_meta: n_embd_v_gqa     = 256
llm_load_print_meta: f_norm_eps       = 0.0e+00
llm_load_print_meta: f_norm_rms_eps   = 1.0e-05
llm_load_print_meta: f_clamp_kqv      = 0.0e+00
llm_load_print_meta: f_max_alibi_bias = 0.0e+00
llm_load_print_meta: f_logit_scale    = 0.0e+00
llm_load_print_meta: n_ff             = 5632
llm_load_print_meta: n_expert         = 0
llm_load_print_meta: n_expert_used    = 0
llm_load_print_meta: causal attn      = 1
llm_load_print_meta: pooling type     = 0
llm_load_print_meta: rope type        = 0
llm_load_print_meta: rope scaling     = linear
llm_load_print_meta: freq_base_train  = 10000.0
llm_load_print_meta: freq_scale_train = 1
llm_load_print_meta: n_ctx_orig_yarn  = 2048
llm_load_print_meta: rope_finetuned   = unknown
llm_load_print_meta: ssm_d_conv       = 0
llm_load_print_meta: ssm_d_inner      = 0
llm_load_print_meta: ssm_d_state      = 0
llm_load_print_meta: ssm_dt_rank      = 0
llm_load_print_meta: ssm_dt_b_c_rms   = 0
llm_load_print_meta: model type       = 1B
llm_load_print_meta: model ftype      = Q2_K - Medium
llm_load_print_meta: model params     = 1.10 B
llm_load_print_meta: model size       = 459.11 MiB (3.50 BPW) 
llm_load_print_meta: general.name     = tinyllama_tinyllama-1.1b-chat-v1.0
llm_load_print_meta: BOS token        = 1 '<s>'
llm_load_print_meta: EOS token        = 2 '</s>'
llm_load_print_meta: UNK token        = 0 '<unk>'
llm_load_print_meta: PAD token        = 2 '</s>'
llm_load_print_meta: LF token         = 13 '<0x0A>'
llm_load_print_meta: EOG token        = 2 '</s>'
llm_load_print_meta: max token length = 48
llm_load_tensors: offloading 22 repeating layers to GPU
llm_load_tensors: offloading output layer to GPU
llm_load_tensors: offloaded 23/23 layers to GPU
llm_load_tensors: Metal_Mapped model buffer size =   387.33 MiB
llm_load_tensors:   CPU_Mapped model buffer size =   459.10 MiB
...................................................................................
llama_new_context_with_model: n_seq_max     = 1
llama_new_context_with_model: n_ctx         = 4096
llama_new_context_with_model: n_ctx_per_seq = 4096
llama_new_context_with_model: n_batch       = 2048
llama_new_context_with_model: n_ubatch      = 512
llama_new_context_with_model: flash_attn    = 0
llama_new_context_with_model: freq_base     = 10000.0
llama_new_context_with_model: freq_scale    = 1
llama_new_context_with_model: n_ctx_pre_seq (4096) > n_ctx_train (2048) -- possible training context overflow
ggml_metal_init: allocating
ggml_metal_init: found device: Intel(R) Iris(TM) Plus Graphics 655
ggml_metal_init: picking default device: Intel(R) Iris(TM) Plus Graphics 655
ggml_metal_init: using embedded metal library
ggml_metal_init: error: Error Domain=MTLLibraryErrorDomain Code=3 "program_source:56:35: error: unknown type name 'block_q4_0'
void dequantize_q4_0(device const block_q4_0 *xb, short il, thread type4x4 & reg) {
                                  ^
program_source:75:35: error: unknown type name 'block_q4_1'
void dequantize_q4_1(device const block_q4_1 *xb, short il, thread type4x4 & reg) {
                                  ^
program_source:94:35: error: unknown type name 'block_q5_0'
void dequantize_q5_0(device const block_q5_0 *xb, short il, thread type4x4 & reg) {
                                  ^
program_source:126:35: error: unknown type name 'block_q5_1'
void dequantize_q5_1(device const block_q5_1 *xb, short il, thread type4x4 & reg) {
                                  ^


...


ggml_backend_metal_device_init: error: failed to allocate context
llama_new_context_with_model: failed to initialize Metal backend
common_init_from_params: failed to create context with model 'models/tinyllama-1.1b-chat-v1.0.Q2_K.gguf'
main: error: unable to load model
@eugeniosegala
Copy link
Contributor

Could it be related to #10208?

@ggerganov
Copy link
Owner

Could it be related to #10208?

No. The problem here is trying to run the Metal backend on Intel device which is not supported.

@eugeniosegala
Copy link
Contributor

eugeniosegala commented Dec 8, 2024

Thank you @ggerganov.

My setup is:

version: 1 (43ed389)
built with Apple clang version 16.0.0 (clang-1600.0.26.4) for arm64-apple-darwin24.1.0

Is this supported?

As I'm experiencing the same problem.

@ggerganov
Copy link
Owner

It is supported. Show the commands and the full log that you get.

@eugeniosegala
Copy link
Contributor

eugeniosegala commented Dec 8, 2024

Command:

./build/bin/llama-cli -m ./FastLlama-3.2-1B-Instruct.i1-IQ3_XS.gguf -p "I believe the meaning of life is"

Error:

ggml_backend_metal_device_init: error: failed to allocate context
llama_new_context_with_model: failed to initialize Metal backend
common_init_from_params: failed to create context with model './FastLlama-3.2-1B-Instruct.i1-IQ3_XS.gguf'
main: error: unable to load model

However, it works fine when I re-build everything without Metal using -DGGML_METAL=OFF.

@VJHack
Copy link
Contributor Author

VJHack commented Dec 8, 2024

@ggerganov and @eugeniosegala Thanks for the support! Re-building everything without the metal backend worked for me. I'm closing this issue as it is not a bug.

@VJHack VJHack closed this as completed Dec 8, 2024
@eugeniosegala
Copy link
Contributor

@VJHack the fact that the Metal build does not work is okay though?

Is it a working in progress feature?

@ggerganov
Copy link
Owner

Provide more logs: ./build/bin/llama-cli -m ./FastLlama-3.2-1B-Instruct.i1-IQ3_XS.gguf -p "I believe the meaning of life is" -lv 1

@eugeniosegala
Copy link
Contributor

@ggerganov this is what I got back:

debug.log

I got the same with other models too, like llama 3 8b.

@ggerganov
Copy link
Owner

This should fix it:

rm -rf build

cmake -B build
cmake --build build --config Release

./build/bin/llama-cli -m ./FastLlama-3.2-1B-Instruct.i1-IQ3_XS.gguf -p "I believe the meaning of life is"

@eugeniosegala
Copy link
Contributor

eugeniosegala commented Dec 9, 2024

@ggerganov I get the same error.

I have tried to re-build it several times.

P.S: I'm building from latest master

I will try to build it from some previous commits as well.

@ggerganov
Copy link
Owner

Clone the repo from scratch. You likely have some local modifications.

@eugeniosegala
Copy link
Contributor

@ggerganov you are correct, I had to re-clone everything and re-build again, then it worked!

I did not have local changes or anything but maybe something was cached or similar (I did delete the build folder though).

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants