ARM-software / ML-examples

Arm Machine Learning tutorials and examples
https://developer.arm.com/technologies/machine-learning-on-arm
Apache License 2.0
437 stars 195 forks source link

[Bug]"GGML_ASSERT: ……llama.cpp/ggml-kleidiai.cpp:444: n % nth == 0 Aborted" assert fail after run kleidiai demo with more thread on SM8650 #141

Open AndreaChiChengdu opened 3 months ago

AndreaChiChengdu commented 3 months ago

I only modified t6 instead of t4, t4 t5 both work well for this model,but if we set the thread=6,will always trigger the problem on my XIAOMI14Pro(SM8650 8Gen3) please check it for resolve thanks~ ———————————————————————————————————————————————————— shennong:/data/local/tmp $ ./llama-cli -m phi-2.Q4_0.gguf -p "Write a code in C for bubble sorting" -n 32 -t 6

Log start

main: build = 3147 (6fcd1331)

main: built with Android (12027248, +pgo, +bolt, +lto, +mlgo, based on r522817) clang version 18.0.1 (https://android.googlesource.com/toolchain/llvm-project d8003a456d14a3deb8054cdaa529ffbf02d9b262) for x86_64-unknown-linux-gnu

main: seed = 1722577686

llama_model_loader: loaded meta data with 20 key-value pairs and 325 tensors from phi-2.Q4_0.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 = phi2

llama_model_loader: - kv 1: general.name str = Phi2

llama_model_loader: - kv 2: phi2.context_length u32 = 2048

llama_model_loader: - kv 3: phi2.embedding_length u32 = 2560

llama_model_loader: - kv 4: phi2.feed_forward_length u32 = 10240

llama_model_loader: - kv 5: phi2.block_count u32 = 32

llama_model_loader: - kv 6: phi2.attention.head_count u32 = 32

llama_model_loader: - kv 7: phi2.attention.head_count_kv u32 = 32

llama_model_loader: - kv 8: phi2.attention.layer_norm_epsilon f32 = 0.000010

llama_model_loader: - kv 9: phi2.rope.dimension_count u32 = 32

llama_model_loader: - kv 10: general.file_type u32 = 2

llama_model_loader: - kv 11: tokenizer.ggml.add_bos_token bool = false

llama_model_loader: - kv 12: tokenizer.ggml.model str = gpt2

llama_model_loader: - kv 13: tokenizer.ggml.tokens arr[str,51200] = ["!", "\"", "#", "$", "%", "&", "'", ...

llama_model_loader: - kv 14: tokenizer.ggml.token_type arr[i32,51200] = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...

llama_model_loader: - kv 15: tokenizer.ggml.merges arr[str,50000] = ["Ġ t", "Ġ a", "h e", "i n", "r e",...

llama_model_loader: - kv 16: tokenizer.ggml.bos_token_id u32 = 50256

llama_model_loader: - kv 17: tokenizer.ggml.eos_token_id u32 = 50256

llama_model_loader: - kv 18: tokenizer.ggml.unknown_token_id u32 = 50256

llama_model_loader: - kv 19: general.quantization_version u32 = 2

llama_model_loader: - type f32: 195 tensors

llama_model_loader: - type q4_0: 129 tensors

llama_model_loader: - type q6_K: 1 tensors

llama_model_loader: mmap is not supported on this platform

llm_load_vocab: missing pre-tokenizer type, using: 'default'

llm_load_vocab:

llm_load_vocab: ****

llm_load_vocab: GENERATION QUALITY WILL BE DEGRADED!

llm_load_vocab: CONSIDER REGENERATING THE MODEL

llm_load_vocab: ****

llm_load_vocab:

llm_load_vocab: special tokens cache size = 944

llm_load_vocab: token to piece cache size = 0.3151 MB

llm_load_print_meta: format = GGUF V3 (latest)

llm_load_print_meta: arch = phi2

llm_load_print_meta: vocab type = BPE

llm_load_print_meta: n_vocab = 51200

llm_load_print_meta: n_merges = 50000

llm_load_print_meta: n_ctx_train = 2048

llm_load_print_meta: n_embd = 2560

llm_load_print_meta: n_head = 32

llm_load_print_meta: n_head_kv = 32

llm_load_print_meta: n_layer = 32

llm_load_print_meta: n_rot = 32

llm_load_print_meta: n_embd_head_k = 80

llm_load_print_meta: n_embd_head_v = 80

llm_load_print_meta: n_gqa = 1

llm_load_print_meta: n_embd_k_gqa = 2560

llm_load_print_meta: n_embd_v_gqa = 2560

llm_load_print_meta: f_norm_eps = 1.0e-05

llm_load_print_meta: f_norm_rms_eps = 0.0e+00

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 = 10240

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 = 2

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: model type = 3B

llm_load_print_meta: model ftype = Q4_0

llm_load_print_meta: model params = 2.78 B

llm_load_print_meta: model size = 1.49 GiB (4.61 BPW)

llm_load_print_meta: general.name = Phi2

llm_load_print_meta: BOS token = 50256 '<|endoftext|>'

llm_load_print_meta: EOS token = 50256 '<|endoftext|>'

llm_load_print_meta: UNK token = 50256 '<|endoftext|>'

llm_load_print_meta: LF token = 128 'Ä'

llm_load_print_meta: EOT token = 50256 '<|endoftext|>'

llm_load_tensors: ggml ctx size = 0.16 MiB

llm_load_tensors: CPU buffer size = 1526.50 MiB

...........................................................................................

llama_new_context_with_model: n_ctx = 2048

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_kv_cache_init: CPU KV buffer size = 640.00 MiB

llama_new_context_with_model: KV self size = 640.00 MiB, K (f16): 320.00 MiB, V (f16): 320.00 MiB

llama_new_context_with_model: CPU output buffer size = 0.20 MiB

llama_new_context_with_model: CPU compute buffer size = 167.01 MiB

llama_new_context_with_model: graph nodes = 1225

llama_new_context_with_model: graph splits = 1

GGML_ASSERT: /home/andreaji/workspace/arm_kleidiAI/llama.cpp/ggml-kleidiai.cpp:444: n % nth == 0

GGML_ASSERT: /home/andreaji/workspace/arm_kleidiAI/llama.cpp/ggml-kleidiai.cpp:444: n % nth == 0

GGML_ASSERT: /home/andreaji/workspace/arm_kleidiAI/llama.cpp/ggml-kleidiai.cpp:444: n % nth == 0

GGML_ASSERT: /home/andreaji/workspace/arm_kleidiAI/llama.cpp/ggml-kleidiai.cpp:444: n % nth == 0

GGML_ASSERT: /home/andreaji/workspace/arm_kleidiAI/llama.cpp/ggml-kleidiai.cpp:444: n % nth == 0

GGML_ASSERT: /home/andreaji/workspace/arm_kleidiAI/llama.cpp/ggml-kleidiai.cpp:444: n % nth == 0

Aborted

kshitij-sisodia-arm commented 2 months ago

Hi @AndreaChiChengdu,

Thanks for bringing this to our attention. This patch was created to demonstrate a possible integration point for KleidiAI in llama.cpp. We will work separately with llama.cpp to provide a proper solution.