mirror of
https://github.com/dogkeeper886/ollama37.git
synced 2025-12-09 23:37:06 +00:00
This commit represents a complete rework after pulling the latest changes from official ollama/ollama repository and re-applying Tesla K80 compatibility patches. ## Key Changes ### CUDA Compute Capability 3.7 Support (Tesla K80) - Added sm_37 (compute 3.7) to CMAKE_CUDA_ARCHITECTURES in CMakeLists.txt - Updated CMakePresets.json to include compute 3.7 in "CUDA 11" preset - Using 37-virtual (PTX with JIT compilation) for maximum compatibility ### Legacy Toolchain Compatibility - **NVIDIA Driver**: 470.256.02 (last version supporting Kepler/K80) - **CUDA Version**: 11.4.4 (last CUDA 11.x supporting compute 3.7) - **GCC Version**: 10.5.0 (required by CUDA 11.4 host_config.h) ### CPU Architecture Trade-offs Due to GCC 10.5 limitation, sacrificed newer CPU optimizations: - Alderlake CPU variant enabled WITHOUT AVX_VNNI (requires GCC 11+) - Still supports: SSE4.2, AVX, F16C, AVX2, BMI2, FMA - Performance impact: ~3-7% on newer CPUs (acceptable for K80 compatibility) ### Build System Updates - Modified ml/backend/ggml/ggml/src/ggml-cuda/CMakeLists.txt for compute 3.7 - Added -Wno-deprecated-gpu-targets flag to suppress warnings - Updated ml/backend/ggml/ggml/src/CMakeLists.txt for Alderlake without AVX_VNNI ### Upstream Sync Merged latest llama.cpp changes including: - Enhanced KV cache management with ISWA and hybrid memory support - Improved multi-modal support (mtmd framework) - New model architectures (Gemma3, Llama4, Qwen3, etc.) - GPU backend improvements for CUDA, Metal, and ROCm - Updated quantization support and GGUF format handling ### Documentation - Updated CLAUDE.md with comprehensive build instructions - Documented toolchain constraints and CPU architecture trade-offs - Removed outdated CI/CD workflows (tesla-k80-*.yml) - Cleaned up temporary development artifacts ## Rationale This fork maintains Tesla K80 GPU support (compute 3.7) which was dropped in official Ollama due to legacy driver/CUDA requirements. The toolchain constraint creates a deadlock: - K80 → Driver 470 → CUDA 11.4 → GCC 10 → No AVX_VNNI We accept the loss of cutting-edge CPU optimizations to enable running modern LLMs on legacy but still capable Tesla K80 hardware (12GB VRAM per GPU). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
133 lines
3.1 KiB
Go
133 lines
3.1 KiB
Go
//go:build integration
|
|
|
|
package integration
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/ollama/ollama/api"
|
|
)
|
|
|
|
func TestAPIToolCalling(t *testing.T) {
|
|
initialTimeout := 60 * time.Second
|
|
streamTimeout := 60 * time.Second
|
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Minute)
|
|
defer cancel()
|
|
|
|
client, _, cleanup := InitServerConnection(ctx, t)
|
|
defer cleanup()
|
|
|
|
minVRAM := map[string]uint64{
|
|
"qwen3-vl": 16,
|
|
"gpt-oss:20b": 16,
|
|
"gpt-oss:120b": 70,
|
|
"qwen3": 6,
|
|
"llama3.1": 8,
|
|
"llama3.2": 4,
|
|
"mistral": 6,
|
|
"qwen2.5": 6,
|
|
"qwen2": 6,
|
|
"mistral-nemo": 9,
|
|
"mistral-small": 16,
|
|
"mixtral:8x22b": 80,
|
|
"qwq": 20,
|
|
"granite3.3": 7,
|
|
}
|
|
|
|
for _, model := range libraryToolsModels {
|
|
t.Run(model, func(t *testing.T) {
|
|
if v, ok := minVRAM[model]; ok {
|
|
skipUnderMinVRAM(t, v)
|
|
}
|
|
|
|
if err := PullIfMissing(ctx, client, model); err != nil {
|
|
t.Fatalf("pull failed %s", err)
|
|
}
|
|
|
|
tools := []api.Tool{
|
|
{
|
|
Type: "function",
|
|
Function: api.ToolFunction{
|
|
Name: "get_weather",
|
|
Description: "Get the current weather in a given location",
|
|
Parameters: api.ToolFunctionParameters{
|
|
Type: "object",
|
|
Required: []string{"location"},
|
|
Properties: map[string]api.ToolProperty{
|
|
"location": {
|
|
Type: api.PropertyType{"string"},
|
|
Description: "The city and state, e.g. San Francisco, CA",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}
|
|
|
|
req := api.ChatRequest{
|
|
Model: model,
|
|
Messages: []api.Message{
|
|
{
|
|
Role: "user",
|
|
Content: "Call get_weather with location set to San Francisco.",
|
|
},
|
|
},
|
|
Tools: tools,
|
|
Options: map[string]any{
|
|
"temperature": 0,
|
|
},
|
|
}
|
|
|
|
stallTimer := time.NewTimer(initialTimeout)
|
|
var gotToolCall bool
|
|
var lastToolCall api.ToolCall
|
|
|
|
fn := func(response api.ChatResponse) error {
|
|
if len(response.Message.ToolCalls) > 0 {
|
|
gotToolCall = true
|
|
lastToolCall = response.Message.ToolCalls[len(response.Message.ToolCalls)-1]
|
|
}
|
|
if !stallTimer.Reset(streamTimeout) {
|
|
return fmt.Errorf("stall was detected while streaming response, aborting")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
stream := true
|
|
req.Stream = &stream
|
|
done := make(chan int)
|
|
var genErr error
|
|
go func() {
|
|
genErr = client.Chat(ctx, &req, fn)
|
|
done <- 0
|
|
}()
|
|
|
|
select {
|
|
case <-stallTimer.C:
|
|
t.Errorf("tool-calling chat never started. Timed out after: %s", initialTimeout.String())
|
|
case <-done:
|
|
if genErr != nil {
|
|
t.Fatalf("chat failed: %v", genErr)
|
|
}
|
|
|
|
if !gotToolCall {
|
|
t.Fatalf("expected at least one tool call, got none")
|
|
}
|
|
|
|
if lastToolCall.Function.Name != "get_weather" {
|
|
t.Errorf("unexpected tool called: got %q want %q", lastToolCall.Function.Name, "get_weather")
|
|
}
|
|
|
|
if _, ok := lastToolCall.Function.Arguments["location"]; !ok {
|
|
t.Errorf("expected tool arguments to include 'location', got: %s", lastToolCall.Function.Arguments.String())
|
|
}
|
|
case <-ctx.Done():
|
|
t.Error("outer test context done while waiting for tool-calling chat")
|
|
}
|
|
})
|
|
}
|
|
}
|