Open AppleJunJiang opened 4 months ago
For the llama.cpp , solution is to use flash attention option "-fa" as said here: https://github.com/ggerganov/llama.cpp/issues/7805 I will test to add the option flash_attn=True and see Is it possible to rebuild my llama.cpp only in a current setup of llama-cpp-python ? or should I have to reinstall llama-cpp-python ?
it is working fine with flash_attn=True : llama = Llama(model_path=model_path, n_gpu_layers=n_gpu_layers, n_ctx=n_ctx, echo=echo, n_batch=n_batch,flash_attn=True)
it is working fine with flash_attn=True : llama = Llama(model_path=model_path, n_gpu_layers=n_gpu_layers, n_ctx=n_ctx, echo=echo, n_batch=n_batch,flash_attn=True)
How to use "flash_attn=True" to docker run command?
2024-06-09 21:59:48 ========== 2024-06-09 21:59:48 == CUDA == 2024-06-09 21:59:48 ========== 2024-06-09 21:59:48 2024-06-09 21:59:48 CUDA Version 12.1.1 2024-06-09 21:59:48 2024-06-09 21:59:48 Container image Copyright (c) 2016-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. 2024-06-09 21:59:48 2024-06-09 21:59:48 This container image and its contents are governed by the NVIDIA Deep Learning Container License. 2024-06-09 21:59:48 By pulling and using the container, you accept the terms and conditions of this license: 2024-06-09 21:59:48 https://developer.nvidia.com/ngc/nvidia-deep-learning-container-license 2024-06-09 21:59:48 2024-06-09 21:59:48 A copy of this license is made available in this container at /NGC-DL-CONTAINER-LICENSE for your convenience. 2024-06-09 21:59:48 2024-06-09 21:59:49 llama_model_loader: loaded meta data with 21 key-value pairs and 339 tensors from /models/qwen2-7b-instruct-q6_k.gguf (version GGUF V3 (latest)) 2024-06-09 21:59:49 llama_model_loader: Dumping metadata keys/values. Note: KV overrides do not apply in this output. 2024-06-09 21:59:49 llama_model_loader: - kv 0: general.architecture str = qwen2 2024-06-09 21:59:49 llama_model_loader: - kv 1: general.name str = qwen2-7b 2024-06-09 21:59:49 llama_model_loader: - kv 2: qwen2.block_count u32 = 28 2024-06-09 21:59:49 llama_model_loader: - kv 3: qwen2.context_length u32 = 32768 2024-06-09 21:59:49 llama_model_loader: - kv 4: qwen2.embedding_length u32 = 3584 2024-06-09 21:59:49 llama_model_loader: - kv 5: qwen2.feed_forward_length u32 = 18944 2024-06-09 21:59:49 llama_model_loader: - kv 6: qwen2.attention.head_count u32 = 28 2024-06-09 21:59:49 llama_model_loader: - kv 7: qwen2.attention.head_count_kv u32 = 4 2024-06-09 21:59:49 llama_model_loader: - kv 8: qwen2.rope.freq_base f32 = 1000000.000000 2024-06-09 21:59:49 llama_model_loader: - kv 9: qwen2.attention.layer_norm_rms_epsilon f32 = 0.000001 2024-06-09 21:59:49 llama_model_loader: - kv 10: general.file_type u32 = 18 2024-06-09 21:59:49 llama_model_loader: - kv 11: tokenizer.ggml.model str = gpt2 2024-06-09 21:59:49 llama_model_loader: - kv 12: tokenizer.ggml.pre str = qwen2 2024-06-09 21:59:49 llama_model_loader: - kv 13: tokenizer.ggml.tokens arr[str,152064] = ["!", "\"", "#", "$", "%", "&", "'", ... 2024-06-09 21:59:49 llama_model_loader: - kv 14: tokenizer.ggml.token_type arr[i32,152064] = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ... 2024-06-09 21:59:49 llama_model_loader: - kv 15: tokenizer.ggml.merges arr[str,151387] = ["Ġ Ġ", "ĠĠ ĠĠ", "i n", "Ġ t",... 2024-06-09 21:59:49 llama_model_loader: - kv 16: tokenizer.ggml.eos_token_id u32 = 151645 2024-06-09 21:59:49 llama_model_loader: - kv 17: tokenizer.ggml.padding_token_id u32 = 151643 2024-06-09 21:59:49 llama_model_loader: - kv 18: tokenizer.ggml.bos_token_id u32 = 151643 2024-06-09 21:59:49 llama_model_loader: - kv 19: tokenizer.chat_template str = {% for message in messages %}{% if lo... 2024-06-09 21:59:49 llama_model_loader: - kv 20: general.quantization_version u32 = 2 2024-06-09 21:59:49 llama_model_loader: - type f32: 141 tensors 2024-06-09 21:59:49 llama_model_loader: - type q6_K: 198 tensors 2024-06-09 21:59:49 llm_load_vocab: special tokens cache size = 421 2024-06-09 21:59:49 llm_load_vocab: token to piece cache size = 0.9352 MB 2024-06-09 21:59:49 llm_load_print_meta: format = GGUF V3 (latest) 2024-06-09 21:59:49 llm_load_print_meta: arch = qwen2 2024-06-09 21:59:49 llm_load_print_meta: vocab type = BPE 2024-06-09 21:59:49 llm_load_print_meta: n_vocab = 152064 2024-06-09 21:59:49 llm_load_print_meta: n_merges = 151387 2024-06-09 21:59:49 llm_load_print_meta: n_ctx_train = 32768 2024-06-09 21:59:49 llm_load_print_meta: n_embd = 3584 2024-06-09 21:59:49 llm_load_print_meta: n_head = 28 2024-06-09 21:59:49 llm_load_print_meta: n_head_kv = 4 2024-06-09 21:59:49 llm_load_print_meta: n_layer = 28 2024-06-09 21:59:49 llm_load_print_meta: n_rot = 128 2024-06-09 21:59:49 llm_load_print_meta: n_embd_head_k = 128 2024-06-09 21:59:49 llm_load_print_meta: n_embd_head_v = 128 2024-06-09 21:59:49 llm_load_print_meta: n_gqa = 7 2024-06-09 21:59:49 llm_load_print_meta: n_embd_k_gqa = 512 2024-06-09 21:59:49 llm_load_print_meta: n_embd_v_gqa = 512 2024-06-09 21:59:49 llm_load_print_meta: f_norm_eps = 0.0e+00 2024-06-09 21:59:49 llm_load_print_meta: f_norm_rms_eps = 1.0e-06 2024-06-09 21:59:49 llm_load_print_meta: f_clamp_kqv = 0.0e+00 2024-06-09 21:59:49 llm_load_print_meta: f_max_alibi_bias = 0.0e+00 2024-06-09 21:59:49 llm_load_print_meta: f_logit_scale = 0.0e+00 2024-06-09 21:59:49 llm_load_print_meta: n_ff = 18944 2024-06-09 21:59:49 llm_load_print_meta: n_expert = 0 2024-06-09 21:59:49 llm_load_print_meta: n_expert_used = 0 2024-06-09 21:59:49 llm_load_print_meta: causal attn = 1 2024-06-09 21:59:49 llm_load_print_meta: pooling type = 0 2024-06-09 21:59:49 llm_load_print_meta: rope type = 2 2024-06-09 21:59:49 llm_load_print_meta: rope scaling = linear 2024-06-09 21:59:49 llm_load_print_meta: freq_base_train = 1000000.0 2024-06-09 21:59:49 llm_load_print_meta: freq_scale_train = 1 2024-06-09 21:59:49 llm_load_print_meta: n_yarn_orig_ctx = 32768 2024-06-09 21:59:49 llm_load_print_meta: rope_finetuned = unknown 2024-06-09 21:59:49 llm_load_print_meta: ssm_d_conv = 0 2024-06-09 21:59:49 llm_load_print_meta: ssm_d_inner = 0 2024-06-09 21:59:49 llm_load_print_meta: ssm_d_state = 0 2024-06-09 21:59:49 llm_load_print_meta: ssm_dt_rank = 0 2024-06-09 21:59:49 llm_load_print_meta: model type = ?B 2024-06-09 21:59:49 llm_load_print_meta: model ftype = Q6_K 2024-06-09 21:59:49 llm_load_print_meta: model params = 7.62 B 2024-06-09 21:59:49 llm_load_print_meta: model size = 5.82 GiB (6.56 BPW) 2024-06-09 21:59:49 llm_load_print_meta: general.name = qwen2-7b 2024-06-09 21:59:49 llm_load_print_meta: BOS token = 151643 '<|endoftext|>' 2024-06-09 21:59:49 llm_load_print_meta: EOS token = 151645 '<|im_end|>' 2024-06-09 21:59:49 llm_load_print_meta: PAD token = 151643 '<|endoftext|>' 2024-06-09 21:59:49 llm_load_print_meta: LF token = 148848 'ÄĬ' 2024-06-09 21:59:49 llm_load_print_meta: EOT token = 151645 '<|im_end|>' 2024-06-09 21:59:50 ggml_cuda_init: GGML_CUDA_FORCE_MMQ: no 2024-06-09 21:59:50 ggml_cuda_init: CUDA_USE_TENSOR_CORES: yes 2024-06-09 21:59:50 ggml_cuda_init: found 1 CUDA devices: 2024-06-09 21:59:50 Device 0: NVIDIA GeForce RTX 3060 Laptop GPU, compute capability 8.6, VMM: yes 2024-06-09 21:59:50 llm_load_tensors: ggml ctx size = 0.32 MiB 2024-06-09 22:07:09 llm_load_tensors: offloading 15 repeating layers to GPU 2024-06-09 22:07:09 llm_load_tensors: offloaded 15/29 layers to GPU 2024-06-09 22:07:09 llm_load_tensors: CPU buffer size = 5958.79 MiB 2024-06-09 22:07:09 llm_load_tensors: CUDA0 buffer size = 2735.39 MiB 2024-06-09 22:07:10 ........................................................................................ 2024-06-09 22:07:10 llama_new_context_with_model: n_ctx = 4096 2024-06-09 22:07:10 llama_new_context_with_model: n_batch = 512 2024-06-09 22:07:10 llama_new_context_with_model: n_ubatch = 512 2024-06-09 22:07:10 llama_new_context_with_model: flash_attn = 0 2024-06-09 22:07:10 llama_new_context_with_model: freq_base = 1000000.0 2024-06-09 22:07:10 llama_new_context_with_model: freq_scale = 1 2024-06-09 22:07:10 llama_kv_cache_init: CUDA_Host KV buffer size = 104.00 MiB 2024-06-09 22:07:10 llama_kv_cache_init: CUDA0 KV buffer size = 120.00 MiB 2024-06-09 22:07:10 llama_new_context_with_model: KV self size = 224.00 MiB, K (f16): 112.00 MiB, V (f16): 112.00 MiB 2024-06-09 22:07:10 llama_new_context_with_model: CUDA_Host output buffer size = 0.59 MiB 2024-06-09 22:07:10 llama_new_context_with_model: CUDA0 compute buffer size = 730.36 MiB 2024-06-09 22:07:10 llama_new_context_with_model: CUDA_Host compute buffer size = 15.01 MiB 2024-06-09 22:07:10 llama_new_context_with_model: graph nodes = 986 2024-06-09 22:07:10 llama_new_context_with_model: graph splits = 186 2024-06-09 22:07:10 AVX = 1 | AVX_VNNI = 1 | AVX2 = 1 | AVX512 = 0 | AVX512_VBMI = 0 | AVX512_VNNI = 0 | AVX512_BF16 = 0 | FMA = 1 | NEON = 0 | SVE = 0 | ARM_FMA = 0 | F16C = 1 | FP16_VA = 0 | WASM_SIMD = 0 | BLAS = 1 | SSE3 = 1 | SSSE3 = 1 | VSX = 0 | MATMUL_INT8 = 0 | LLAMAFILE = 1 | 2024-06-09 22:07:10 Model metadata: {'tokenizer.ggml.bos_token_id': '151643', 'general.architecture': 'qwen2', 'qwen2.block_count': '28', 'qwen2.context_length': '32768', 'tokenizer.chat_template': "{% for message in messages %}{% if loop.first and messages[0]['role'] != 'system' %}{{ '<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n' }}{% endif %}{{'<|im_start|>' + message['role'] + '\n' + message['content'] + '<|im_end|>' + '\n'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant\n' }}{% endif %}", 'qwen2.attention.head_count_kv': '4', 'tokenizer.ggml.padding_token_id': '151643', 'qwen2.embedding_length': '3584', 'qwen2.attention.layer_norm_rms_epsilon': '0.000001', 'qwen2.attention.head_count': '28', 'tokenizer.ggml.eos_token_id': '151645', 'qwen2.rope.freq_base': '1000000.000000', 'general.file_type': '18', 'general.quantization_version': '2', 'qwen2.feed_forward_length': '18944', 'tokenizer.ggml.model': 'gpt2', 'general.name': 'qwen2-7b', 'tokenizer.ggml.pre': 'qwen2'} 2024-06-09 22:07:10 Available chat formats from metadata: chat_template.default 2024-06-09 22:07:10 INFO: Started server process [27] 2024-06-09 22:07:10 INFO: Waiting for application startup. 2024-06-09 22:07:10 INFO: Application startup complete. 2024-06-09 22:07:10 INFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
the answer has Garbled code Response body { "id": "chatcmpl-bc7f4fb2-b0ea-4b4e-aca2-b691df58ac50", "object": "chat.completion", "created": 1717942631, "model": "gpt-3.5-turbo", "choices": [ { "index": 0, "message": { "content": "Huh,C'est\"Paris\".",
"role": "assistant" }, "logprobs": null, "finish_reason": "stop" } ], "usage": { "prompt_tokens": 27, "completion_tokens": 8, "total_tokens": 35 } }