Skip to content

Eval bug: usr/lib/gcc/x86_64-pc-linux-gnu/14/include/g++-v14/bits/random.tcc:2668: void std::discrete_distribution<_IntType>::param_type::_M_initialize() [with _IntType = int]: Assertion '__sum > 0' failed. #15551

@l29ah

Description

@l29ah

Name and Version

b6264 here

ggml_vulkan: Found 1 Vulkan devices:
ggml_vulkan: 0 = AMD Radeon 760M Graphics (RADV PHOENIX) (radv) | uma: 1 | fp16: 1 | bf16: 0 | warp size: 64 | shared memory: 65536 | int dot: 1 | matrix cores: KHR_coopmat
register_backend: registered backend Vulkan (1 devices)
register_device: registered device Vulkan0 (AMD Radeon 760M Graphics (RADV PHOENIX))
register_backend: registered backend BLAS (1 devices)
register_device: registered device BLAS (BLIS)
register_backend: registered backend RPC (0 devices)
register_backend: registered backend CPU (1 devices)
register_device: registered device CPU (AMD Ryzen 5 7640U w/ Radeon 760M Graphics)
version: 0 (unknown)
built with x86_64-pc-linux-gnu-gcc (Gentoo Hardened 14.2.1_p20250419 p8) 14.2.1 20250419 for x86_64-pc-linux-gnu

Operating systems

Linux

GGML backends

Vulkan

Hardware

Radeon 760M Graphics

Models

https://huggingface.co/unsloth/GLM-4.5-Air-GGUF/resolve/main/GLM-4.5-Air-UD-Q2_K_XL.gguf

Problem description & steps to reproduce

I get the assertion failure on some evaluations:

/usr/lib/gcc/x86_64-pc-linux-gnu/14/include/g++-v14/bits/random.tcc:2668: void std::discrete_distribution<_IntType>::param_type::_M_initialize() [with _IntType = int]: Assertion '__sum > 0' failed.

Backtrace:

#0  0x00007f59774cf68c in __pthread_kill_implementation () from /lib64/libc.so.6
#1  0x00007f5977477686 in raise () from /lib64/libc.so.6
#2  0x00007f597745f30b in abort () from /lib64/libc.so.6
#3  0x00007f59776a2954 in std::__glibcxx_assert_fail (file=<optimized out>, line=<optimized out>, function=<optimized out>, condition=<optimized out>)
    at /var/tmp/portage/sys-devel/gcc-15.2.0/work/gcc-15.2.0/libstdc++-v3/src/c++11/assert_fail.cc:41
#4  0x00007f5977b7c11f in std::discrete_distribution<int>::param_type::_M_initialize() () from /usr/lib64/llama.cpp/libllama.so
#5  0x00007f5977b77a3e in llama_sample_dist(llama_token_data_array*, std::mersenne_twister_engine<unsigned long, 32ul, 624ul, 397ul, 31ul, 2567483615ul, 11ul, 4294967295ul, 7ul, 2636928640ul, 15ul, 4022730752ul, 18ul, 1812433253ul>&) [clone .isra.0] () from /usr/lib64/llama.cpp/libllama.so
#6  0x00007f5977b78089 in llama_sampler_dist_apply(llama_sampler*, llama_token_data_array*) () from /usr/lib64/llama.cpp/libllama.so
#7  0x00007f5977b7164b in llama_sampler_chain_apply(llama_sampler*, llama_token_data_array*) () from /usr/lib64/llama.cpp/libllama.so
#8  0x000055f4d339413e in common_sampler_sample(common_sampler*, llama_context*, int, bool) ()
#9  0x000055f4d327403b in server_context::update_slots() ()
#10 0x000055f4d3248cf0 in server_queue::start_loop() ()
#11 0x000055f4d31fb5b2 in main ()

Probably that assert would only be triggered if you build with -D_GLIBCXX_ASSERTIONS or so; i run Hardened Gentoo where this is the default.

First Bad Commit

The earliest i've seen it was on b6181. It doesn't occur every time.

Relevant log output

ggml_vulkan: Found 1 Vulkan devices:
ggml_vulkan: 0 = AMD Radeon 760M Graphics (RADV PHOENIX) (radv) | uma: 1 | fp16: 1 | bf16: 0 | warp size: 64 | shared memory: 65536 | int dot: 1 | matrix cores: KHR_coopmat
register_backend: registered backend Vulkan (1 devices)
register_device: registered device Vulkan0 (AMD Radeon 760M Graphics (RADV PHOENIX))
register_backend: registered backend BLAS (1 devices)
register_device: registered device BLAS (BLIS)
register_backend: registered backend RPC (0 devices)
register_backend: registered backend CPU (1 devices)
register_device: registered device CPU (AMD Ryzen 5 7640U w/ Radeon 760M Graphics)
build: 0 (unknown) with x86_64-pc-linux-gnu-gcc (Gentoo Hardened 14.2.1_p20250419 p8) 14.2.1 20250419 for x86_64-pc-linux-gnu (debug)
system info: n_threads = 6, n_threads_batch = 6, total_threads = 12

system_info: n_threads = 6 (n_threads_batch = 6) / 12 | CPU : SSE3 = 1 | SSSE3 = 1 | AVX = 1 | AVX2 = 1 | F16C = 1 | FMA = 1 | BMI2 = 1 | AVX512 = 1 | AVX512_VBMI = 1 | AVX512_VNNI = 1 | AVX512_BF16 = 1 | LLAMAFILE = 1 | OPENMP = 1 | REPACK = 1 | 

main: binding port with default address family
main: HTTP server is listening, hostname: 127.0.0.1, port: 8080, http threads: 11
main: loading model
srv    load_model: loading model './models/GLM-4.5-Air/GLM-4.5-Air-UD-Q2_K_XL.gguf'
llama_model_load_from_file_impl: using device Vulkan0 (AMD Radeon 760M Graphics (RADV PHOENIX)) - 42759 MiB free
llama_model_loader: loaded meta data with 52 key-value pairs and 803 tensors from ./models/GLM-4.5-Air/GLM-4.5-Air-UD-Q2_K_XL.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              = glm4moe
llama_model_loader: - kv   1:                               general.type str              = model
llama_model_loader: - kv   2:                               general.name str              = Glm-4.5-Air
llama_model_loader: - kv   3:                           general.basename str              = Glm-4.5-Air
llama_model_loader: - kv   4:                       general.quantized_by str              = Unsloth
llama_model_loader: - kv   5:                         general.size_label str              = 128x9.4B
llama_model_loader: - kv   6:                            general.license str              = mit
llama_model_loader: - kv   7:                           general.repo_url str              = https://huggingface.co/unsloth
llama_model_loader: - kv   8:                   general.base_model.count u32              = 1
llama_model_loader: - kv   9:                  general.base_model.0.name str              = GLM 4.5 Air
llama_model_loader: - kv  10:          general.base_model.0.organization str              = Zai Org
llama_model_loader: - kv  11:              general.base_model.0.repo_url str              = https://huggingface.co/zai-org/GLM-4....
llama_model_loader: - kv  12:                               general.tags arr[str,2]       = ["unsloth", "text-generation"]
llama_model_loader: - kv  13:                          general.languages arr[str,2]       = ["en", "zh"]
llama_model_loader: - kv  14:                        glm4moe.block_count u32              = 47
llama_model_loader: - kv  15:                     glm4moe.context_length u32              = 131072
llama_model_loader: - kv  16:                   glm4moe.embedding_length u32              = 4096
llama_model_loader: - kv  17:                glm4moe.feed_forward_length u32              = 10944
llama_model_loader: - kv  18:               glm4moe.attention.head_count u32              = 96
llama_model_loader: - kv  19:            glm4moe.attention.head_count_kv u32              = 8
llama_model_loader: - kv  20:                     glm4moe.rope.freq_base f32              = 1000000.000000
llama_model_loader: - kv  21:   glm4moe.attention.layer_norm_rms_epsilon f32              = 0.000010
llama_model_loader: - kv  22:                  glm4moe.expert_used_count u32              = 8
llama_model_loader: - kv  23:               glm4moe.attention.key_length u32              = 128
llama_model_loader: - kv  24:             glm4moe.attention.value_length u32              = 128
llama_model_loader: - kv  25:               glm4moe.rope.dimension_count u32              = 64
llama_model_loader: - kv  26:                       glm4moe.expert_count u32              = 128
llama_model_loader: - kv  27:         glm4moe.expert_feed_forward_length u32              = 1408
llama_model_loader: - kv  28:                glm4moe.expert_shared_count u32              = 1
llama_model_loader: - kv  29:          glm4moe.leading_dense_block_count u32              = 1
llama_model_loader: - kv  30:                 glm4moe.expert_gating_func u32              = 2
llama_model_loader: - kv  31:               glm4moe.expert_weights_scale f32              = 1.000000
llama_model_loader: - kv  32:                glm4moe.expert_weights_norm bool             = true
llama_model_loader: - kv  33:               glm4moe.nextn_predict_layers u32              = 1
llama_model_loader: - kv  34:                       tokenizer.ggml.model str              = gpt2
llama_model_loader: - kv  35:                         tokenizer.ggml.pre str              = glm4
llama_model_loader: - kv  36:                      tokenizer.ggml.tokens arr[str,151552]  = ["!", "\"", "#", "$", "%", "&", "'", ...
llama_model_loader: - kv  37:                  tokenizer.ggml.token_type arr[i32,151552]  = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...
llama_model_loader: - kv  38:                      tokenizer.ggml.merges arr[str,318088]  = ["Ġ Ġ", "Ġ ĠĠĠ", "ĠĠ ĠĠ", "...
llama_model_loader: - kv  39:                tokenizer.ggml.eos_token_id u32              = 151329
llama_model_loader: - kv  40:            tokenizer.ggml.padding_token_id u32              = 151330
llama_model_loader: - kv  41:                tokenizer.ggml.bos_token_id u32              = 151331
llama_model_loader: - kv  42:                tokenizer.ggml.eot_token_id u32              = 151336
llama_model_loader: - kv  43:            tokenizer.ggml.unknown_token_id u32              = 151329
llama_model_loader: - kv  44:                tokenizer.ggml.eom_token_id u32              = 151338
llama_model_loader: - kv  45:                    tokenizer.chat_template str              = [gMASK]<sop>\n{%- if tools -%}\n<|syste...
llama_model_loader: - kv  46:               general.quantization_version u32              = 2
llama_model_loader: - kv  47:                          general.file_type u32              = 10
llama_model_loader: - kv  48:                      quantize.imatrix.file str              = GLM-4.5-Air-GGUF/imatrix_unsloth.gguf
llama_model_loader: - kv  49:                   quantize.imatrix.dataset str              = unsloth_calibration_GLM-4.5-Air.txt
llama_model_loader: - kv  50:             quantize.imatrix.entries_count u32              = 502
llama_model_loader: - kv  51:              quantize.imatrix.chunks_count u32              = 88
llama_model_loader: - type  f32:  331 tensors
llama_model_loader: - type q5_0:    2 tensors
llama_model_loader: - type q2_K:   95 tensors
llama_model_loader: - type q4_K:  258 tensors
llama_model_loader: - type q5_K:   15 tensors
llama_model_loader: - type q6_K:   11 tensors
llama_model_loader: - type iq4_nl:   91 tensors
print_info: file format = GGUF V3 (latest)
print_info: file type   = Q2_K - Medium
print_info: file size   = 43.25 GiB (3.36 BPW) 
load: special_eot_id is not in special_eog_ids - the tokenizer config may be incorrect
load: special_eom_id is not in special_eog_ids - the tokenizer config may be incorrect
load: printing all EOG tokens:
load:   - 151329 ('<|endoftext|>')
load:   - 151336 ('<|user|>')
load:   - 151338 ('<|observation|>')
load: special tokens cache size = 36
load: token to piece cache size = 0.9713 MB
print_info: arch             = glm4moe
print_info: vocab_only       = 0
print_info: n_ctx_train      = 131072
print_info: n_embd           = 4096
print_info: n_layer          = 47
print_info: n_head           = 96
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    = 128
print_info: n_embd_head_v    = 128
print_info: n_gqa            = 12
print_info: n_embd_k_gqa     = 1024
print_info: n_embd_v_gqa     = 1024
print_info: f_norm_eps       = 0.0e+00
print_info: f_norm_rms_eps   = 1.0e-05
print_info: f_clamp_kqv      = 0.0e+00
print_info: f_max_alibi_bias = 0.0e+00
print_info: f_logit_scale    = 0.0e+00
print_info: f_attn_scale     = 0.0e+00
print_info: n_ff             = 10944
print_info: n_expert         = 128
print_info: n_expert_used    = 8
print_info: causal attn      = 1
print_info: pooling type     = 0
print_info: rope type        = 2
print_info: rope scaling     = linear
print_info: freq_base_train  = 1000000.0
print_info: freq_scale_train = 1
print_info: n_ctx_orig_yarn  = 131072
print_info: rope_finetuned   = unknown
print_info: model type       = 106B.A12B
print_info: model params     = 110.47 B
print_info: general.name     = Glm-4.5-Air
print_info: vocab type       = BPE
print_info: n_vocab          = 151552
print_info: n_merges         = 318088
print_info: BOS token        = 151331 '[gMASK]'
print_info: EOS token        = 151329 '<|endoftext|>'
print_info: EOT token        = 151336 '<|user|>'
print_info: EOM token        = 151338 '<|observation|>'
print_info: UNK token        = 151329 '<|endoftext|>'
print_info: PAD token        = 151330 '[MASK]'
print_info: LF token         = 198 'Ċ'
print_info: FIM PRE token    = 151347 '<|code_prefix|>'
print_info: FIM SUF token    = 151349 '<|code_suffix|>'
print_info: FIM MID token    = 151348 '<|code_middle|>'
print_info: EOG token        = 151329 '<|endoftext|>'
print_info: EOG token        = 151336 '<|user|>'
print_info: EOG token        = 151338 '<|observation|>'
print_info: max token length = 1024
load_tensors: loading model tensors, this can take a while... (mmap = true)
model has unused tensor blk.46.attn_norm.weight (size = 16384 bytes) -- ignoring
model has unused tensor blk.46.attn_q.weight (size = 28311552 bytes) -- ignoring
model has unused tensor blk.46.attn_k.weight (size = 2359296 bytes) -- ignoring
model has unused tensor blk.46.attn_v.weight (size = 2359296 bytes) -- ignoring
model has unused tensor blk.46.attn_q.bias (size = 49152 bytes) -- ignoring
model has unused tensor blk.46.attn_k.bias (size = 4096 bytes) -- ignoring
model has unused tensor blk.46.attn_v.bias (size = 4096 bytes) -- ignoring
model has unused tensor blk.46.attn_output.weight (size = 28311552 bytes) -- ignoring
model has unused tensor blk.46.post_attention_norm.weight (size = 16384 bytes) -- ignoring
model has unused tensor blk.46.ffn_gate_inp.weight (size = 2097152 bytes) -- ignoring
model has unused tensor blk.46.exp_probs_b.bias (size = 512 bytes) -- ignoring
model has unused tensor blk.46.ffn_gate_exps.weight (size = 242221056 bytes) -- ignoring
model has unused tensor blk.46.ffn_down_exps.weight (size = 507510784 bytes) -- ignoring
model has unused tensor blk.46.ffn_up_exps.weight (size = 242221056 bytes) -- ignoring
model has unused tensor blk.46.ffn_gate_shexp.weight (size = 3244032 bytes) -- ignoring
model has unused tensor blk.46.ffn_down_shexp.weight (size = 3964928 bytes) -- ignoring
model has unused tensor blk.46.ffn_up_shexp.weight (size = 3244032 bytes) -- ignoring
model has unused tensor blk.46.nextn.eh_proj.weight (size = 11010048 bytes) -- ignoring
model has unused tensor blk.46.nextn.embed_tokens.weight (size = 203685888 bytes) -- ignoring
model has unused tensor blk.46.nextn.enorm.weight (size = 16384 bytes) -- ignoring
model has unused tensor blk.46.nextn.hnorm.weight (size = 16384 bytes) -- ignoring
model has unused tensor blk.46.nextn.shared_head_head.weight (size = 203685888 bytes) -- ignoring
model has unused tensor blk.46.nextn.shared_head_norm.weight (size = 16384 bytes) -- ignoring
load_tensors: offloading 47 repeating layers to GPU
load_tensors: offloading output layer to GPU
load_tensors: offloaded 48/48 layers to GPU
load_tensors:      Vulkan0 model buffer size = 42540.16 MiB
load_tensors:   CPU_Mapped model buffer size =   333.00 MiB
....................................................................................................
llama_context: constructing llama_context
llama_context: n_seq_max     = 1
llama_context: n_ctx         = 16384
llama_context: n_ctx_per_seq = 16384
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     = 1000000.0
llama_context: freq_scale    = 1
llama_context: n_ctx_per_seq (16384) < n_ctx_train (131072) -- the full capacity of the model will not be utilized
llama_context: Vulkan_Host  output buffer size =     0.58 MiB
llama_kv_cache:    Vulkan0 KV buffer size =  2944.00 MiB
llama_kv_cache: size = 2944.00 MiB ( 16384 cells,  46 layers,  1/1 seqs), K (f16): 1472.00 MiB, V (f16): 1472.00 MiB
llama_context:    Vulkan0 compute buffer size =  3180.01 MiB
llama_context: Vulkan_Host compute buffer size =    44.02 MiB
llama_context: graph nodes  = 3284
llama_context: graph splits = 2
common_init_from_params: added <|endoftext|> logit bias = -inf
common_init_from_params: added <|user|> logit bias = -inf
common_init_from_params: added <|observation|> logit bias = -inf
common_init_from_params: setting dry_penalty_last_n to ctx_size = 16384
srv          init: initializing slots, n_slots = 1
slot         init: id  0 | task -1 | new slot n_ctx_slot = 16384
main: model loaded
main: chat template, chat_template: [gMASK]<sop>
{%- if tools -%}
<|system|>
# Tools

You may call one or more functions to assist with the user query.

You are provided with function signatures within <tools></tools> XML tags:
<tools>
{% for tool in tools %}
{{ tool | tojson|string }}
{% endfor %}
</tools>

For each function call, output the function name and arguments within the following XML format:
<tool_call>{function-name}
<arg_key>{arg-key-1}</arg_key>
<arg_value>{arg-value-1}</arg_value>
<arg_key>{arg-key-2}</arg_key>
<arg_value>{arg-value-2}</arg_value>
...
</tool_call>{%- endif -%}
{%- macro visible_text(content) -%}
    {%- if content is string -%}
        {{- content }}
    {%- elif content is iterable and content is not mapping -%}
        {%- for item in content -%}
            {%- if item is mapping and item.type == 'text' -%}
                {{- item.text }}
            {%- elif item is string -%}
                {{- item }}
            {%- endif -%}
        {%- endfor -%}
    {%- else -%}
        {{- content }}
    {%- endif -%}
{%- endmacro -%}
{%- set ns = namespace(last_user_index=-1) %}
{%- for m in messages %}
    {%- if m.role == 'user' %}
        {% set ns.last_user_index = loop.index0 -%}
    {%- endif %}
{%- endfor %}
{% for m in messages %}
{%- if m.role == 'user' -%}<|user|>
{% set content = visible_text(m.content) %}{{ content }}
{{- '/nothink' if (enable_thinking is defined and not enable_thinking and not content.endswith("/nothink")) else '' -}}
{%- elif m.role == 'assistant' -%}
<|assistant|>
{%- set reasoning_content = '' %}
{%- set content = visible_text(m.content) %}
{%- if m.reasoning_content is string %}
    {%- set reasoning_content = m.reasoning_content %}
{%- else %}
    {%- if '</think>' in content %}
        {%- set reasoning_content = ((content.split('</think>')|first).rstrip('\n').split('<think>')|last).lstrip('\n') %}
        {%- set content = (content.split('</think>')|last).lstrip('\n') %}
    {%- endif %}
{%- endif %}
{%- if loop.index0 > ns.last_user_index and reasoning_content -%}
{{ '\n<think>' + reasoning_content.strip() +  '</think>'}}
{%- else -%}
{{ '\n<think></think>' }}
{%- endif -%}
{%- if content.strip() -%}
{{ '\n' + content.strip() }}
{%- endif -%}
{% if m.tool_calls %}
{% for tc in m.tool_calls %}
{%- if tc.function %}
    {%- set tc = tc.function %}
{%- endif %}
{{ '\n<tool_call>' + tc.name }}
{% set _args = tc.arguments %}
{% for k, v in _args.items() %}
<arg_key>{{ k }}</arg_key>
<arg_value>{{ v | tojson|string if v is not string else v }}</arg_value>
{% endfor %}
</tool_call>{% endfor %}
{% endif %}
{%- elif m.role == 'tool' -%}
{%- if m.content is string -%}
{%- if loop.first or (messages[loop.index0 - 1].role != "tool") %}
    {{- '<|observation|>' }}
{%- endif %}
{{- '\n<tool_response>\n' }}
{{- m.content }}
{{- '\n</tool_response>' }}
{%- else -%}
<|observation|>{% for tr in m.content %}

<tool_response>
{{ tr.output if tr.output is defined else tr }}
</tool_response>{% endfor -%}
{% endif -%}
{%- elif m.role == 'system' -%}
<|system|>
{{ visible_text(m.content) }}
{%- endif -%}
{%- endfor -%}
{%- if add_generation_prompt -%}
    <|assistant|>{{- '\n<think></think>' if (enable_thinking is defined and not enable_thinking) else '' -}}
{%- endif -%}, example_format: '[gMASK]<sop><|system|>
You are a helpful assistant<|user|>
Hello<|assistant|>
<think></think>
Hi there<|user|>
How are you?<|assistant|>'
main: server is listening on http://127.0.0.1:8080 - starting the main loop
srv  update_slots: all slots are idle
srv  log_server_r: request: POST /apply-template 127.0.0.1 200
slot launch_slot_: id  0 | task 0 | processing task
slot update_slots: id  0 | task 0 | new prompt, n_ctx_slot = 16384, n_keep = 0, n_prompt_tokens = 790
slot update_slots: id  0 | task 0 | kv cache rm [0, end)
slot update_slots: id  0 | task 0 | prompt processing progress, n_past = 790, n_tokens = 790, progress = 1.000000
slot update_slots: id  0 | task 0 | prompt done, n_past = 790, n_tokens = 790
slot      release: id  0 | task 0 | stop processing: n_past = 1226, truncated = 0
slot print_timing: id  0 | task 0 | 
prompt eval time =   27365.35 ms /   790 tokens (   34.64 ms per token,    28.87 tokens per second)
       eval time =   54962.30 ms /   437 tokens (  125.77 ms per token,     7.95 tokens per second)
      total time =   82327.65 ms /  1227 tokens
srv  update_slots: all slots are idle
srv  log_server_r: request: POST /completion 127.0.0.1 200
srv  log_server_r: request: POST /apply-template 127.0.0.1 200
slot launch_slot_: id  0 | task 438 | processing task
slot update_slots: id  0 | task 438 | new prompt, n_ctx_slot = 16384, n_keep = 0, n_prompt_tokens = 685
slot update_slots: id  0 | task 438 | kv cache rm [71, end)
slot update_slots: id  0 | task 438 | prompt processing progress, n_past = 685, n_tokens = 614, progress = 0.896350
slot update_slots: id  0 | task 438 | prompt done, n_past = 685, n_tokens = 614
/usr/lib/gcc/x86_64-pc-linux-gnu/14/include/g++-v14/bits/random.tcc:2668: void std::discrete_distribution<_IntType>::param_type::_M_initialize() [with _IntType = int]: Assertion '__sum > 0' failed.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions