Repository: ollama
Issue: qwen2:72b-instruct-q4_K_M produces gibberish output
Labels: bug,memory

### What is the issue?

qwen2:72b-instruct-q4_K_M produces gibberish output:

```
>>> hello.
#:<,H=&*1(E.E*>G*:^C
```
Other models in other quantizations work correctly.

Ollama server output:

```
$ ./ollama serve 
2024/07/08 10:07:57 routes.go:1064: INFO server config env="map[CUDA_VISIBLE_DEVICES: GPU_DEVICE_ORDINAL: HIP_VISIBLE_DEVICES: HSA_OVERRIDE_GFX_VERSION: OLLAMA_DEBUG:false OLLAMA_FLASH_ATTENTION:false OLLAMA_HOST:http://127.0.0.1:11434 OLLAMA_INTEL_GPU:false OLLAMA_KEEP_ALIVE: OLLAMA_LLM_LIBRARY: OLLAMA_MAX_LOADED_MODELS:1 OLLAMA_MAX_QUEUE:512 OLLAMA_MAX_VRAM:0 OLLAMA_MODELS:/home/test/.ollama/models OLLAMA_NOHISTORY:false OLLAMA_NOPRUNE:false OLLAMA_NUM_PARALLEL:1 OLLAMA_ORIGINS:[http://localhost https://localhost http://localhost:* https://localhost:* http://127.0.0.1 https://127.0.0.1 http://127.0.0.1:* https://127.0.0.1:* http://0.0.0.0 https://0.0.0.0 http://0.0.0.0:* https://0.0.0.0:* app://* file://* tauri://*] OLLAMA_RUNNERS_DIR: OLLAMA_SCHED_SPREAD:false OLLAMA_TMPDIR: ROCR_VISIBLE_DEVICES:]"
time=2024-07-08T10:07:57.658+02:00 level=INFO source=images.go:730 msg="total blobs: 30"
time=2024-07-08T10:07:57.661+02:00 level=INFO source=images.go:737 msg="total unused blobs removed: 0"
time=2024-07-08T10:07:57.661+02:00 level=INFO source=routes.go:1111 msg="Listening on 127.0.0.1:11434 (version 0.1.48)"
time=2024-07-08T10:07:57.662+02:00 level=INFO source=payload.go:30 msg="extracting embedded files" dir=/tmp/ollama2929279884/runners
time=2024-07-08T10:08:00.530+02:00 level=INFO source=payload.go:44 msg="Dynamic LLM libraries [cpu cpu_avx cpu_avx2 cuda_v11 rocm_v60101]"
time=2024-07-08T10:08:00.679+02:00 level=INFO source=types.go:98 msg="inference compute" id=GPU-7b971568-6cd2-b804-d8eb-902eb8689068 library=cuda compute=6.1 driver=12.2 name="NVIDIA GeForce GTX 1080 Ti" total="10.9 GiB" available="10.4 GiB"
[GIN] 2024/07/08 - 10:08:22 | 200 |      81.665µs |       127.0.0.1 | HEAD     "/"
[GIN] 2024/07/08 - 10:08:22 | 200 |   37.454138ms |       127.0.0.1 | POST     "/api/show"
time=2024-07-08T10:08:22.768+02:00 level=INFO source=memory.go:309 msg="offload to cuda" layers.requested=-1 layers.model=81 layers.offload=14 layers.split="" memory.available="[10.4 GiB]" memory.required.full="49.6 GiB" memory.required.partial="10.2 GiB" memory.required.kv="640.0 MiB" memory.required.allocations="[10.2 GiB]" memory.weights.total="43.2 GiB" memory.weights.repeating="42.2 GiB" memory.weights.nonrepeating="974.6 MiB" memory.graph.full="313.0 MiB" memory.graph.partial="1.3 GiB"
time=2024-07-08T10:08:22.769+02:00 level=INFO source=server.go:368 msg="starting llama server" cmd="/tmp/ollama2929279884/runners/cuda_v11/ollama_llama_server --model /home/test/.ollama/models/blobs/sha256-59e062dadfebe1e1b7dae3aa2ed6f60190c03e9738451e6963d74a5aa6a464a9 --ctx-size 2048 --batch-size 512 --embedding --log-disable --n-gpu-layers 14 --no-mmap --parallel 1 --port 45747"
time=2024-07-08T10:08:22.769+02:00 level=INFO source=sched.go:382 msg="loaded runners" count=1
time=2024-07-08T10:08:22.769+02:00 level=INFO source=server.go:556 msg="waiting for llama runner to start responding"
time=2024-07-08T10:08:22.770+02:00 level=INFO source=server.go:594 msg="waiting for server to become available" status="llm server error"
INFO [main] build info | build=1 commit="7c26775" tid="139967113396224" timestamp=1720426102
INFO [main] system info | n_threads=8 n_threads_batch=-1 system_info="AVX = 1 | AVX_VNNI = 0 | AVX2 = 0 | AVX512 = 0 | AVX512_VBMI = 0 | AVX512_VNNI = 0 | AVX512_BF16 = 0 | FMA = 0 | NEON = 0 | SVE = 0 | ARM_FMA = 0 | F16C = 0 | FP16_VA = 0 | WASM_SIMD = 0 | BLAS = 1 | SSE3 = 1 | SSSE3 = 1 | VSX = 0 | MATMUL_INT8 = 0 | LLAMAFILE = 1 | " tid="139967113396224" timestamp=1720426102 total_threads=16
INFO [main] HTTP server listening | hostname="127.0.0.1" n_threads_http="15" port="45747" tid="139967113396224" timestamp=1720426102
llama_model_loader: loaded meta data with 21 key-value pairs and 963 tensors from /home/test/.ollama/models/blobs/sha256-59e062dadfebe1e1b7dae3aa2ed6f60190c03e9738451e6963d74a5aa6a464a9 (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              = qwen2
llama_model_loader: - kv   1:                               general.name str              = Qwen2-72B-Instruct
llama_model_loader: - kv   2:                          qwen2.block_count u32              = 80
llama_model_loader: - kv   3:                       qwen2.context_length u32              = 32768
llama_model_loader: - kv   4:                     qwen2.embedding_length u32              = 8192
llama_model_loader: - kv   5:                  qwen2.feed_forward_length u32              = 29568
llama_model_loader: - kv   6:                 qwen2.attention.head_count u32              = 64
llama_model_loader: - kv   7:              qwen2.attention.head_count_kv u32              = 8
llama_model_loader: - kv   8:                       qwen2.rope.freq_base f32              = 1000000.000000
llama_model_loader: - kv   9:     qwen2.attention.layer_norm_rms_epsilon f32              = 0.000001
llama_model_loader: - kv  10:                          general.file_type u32              = 15
llama_model_loader: - kv  11:                       tokenizer.ggml.model str              = gpt2
llama_model_loader: - kv  12:                         tokenizer.ggml.pre str              = qwen2
llama_model_loader: - kv  13:                      tokenizer.ggml.tokens arr[str,152064]  = ["!", "\"", "#", "$", "%", "&", "'", ...
llama_model_loader: - kv  14:                  tokenizer.ggml.token_type arr[i32,152064]  = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...
llama_model_loader: - kv  15:                      tokenizer.ggml.merges arr[str,151387]  = ["Ġ Ġ", "ĠĠ ĠĠ", "i n", "Ġ t",...
llama_model_loader: - kv  16:                tokenizer.ggml.eos_token_id u32              = 151645
llama_model_loader: - kv  17:            tokenizer.ggml.padding_token_id u32              = 151643
llama_model_loader: - kv  18:                tokenizer.ggml.bos_token_id u32              = 151643
llama_model_loader: - kv  19:                    tokenizer.chat_template str              = {% for message in messages %}{% if lo...
llama_model_loader: - kv  20:               general.quantization_version u32              = 2
llama_model_loader: - type  f32:  401 tensors
llama_model_loader: - type q5_0:   40 tensors
llama_model_loader: - type q8_0:   40 tensors
llama_model_loader: - type q4_K:  401 tensors
llama_model_loader: - type q5_K:   40 tensors
llama_model_loader: - type q6_K:   41 tensors
time=2024-07-08T10:08:23.021+02:00 level=INFO source=server.go:594 msg="waiting for server to become available" status="llm server loading model"
llm_load_vocab: special tokens cache size = 421
llm_load_vocab: token to piece cache size = 0.9352 MB
llm_load_print_meta: format           = GGUF V3 (latest)
llm_load_print_meta: arch             = qwen2
llm_load_print_meta: vocab type       = BPE
llm_load_print_meta: n_vocab          = 152064
llm_load_print_meta: n_merges         = 151387
llm_load_print_meta: n_ctx_train      = 32768
llm_load_print_meta: n_embd           = 8192
llm_load_print_meta: n_head           = 64
llm_load_print_meta: n_head_kv        = 8
llm_load_print_meta: n_layer          = 80
llm_load_print_meta: n_rot            = 128
llm_load_print_meta: n_embd_head_k    = 128
llm_load_print_meta: n_embd_head_v    = 128
llm_load_print_meta: n_gqa            = 8
llm_load_print_meta: n_embd_k_gqa     = 1024
llm_load_print_meta: n_embd_v_gqa     = 1024
llm_load_print_meta: f_norm_eps       = 0.0e+00
llm_load_print_meta: f_norm_rms_eps   = 1.0e-06
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             = 29568
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  = 1000000.0
llm_load_print_meta: freq_scale_train = 1
llm_load_print_meta: n_ctx_orig_yarn  = 32768
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       = 70B
llm_load_print_meta: model ftype      = Q4_K - Medium
llm_load_print_meta: model params     = 72.71 B
llm_load_print_meta: model size       = 44.15 GiB (5.22 BPW) 
llm_load_print_meta: general.name     = Qwen2-72B-Instruct
llm_load_print_meta: BOS token        = 151643 '
'
llm_load_print_meta: EOS token        = 151645 '
'
llm_load_print_meta: PAD token        = 151643 '
'
llm_load_print_meta: LF token         = 148848 'ÄĬ'
llm_load_print_meta: EOT token        = 151645 '
'
ggml_cuda_init: GGML_CUDA_FORCE_MMQ:   yes
ggml_cuda_init: CUDA_USE_TENSOR_CORES: no
ggml_cuda_init: found 1 CUDA devices:
  Device 0: NVIDIA GeForce GTX 1080 Ti, compute capability 6.1, VMM: yes
llm_load_tensors: ggml ctx size =    0.92 MiB
time=2024-07-08T10:08:24.478+02:00 level=INFO source=server.go:594 msg="waiting for server to become available" status="llm server not responding"
time=2024-07-08T10:08:31.046+02:00 level=INFO source=server.go:594 msg="waiting for server to become available" status="llm server loading model"
llm_load_tensors: offloading 14 repeating layers to GPU
llm_load_tensors: offloaded 14/81 layers to GPU
llm_load_tensors:  CUDA_Host buffer size = 37150.14 MiB
llm_load_tensors:      CUDA0 buffer size =  8063.30 MiB
llama_new_context_with_model: n_ctx      = 2048
llama_new_context_with_model: n_batch    = 512
llama_new_context_with_model: n_ubatch   = 512
llama_new_context_with_model: flash_attn = 0
llama_new_context_with_model: freq_base  = 1000000.0
llama_new_context_with_model: freq_scale = 1
llama_kv_cache_init:  CUDA_Host KV buffer size =   528.00 MiB
llama_kv_cache_init:      CUDA0 KV buffer size =   112.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:  CUDA_Host  output buffer size =     0.61 MiB
llama_new_context_with_model:      CUDA0 compute buffer size =  1287.53 MiB
llama_new_context_with_model:  CUDA_Host compute buffer size =    20.01 MiB
llama_new_context_with_model: graph nodes  = 2806
llama_new_context_with_model: graph splits = 928
INFO [main] model loaded | tid="139967113396224" timestamp=1720426189
time=2024-07-08T10:09:49.209+02:00 level=INFO source=server.go:599 msg="llama runner started in 86.44 seconds"
[GIN] 2024/07/08 - 10:09:49 | 200 |         1m26s |       127.0.0.1 | POST     "/api/chat"
[GIN] 2024/07/08 - 10:11:28 | 200 | 47.974392692s |       127.0.0.1 | POST     "/api/chat"
[GIN] 2024/07/08 - 10:12:52 | 200 | 20.454650534s |       127.0.0.1 | POST     "/api/chat"

```

### OS

Linux

### GPU

Nvidia

### CPU

Intel

### Ollama version

0.1.48