-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ci: test GPU Signed-off-by: Ettore Di Giacinto <[email protected]> * ci: show logs Signed-off-by: Ettore Di Giacinto <[email protected]> * Debug * debug Signed-off-by: Ettore Di Giacinto <[email protected]> * split extra/core images Signed-off-by: Ettore Di Giacinto <[email protected]> * split extra/core images Signed-off-by: Ettore Di Giacinto <[email protected]> * consider runner host dir Signed-off-by: Ettore Di Giacinto <[email protected]> --------- Signed-off-by: Ettore Di Giacinto <[email protected]>
- Loading branch information
Showing
6 changed files
with
242 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
--- | ||
name: 'GPU tests' | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- master | ||
tags: | ||
- '*' | ||
|
||
concurrency: | ||
group: ci-gpu-tests-${{ github.head_ref || github.ref }}-${{ github.repository }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
ubuntu-latest: | ||
runs-on: self-hosted | ||
strategy: | ||
matrix: | ||
go-version: ['1.21.x'] | ||
steps: | ||
- name: Clone | ||
uses: actions/checkout@v3 | ||
with: | ||
submodules: true | ||
- name: Setup Go ${{ matrix.go-version }} | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
# You can test your matrix by printing the current Go version | ||
- name: Display Go version | ||
run: go version | ||
- name: Dependencies | ||
run: | | ||
sudo apt-get update | ||
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y make wget | ||
- name: Build | ||
run: | | ||
if [ ! -e /run/systemd/system ]; then | ||
sudo mkdir /run/systemd/system | ||
fi | ||
make \ | ||
TEST_DIR="/host/tests/${{ github.head_ref || github.ref }}" \ | ||
BUILD_TYPE=cublas \ | ||
prepare-e2e run-e2e-image test-e2e | ||
- name: Release space from worker ♻ | ||
if: always() | ||
run: | | ||
sudo rm -rf build || true | ||
sudo rm -rf bin || true | ||
sudo rm -rf dist || true | ||
sudo docker logs $(sudo docker ps -q --filter ancestor=localai-tests) > logs.txt | ||
sudo cat logs.txt || true | ||
sudo rm -rf logs.txt | ||
make clean || true | ||
make \ | ||
TEST_DIR="/host/tests/${{ github.head_ref || github.ref }}" \ | ||
teardown-e2e || true | ||
docker system prune -f -a --volumes || true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
context_size: 2048 | ||
mirostat: 2 | ||
mirostat_tau: 5.0 | ||
mirostat_eta: 0.1 | ||
f16: true | ||
threads: 1 | ||
gpu_layers: 90 | ||
name: gpt-4 | ||
mmap: true | ||
parameters: | ||
model: ggllm-test-model.bin | ||
rope_freq_base: 10000 | ||
max_tokens: 20 | ||
rope_freq_scale: 1 | ||
temperature: 0.2 | ||
top_k: 40 | ||
top_p: 0.95 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package e2e_test | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
var ( | ||
localAIURL = os.Getenv("LOCALAI_API") | ||
) | ||
|
||
func TestLocalAI(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
RunSpecs(t, "LocalAI E2E test suite") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package e2e_test | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"os" | ||
"os/exec" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
|
||
openaigo "github.com/otiai10/openaigo" | ||
"github.com/sashabaranov/go-openai" | ||
) | ||
|
||
var _ = Describe("E2E test", func() { | ||
var client *openai.Client | ||
var client2 *openaigo.Client | ||
|
||
Context("API with ephemeral models", func() { | ||
BeforeEach(func() { | ||
defaultConfig := openai.DefaultConfig("") | ||
defaultConfig.BaseURL = localAIURL | ||
|
||
client2 = openaigo.NewClient("") | ||
client2.BaseURL = defaultConfig.BaseURL | ||
|
||
// Wait for API to be ready | ||
client = openai.NewClientWithConfig(defaultConfig) | ||
Eventually(func() error { | ||
_, err := client.ListModels(context.TODO()) | ||
return err | ||
}, "2m").ShouldNot(HaveOccurred()) | ||
}) | ||
|
||
// Check that the GPU was used | ||
AfterEach(func() { | ||
cmd := exec.Command("/bin/bash", "-xce", "docker logs $(docker ps -q --filter ancestor=localai-tests)") | ||
out, err := cmd.CombinedOutput() | ||
Expect(err).ToNot(HaveOccurred(), string(out)) | ||
// Execute docker logs $$(docker ps -q --filter ancestor=localai-tests) as a command and check the output | ||
if os.Getenv("BUILD_TYPE") == "cublas" { | ||
|
||
Expect(string(out)).To(ContainSubstring("found 1 CUDA devices"), string(out)) | ||
Expect(string(out)).To(ContainSubstring("using CUDA for GPU acceleration"), string(out)) | ||
} else { | ||
fmt.Println("Skipping GPU check") | ||
Expect(string(out)).To(ContainSubstring("[llama-cpp] Loads OK"), string(out)) | ||
Expect(string(out)).To(ContainSubstring("llama_model_loader"), string(out)) | ||
} | ||
}) | ||
|
||
Context("Generates text", func() { | ||
It("streams chat tokens", func() { | ||
model := "gpt-4" | ||
resp, err := client.CreateChatCompletion(context.TODO(), | ||
openai.ChatCompletionRequest{ | ||
Model: model, Messages: []openai.ChatCompletionMessage{ | ||
{ | ||
Role: "user", | ||
Content: "How much is 2+2?", | ||
}, | ||
}}) | ||
Expect(err).ToNot(HaveOccurred()) | ||
Expect(len(resp.Choices)).To(Equal(1), fmt.Sprint(resp)) | ||
Expect(resp.Choices[0].Message.Content).To(Or(ContainSubstring("4"), ContainSubstring("four")), fmt.Sprint(resp.Choices[0].Message.Content)) | ||
}) | ||
}) | ||
}) | ||
}) |