From 528de7c788e453b47f0d183fa49a0233988b91ca Mon Sep 17 00:00:00 2001 From: sasha0552 Date: Tue, 9 Apr 2024 01:41:00 +0000 Subject: [PATCH] Refactor --- .gitmodules | 31 ---------- airootfs/home/tori/ComfyUI | 1 - airootfs/home/tori/SillyTavern-Extras | 1 - airootfs/home/tori/automatic | 1 - airootfs/home/tori/axolotl | 1 - airootfs/home/tori/koboldcpp | 1 - airootfs/home/tori/llama.cpp | 1 - airootfs/home/tori/text-generation-webui | 1 - airootfs/home/tori/vllm | 1 - .../0100-llamacpp-enable-prompt-cache.patch | 20 ------- .../0000-remove-git-submodule-pointers.sh | 5 -- .../scripts/0100-axolotl-patches.sh | 8 --- .../scripts/0100-llamacpp-patches.sh | 8 --- .../1000-automatic-dependencies.sh.jinja2 | 28 --------- ...hes.sh.jinja2 => 1000-automatic.sh.jinja2} | 35 ++++++++++++ ...ncies.sh.jinja2 => 1000-axolotl.sh.jinja2} | 13 ++++- .../1000-comfyui-dependencies.sh.jinja2 | 9 +++ ...hes.sh.jinja2 => 1000-koboldcpp.sh.jinja2} | 8 ++- .../scripts/1000-llamacpp.sh.jinja2 | 11 ++++ ...-sillytavern-extras-dependencies.sh.jinja2 | 9 +++ ...xt-generation-webui-dependencies.sh.jinja2 | 9 +++ .../scripts/1000-vllm.sh.jinja2 | 57 +++++++++++++++++++ .../scripts/9999-cleanup.sh.jinja2 | 8 --- 23 files changed, 148 insertions(+), 119 deletions(-) delete mode 100644 .gitmodules delete mode 160000 airootfs/home/tori/ComfyUI delete mode 160000 airootfs/home/tori/SillyTavern-Extras delete mode 160000 airootfs/home/tori/automatic delete mode 160000 airootfs/home/tori/axolotl delete mode 160000 airootfs/home/tori/koboldcpp delete mode 160000 airootfs/home/tori/llama.cpp delete mode 160000 airootfs/home/tori/text-generation-webui delete mode 160000 airootfs/home/tori/vllm delete mode 100644 airootfs/root/customize_airootfs/patches/0100-llamacpp-enable-prompt-cache.patch delete mode 100644 airootfs/root/customize_airootfs/scripts/0000-remove-git-submodule-pointers.sh delete mode 100644 airootfs/root/customize_airootfs/scripts/0100-axolotl-patches.sh delete mode 100644 airootfs/root/customize_airootfs/scripts/0100-llamacpp-patches.sh delete mode 100644 airootfs/root/customize_airootfs/scripts/1000-automatic-dependencies.sh.jinja2 rename airootfs/root/customize_airootfs/scripts/{0100-automatic-patches.sh.jinja2 => 1000-automatic.sh.jinja2} (51%) rename airootfs/root/customize_airootfs/scripts/{1000-axolotl-dependencies.sh.jinja2 => 1000-axolotl.sh.jinja2} (80%) rename airootfs/root/customize_airootfs/scripts/{0100-koboldcpp-patches.sh.jinja2 => 1000-koboldcpp.sh.jinja2} (54%) create mode 100644 airootfs/root/customize_airootfs/scripts/1000-llamacpp.sh.jinja2 create mode 100644 airootfs/root/customize_airootfs/scripts/1000-vllm.sh.jinja2 diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index ffebff8..0000000 --- a/.gitmodules +++ /dev/null @@ -1,31 +0,0 @@ -[submodule "airootfs/home/tori/automatic"] - path = airootfs/home/tori/automatic - url = https://github.com/vladmandic/automatic.git - -[submodule "airootfs/home/tori/axolotl"] - path = airootfs/home/tori/axolotl - url = https://github.com/OpenAccess-AI-Collective/axolotl.git - -[submodule "airootfs/home/tori/ComfyUI"] - path = airootfs/home/tori/ComfyUI - url = https://github.com/comfyanonymous/ComfyUI.git - -[submodule "airootfs/home/tori/koboldcpp"] - path = airootfs/home/tori/koboldcpp - url = https://github.com/LostRuins/koboldcpp.git - -[submodule "airootfs/home/tori/llama.cpp"] - path = airootfs/home/tori/llama.cpp - url = https://github.com/ggerganov/llama.cpp.git - -[submodule "airootfs/home/tori/SillyTavern-Extras"] - path = airootfs/home/tori/SillyTavern-Extras - url = https://github.com/SillyTavern/SillyTavern-Extras.git - -[submodule "airootfs/home/tori/text-generation-webui"] - path = airootfs/home/tori/text-generation-webui - url = https://github.com/oobabooga/text-generation-webui.git - -[submodule "airootfs/home/tori/vllm"] - path = airootfs/home/tori/vllm - url = https://github.com/vllm-project/vllm.git diff --git a/airootfs/home/tori/ComfyUI b/airootfs/home/tori/ComfyUI deleted file mode 160000 index c6de09b..0000000 --- a/airootfs/home/tori/ComfyUI +++ /dev/null @@ -1 +0,0 @@ -Subproject commit c6de09b02e20d748739fb6af58e196ebdd12825a diff --git a/airootfs/home/tori/SillyTavern-Extras b/airootfs/home/tori/SillyTavern-Extras deleted file mode 160000 index 5b35e91..0000000 --- a/airootfs/home/tori/SillyTavern-Extras +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 5b35e91e01f3d29c0147829f702fa79210948cd1 diff --git a/airootfs/home/tori/automatic b/airootfs/home/tori/automatic deleted file mode 160000 index 82973c4..0000000 --- a/airootfs/home/tori/automatic +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 82973c49ca491b1d50418b00e37131d308fad6b6 diff --git a/airootfs/home/tori/axolotl b/airootfs/home/tori/axolotl deleted file mode 160000 index ff939d8..0000000 --- a/airootfs/home/tori/axolotl +++ /dev/null @@ -1 +0,0 @@ -Subproject commit ff939d8a644c27cbe42889e772a1fc5502596759 diff --git a/airootfs/home/tori/koboldcpp b/airootfs/home/tori/koboldcpp deleted file mode 160000 index f3b7651..0000000 --- a/airootfs/home/tori/koboldcpp +++ /dev/null @@ -1 +0,0 @@ -Subproject commit f3b7651102c3ce3e4f331b93137dc32d752eada0 diff --git a/airootfs/home/tori/llama.cpp b/airootfs/home/tori/llama.cpp deleted file mode 160000 index b06c16e..0000000 --- a/airootfs/home/tori/llama.cpp +++ /dev/null @@ -1 +0,0 @@ -Subproject commit b06c16ef9f81d84da520232c125d4d8a1d273736 diff --git a/airootfs/home/tori/text-generation-webui b/airootfs/home/tori/text-generation-webui deleted file mode 160000 index 7cf1402..0000000 --- a/airootfs/home/tori/text-generation-webui +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 7cf1402bde48fd76af501d5efecb34227bf4d082 diff --git a/airootfs/home/tori/vllm b/airootfs/home/tori/vllm deleted file mode 160000 index f408d05..0000000 --- a/airootfs/home/tori/vllm +++ /dev/null @@ -1 +0,0 @@ -Subproject commit f408d05c523c25e2f638a13cb34a2dab3dcb2754 diff --git a/airootfs/root/customize_airootfs/patches/0100-llamacpp-enable-prompt-cache.patch b/airootfs/root/customize_airootfs/patches/0100-llamacpp-enable-prompt-cache.patch deleted file mode 100644 index 978e657..0000000 --- a/airootfs/root/customize_airootfs/patches/0100-llamacpp-enable-prompt-cache.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/examples/server/server.cpp -+++ b/examples/server/server.cpp -@@ -95,7 +95,7 @@ struct server_task_multi { - - struct slot_params { - bool stream = true; -- bool cache_prompt = false; // remember the prompt to avoid reprocessing all prompt -+ bool cache_prompt = true; // remember the prompt to avoid reprocessing all prompt - - uint32_t seed = -1; // RNG seed - int32_t n_keep = 0; // number of tokens to keep from initial prompt -@@ -827,7 +827,7 @@ struct server_context { - } - - slot.params.stream = json_value(data, "stream", false); -- slot.params.cache_prompt = json_value(data, "cache_prompt", false); -+ slot.params.cache_prompt = json_value(data, "cache_prompt", true); - slot.params.n_predict = json_value(data, "n_predict", default_params.n_predict); - slot.sparams.top_k = json_value(data, "top_k", default_sparams.top_k); - slot.sparams.top_p = json_value(data, "top_p", default_sparams.top_p); diff --git a/airootfs/root/customize_airootfs/scripts/0000-remove-git-submodule-pointers.sh b/airootfs/root/customize_airootfs/scripts/0000-remove-git-submodule-pointers.sh deleted file mode 100644 index 5ad1dcc..0000000 --- a/airootfs/root/customize_airootfs/scripts/0000-remove-git-submodule-pointers.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -set -eu - -# remove git submodule pointers to the root project -find -type f -name .git -exec rm {} \; diff --git a/airootfs/root/customize_airootfs/scripts/0100-axolotl-patches.sh b/airootfs/root/customize_airootfs/scripts/0100-axolotl-patches.sh deleted file mode 100644 index acb5c3c..0000000 --- a/airootfs/root/customize_airootfs/scripts/0100-axolotl-patches.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -set -eu - -# axolotl patches -pushd "axolotl" - # TODO: fix xformers version - sed -i 's/xformers>=0.0.23/xformers==0.0.23/g' setup.py -popd diff --git a/airootfs/root/customize_airootfs/scripts/0100-llamacpp-patches.sh b/airootfs/root/customize_airootfs/scripts/0100-llamacpp-patches.sh deleted file mode 100644 index 72d6c8f..0000000 --- a/airootfs/root/customize_airootfs/scripts/0100-llamacpp-patches.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -set -eu - -# llama.cpp patches -pushd "llama.cpp" - # enable prompt cache by default - patch -p1 < "$CUSTOMIZE_AIROOTFS/patches/0100-llamacpp-enable-prompt-cache.patch" -popd diff --git a/airootfs/root/customize_airootfs/scripts/1000-automatic-dependencies.sh.jinja2 b/airootfs/root/customize_airootfs/scripts/1000-automatic-dependencies.sh.jinja2 deleted file mode 100644 index 328b31b..0000000 --- a/airootfs/root/customize_airootfs/scripts/1000-automatic-dependencies.sh.jinja2 +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash -set -eu - -# automatic dependencies -pushd "automatic" - # disable package caching - export PIP_NO_CACHE_DIR=0 - - # create venv - python3 -m venv venv - - # activate venv - source venv/bin/activate - {% if platform == "cuda" %} - # install nvidia-pstate if cuda - pip3 install nvidia-pstate - {% endif %} - - # install dependencies - python3 launch.py --test - deactivate - - # remove installation config - rm config.json - - # remove installation log - rm sdnext.log -popd diff --git a/airootfs/root/customize_airootfs/scripts/0100-automatic-patches.sh.jinja2 b/airootfs/root/customize_airootfs/scripts/1000-automatic.sh.jinja2 similarity index 51% rename from airootfs/root/customize_airootfs/scripts/0100-automatic-patches.sh.jinja2 rename to airootfs/root/customize_airootfs/scripts/1000-automatic.sh.jinja2 index fb08e5d..815fa44 100644 --- a/airootfs/root/customize_airootfs/scripts/0100-automatic-patches.sh.jinja2 +++ b/airootfs/root/customize_airootfs/scripts/1000-automatic.sh.jinja2 @@ -1,8 +1,17 @@ #!/bin/bash set -eu +# clone repository +git clone "https://github.com/vladmandic/automatic.git" + # automatic patches pushd "automatic" + # use specific revision + git checkout e783b098fd0ad28acabb29844ab0af0978684c04 + + # clone submodules + git submodule update --init --recursive + # remove git dependency sed -i '/installer.check_modified_files()/d' launch.py sed -i '/installer.install_submodules()/d' launch.py @@ -19,3 +28,29 @@ pushd "automatic" patch -p1 < "$CUSTOMIZE_AIROOTFS/patches/0000-automatic-drop-pstate-in-idle.patch" {% endif %} popd + +# automatic dependencies +pushd "automatic" + # disable package caching + export PIP_NO_CACHE_DIR=0 + + # create venv + python3 -m venv venv + + # activate venv + source venv/bin/activate + {% if platform == "cuda" %} + # install nvidia-pstate if cuda + pip3 install nvidia-pstate + {% endif %} + + # install dependencies + python3 launch.py --test + deactivate + + # remove installation config + rm config.json + + # remove installation log + rm sdnext.log +popd diff --git a/airootfs/root/customize_airootfs/scripts/1000-axolotl-dependencies.sh.jinja2 b/airootfs/root/customize_airootfs/scripts/1000-axolotl.sh.jinja2 similarity index 80% rename from airootfs/root/customize_airootfs/scripts/1000-axolotl-dependencies.sh.jinja2 rename to airootfs/root/customize_airootfs/scripts/1000-axolotl.sh.jinja2 index 445c428..e8e1188 100644 --- a/airootfs/root/customize_airootfs/scripts/1000-axolotl-dependencies.sh.jinja2 +++ b/airootfs/root/customize_airootfs/scripts/1000-axolotl.sh.jinja2 @@ -1,9 +1,18 @@ #!/bin/bash set -eu +{% if platform == "cuda" %} +# clone repository +git clone "https://github.com/OpenAccess-AI-Collective/axolotl.git" + +# axolotl patches +pushd "axolotl" + # use specific revision + git checkout 2fa65b95997fa0ae68ae2b66933521ff8dfa3980 +popd + # axolotl dependencies pushd "axolotl" -{% if platform == "cuda" %} # disable package caching export PIP_NO_CACHE_DIR=0 @@ -35,5 +44,5 @@ pushd "axolotl" # downgrade flash-attn (https://github.com/OpenAccess-AI-Collective/axolotl/issues/911#issuecomment-1868546443) pip3 install flash-attn==2.3.2 deactivate -{% endif %} popd +{% endif %} diff --git a/airootfs/root/customize_airootfs/scripts/1000-comfyui-dependencies.sh.jinja2 b/airootfs/root/customize_airootfs/scripts/1000-comfyui-dependencies.sh.jinja2 index 326445a..255d656 100644 --- a/airootfs/root/customize_airootfs/scripts/1000-comfyui-dependencies.sh.jinja2 +++ b/airootfs/root/customize_airootfs/scripts/1000-comfyui-dependencies.sh.jinja2 @@ -1,6 +1,15 @@ #!/bin/bash set -eu +# clone repository +git clone "https://github.com/comfyanonymous/ComfyUI.git" + +# ComfyUI patches +pushd "ComfyUI" + # use specific revision + git checkout 30abc324c2f73e6b648093ccd4741dece20be1e5 +popd + # ComfyUI dependencies pushd "ComfyUI" # disable package caching diff --git a/airootfs/root/customize_airootfs/scripts/0100-koboldcpp-patches.sh.jinja2 b/airootfs/root/customize_airootfs/scripts/1000-koboldcpp.sh.jinja2 similarity index 54% rename from airootfs/root/customize_airootfs/scripts/0100-koboldcpp-patches.sh.jinja2 rename to airootfs/root/customize_airootfs/scripts/1000-koboldcpp.sh.jinja2 index 18f085d..59d5a81 100644 --- a/airootfs/root/customize_airootfs/scripts/0100-koboldcpp-patches.sh.jinja2 +++ b/airootfs/root/customize_airootfs/scripts/1000-koboldcpp.sh.jinja2 @@ -1,8 +1,14 @@ -#!/bin/bash +#!/bin/sh set -eu +# clone repository +git clone "https://github.com/LostRuins/koboldcpp.git" + # koboldcpp patches pushd "koboldcpp" + # use specific revision + git checkout f3b7651102c3ce3e4f331b93137dc32d752eada0 + {% if platform == "cuda" %} # drop pstate in idle patch -p1 < "$CUSTOMIZE_AIROOTFS/patches/0000-koboldcpp-drop-pstate-in-idle.patch" diff --git a/airootfs/root/customize_airootfs/scripts/1000-llamacpp.sh.jinja2 b/airootfs/root/customize_airootfs/scripts/1000-llamacpp.sh.jinja2 new file mode 100644 index 0000000..a5da2cd --- /dev/null +++ b/airootfs/root/customize_airootfs/scripts/1000-llamacpp.sh.jinja2 @@ -0,0 +1,11 @@ +#!/bin/sh +set -eu + +# clone repository +git clone "https://github.com/ggerganov/llama.cpp.git" + +# llama.cpp patches +pushd "llama.cpp" + # use specific revision + git checkout cc4a95426d17417d3c83f12bdb514fbe8abe2a88 +popd diff --git a/airootfs/root/customize_airootfs/scripts/1000-sillytavern-extras-dependencies.sh.jinja2 b/airootfs/root/customize_airootfs/scripts/1000-sillytavern-extras-dependencies.sh.jinja2 index 6e03319..f017703 100644 --- a/airootfs/root/customize_airootfs/scripts/1000-sillytavern-extras-dependencies.sh.jinja2 +++ b/airootfs/root/customize_airootfs/scripts/1000-sillytavern-extras-dependencies.sh.jinja2 @@ -1,6 +1,15 @@ #!/bin/bash set -eu +# clone repository +git clone "https://github.com/SillyTavern/SillyTavern-Extras.git" + +# SillyTavern-Extras patches +pushd "SillyTavern-Extras" + # use specific revision + git checkout 86793c6e104ce7e69da919eecea7f4d87ed61727 +popd + # SillyTavern-Extras dependencies pushd "SillyTavern-Extras" # disable package caching diff --git a/airootfs/root/customize_airootfs/scripts/1000-text-generation-webui-dependencies.sh.jinja2 b/airootfs/root/customize_airootfs/scripts/1000-text-generation-webui-dependencies.sh.jinja2 index 438a32d..05e45bc 100644 --- a/airootfs/root/customize_airootfs/scripts/1000-text-generation-webui-dependencies.sh.jinja2 +++ b/airootfs/root/customize_airootfs/scripts/1000-text-generation-webui-dependencies.sh.jinja2 @@ -1,6 +1,15 @@ #!/bin/bash set -eu +# clone repository +git clone "https://github.com/oobabooga/text-generation-webui.git" + +# text-generation-webui patches +pushd "text-generation-webui" + # use specific revision + git checkout 91a7370a655881c55274284509a546ffd644dc16 +popd + # text-generation-webui dependencies pushd "text-generation-webui" # disable package caching diff --git a/airootfs/root/customize_airootfs/scripts/1000-vllm.sh.jinja2 b/airootfs/root/customize_airootfs/scripts/1000-vllm.sh.jinja2 new file mode 100644 index 0000000..d7ee340 --- /dev/null +++ b/airootfs/root/customize_airootfs/scripts/1000-vllm.sh.jinja2 @@ -0,0 +1,57 @@ +#!/bin/sh +set -eu + +{% if platform == "cuda" %} +# clone repository +git clone "https://github.com/vllm-project/vllm.git" + +# vllm patches +pushd "vllm" + # use specific revision + git checkout d036198e23345f3c25438f082396f7487028e8b6 +popd + +# vllm dependencies +pushd "vllm" + # disable package caching + export PIP_NO_CACHE_DIR=0 + + # limit the number of parallel jobs to avoid OOM + export MAX_JOBS=1 + + # define supported architectures + export TORCH_CUDA_ARCH_LIST="6.0 6.1 7.0 7.5 8.0 8.6 8.9 9.0" + + # cuda home directory + export CUDA_HOME=/opt/cuda + + # use gcc 12 + export CC=gcc-12 + export CXX=g++-12 + + # create venv + python3 -m venv venv + + # activate venv + source venv/bin/activate + # install dependencies + pip3 install -r requirements.txt + pip3 install -r requirements-build.txt + + # build native extension + python3 setup.py build_ext --inplace + deactivate + + # remove venv + rm -fr venv + + # create venv + python3 -m venv venv + + # activate venv + source venv/bin/activate + # install dependencies + pip3 install -r requirements.txt + deactivate +popd +{% endif %} diff --git a/airootfs/root/customize_airootfs/scripts/9999-cleanup.sh.jinja2 b/airootfs/root/customize_airootfs/scripts/9999-cleanup.sh.jinja2 index 33f2992..4b6f6d5 100644 --- a/airootfs/root/customize_airootfs/scripts/9999-cleanup.sh.jinja2 +++ b/airootfs/root/customize_airootfs/scripts/9999-cleanup.sh.jinja2 @@ -9,11 +9,3 @@ rm -fr /home/tori/.config/matplotlib # keras rm -fr /home/tori/.keras - -{% if platform == "rocm" %} -# remove axolotl if rocm -rm -fr /home/tori/axolotl - -# remove vllm if rocm -rm -fr /home/tori/vllm -{% endif %}