Skip to content

Misc. bug: Chat template thinking block head <think> tag is not rendered / generated correctly (MiniMax-M2.5 + possibly other models) #21465

@AiverAiva

Description

@AiverAiva

Name and Version

using an image that doesn't have llama cli
ghcr.io/ggml-org/llama.cpp:server-cuda13-b8589, ghcr.io/ggml-org/llama.cpp:server-cuda13

Operating systems

Linux

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

llama-server

Problem description & steps to reproduce

Description

When using the official chat template from unsloth/MiniMax-M2.5-GGUF, the model fails to output the expected <think> block header that is part of the add_generation_prompt section.

Instead of seeing:

] ~b]ai
<think>
...reasoning...

the generation starts directly after the user message (or produces broken/incomplete output), breaking the expected reasoning flow the model was trained on.

The issue occurs with the llama.cpp server (both latest server-cuda13 and the tagged server-cuda13-b8589 image). It is not resolved by changing quantization (tested UD-IQ3_XXS and UD-Q2_K_XL) or by using older images predating Gemma-4 template changes.

Workaround that fully restores correct behaviour:

--jinja \
--chat-template-file /path/to/modified/chat_template.jinja

with the following tiny modification in chat_template.jinja (lines ~157–159):

Original (broken):

{%- if add_generation_prompt -%}
{{- ']~b]ai' ~ '\n' ~ '<think>' ~ '\n' }}
{%- endif -%}

Modified (works):

{%- if add_generation_prompt -%}
{{- ']~b]ai' ~ '\n' }}
{%- endif -%}

Removing the <think> part from the template makes generation behave exactly as expected.

This strongly suggests the bug is not model-specific to MiniMax-M2.5, but rather a general problem in how llama.cpp (or the Jinja renderer) handles certain strings / special tokens inside the add_generation_prompt block of a chat template.

Environment

  • Image: ghcr.io/ggml-org/llama.cpp:server-cuda13-b8589 (also tested latest server-cuda13 and pre-Gemma-4 images)
  • GPU: CUDA (GB10)
  • Model: MiniMax-M2.5-UD-IQ3_XXS (and UD-Q2_K_XL)
  • Command (full repro):
docker run -d --rm \
  --name minimax-m25 \
  --gpus all \
  -p 8080:8080 \
  -v /raid/models:/models \
  ghcr.io/ggml-org/llama.cpp:server-cuda13-b8589 \
  -m /models/MiniMax-M2.5-UD-IQ3_XXS/MiniMax-M2.5-UD-IQ3_XXS-00001-of-00003.gguf \
  --alias minimax-m25 \
  --n-gpu-layers all \
  --cache-type-k q8_0 \
  --cache-type-v q8_0 \
  --ctx-size 196608 \
  --batch-size 8192 \
  --ubatch-size 2048 \
  --threads 20 \
  --threads-batch 20 \
  --numa isolate \
  --no-mmap \
  --flash-attn on \
  --host 0.0.0.0

References

Happy to provide full template file, or any API request payloads if needed for debugging.

First Bad Commit

No response

Relevant log output

Logs
ggml_cuda_init: found 1 CUDA devices (Total VRAM: 124546 MiB):
  Device 0: NVIDIA GB10, compute capability 12.1, VMM: yes, VRAM: 124546 MiB
load_backend: loaded CUDA backend from /app/libggml-cuda.so
load_backend: loaded CPU backend from /app/libggml-cpu-armv8.6_2.so
warn: LLAMA_ARG_HOST environment variable is set, but will be overwritten by command line argument --host
main: n_parallel is set to auto, using n_parallel = 4 and kv_unified = true
build: 8589 (08f21453a) with GNU 14.2.0 for Linux aarch64
system info: n_threads = 20, n_threads_batch = 20, total_threads = 20

system_info: n_threads = 20 (n_threads_batch = 20) / 20 | CUDA : ARCHS = 750,800,860,890,1200,1210 | USE_GRAPHS = 1 | PEER_MAX_BATCH_SIZE = 128 | BLACKWELL_NATIVE_FP4 = 1 | CPU : NEON = 1 | ARM_FMA = 1 | FP16_VA = 1 | MATMUL_INT8 = 1 | SVE = 1 | DOTPROD = 1 | SVE_CNT = 16 | OPENMP = 1 | REPACK = 1 |

Running without SSL
init: using 19 threads for HTTP server
start: binding port with default address family
main: loading model
srv    load_model: loading model '/models/MiniMax-M2.5-UD-IQ3_XXS/MiniMax-M2.5-UD-IQ3_XXS-00001-of-00003.gguf'
common_init_result: fitting params to device memory, for bugs during this step try to reproduce them with -fit off, or provide --verbose logs if the bug only occurs with -fit on
llama_params_fit_impl: projected to use 116399 MiB of device memory vs. 121336 MiB of free device memory
llama_params_fit_impl: will leave 4937 >= 1024 MiB of free device memory, no changes needed
llama_params_fit: successfully fit params to free device memory
llama_params_fit: fitting params to free memory took 0.25 seconds
llama_model_load_from_file_impl: using device CUDA0 (NVIDIA GB10) (000f:01:00.0) - 121336 MiB free
llama_model_loader: additional 2 GGUFs metadata loaded.
llama_model_loader: loaded meta data with 53 key-value pairs and 809 tensors from /models/MiniMax-M2.5-UD-IQ3_XXS/MiniMax-M2.5-UD-IQ3_XXS-00001-of-00003.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              = minimax-m2
llama_model_loader: - kv   1:                               general.type str              = model
llama_model_loader: - kv   2:                     general.sampling.top_k i32              = 40
llama_model_loader: - kv   3:                     general.sampling.top_p f32              = 0.950000
llama_model_loader: - kv   4:                      general.sampling.temp f32              = 1.000000
llama_model_loader: - kv   5:                               general.name str              = Minimax-M2.5
llama_model_loader: - kv   6:                           general.basename str              = Minimax-M2.5
llama_model_loader: - kv   7:                       general.quantized_by str              = Unsloth
llama_model_loader: - kv   8:                         general.size_label str              = 256x4.9B
llama_model_loader: - kv   9:                            general.license str              = other
llama_model_loader: - kv  10:                       general.license.name str              = modified-mit
llama_model_loader: - kv  11:                       general.license.link str              = https://github.com/MiniMax-AI/MiniMax...
llama_model_loader: - kv  12:                           general.repo_url str              = https://huggingface.co/unsloth
llama_model_loader: - kv  13:                   general.base_model.count u32              = 1
llama_model_loader: - kv  14:                  general.base_model.0.name str              = MiniMax M2.5
llama_model_loader: - kv  15:          general.base_model.0.organization str              = MiniMaxAI
llama_model_loader: - kv  16:              general.base_model.0.repo_url str              = https://huggingface.co/MiniMaxAI/Mini...
llama_model_loader: - kv  17:                               general.tags arr[str,2]       = ["unsloth", "text-generation"]
llama_model_loader: - kv  18:                     minimax-m2.block_count u32              = 62
llama_model_loader: - kv  19:                  minimax-m2.context_length u32              = 196608
llama_model_loader: - kv  20:                minimax-m2.embedding_length u32              = 3072
llama_model_loader: - kv  21:             minimax-m2.feed_forward_length u32              = 1536
llama_model_loader: - kv  22:            minimax-m2.attention.head_count u32              = 48
llama_model_loader: - kv  23:         minimax-m2.attention.head_count_kv u32              = 8
llama_model_loader: - kv  24:                  minimax-m2.rope.freq_base f32              = 5000000.000000
llama_model_loader: - kv  25: minimax-m2.attention.layer_norm_rms_epsilon f32              = 0.000001
llama_model_loader: - kv  26:                    minimax-m2.expert_count u32              = 256
llama_model_loader: - kv  27:               minimax-m2.expert_used_count u32              = 8
llama_model_loader: - kv  28:              minimax-m2.expert_gating_func u32              = 2
llama_model_loader: - kv  29:            minimax-m2.attention.key_length u32              = 128
llama_model_loader: - kv  30:          minimax-m2.attention.value_length u32              = 128
llama_model_loader: - kv  31:      minimax-m2.expert_feed_forward_length u32              = 1536
llama_model_loader: - kv  32:            minimax-m2.rope.dimension_count u32              = 64
llama_model_loader: - kv  33:                       tokenizer.ggml.model str              = gpt2
llama_model_loader: - kv  34:                         tokenizer.ggml.pre str              = minimax-m2
llama_model_loader: - kv  35:                      tokenizer.ggml.tokens arr[str,200064]  = ["Ā", "ā", "Ă", "ă", "Ą", "ą", ...
llama_model_loader: - kv  36:                  tokenizer.ggml.token_type arr[i32,200064]  = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...
llama_model_loader: - kv  37:                      tokenizer.ggml.merges arr[str,199744]  = ["Ġ Ġ", "Ġ t", "Ġ a", "i n", "e r...
llama_model_loader: - kv  38:                tokenizer.ggml.bos_token_id u32              = 200034
llama_model_loader: - kv  39:                tokenizer.ggml.eos_token_id u32              = 200020
llama_model_loader: - kv  40:            tokenizer.ggml.unknown_token_id u32              = 200021
llama_model_loader: - kv  41:            tokenizer.ggml.padding_token_id u32              = 200004
llama_model_loader: - kv  42:               tokenizer.ggml.add_bos_token bool             = true
llama_model_loader: - kv  43:                    tokenizer.chat_template str              = {# Unsloth template fixes #}\n{# -----...
llama_model_loader: - kv  44:               general.quantization_version u32              = 2
llama_model_loader: - kv  45:                          general.file_type u32              = 23
llama_model_loader: - kv  46:                      quantize.imatrix.file str              = MiniMax-M2.5-GGUF/imatrix_unsloth.gguf
llama_model_loader: - kv  47:                   quantize.imatrix.dataset str              = unsloth_calibration_MiniMax-M2.5.txt
llama_model_loader: - kv  48:             quantize.imatrix.entries_count u32              = 496
llama_model_loader: - kv  49:              quantize.imatrix.chunks_count u32              = 81
llama_model_loader: - kv  50:                                   split.no u16              = 0
llama_model_loader: - kv  51:                        split.tensors.count i32              = 809
llama_model_loader: - kv  52:                                split.count u16              = 3
llama_model_loader: - type  f32:  373 tensors
llama_model_loader: - type q4_K:    1 tensors
llama_model_loader: - type q5_K:   20 tensors
llama_model_loader: - type q6_K:   11 tensors
llama_model_loader: - type iq3_xxs:  131 tensors
llama_model_loader: - type iq3_s:   42 tensors
llama_model_loader: - type iq4_xs:  231 tensors
print_info: file format = GGUF V3 (latest)
print_info: file type   = IQ3_XXS - 3.0625 bpw
print_info: file size   = 86.90 GiB (3.26 BPW)
load: 0 unused tokens
load: special_eos_id is not in special_eog_ids - the tokenizer config may be incorrect
load: printing all EOG tokens:
load:   - 200004 ('<fim_pad>')
load:   - 200005 ('<reponame>')
load:   - 200020 ('[e~[')
load: special tokens cache size = 54
load: token to piece cache size = 1.3355 MB
print_info: arch                  = minimax-m2
print_info: vocab_only            = 0
print_info: no_alloc              = 0
print_info: n_ctx_train           = 196608
print_info: n_embd                = 3072
print_info: n_embd_inp            = 3072
print_info: n_layer               = 62
print_info: n_head                = 48
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                 = 6
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-06
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                  = 1536
print_info: n_expert              = 256
print_info: n_expert_used         = 8
print_info: n_expert_groups       = 0
print_info: n_group_used          = 0
print_info: causal attn           = 1
print_info: pooling type          = -1
print_info: rope type             = 2
print_info: rope scaling          = linear
print_info: freq_base_train       = 5000000.0
print_info: freq_scale_train      = 1
print_info: n_ctx_orig_yarn       = 196608
print_info: rope_yarn_log_mul     = 0.0000
print_info: rope_finetuned        = unknown
print_info: model type            = 230B.A10B
print_info: model params          = 228.69 B
print_info: general.name          = Minimax-M2.5
print_info: vocab type            = BPE
print_info: n_vocab               = 200064
print_info: n_merges              = 199744
print_info: BOS token             = 200034 ']~!b['
print_info: EOS token             = 200020 '[e~['
print_info: UNK token             = 200021 ']!d~['
print_info: PAD token             = 200004 '<fim_pad>'
print_info: LF token              = 10 'Ċ'
print_info: FIM PRE token         = 200001 '<fim_prefix>'
print_info: FIM SUF token         = 200003 '<fim_suffix>'
print_info: FIM MID token         = 200002 '<fim_middle>'
print_info: FIM PAD token         = 200004 '<fim_pad>'
print_info: FIM REP token         = 200005 '<reponame>'
print_info: EOG token             = 200004 '<fim_pad>'
print_info: EOG token             = 200005 '<reponame>'
print_info: EOG token             = 200020 '[e~['
print_info: max token length      = 256
load_tensors: loading model tensors, this can take a while... (mmap = false, direct_io = false)
load_tensors: offloading output layer to GPU
load_tensors: offloading 61 repeating layers to GPU
load_tensors: offloaded 63/63 layers to GPU
load_tensors:          CPU model buffer size =   329.70 MiB
load_tensors:        CUDA0 model buffer size = 88655.25 MiB
....................................................................................................
common_init_result: added <fim_pad> logit bias = -inf
common_init_result: added <reponame> logit bias = -inf
common_init_result: added [e~[ logit bias = -inf
llama_context: constructing llama_context
llama_context: n_seq_max     = 4
llama_context: n_ctx         = 196608
llama_context: n_ctx_seq     = 196608
llama_context: n_batch       = 8192
llama_context: n_ubatch      = 2048
llama_context: causal_attn   = 1
llama_context: flash_attn    = enabled
llama_context: kv_unified    = true
llama_context: freq_base     = 5000000.0
llama_context: freq_scale    = 1
llama_context:  CUDA_Host  output buffer size =     3.05 MiB
llama_kv_cache:      CUDA0 KV buffer size = 25296.00 MiB
llama_kv_cache: size = 25296.00 MiB (196608 cells,  62 layers,  4/1 seqs), K (q8_0): 12648.00 MiB, V (q8_0): 12648.00 MiB
sched_reserve: reserving ...
sched_reserve: resolving fused Gated Delta Net support:
sched_reserve: fused Gated Delta Net (autoregressive) enabled
sched_reserve: fused Gated Delta Net (chunked) enabled
sched_reserve:      CUDA0 compute buffer size =  2448.05 MiB
sched_reserve:  CUDA_Host compute buffer size =  1584.05 MiB
sched_reserve: graph nodes  = 3975
sched_reserve: graph splits = 2
sched_reserve: reserve took 550.74 ms, sched copies = 1
common_init_from_params: warming up the model with an empty run - please wait ... (--no-warmup to disable)
srv    load_model: initializing slots, n_slots = 4
no implementations specified for speculative decoding
slot   load_model: id  0 | task -1 | speculative decoding context not initialized
slot   load_model: id  0 | task -1 | new slot, n_ctx = 196608
no implementations specified for speculative decoding
slot   load_model: id  1 | task -1 | speculative decoding context not initialized
slot   load_model: id  1 | task -1 | new slot, n_ctx = 196608
no implementations specified for speculative decoding
slot   load_model: id  2 | task -1 | speculative decoding context not initialized
slot   load_model: id  2 | task -1 | new slot, n_ctx = 196608
no implementations specified for speculative decoding
slot   load_model: id  3 | task -1 | speculative decoding context not initialized
slot   load_model: id  3 | task -1 | new slot, n_ctx = 196608
srv    load_model: prompt cache is enabled, size limit: 8192 MiB
srv    load_model: use `--cache-ram 0` to disable the prompt cache
srv    load_model: for more info see https://github.com/ggml-org/llama.cpp/pull/16391
init: chat template, example_format: ']~b]system
You are a helpful assistant[e~[
]~b]user
Hello[e~[
]~b]ai
Hi there[e~[
]~b]user
How are you?[e~[
]~b]ai

'
srv          init: init: chat template, thinking = 1
main: model loaded
main: server is listening on http://0.0.0.0:8080
main: starting the main loop...
srv  update_slots: all slots are idle
srv  params_from_: Chat format: peg-native

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions