Skip to content

Eval bug: Garbled output with Granite-3.1 3B Q4_0 on OpenCL after #15270 #16152

@Kieran-Griperay

Description

@Kieran-Griperay

Name and Version

./llama-cli -m granite-3.1-3b-a800m-instruct-Q4_0.gguf -p "What is the capital of France? Answer consisely" -ngl 90
built using the adrenoCL tools.
Ran on samsung s25 with snapdragon 8 elite
version: 6166 (c36e54d06)
built with Android (11349228, +pgo, +bolt, +lto, -mlgo, based on r487747e) clang version 17.0.2 (https://android.googlesource.com/toolchain/llvm-project d9f89f4d16663d5012e5c09495f3b30ece3d2362) for x86_64-unknown-linux-gnu

Operating systems

Linux

GGML backends

OpenCL

Hardware

samsung s25 with snapdragon 8 elite

Models

granite-3.1-3b-a800m-instruct-Q4_0.gguf

Problem description & steps to reproduce

When I run the granite ibm Q4 moe model on the latest release of llama.cpp I get garbled output. When I revert back to the version before mxfp4 I get more coherent output, but I lose the ability to use Q8 MoE models.

First Bad Commit

#15270 #15270

Relevant log output

130|pa1q:/data/local/tmp # ./llama-cli -m granite-3.1-3b-a800m-instruct-Q4_0.gguf -p "What is the capital of France? Answer consisely" -ngl 90
ggml_opencl: selected platform: 'QUALCOMM Snapdragon(TM)'

ggml_opencl: device: 'QUALCOMM Adreno(TM) 830 (OpenCL 3.0 Adreno(TM) 830)'
ggml_opencl: OpenCL driver: OpenCL 3.0 QUALCOMM build: commit unknown Compiler E031.47.18.13
ggml_opencl: vector subgroup broadcast support: true
ggml_opencl: device FP16 support: true
ggml_opencl: mem base addr align: 128
ggml_opencl: max mem alloc size: 1024 MB
ggml_opencl: SVM coarse grain buffer support: true
ggml_opencl: SVM fine grain buffer support: true
ggml_opencl: SVM fine grain system support: false
ggml_opencl: SVM atomics support: true
ggml_opencl: flattening quantized weights representation as struct of arrays (GGML_OPENCL_SOA_Q)
ggml_opencl: using kernels optimized for Adreno (GGML_OPENCL_USE_ADRENO_KERNELS)
ggml_opencl: loading OpenCL kernels..................................................................
ggml_opencl: default device: 'QUALCOMM Adreno(TM) 830 (OpenCL 3.0 Adreno(TM) 830)'
build: 6166 (c36e54d06) with Android (11349228, +pgo, +bolt, +lto, -mlgo, based on r487747e) clang version 17.0.2 (https://android.googlesource.com/toolchain/llvm-project d9f89f4d16663d5012e5c09495f3b30ece3d2362) for x86_64-unknown-linux-gnu
main: llama backend init
main: load the model and apply lora adapter, if any
llama_model_load_from_file_impl: using device GPUOpenCL (QUALCOMM Adreno(TM) 830) - 0 MiB free
llama_model_loader: loaded meta data with 46 key-value pairs and 322 tensors from granite-3.1-3b-a800m-instruct-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              = granitemoe
llama_model_loader: - kv   1:                               general.type str              = model
llama_model_loader: - kv   2:                               general.name str              = Granite 3.1 3b A800M Instruct
llama_model_loader: - kv   3:                           general.finetune str              = instruct
llama_model_loader: - kv   4:                           general.basename str              = granite-3.1
llama_model_loader: - kv   5:                         general.size_label str              = 3B-a800M
llama_model_loader: - kv   6:                            general.license str              = apache-2.0
llama_model_loader: - kv   7:                   general.base_model.count u32              = 1
llama_model_loader: - kv   8:                  general.base_model.0.name str              = Granite 3.1 3b A800M Base
llama_model_loader: - kv   9:          general.base_model.0.organization str              = Ibm Granite
llama_model_loader: - kv  10:              general.base_model.0.repo_url str              = https://huggingface.co/ibm-granite/gr...
llama_model_loader: - kv  11:                               general.tags arr[str,3]       = ["language", "granite-3.1", "text-gen...
llama_model_loader: - kv  12:                     granitemoe.block_count u32              = 32
llama_model_loader: - kv  13:                  granitemoe.context_length u32              = 131072
llama_model_loader: - kv  14:                granitemoe.embedding_length u32              = 1536
llama_model_loader: - kv  15:             granitemoe.feed_forward_length u32              = 512
llama_model_loader: - kv  16:            granitemoe.attention.head_count u32              = 24
llama_model_loader: - kv  17:         granitemoe.attention.head_count_kv u32              = 8
llama_model_loader: - kv  18:                  granitemoe.rope.freq_base f32              = 10000000.000000
llama_model_loader: - kv  19: granitemoe.attention.layer_norm_rms_epsilon f32              = 0.000001
llama_model_loader: - kv  20:                    granitemoe.expert_count u32              = 40
llama_model_loader: - kv  21:               granitemoe.expert_used_count u32              = 8
llama_model_loader: - kv  22:                          general.file_type u32              = 2
llama_model_loader: - kv  23:                      granitemoe.vocab_size u32              = 49155
llama_model_loader: - kv  24:            granitemoe.rope.dimension_count u32              = 64
llama_model_loader: - kv  25:                 granitemoe.attention.scale f32              = 0.015625
llama_model_loader: - kv  26:                 granitemoe.embedding_scale f32              = 12.000000
llama_model_loader: - kv  27:                  granitemoe.residual_scale f32              = 0.220000
llama_model_loader: - kv  28:                     granitemoe.logit_scale f32              = 6.000000
llama_model_loader: - kv  29:                       tokenizer.ggml.model str              = gpt2
llama_model_loader: - kv  30:                         tokenizer.ggml.pre str              = refact
llama_model_loader: - kv  31:                      tokenizer.ggml.tokens arr[str,49155]   = ["<|end_of_text|>", "<fim_prefix>", "...
llama_model_loader: - kv  32:                  tokenizer.ggml.token_type arr[i32,49155]   = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, ...
llama_model_loader: - kv  33:                      tokenizer.ggml.merges arr[str,48891]   = ["Ġ Ġ", "ĠĠ ĠĠ", "ĠĠĠĠ ĠĠ...
llama_model_loader: - kv  34:                tokenizer.ggml.bos_token_id u32              = 0
llama_model_loader: - kv  35:                tokenizer.ggml.eos_token_id u32              = 0
llama_model_loader: - kv  36:            tokenizer.ggml.unknown_token_id u32              = 0
llama_model_loader: - kv  37:            tokenizer.ggml.padding_token_id u32              = 0
llama_model_loader: - kv  38:               tokenizer.ggml.add_bos_token bool             = false
llama_model_loader: - kv  39:                    tokenizer.chat_template str              = {%- if messages[0]['role'] == 'system...
llama_model_loader: - kv  40:            tokenizer.ggml.add_space_prefix bool             = false
llama_model_loader: - kv  41:               general.quantization_version u32              = 2
llama_model_loader: - kv  42:                      quantize.imatrix.file str              = /models_out/granite-3.1-3b-a800m-inst...
llama_model_loader: - kv  43:                   quantize.imatrix.dataset str              = /training_dir/calibration_datav3.txt
llama_model_loader: - kv  44:             quantize.imatrix.entries_count i32              = 250
llama_model_loader: - kv  45:              quantize.imatrix.chunks_count i32              = 152
llama_model_loader: - type  f32:   97 tensors
llama_model_loader: - type q4_0:  220 tensors
llama_model_loader: - type q4_1:    4 tensors
llama_model_loader: - type q6_K:    1 tensors
print_info: file format = GGUF V3 (latest)
print_info: file type   = Q4_0
print_info: file size   = 1.76 GiB (4.58 BPW)
load: printing all EOG tokens:
load:   - 0 ('<|end_of_text|>')
load:   - 4 ('<fim_pad>')
load:   - 18 ('<reponame>')
load: special tokens cache size = 22
load: token to piece cache size = 0.2826 MB
print_info: arch             = granitemoe
print_info: vocab_only       = 0
print_info: n_ctx_train      = 131072
print_info: n_embd           = 1536
print_info: n_layer          = 32
print_info: n_head           = 24
print_info: n_head_kv        = 8
print_info: n_rot            = 64
print_info: n_swa            = 0
print_info: is_swa_any       = 0
print_info: n_embd_head_k    = 64
print_info: n_embd_head_v    = 64
print_info: n_gqa            = 3
print_info: n_embd_k_gqa     = 512
print_info: n_embd_v_gqa     = 512
print_info: f_norm_eps       = 0.0e+00
print_info: f_norm_rms_eps   = 1.0e-06
print_info: f_clamp_kqv      = 0.0e+00
print_info: f_max_alibi_bias = 0.0e+00
n_tensors: 322
print_info: f_logit_scale    = 6.0e+00
Context size 142416
print_info: f_attn_scale     = 1.6e-02
print_info: n_ff             = 512
print_info: n_expert         = 40
print_info: n_expert_used    = 8
print_info: causal attn      = 1
print_info: pooling type     = 0
print_info: rope type        = 0
print_info: rope scaling     = linear
print_info: freq_base_train  = 10000000.0
print_info: freq_scale_train = 1
print_info: n_ctx_orig_yarn  = 131072
print_info: rope_finetuned   = yes
print_info: model type       = 3B
print_info: model params     = 3.30 B
print_info: general.name     = Granite 3.1 3b A800M Instruct
print_info: f_embedding_scale = 12.000000
print_info: f_residual_scale  = 0.220000
print_info: f_attention_scale = 0.015625
print_info: n_ff_shexp        = 0
print_info: vocab type       = BPE
print_info: n_vocab          = 49155
print_info: n_merges         = 48891
print_info: BOS token        = 0 '<|end_of_text|>'
print_info: EOS token        = 0 '<|end_of_text|>'
print_info: UNK token        = 0 '<|end_of_text|>'
print_info: PAD token        = 0 '<|end_of_text|>'
print_info: LF token         = 203 'Ċ'
print_info: FIM PRE token    = 1 '<fim_prefix>'
print_info: FIM SUF token    = 3 '<fim_suffix>'
print_info: FIM MID token    = 2 '<fim_middle>'
print_info: FIM PAD token    = 4 '<fim_pad>'
print_info: FIM REP token    = 18 '<reponame>'
print_info: EOG token        = 0 '<|end_of_text|>'
print_info: EOG token        = 4 '<fim_pad>'
print_info: EOG token        = 18 '<reponame>'
print_info: max token length = 512
load_tensors: loading model tensors, this can take a while... (mmap = true)
load_tensors: offloading 32 repeating layers to GPU
load_tensors: offloading output layer to GPU
load_tensors: offloaded 33/33 layers to GPU
load_tensors:   CPU_Mapped model buffer size =   249.56 MiB
load_tensors:       OpenCL model buffer size =  1727.45 MiB
................................................................................................
llama_context: constructing llama_context
llama_context: n_seq_max     = 1
llama_context: n_ctx         = 4096
llama_context: n_ctx_per_seq = 4096
llama_context: n_batch       = 2048
llama_context: n_ubatch      = 512
llama_context: causal_attn   = 1
llama_context: flash_attn    = 0
llama_context: kv_unified    = false
llama_context: freq_base     = 10000000.0
llama_context: freq_scale    = 1
llama_context: n_ctx_per_seq (4096) < n_ctx_train (131072) -- the full capacity of the model will not be utilized
llama_context:        CPU  output buffer size =     0.19 MiB
llama_kv_cache_unified:     OpenCL KV buffer size =   256.00 MiB
llama_kv_cache_unified: size =  256.00 MiB (  4096 cells,  32 layers,  1/1 seqs), K (f16):  128.00 MiB, V (f16):  128.00 MiB
llama_context:     OpenCL compute buffer size =   235.16 MiB
llama_context:        CPU compute buffer size =    34.01 MiB
llama_context: graph nodes  = 2056
llama_context: graph splits = 10
common_init_from_params: added <|end_of_text|> logit bias = -inf
common_init_from_params: added <fim_pad> logit bias = -inf
common_init_from_params: added <reponame> logit bias = -inf
common_init_from_params: setting dry_penalty_last_n to ctx_size = 4096
common_init_from_params: warming up the model with an empty run - please wait ... (--no-warmup to disable)
main: llama threadpool init, n_threads = 8
main: chat template is available, enabling conversation mode (disable it with -no-cnv)
*** User-specified prompt will pre-start conversation, did you mean to set --system-prompt (-sys) instead?
main: chat template example:
<|start_of_role|>system<|end_of_role|>You are a helpful assistant<|end_of_text|>
<|start_of_role|>user<|end_of_role|>Hello<|end_of_text|>
<|start_of_role|>assistant<|end_of_role|>Hi there<|end_of_text|>
<|start_of_role|>user<|end_of_role|>How are you?<|end_of_text|>
<|start_of_role|>assistant<|end_of_role|>


system_info: n_threads = 8 (n_threads_batch = 8) / 8 | CPU : NEON = 1 | ARM_FMA = 1 | LLAMAFILE = 1 | OPENMP = 1 | REPACK = 1 |

main: interactive mode on.
sampler seed: 3717627816
sampler params:
        repeat_last_n = 64, repeat_penalty = 1.000, frequency_penalty = 0.000, presence_penalty = 0.000
        dry_multiplier = 0.000, dry_base = 1.750, dry_allowed_length = 2, dry_penalty_last_n = 4096
        top_k = 40, top_p = 0.950, min_p = 0.050, xtc_probability = 0.000, xtc_threshold = 0.100, typical_p = 1.000, top_n_sigma = -1.000, temp = 0.800
        mirostat = 0, mirostat_lr = 0.100, mirostat_ent = 5.000
sampler chain: logits -> logit-bias -> penalties -> dry -> top-n-sigma -> top-k -> typical -> top-p -> min-p -> xtc -> temp-ext -> dist
generate: n_ctx = 4096, n_batch = 2048, n_predict = -1, n_keep = 0

== Running in interactive mode. ==
 - Press Ctrl+C to interject at any time.
 - Press Return to return control to the AI.
 - To return control without starting a new line, end your input with '/'.
 - If you want to submit another line, end your input with '\'.
 - Not using system message. To change it, set a different value via -sys PROMPT

userWhat is the capital of France? Answer consisely
assistant
The capital of France is Paris.[PARISON]
Paris
Paris

The capital city of
France
is
Paris.

Indeed
Here's the capital city ofFrance
in
Paris

indeed

>
llama_perf_sampler_print:    sampling time =       3.81 ms /    89 runs   (    0.04 ms per token, 23353.45 tokens per second)
llama_perf_context_print:        load time =    3893.32 ms
llama_perf_context_print: prompt eval time =     229.87 ms /    20 tokens (   11.49 ms per token,    87.01 tokens per second)
llama_perf_context_print:        eval time =    1562.51 ms /    68 runs   (   22.98 ms per token,    43.52 tokens per second)
llama_perf_context_print:       total time =    4077.01 ms /    88 tokens
llama_perf_context_print:    graphs reused =         65
Interrupted by user

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions