Skip to content

Commit ed5734a

Browse files
authored
test/fix: OSX Test Repair (#1843)
* test with gguf instead of ggml. Updates testPrompt to match? Adds debugging line to Dockerfile that I've found helpful recently. * fix testPrompt slightly * Sad Experiment: Test GH runner without metal? * break apart CGO_LDFLAGS * switch runner * upstream llama.cpp disables Metal on Github CI! * missed a dir from clean-tests * CGO_LDFLAGS * tmate failure + NO_ACCELERATE * whisper.cpp has a metal fix * do the exact opposite of the name of this branch, but keep it around for unrelated fixes? * add back newlines * add tmate to linux for testing * update fixtures * timeout for tmate
1 parent a046dca commit ed5734a

File tree

8 files changed

+39
-14
lines changed

8 files changed

+39
-14
lines changed

.github/workflows/test.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,13 @@ jobs:
105105
- name: Test
106106
run: |
107107
GO_TAGS="stablediffusion tts" make test
108+
- name: Setup tmate session if tests fail
109+
if: ${{ failure() }}
110+
uses: mxschmitt/action-tmate@v3
111+
timeout-minutes: 5
108112

109113
tests-apple:
110-
runs-on: macOS-latest
114+
runs-on: macOS-14
111115
strategy:
112116
matrix:
113117
go-version: ['1.21.x']
@@ -130,4 +134,8 @@ jobs:
130134
run: |
131135
export C_INCLUDE_PATH=/usr/local/include
132136
export CPLUS_INCLUDE_PATH=/usr/local/include
133-
CMAKE_ARGS="-DLLAMA_F16C=OFF -DLLAMA_AVX512=OFF -DLLAMA_AVX2=OFF -DLLAMA_FMA=OFF" make test
137+
BUILD_TYPE="GITHUB_CI_HAS_BROKEN_METAL" CMAKE_ARGS="-DLLAMA_F16C=OFF -DLLAMA_AVX512=OFF -DLLAMA_AVX2=OFF -DLLAMA_FMA=OFF" make test
138+
- name: Setup tmate session if tests fail
139+
if: ${{ failure() }}
140+
uses: mxschmitt/action-tmate@v3
141+
timeout-minutes: 5

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ WORKDIR /build
108108

109109
COPY . .
110110
COPY .git .
111+
RUN echo "GO_TAGS: $GO_TAGS"
111112
RUN make prepare
112113

113114
# If we are building with clblas support, we need the libraries for the builds

Makefile

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ UNAME_S := $(shell uname -s)
7070
endif
7171

7272
ifeq ($(OS),Darwin)
73-
CGO_LDFLAGS += -lcblas -framework Accelerate
73+
7474
ifeq ($(OSX_SIGNING_IDENTITY),)
7575
OSX_SIGNING_IDENTITY := $(shell security find-identity -v -p codesigning | grep '"' | head -n 1 | sed -E 's/.*"(.*)"/\1/')
7676
endif
@@ -81,6 +81,12 @@ ifeq ($(OS),Darwin)
8181
# disable metal if on Darwin and any other value is explicitly passed.
8282
else ifneq ($(BUILD_TYPE),metal)
8383
CMAKE_ARGS+=-DLLAMA_METAL=OFF
84+
export LLAMA_NO_ACCELERATE=1
85+
endif
86+
87+
ifeq ($(BUILD_TYPE),metal)
88+
# -lcblas removed: it seems to always be listed as a duplicate flag.
89+
CGO_LDFLAGS += -framework Accelerate
8490
endif
8591
endif
8692

@@ -286,6 +292,11 @@ clean: ## Remove build related file
286292
$(MAKE) -C backend/cpp/llama clean
287293
$(MAKE) dropreplace
288294

295+
clean-tests:
296+
rm -rf test-models
297+
rm -rf test-dir
298+
rm -rf core/http/backend-assets
299+
289300
## Build:
290301
build: prepare backend-assets grpcs ## Build the project
291302
$(info ${GREEN}I local-ai build info:${RESET})
@@ -305,10 +316,10 @@ osx-signed: build
305316
run: prepare ## run local-ai
306317
CGO_LDFLAGS="$(CGO_LDFLAGS)" $(GOCMD) run ./
307318

308-
test-models/testmodel:
319+
test-models/testmodel.ggml:
309320
mkdir test-models
310321
mkdir test-dir
311-
wget -q https://huggingface.co/TheBloke/orca_mini_3B-GGML/resolve/main/orca-mini-3b.ggmlv3.q4_0.bin -O test-models/testmodel
322+
wget -q https://huggingface.co/TheBloke/orca_mini_3B-GGML/resolve/main/orca-mini-3b.ggmlv3.q4_0.bin -O test-models/testmodel.ggml
312323
wget -q https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-base.en.bin -O test-models/whisper-en
313324
wget -q https://huggingface.co/mudler/all-MiniLM-L6-v2/resolve/main/ggml-model-q4_0.bin -O test-models/bert
314325
wget -q https://cdn.openai.com/whisper/draft-20220913a/micro-machines.wav -O test-dir/audio.wav
@@ -320,7 +331,7 @@ prepare-test: grpcs
320331
cp -rf backend-assets core/http
321332
cp tests/models_fixtures/* test-models
322333

323-
test: prepare test-models/testmodel grpcs
334+
test: prepare test-models/testmodel.ggml grpcs
324335
@echo 'Running tests'
325336
export GO_TAGS="tts stablediffusion"
326337
$(MAKE) prepare-test

backend/cpp/llama/Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ else ifeq ($(BUILD_TYPE),clblas)
1919
else ifeq ($(BUILD_TYPE),hipblas)
2020
CMAKE_ARGS+=-DLLAMA_HIPBLAS=ON
2121
# If it's OSX, DO NOT embed the metal library - -DLLAMA_METAL_EMBED_LIBRARY=ON requires further investigation
22+
# But if it's OSX without metal, disable it here
23+
else ifeq ($(OS),darwin)
24+
ifneq ($(BUILD_TYPE),metal)
25+
CMAKE_ARGS+=-DLLAMA_METAL=OFF
26+
endif
2227
endif
2328

2429
ifeq ($(BUILD_TYPE),sycl_f16)

core/http/api_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -666,15 +666,15 @@ var _ = Describe("API test", func() {
666666
Expect(err).ToNot(HaveOccurred())
667667
Expect(len(models.Models)).To(Equal(6)) // If "config.yaml" should be included, this should be 8?
668668
})
669-
It("can generate completions", func() {
670-
resp, err := client.CreateCompletion(context.TODO(), openai.CompletionRequest{Model: "testmodel", Prompt: testPrompt})
669+
It("can generate completions via ggml", func() {
670+
resp, err := client.CreateCompletion(context.TODO(), openai.CompletionRequest{Model: "testmodel.ggml", Prompt: testPrompt})
671671
Expect(err).ToNot(HaveOccurred())
672672
Expect(len(resp.Choices)).To(Equal(1))
673673
Expect(resp.Choices[0].Text).ToNot(BeEmpty())
674674
})
675675

676-
It("can generate chat completions ", func() {
677-
resp, err := client.CreateChatCompletion(context.TODO(), openai.ChatCompletionRequest{Model: "testmodel", Messages: []openai.ChatCompletionMessage{openai.ChatCompletionMessage{Role: "user", Content: testPrompt}}})
676+
It("can generate chat completions via ggml", func() {
677+
resp, err := client.CreateChatCompletion(context.TODO(), openai.ChatCompletionRequest{Model: "testmodel.ggml", Messages: []openai.ChatCompletionMessage{openai.ChatCompletionMessage{Role: "user", Content: testPrompt}}})
678678
Expect(err).ToNot(HaveOccurred())
679679
Expect(len(resp.Choices)).To(Equal(1))
680680
Expect(resp.Choices[0].Message.Content).ToNot(BeEmpty())

tests/models_fixtures/config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
- name: list1
22
parameters:
3-
model: testmodel
3+
model: testmodel.ggml
44
top_p: 80
55
top_k: 0.9
66
temperature: 0.1
@@ -19,7 +19,7 @@
1919
top_p: 80
2020
top_k: 0.9
2121
temperature: 0.1
22-
model: testmodel
22+
model: testmodel.ggml
2323
context_size: 200
2424
stopwords:
2525
- "HUMAN:"

tests/models_fixtures/gpt4.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: gpt4all
22
parameters:
3-
model: testmodel
3+
model: testmodel.ggml
44
top_p: 80
55
top_k: 0.9
66
temperature: 0.1

tests/models_fixtures/gpt4_2.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: gpt4all-2
22
parameters:
3-
model: testmodel
3+
model: testmodel.ggml
44
top_p: 80
55
top_k: 0.9
66
temperature: 0.1

0 commit comments

Comments
 (0)