From 6170b5ba31926ee32200a062707269cd8fbd923d Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Thu, 17 Aug 2023 21:39:26 -0700 Subject: [PATCH] Bump llama-cpp-python --- README.md | 1 + modules/llamacpp_hf.py | 7 +++++++ modules/llamacpp_model.py | 7 +++++++ modules/loaders.py | 2 ++ modules/shared.py | 1 + modules/ui.py | 1 + requirements.txt | 4 ++-- 7 files changed, 21 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 18f6d73..4607ab5 100644 --- a/README.md +++ b/README.md @@ -262,6 +262,7 @@ Optionally, you can use the following command-line flags: | `--no-mmap` | Prevent mmap from being used. | | `--mlock` | Force the system to keep the model in RAM. | | `--cache-capacity CACHE_CAPACITY` | Maximum cache capacity. Examples: 2000MiB, 2GiB. When provided without units, bytes will be assumed. | +| `--tensor_split TENSOR_SPLIT` | Split the model across multiple GPUs, comma-separated list of proportions, e.g. 18,17 | | `--llama_cpp_seed SEED` | Seed for llama-cpp models. Default 0 (random). | | `--n_gqa N_GQA` | grouped-query attention. Must be 8 for llama-2 70b. | | `--rms_norm_eps RMS_NORM_EPS` | 5e-6 is a good value for llama-2 models. | diff --git a/modules/llamacpp_hf.py b/modules/llamacpp_hf.py index fa0554c..7deae98 100644 --- a/modules/llamacpp_hf.py +++ b/modules/llamacpp_hf.py @@ -102,6 +102,12 @@ class LlamacppHF(PreTrainedModel): model_file = list(path.glob('*ggml*.bin'))[0] logger.info(f"llama.cpp weights detected: {model_file}\n") + + if shared.args.tensor_split is None or shared.args.tensor_split.strip() == '': + tensor_split_list = None + else: + tensor_split_list = [float(x) for x in shared.args.tensor_split.strip().split(",")] + params = { 'model_path': str(model_file), 'n_ctx': shared.args.n_ctx, @@ -113,6 +119,7 @@ class LlamacppHF(PreTrainedModel): 'low_vram': shared.args.low_vram, 'n_gpu_layers': shared.args.n_gpu_layers, 'rope_freq_base': 10000 * shared.args.alpha_value ** (64 / 63.), + 'tensor_split': tensor_split_list, 'rope_freq_scale': 1.0 / shared.args.compress_pos_emb, 'n_gqa': shared.args.n_gqa or None, 'rms_norm_eps': shared.args.rms_norm_eps or None, diff --git a/modules/llamacpp_model.py b/modules/llamacpp_model.py index f7f4cc9..0e635da 100644 --- a/modules/llamacpp_model.py +++ b/modules/llamacpp_model.py @@ -55,6 +55,12 @@ class LlamaCppModel: cache_capacity = int(shared.args.cache_capacity) logger.info("Cache capacity is " + str(cache_capacity) + " bytes") + + if shared.args.tensor_split is None or shared.args.tensor_split.strip() == '': + tensor_split_list = None + else: + tensor_split_list = [float(x) for x in shared.args.tensor_split.strip().split(",")] + params = { 'model_path': str(path), 'n_ctx': shared.args.n_ctx, @@ -66,6 +72,7 @@ class LlamaCppModel: 'low_vram': shared.args.low_vram, 'n_gpu_layers': shared.args.n_gpu_layers, 'rope_freq_base': 10000 * shared.args.alpha_value ** (64 / 63.), + 'tensor_split': tensor_split_list, 'rope_freq_scale': 1.0 / shared.args.compress_pos_emb, 'n_gqa': shared.args.n_gqa or None, 'rms_norm_eps': shared.args.rms_norm_eps or None, diff --git a/modules/loaders.py b/modules/loaders.py index 08a11ac..d49f7c0 100644 --- a/modules/loaders.py +++ b/modules/loaders.py @@ -67,6 +67,7 @@ loaders_and_params = OrderedDict({ 'n_gqa', 'rms_norm_eps', 'n_gpu_layers', + 'tensor_split', 'n_batch', 'threads', 'no_mmap', @@ -82,6 +83,7 @@ loaders_and_params = OrderedDict({ 'n_gqa', 'rms_norm_eps', 'n_gpu_layers', + 'tensor_split', 'n_batch', 'threads', 'no_mmap', diff --git a/modules/shared.py b/modules/shared.py index 88aa8cf..23eb398 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -121,6 +121,7 @@ parser.add_argument('--low-vram', action='store_true', help='Low VRAM Mode') parser.add_argument('--mlock', action='store_true', help='Force the system to keep the model in RAM.') parser.add_argument('--cache-capacity', type=str, help='Maximum cache capacity. Examples: 2000MiB, 2GiB. When provided without units, bytes will be assumed.') parser.add_argument('--n-gpu-layers', type=int, default=0, help='Number of layers to offload to the GPU.') +parser.add_argument('--tensor_split', type=str, default=None, help="Split the model across multiple GPUs, comma-separated list of proportions, e.g. 18,17") parser.add_argument('--n_ctx', type=int, default=2048, help='Size of the prompt context.') parser.add_argument('--llama_cpp_seed', type=int, default=0, help='Seed for llama-cpp models. Default 0 (random)') parser.add_argument('--n_gqa', type=int, default=0, help='grouped-query attention. Must be 8 for llama-2 70b.') diff --git a/modules/ui.py b/modules/ui.py index a99af37..ea1ca74 100644 --- a/modules/ui.py +++ b/modules/ui.py @@ -69,6 +69,7 @@ def list_model_elements(): 'low_vram', 'mlock', 'n_gpu_layers', + 'tensor_split', 'n_ctx', 'n_gqa', 'rms_norm_eps', diff --git a/requirements.txt b/requirements.txt index 888dda8..9a62354 100644 --- a/requirements.txt +++ b/requirements.txt @@ -31,8 +31,8 @@ https://github.com/jllllll/exllama/releases/download/0.0.10/exllama-0.0.10+cu117 https://github.com/jllllll/exllama/releases/download/0.0.10/exllama-0.0.10+cu117-cp310-cp310-linux_x86_64.whl; platform_system == "Linux" and platform_machine == "x86_64" # llama-cpp-python without GPU support -llama-cpp-python==0.1.77; platform_system != "Windows" -https://github.com/abetlen/llama-cpp-python/releases/download/v0.1.77/llama_cpp_python-0.1.77-cp310-cp310-win_amd64.whl; platform_system == "Windows" +llama-cpp-python==0.1.78; platform_system != "Windows" +https://github.com/abetlen/llama-cpp-python/releases/download/v0.1.78/llama_cpp_python-0.1.78-cp310-cp310-win_amd64.whl; platform_system == "Windows" # llama-cpp-python with CUDA support https://github.com/jllllll/llama-cpp-python-cuBLAS-wheels/releases/download/textgen-webui/llama_cpp_python_cuda-0.1.77+cu117-cp310-cp310-win_amd64.whl; platform_system == "Windows" https://github.com/jllllll/llama-cpp-python-cuBLAS-wheels/releases/download/textgen-webui/llama_cpp_python_cuda-0.1.77+cu117-cp310-cp310-linux_x86_64.whl; platform_system == "Linux" and platform_machine == "x86_64"