-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathengine_gpu_test.go
More file actions
69 lines (58 loc) · 1.84 KB
/
Copy pathengine_gpu_test.go
File metadata and controls
69 lines (58 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package ortgenai
import (
"os"
"testing"
)
func TestEngineGPU(t *testing.T) {
if os.Getenv("CI") == "true" {
t.Skip("skip by default in CI")
}
SetSharedLibraryPath(getLibraryPath())
if err := InitializeEnvironment(); err != nil {
t.Fatalf("failed to initialize environment: %v", err)
}
defer func() {
if err := DestroyEnvironment(); err != nil {
t.Fatalf("failed to destroy environment: %v", err)
}
}()
modelPath := "./models/phi3.5gpu" // use the gpu-optimized model
if _, err := os.Stat(modelPath); os.IsNotExist(err) {
t.Skip("GPU model not found at " + modelPath)
}
providers := []string{"cuda"}
providerOptions := map[string]map[string]string{}
engine, err := CreateEngineWithOptions(modelPath, providers, providerOptions)
if err != nil {
t.Fatalf("failed to create engine with CUDA: %v", err)
}
defer engine.Destroy()
t.Run("Generation", func(t *testing.T) {
options := &GenerationOptions{
MaxLength: 2048,
BatchSize: 1,
}
testGenericGeneration(t, engine, [][]Message{inputMessagesFirstGeneration, inputMessagesSecondGeneration}, options)
})
t.Run("ConcurrentGeneration", func(t *testing.T) {
testGenericConcurrentGeneration(t, engine)
})
t.Run("ContextCancellation", func(t *testing.T) {
testGenericContextCancellation(t, engine)
})
t.Run("GenerationWithTools", func(t *testing.T) {
if os.Getenv("CI") == "true" {
t.Skip("Skipping tool-calling test in CI as it requires qwen, we run this locally")
}
toolModelPath := "./models/qwen3-4B-int4"
if _, err := os.Stat(toolModelPath); os.IsNotExist(err) {
t.Skip("Model not found at " + toolModelPath)
}
toolEngine, err := CreateEngineWithOptions(toolModelPath, providers, providerOptions)
if err != nil {
t.Fatalf("failed to create tool engine: %v", err)
}
defer toolEngine.Destroy()
testGenericGenerationWithTools(t, toolEngine)
})
}