Skip to content

Commit

Permalink
Update repositories, reenable ROCm on selfhosted runner, add packages (
Browse files Browse the repository at this point in the history
…#24)

CI:

* Rename actions

* Create actions generator

* Configure mirrorlist before building

* Use work dir inside container

* Remove container when stopped

* Fix CI exec conditions

Misc:

* Update repositories

* Add useful packages

* Update README.md

* Add vm shutdown logic
  • Loading branch information
sasha0552 authored Feb 14, 2024
1 parent c43bcc8 commit cf09f61
Show file tree
Hide file tree
Showing 16 changed files with 248 additions and 23 deletions.
28 changes: 28 additions & 0 deletions .ci/actions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env python3

import jinja2

def main():
for filename in [ "gh-build-iso", "sh-build-iso" ]:
for type in [ "cuda", "rocm" ]:
# read input file
with open(f".ci/template/{filename}.yml.jinja2", "r") as file:
template = jinja2.Template(file.read())

# render template
rendered = template.render(type=type)

# FIXME: skip if hosted and rocm
if filename == "gh-build-iso" and type == "rocm":
continue

# FIXME: skip if selfhosted and cuda
if filename == "sh-build-iso" and type == "cuda":
continue

# write output file
with open(f".github/workflows/{filename}-{type}.yml", "w") as file:
file.write(rendered)

if __name__ == "__main__":
main()
5 changes: 4 additions & 1 deletion .ci/dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ pacman-key --init
pacman-key --populate

# Install required packages
pacman --sync --noconfirm --needed archiso patch python python-jinja rdfind
pacman --sync --noconfirm --needed archiso patch python python-jinja rdfind reflector

# Configure mirrorlist
reflector --latest 5 --sort rate --save /etc/pacman.d/mirrorlist
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
name: Build ISO (ROCm)
name: Build ISO on hosted runner ({{ "CUDA" if type == "cuda" else "ROCm" }})

on:
- push
- pull_request
push:
branches:
- main

pull_request:
branches:
- main

jobs:
build:
Expand All @@ -23,7 +28,9 @@ jobs:
uses: addnab/docker-run-action@v3
with:
image: archlinux:latest
{%- raw %}
options: --privileged --volume ${{ github.workspace }}:/workspace
{%- endraw %}
run: |
# Exit on error
set -eu
Expand All @@ -36,12 +43,12 @@ jobs:
# Patch mkarchiso
.ci/mkarchiso.sh

# Configure to use ROCm
.ci/configure.py rocm
# Configure to use {{ "CUDA" if type == "cuda" else "ROCm" }}
.ci/configure.py {{ type }}
popd

# Build image
mkarchiso -v -m iso -w /workspace/work -o /workspace/out /workspace
mkarchiso -v -m iso -w /_work -o /workspace/out /workspace

- name: Create summary
run: |
Expand Down
90 changes: 90 additions & 0 deletions .ci/template/sh-build-iso.yml.jinja2
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Build ISO on selfhosted runner ({{ "CUDA" if type == "cuda" else "ROCm" }})

on:
push:
branches:
- main

pull_request:
branches:
- main

jobs:
vm-start:
runs-on: ubuntu-latest

steps:
- name: Start virtual machine
run: |
# Do nothing for now
exit 0

build:
needs: vm-start
runs-on: self-hosted

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive

- name: Build image
uses: addnab/docker-run-action@v3
with:
image: archlinux:latest
{%- raw %}
options: --privileged --rm --volume ${{ github.workspace }}:/workspace
{%- endraw %}
run: |
# Exit on error
set -eu

# Enter project directory
pushd /workspace
# Install dependencies
.ci/dependencies.sh

# Patch mkarchiso
.ci/mkarchiso.sh

# Configure to use {{ "CUDA" if type == "cuda" else "ROCm" }}
.ci/configure.py {{ type }}
popd

# Build image
mkarchiso -v -m iso -w /_work -o /workspace/out /workspace

- name: Create summary
run: |
# Exit on error
set -eu

# Print checksums to summary
sha256sum out/* > "$GITHUB_STEP_SUMMARY"

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: archiso-output
path: out/

vm-shutdown:
needs: build
runs-on: self-hosted

steps:
- name: Stop virtual machine
run: |
# Shutdown in 1 minute
sudo shutdown 1

vm-shutdown-wait:
needs: vm-shutdown
runs-on: ubuntu-latest

steps:
- name: Wait until virtual machine is stopped
run: |
# Wait for 2 minutes
sleep 120
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
name: Build ISO (CUDA)
name: Build ISO on hosted runner (CUDA)

on:
- push
- pull_request
push:
branches:
- main

pull_request:
branches:
- main

jobs:
build:
Expand Down Expand Up @@ -41,7 +46,7 @@ jobs:
popd
# Build image
mkarchiso -v -m iso -w /workspace/work -o /workspace/out /workspace
mkarchiso -v -m iso -w /_work -o /workspace/out /workspace
- name: Create summary
run: |
Expand All @@ -55,4 +60,4 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: archiso-output
path: out/
path: out/
88 changes: 88 additions & 0 deletions .github/workflows/sh-build-iso-rocm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Build ISO on selfhosted runner (ROCm)

on:
push:
branches:
- main

pull_request:
branches:
- main

jobs:
vm-start:
runs-on: ubuntu-latest

steps:
- name: Start virtual machine
run: |
# Do nothing for now
exit 0
build:
needs: vm-start
runs-on: self-hosted

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive

- name: Build image
uses: addnab/docker-run-action@v3
with:
image: archlinux:latest
options: --privileged --rm --volume ${{ github.workspace }}:/workspace
run: |
# Exit on error
set -eu
# Enter project directory
pushd /workspace
# Install dependencies
.ci/dependencies.sh
# Patch mkarchiso
.ci/mkarchiso.sh
# Configure to use ROCm
.ci/configure.py rocm
popd
# Build image
mkarchiso -v -m iso -w /_work -o /workspace/out /workspace
- name: Create summary
run: |
# Exit on error
set -eu
# Print checksums to summary
sha256sum out/* > "$GITHUB_STEP_SUMMARY"
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: archiso-output
path: out/

vm-shutdown:
needs: build
runs-on: self-hosted

steps:
- name: Stop virtual machine
run: |
# Shutdown in 1 minute
sudo shutdown 1
vm-shutdown-wait:
needs: vm-shutdown
runs-on: ubuntu-latest

steps:
- name: Wait until virtual machine is stopped
run: |
# Wait for 2 minutes
sleep 120
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ If you would like to see another AI-related project included in ToriLinux, pleas

To use ToriLinux:
1. Install [Ventoy](https://ventoy.net/en/doc_start.html) on a USB drive.
2. Download the latest ISO from workflows ([NVIDIA](https://github.com/sasha0552/ToriLinux/actions/workflows/build-iso-cuda.yml?query=branch%3Amain) / [AMD](https://github.com/sasha0552/ToriLinux/actions/workflows/build-iso-rocm.yml?query=branch%3Amain)) and copy it to the USB drive.
2. Download the latest ISO from workflows ([NVIDIA](https://github.com/sasha0552/ToriLinux/actions/workflows/gh-build-iso-cuda?query=branch%3Amain) / [AMD](https://github.com/sasha0552/ToriLinux/actions/workflows/sh-build-iso-rocm.yml?query=branch%3Amain)) and copy it to the USB drive.
3. Boot from the USB drive (select it as the boot device in BIOS/UEFI).
4. Log in with the username `tori` and password `tori`. You can also use [SSH](https://en.wikipedia.org/wiki/Secure_Shell).

Expand All @@ -33,3 +33,5 @@ Note that you need pre-downloaded models on a local hard drive or NFS server, or
Note that following projects is not available on ROCm version:
* [axolotl](https://github.com/OpenAccess-AI-Collective/axolotl)
* [vllm](https://github.com/vllm-project/vllm)

The server for building the ROCm version is provided by [@Sepera-okeq](https://github.com/Sepera-okeq/).
2 changes: 1 addition & 1 deletion airootfs/home/tori/automatic
2 changes: 1 addition & 1 deletion airootfs/home/tori/axolotl
2 changes: 1 addition & 1 deletion airootfs/home/tori/koboldcpp
2 changes: 1 addition & 1 deletion airootfs/home/tori/llama.cpp
Submodule llama.cpp updated 54 files
+1 −0 .flake8
+1 −1 .github/workflows/python-lint.yml
+19 −5 Package.swift
+1 −0 README.md
+85 −35 common/common.cpp
+5 −2 common/common.h
+14 −21 common/sampling.cpp
+19 −1 common/sampling.h
+94 −0 convert-hf-to-gguf.py
+2 −1 convert-persimmon-to-gguf.py
+11 −1 examples/embedding/embedding.cpp
+5 −14 examples/export-lora/export-lora.cpp
+37 −108 examples/finetune/finetune.cpp
+9 −3 examples/llava/README.md
+81 −71 examples/llava/clip.cpp
+1 −1 examples/llava/convert-image-encoder-to-gguf.py
+1 −1 examples/llava/llava-surgery.py
+3 −0 examples/llava/requirements.txt
+11 −1 examples/lookup/lookup.cpp
+5 −2 examples/main/main.cpp
+1 −1 examples/server/README.md
+6 −2 examples/server/oai.hpp
+49 −13 examples/server/server.cpp
+30 −0 examples/server/utils.hpp
+32 −80 examples/train-text-from-scratch/train-text-from-scratch.cpp
+3 −3 flake.lock
+563 −490 ggml-alloc.c
+39 −65 ggml-alloc.h
+250 −262 ggml-backend.c
+8 −12 ggml-backend.h
+140 −107 ggml-cuda.cu
+2 −0 ggml-metal.m
+329 −22 ggml-quants.c
+14 −14 ggml-quants.h
+14 −61 ggml-sycl.cpp
+89 −6 ggml-vulkan.cpp
+134 −60 ggml.c
+26 −6 ggml.h
+10 −1 ggml_vk_generate_shaders.py
+25 −18 gguf-py/gguf/constants.py
+6 −0 gguf-py/gguf/gguf_writer.py
+10 −3 gguf-py/gguf/tensor_mapping.py
+580 −114 llama.cpp
+1 −0 llama.h
+2 −2 pocs/vdot/q8dot.cpp
+2 −2 pocs/vdot/vdot.cpp
+12 −0 scripts/sync-ggml-am.sh
+1 −1 scripts/sync-ggml.last
+6 −0 scripts/sync-ggml.sh
+1 −0 spm-headers/ggml-alloc.h
+1 −0 spm-headers/ggml-backend.h
+1 −0 spm-headers/ggml.h
+1 −1 tests/test-quantize-fns.cpp
+1 −1 tests/test-quantize-perf.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
--- a/examples/server/oai.hpp
+++ b/examples/server/oai.hpp
@@ -31,7 +31,7 @@ inline static json oaicompat_completion_params_parse(
@@ -35,7 +35,7 @@ inline static json oaicompat_completion_params_parse(
llama_sampling_params default_sparams;
llama_params["model"] = json_value(body, "model", std::string("unknown"));
llama_params["prompt"] = format_chatml(body["messages"]); // OpenAI 'messages' to llama.cpp 'prompt'
llama_params["prompt"] = formatted_prompt;
- llama_params["cache_prompt"] = json_value(body, "cache_prompt", false);
+ llama_params["cache_prompt"] = json_value(body, "cache_prompt", true);
llama_params["temperature"] = json_value(body, "temperature", 0.0);
llama_params["top_k"] = json_value(body, "top_k", default_sparams.top_k);
llama_params["top_p"] = json_value(body, "top_p", 1.0);
--- a/examples/server/server.cpp
+++ b/examples/server/server.cpp
@@ -525,7 +525,7 @@ struct llama_server_context
@@ -526,7 +526,7 @@ struct llama_server_context
}

slot->params.stream = json_value(data, "stream", false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Supported NVIDIA GPU architectures.
-NVIDIA_SUPPORTED_ARCHS = {"7.0", "7.5", "8.0", "8.6", "8.9", "9.0"}
+NVIDIA_SUPPORTED_ARCHS = {"6.0", "6.1", "7.0", "7.5", "8.0", "8.6", "8.9", "9.0"}
ROCM_SUPPORTED_ARCHS = {"gfx90a", "gfx942"}
ROCM_SUPPORTED_ARCHS = {"gfx90a", "gfx942", "gfx1100"}
# SUPPORTED_ARCHS = NVIDIA_SUPPORTED_ARCHS.union(ROCM_SUPPORTED_ARCHS)

@@ -222,9 +222,9 @@ if _is_cuda() and not compute_capabilities:
Expand Down
2 changes: 2 additions & 0 deletions packages.x86_64.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ mkinitcpio-nfs-utils
nano
ncdu
neofetch
net-tools
nfs-utils
ntfs-3g
nvtop
openssh
progress
Expand Down

0 comments on commit cf09f61

Please sign in to comment.