mirror of
https://github.com/ollama/ollama.git
synced 2026-09-21 05:28:00 -05:00
mlx, mlxrunner: move the MLX engine out of x/
The MLX runner is the only Go inference runner left and is no longer experimental, so its packages leave x/. The bindings become a top-level mlx package beside the carried patches in mlx/compat, mirroring how llama/ holds the llama.cpp integration, and the runner becomes mlxrunner with the architectures nested under the package they implement. Subpackages move with their parent unless listed. x/mlxrunner/mlx mlx x/internal/mlxthread mlx/mlxthread x/internal/mlxthreadtest mlx/mlxthread/mlxthreadtest x/internal/mlxtest mlx/mlxtest x/quant mlx/quant mlx/compat/*.patch mlx/compat/mlx-c (MLX patches go in mlx/compat/mlx) x/mlxrunner mlxrunner x/models/nn mlxrunner/nn x/models/<arch> mlxrunner/model/<arch> x/mlxrunner/imports.go mlxrunner/model/architectures (new package) x/create create x/safetensors fs/safetensors x/tokenizer mlxrunner/tokenizer Every package keeps its name, so the Go changes are the import path rewrites the moves force, and the CMake, Dockerfile, CI cache keys, drift check and Darwin payload script follow the new paths. Four edits are not paths: the runner's blank architecture imports become the package mlxrunner/model/architectures, so the list to extend for a new model sits beside the architecture directories; a depguard rule keeps the two test harnesses out of non-test code, as the x/internal placement used to; the CI change filter's two entries for the long-deleted x/imagegen/mlx now name the bindings' CMake project and the carried patches, so a change to either builds the payload; and the tokenizer parity test reads its fixtures from its own testdata instead of walking out of x/. x/server and x/imagegen/manifest stay for the next two commits.
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
#
|
||||
# The payload also depends on Ollama's payload build rules (cmake glue and
|
||||
# carried mlx/compat patches) and the xgrammar native wrapper
|
||||
# (x/mlxrunner/xgrammar/native). Rule drift rebuilds the whole payload from
|
||||
# (mlxrunner/xgrammar/native). Rule drift rebuilds the whole payload from
|
||||
# source; wrapper-only drift rebuilds just libollama_xgrammar.dylib.
|
||||
#
|
||||
# If no release matches the MLX pins (e.g. right after a pin bump), the
|
||||
@@ -54,7 +54,7 @@ read_pin() {
|
||||
|
||||
# Native wrapper sources compiled into libollama_xgrammar.dylib — keep in
|
||||
# sync with the ollama_xgrammar target in cmake/mlx/CMakeLists.txt.
|
||||
xgrammar_native_dir=x/mlxrunner/xgrammar/native
|
||||
xgrammar_native_dir=mlxrunner/xgrammar/native
|
||||
|
||||
# Payload build rules beyond the MLX_VERSION/MLX_C_VERSION pins.
|
||||
payload_rule_files=(
|
||||
@@ -62,7 +62,7 @@ payload_rule_files=(
|
||||
"cmake/apply-git-patches.cmake"
|
||||
"cmake/mlx/CMakeLists.txt"
|
||||
"cmake/mlx/CMakePresets.json"
|
||||
"x/mlxrunner/mlx/CMakeLists.txt"
|
||||
"mlx/CMakeLists.txt"
|
||||
)
|
||||
|
||||
# Build-rule inputs: the rule files plus carried MLX/MLX-C patch content.
|
||||
|
||||
+10
-11
@@ -49,10 +49,11 @@ jobs:
|
||||
'LLAMA_CPP_VERSION' \
|
||||
'MLX_VERSION' \
|
||||
'MLX_C_VERSION' \
|
||||
'x/imagegen/mlx/**' \
|
||||
'x/imagegen/mlx/**/*' \
|
||||
'x/mlxrunner/xgrammar/native/**' \
|
||||
'x/mlxrunner/xgrammar/native/**/*' \
|
||||
'mlx/CMakeLists.txt' \
|
||||
'mlx/compat/**' \
|
||||
'mlx/compat/**/*' \
|
||||
'mlxrunner/xgrammar/native/**' \
|
||||
'mlxrunner/xgrammar/native/**/*' \
|
||||
'.github/**/*') | tee -a $GITHUB_OUTPUT
|
||||
echo app_changed=$(changed 'app/**' 'app/**/*') | tee -a $GITHUB_OUTPUT
|
||||
echo go_mod_changed=$(changed 'go.mod') | tee -a $GITHUB_OUTPUT
|
||||
@@ -417,7 +418,7 @@ jobs:
|
||||
with:
|
||||
path: .cache/mlx-darwin-release
|
||||
# Key on every payload input so a source-built payload survives pushes.
|
||||
key: mlx-darwin-${{ hashFiles('MLX_VERSION', 'MLX_C_VERSION', 'cmake/local.cmake', 'cmake/apply-git-patches.cmake', 'cmake/mlx/CMakeLists.txt', 'cmake/mlx/CMakePresets.json', 'x/mlxrunner/mlx/CMakeLists.txt', 'mlx/compat/**', 'x/mlxrunner/xgrammar/native/**') }}
|
||||
key: mlx-darwin-${{ hashFiles('MLX_VERSION', 'MLX_C_VERSION', 'cmake/local.cmake', 'cmake/apply-git-patches.cmake', 'cmake/mlx/CMakeLists.txt', 'cmake/mlx/CMakePresets.json', 'mlx/CMakeLists.txt', 'mlx/compat/**', 'mlxrunner/xgrammar/native/**') }}
|
||||
- name: Prepare MLX Darwin release payload
|
||||
if: ${{ startsWith(matrix.os, 'macos') }}
|
||||
run: .github/scripts/prepare_mlx_darwin.sh
|
||||
@@ -437,11 +438,9 @@ jobs:
|
||||
cmake -S . -B build/mlx-generate -DOLLAMA_MLX_BACKENDS=cuda_v13
|
||||
cmake --build build/mlx-generate --target ollama-mlx-generate-wrappers
|
||||
git diff --exit-code -- \
|
||||
x/imagegen/mlx/mlx.h \
|
||||
x/imagegen/mlx/mlx.c \
|
||||
x/mlxrunner/mlx/generated.h \
|
||||
x/mlxrunner/mlx/generated.c \
|
||||
x/mlxrunner/mlx/include/mlx/c
|
||||
mlx/generated.h \
|
||||
mlx/generated.c \
|
||||
mlx/include/mlx/c
|
||||
- name: Run go generate
|
||||
run: go generate ./...
|
||||
|
||||
@@ -484,7 +483,7 @@ jobs:
|
||||
with:
|
||||
path: .cache/mlx-darwin-release
|
||||
# Key on every payload input so a source-built payload survives pushes.
|
||||
key: mlx-darwin-${{ hashFiles('MLX_VERSION', 'MLX_C_VERSION', 'cmake/local.cmake', 'cmake/apply-git-patches.cmake', 'cmake/mlx/CMakeLists.txt', 'cmake/mlx/CMakePresets.json', 'x/mlxrunner/mlx/CMakeLists.txt', 'mlx/compat/**', 'x/mlxrunner/xgrammar/native/**') }}
|
||||
key: mlx-darwin-${{ hashFiles('MLX_VERSION', 'MLX_C_VERSION', 'cmake/local.cmake', 'cmake/apply-git-patches.cmake', 'cmake/mlx/CMakeLists.txt', 'cmake/mlx/CMakePresets.json', 'mlx/CMakeLists.txt', 'mlx/compat/**', 'mlxrunner/xgrammar/native/**') }}
|
||||
- name: Prepare MLX Darwin release payload
|
||||
if: ${{ startsWith(matrix.os, 'macos') }}
|
||||
run: .github/scripts/prepare_mlx_darwin.sh
|
||||
|
||||
@@ -27,9 +27,14 @@ linters:
|
||||
files:
|
||||
- $all
|
||||
- "!$test"
|
||||
- "!**/mlx/mlxtest/*.go"
|
||||
deny:
|
||||
- pkg: github.com/ollama/ollama/internal/testutil
|
||||
desc: test helpers may only be imported by test files
|
||||
- pkg: github.com/ollama/ollama/mlx/mlxtest
|
||||
desc: test helpers may only be imported by test files
|
||||
- pkg: github.com/ollama/ollama/mlx/mlxthread/mlxthreadtest
|
||||
desc: test helpers may only be imported by test files
|
||||
govet:
|
||||
disable:
|
||||
- unusedresult
|
||||
|
||||
+2
-3
@@ -220,9 +220,8 @@ ENV CGO_LDFLAGS="-L/usr/local/cuda-13/lib64 -L/usr/local/cuda-13/targets/x86_64-
|
||||
WORKDIR /go/src/github.com/ollama/ollama
|
||||
COPY CMakeLists.txt CMakePresets.json .
|
||||
COPY cmake cmake
|
||||
COPY mlx/compat mlx/compat
|
||||
COPY x/mlxrunner/mlx x/mlxrunner/mlx
|
||||
COPY x/mlxrunner/xgrammar/native x/mlxrunner/xgrammar/native
|
||||
COPY mlx mlx
|
||||
COPY mlxrunner/xgrammar/native mlxrunner/xgrammar/native
|
||||
COPY go.mod go.sum .
|
||||
COPY MLX_VERSION MLX_C_VERSION .
|
||||
RUN curl -fsSL https://golang.org/dl/go$(awk '/^go/ { print $2 }' go.mod).linux-$(case $(uname -m) in x86_64) echo amd64 ;; aarch64) echo arm64 ;; esac).tar.gz | tar xz -C /usr/local
|
||||
|
||||
+4
-4
@@ -175,8 +175,8 @@ if(OLLAMA_MLX_BACKENDS)
|
||||
find_package(Git REQUIRED)
|
||||
set(OLLAMA_MLX_C_COMPAT_PATCH_COMMAND
|
||||
${CMAKE_COMMAND}
|
||||
-DPATCH_DIR=${CMAKE_SOURCE_DIR}/mlx/compat
|
||||
-DPATCH_LABEL=mlx/compat
|
||||
-DPATCH_DIR=${CMAKE_SOURCE_DIR}/mlx/compat/mlx-c
|
||||
-DPATCH_LABEL=mlx/compat/mlx-c
|
||||
-P ${CMAKE_SOURCE_DIR}/cmake/apply-git-patches.cmake
|
||||
CACHE INTERNAL "MLX-C carry patch")
|
||||
|
||||
@@ -236,7 +236,7 @@ if(OLLAMA_MLX_BACKENDS)
|
||||
add_custom_target(ollama-mlx-vendor-headers
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-DMLX_C_HEADERS_DIR=${OLLAMA_MLX_C_SOURCE_DIR}/mlx/c
|
||||
-DMLX_C_HEADERS_DEST=${CMAKE_SOURCE_DIR}/x/mlxrunner/mlx/include/mlx/c
|
||||
-DMLX_C_HEADERS_DEST=${CMAKE_SOURCE_DIR}/mlx/include/mlx/c
|
||||
-P "${CMAKE_SOURCE_DIR}/cmake/vendor-mlx-c-headers.cmake"
|
||||
DEPENDS ${_mlx_source_targets}
|
||||
COMMENT "Vendoring MLX-C headers"
|
||||
@@ -623,7 +623,7 @@ if(OLLAMA_MLX_BACKENDS)
|
||||
add_custom_target(ollama-mlx-generate-wrappers
|
||||
COMMAND ${CMAKE_COMMAND} -E env
|
||||
CC= CGO_CFLAGS= CGO_CXXFLAGS=
|
||||
${GO_EXECUTABLE} generate ./x/...
|
||||
${GO_EXECUTABLE} generate ./mlx/...
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
DEPENDS ollama-mlx-sources
|
||||
COMMENT "Regenerating MLX Go wrappers"
|
||||
|
||||
@@ -59,7 +59,7 @@ foreach(_cudnn_var CUDNN_INCLUDE_PATH CUDNN_LIBRARY_PATH)
|
||||
set(${_cudnn_var} "$ENV{${_cudnn_var}}" CACHE PATH "")
|
||||
endif()
|
||||
endforeach()
|
||||
add_subdirectory(${OLLAMA_SOURCE_DIR}/x/mlxrunner/mlx ${CMAKE_BINARY_DIR}/x/mlxrunner/mlx)
|
||||
add_subdirectory(${OLLAMA_SOURCE_DIR}/mlx ${CMAKE_BINARY_DIR}/mlx)
|
||||
|
||||
include(FetchContent)
|
||||
set(XGRAMMAR_VERSION v0.2.5)
|
||||
@@ -88,9 +88,9 @@ target_compile_definitions(xgrammar PUBLIC
|
||||
XGRAMMAR_ENABLE_INTERNAL_CHECK=0)
|
||||
|
||||
add_library(ollama_xgrammar SHARED
|
||||
"${OLLAMA_SOURCE_DIR}/x/mlxrunner/xgrammar/native/xgrammar.cpp")
|
||||
"${OLLAMA_SOURCE_DIR}/mlxrunner/xgrammar/native/xgrammar.cpp")
|
||||
target_include_directories(ollama_xgrammar PRIVATE
|
||||
"${OLLAMA_SOURCE_DIR}/x/mlxrunner/xgrammar/native")
|
||||
"${OLLAMA_SOURCE_DIR}/mlxrunner/xgrammar/native")
|
||||
target_compile_definitions(ollama_xgrammar PRIVATE
|
||||
OLLAMA_XGRAMMAR_BUILD=1
|
||||
OLLAMA_XGRAMMAR_VERSION="${XGRAMMAR_VERSION}")
|
||||
|
||||
+20
-20
@@ -42,12 +42,15 @@ import (
|
||||
"github.com/ollama/ollama/cmd/config"
|
||||
"github.com/ollama/ollama/cmd/launch"
|
||||
"github.com/ollama/ollama/cmd/tui"
|
||||
"github.com/ollama/ollama/create"
|
||||
createclient "github.com/ollama/ollama/create/client"
|
||||
"github.com/ollama/ollama/discover"
|
||||
"github.com/ollama/ollama/envconfig"
|
||||
"github.com/ollama/ollama/format"
|
||||
"github.com/ollama/ollama/internal/modelref"
|
||||
"github.com/ollama/ollama/logutil"
|
||||
"github.com/ollama/ollama/manifest"
|
||||
"github.com/ollama/ollama/mlxrunner"
|
||||
"github.com/ollama/ollama/parser"
|
||||
"github.com/ollama/ollama/progress"
|
||||
"github.com/ollama/ollama/readline"
|
||||
@@ -55,9 +58,6 @@ import (
|
||||
"github.com/ollama/ollama/types/model"
|
||||
"github.com/ollama/ollama/types/syncmap"
|
||||
"github.com/ollama/ollama/version"
|
||||
xcreate "github.com/ollama/ollama/x/create"
|
||||
xcreateclient "github.com/ollama/ollama/x/create/client"
|
||||
"github.com/ollama/ollama/x/mlxrunner"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -191,7 +191,7 @@ func resolveCreateLocalModelDir(ref, filename string) string {
|
||||
}
|
||||
|
||||
candidate := filepath.Join(filepath.Dir(filename), ref)
|
||||
if xcreate.IsSafetensorsModelDir(candidate) {
|
||||
if create.IsSafetensorsModelDir(candidate) {
|
||||
return candidate
|
||||
}
|
||||
|
||||
@@ -203,14 +203,14 @@ func resolveCreateDraftDir(ref, filename string) (string, error) {
|
||||
return "", nil
|
||||
}
|
||||
if filepath.IsAbs(ref) {
|
||||
if xcreate.IsSafetensorsModelDir(ref) {
|
||||
if create.IsSafetensorsModelDir(ref) {
|
||||
return ref, nil
|
||||
}
|
||||
return "", fmt.Errorf("draft %s is not a supported safetensors model directory", ref)
|
||||
}
|
||||
if filename != "" {
|
||||
candidate := filepath.Join(filepath.Dir(filename), ref)
|
||||
if xcreate.IsSafetensorsModelDir(candidate) {
|
||||
if create.IsSafetensorsModelDir(candidate) {
|
||||
return candidate, nil
|
||||
}
|
||||
}
|
||||
@@ -241,28 +241,28 @@ func readCreateModelfile(cmd *cobra.Command) (*parser.Modelfile, string, error)
|
||||
return modelfile, filename, nil
|
||||
}
|
||||
|
||||
func safetensorsCreateOptions(modelfile *parser.Modelfile, filename, modelName string) (xcreateclient.CreateOptions, bool, error) {
|
||||
modelDir, mfConfig, err := xcreateclient.ConfigFromModelfile(modelfile)
|
||||
func safetensorsCreateOptions(modelfile *parser.Modelfile, filename, modelName string) (createclient.CreateOptions, bool, error) {
|
||||
modelDir, mfConfig, err := createclient.ConfigFromModelfile(modelfile)
|
||||
if err != nil {
|
||||
return xcreateclient.CreateOptions{}, false, err
|
||||
return createclient.CreateOptions{}, false, err
|
||||
}
|
||||
|
||||
modelDir = resolveCreateLocalModelDir(modelDir, filename)
|
||||
isSafetensors := xcreate.IsSafetensorsModelDir(modelDir)
|
||||
isBaseModelWithDraft := mfConfig.Draft != "" && !isSafetensors && xcreate.IsSafetensorsLLMModel(modelDir)
|
||||
isSafetensors := create.IsSafetensorsModelDir(modelDir)
|
||||
isBaseModelWithDraft := mfConfig.Draft != "" && !isSafetensors && create.IsSafetensorsLLMModel(modelDir)
|
||||
if !isSafetensors && !isBaseModelWithDraft {
|
||||
return xcreateclient.CreateOptions{}, false, nil
|
||||
return createclient.CreateOptions{}, false, nil
|
||||
}
|
||||
|
||||
if mfConfig.Draft != "" {
|
||||
draftDir, err := resolveCreateDraftDir(mfConfig.Draft, filename)
|
||||
if err != nil {
|
||||
if isSafetensors {
|
||||
return xcreateclient.CreateOptions{}, false, err
|
||||
return createclient.CreateOptions{}, false, err
|
||||
}
|
||||
// Existing safetensors models may still use a GGUF DRAFT layer;
|
||||
// leave that combination on the standard create path.
|
||||
return xcreateclient.CreateOptions{}, false, nil
|
||||
return createclient.CreateOptions{}, false, nil
|
||||
}
|
||||
mfConfig.Draft = draftDir
|
||||
}
|
||||
@@ -277,13 +277,13 @@ func safetensorsCreateOptions(modelfile *parser.Modelfile, filename, modelName s
|
||||
}
|
||||
}
|
||||
if modelCount != 1 {
|
||||
return xcreateclient.CreateOptions{}, false, errors.New("safetensors imports require exactly one FROM source")
|
||||
return createclient.CreateOptions{}, false, errors.New("safetensors imports require exactly one FROM source")
|
||||
}
|
||||
if draftCount > 1 {
|
||||
return xcreateclient.CreateOptions{}, false, errors.New("safetensors imports support at most one DRAFT source")
|
||||
return createclient.CreateOptions{}, false, errors.New("safetensors imports support at most one DRAFT source")
|
||||
}
|
||||
|
||||
return xcreateclient.CreateOptions{
|
||||
return createclient.CreateOptions{
|
||||
ModelName: modelName,
|
||||
ModelDir: modelDir,
|
||||
Modelfile: mfConfig,
|
||||
@@ -298,9 +298,9 @@ var (
|
||||
|
||||
// createSafetensorsModel imports in-process when the server is local and
|
||||
// otherwise uploads the source files for the server to import.
|
||||
func createSafetensorsModel(cmd *cobra.Command, args []string, opts xcreateclient.CreateOptions, p *progress.Progress) error {
|
||||
func createSafetensorsModel(cmd *cobra.Command, args []string, opts createclient.CreateOptions, p *progress.Progress) error {
|
||||
if !envconfig.CreateRemote() && isLocalhost() {
|
||||
return xcreateclient.CreateModel(cmd.Context(), opts, p)
|
||||
return createclient.CreateModel(cmd.Context(), opts, p)
|
||||
}
|
||||
if opts.Force {
|
||||
return errForceLocalOnly
|
||||
@@ -312,7 +312,7 @@ func createSafetensorsModel(cmd *cobra.Command, args []string, opts xcreateclien
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return xcreateclient.CreateModelRemote(cmd.Context(), client, opts, p)
|
||||
return createclient.CreateModelRemote(cmd.Context(), client, opts, p)
|
||||
}
|
||||
|
||||
func CreateHandler(cmd *cobra.Command, args []string) error {
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/ollama/ollama/x/quant"
|
||||
"github.com/ollama/ollama/mlx/quant"
|
||||
)
|
||||
|
||||
// SourceKind is the overarching dtype for a given safetensors model
|
||||
@@ -14,12 +14,12 @@ import (
|
||||
"golang.org/x/mod/semver"
|
||||
|
||||
"github.com/ollama/ollama/api"
|
||||
"github.com/ollama/ollama/create"
|
||||
"github.com/ollama/ollama/manifest"
|
||||
"github.com/ollama/ollama/mlx/quant"
|
||||
"github.com/ollama/ollama/parser"
|
||||
"github.com/ollama/ollama/progress"
|
||||
"github.com/ollama/ollama/types/model"
|
||||
"github.com/ollama/ollama/x/create"
|
||||
"github.com/ollama/ollama/x/quant"
|
||||
)
|
||||
|
||||
var errAdaptersUnsupported = errors.New("LoRA adapters are no longer supported")
|
||||
@@ -49,7 +49,7 @@ var ignoredModelfileParameters = []string{
|
||||
"mirostat_eta",
|
||||
}
|
||||
|
||||
// ConfigFromModelfile extracts the model directory and x/create-specific
|
||||
// ConfigFromModelfile extracts the model directory and create-specific
|
||||
// Modelfile configuration from a parsed Modelfile.
|
||||
func ConfigFromModelfile(modelfile *parser.Modelfile) (string, *ModelfileConfig, error) {
|
||||
var modelDir string
|
||||
@@ -206,7 +206,7 @@ func CreateModel(ctx context.Context, opts CreateOptions, p *progress.Progress)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Create the model through the x/create pipeline (read → classify → plan
|
||||
// Create the model through the create pipeline (read → classify → plan
|
||||
// → write), supplying blob storage and manifest assembly.
|
||||
pipelineOpts := create.PipelineOptions{
|
||||
Quantize: opts.Quantize,
|
||||
@@ -13,10 +13,10 @@ import (
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
|
||||
"github.com/ollama/ollama/create"
|
||||
"github.com/ollama/ollama/manifest"
|
||||
"github.com/ollama/ollama/parser"
|
||||
"github.com/ollama/ollama/types/model"
|
||||
"github.com/ollama/ollama/x/create"
|
||||
)
|
||||
|
||||
func TestModelfileConfig(t *testing.T) {
|
||||
@@ -18,16 +18,16 @@ import (
|
||||
"golang.org/x/sync/errgroup"
|
||||
|
||||
"github.com/ollama/ollama/api"
|
||||
"github.com/ollama/ollama/create"
|
||||
"github.com/ollama/ollama/envconfig"
|
||||
"github.com/ollama/ollama/progress"
|
||||
"github.com/ollama/ollama/x/create"
|
||||
)
|
||||
|
||||
// Six attempts produce at most 31 seconds of exponential backoff per blob.
|
||||
const maxUploadRetries = 6
|
||||
|
||||
// CreateModelRemote uploads raw safetensors source files and asks the server to
|
||||
// run the x/create import pipeline. The server performs planning, transforms,
|
||||
// run the create import pipeline. The server performs planning, transforms,
|
||||
// and MLX quantization against its own hardware.
|
||||
func CreateModelRemote(ctx context.Context, client *api.Client, opts CreateOptions, p *progress.Progress) error {
|
||||
if opts.Force {
|
||||
@@ -14,9 +14,9 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/ollama/ollama/fs/safetensors"
|
||||
"github.com/ollama/ollama/manifest"
|
||||
"github.com/ollama/ollama/types/model"
|
||||
"github.com/ollama/ollama/x/safetensors"
|
||||
)
|
||||
|
||||
// SafetensorsMinOllamaVersion is the minimum Ollama version required for
|
||||
@@ -12,9 +12,9 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
st "github.com/ollama/ollama/fs/safetensors"
|
||||
"github.com/ollama/ollama/manifest"
|
||||
"github.com/ollama/ollama/types/model"
|
||||
st "github.com/ollama/ollama/x/safetensors"
|
||||
)
|
||||
|
||||
func TestValidateScalarFloat32TensorData(t *testing.T) {
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"slices"
|
||||
"testing"
|
||||
|
||||
st "github.com/ollama/ollama/x/safetensors"
|
||||
st "github.com/ollama/ollama/fs/safetensors"
|
||||
)
|
||||
|
||||
// recordingStore captures the blobs a pipeline run produces so tests can assert
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/ollama/ollama/x/safetensors"
|
||||
"github.com/ollama/ollama/fs/safetensors"
|
||||
)
|
||||
|
||||
// SourceTensor describes one tensor found in a source model: its on-disk type
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
st "github.com/ollama/ollama/x/safetensors"
|
||||
st "github.com/ollama/ollama/fs/safetensors"
|
||||
)
|
||||
|
||||
func writeConfigJSON(t *testing.T, dir, content string) {
|
||||
@@ -6,8 +6,8 @@ import (
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
|
||||
"github.com/ollama/ollama/x/internal/mlxthread"
|
||||
"github.com/ollama/ollama/x/mlxrunner/mlx"
|
||||
"github.com/ollama/ollama/mlx"
|
||||
"github.com/ollama/ollama/mlx/mlxthread"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -10,8 +10,8 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
st "github.com/ollama/ollama/fs/safetensors"
|
||||
"github.com/ollama/ollama/types/model"
|
||||
st "github.com/ollama/ollama/x/safetensors"
|
||||
)
|
||||
|
||||
type blobStoreFunc func(io.Reader, string, string) (LayerInfo, error)
|
||||
@@ -9,8 +9,8 @@ import (
|
||||
"slices"
|
||||
"strconv"
|
||||
|
||||
"github.com/ollama/ollama/x/mlxrunner/mlx"
|
||||
"github.com/ollama/ollama/x/quant"
|
||||
"github.com/ollama/ollama/mlx"
|
||||
"github.com/ollama/ollama/mlx/quant"
|
||||
)
|
||||
|
||||
// quantizeItem is one tensor going into a (possibly multi-tensor) quantized
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/ollama/ollama/x/safetensors"
|
||||
"github.com/ollama/ollama/fs/safetensors"
|
||||
)
|
||||
|
||||
// applyByteTransform produces a TensorSpec's output tensor from its resolved
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"fmt"
|
||||
"log/slog"
|
||||
|
||||
"github.com/ollama/ollama/x/mlxrunner"
|
||||
"github.com/ollama/ollama/mlxrunner"
|
||||
)
|
||||
|
||||
var ErrUnsupportedMLXArchitecture = errors.New("unsupported MLX architecture")
|
||||
@@ -7,8 +7,8 @@ import (
|
||||
"io"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/ollama/ollama/fs/safetensors"
|
||||
"github.com/ollama/ollama/manifest"
|
||||
"github.com/ollama/ollama/x/safetensors"
|
||||
)
|
||||
|
||||
// BlobStore stores a finished blob and returns its layer info. The writer
|
||||
@@ -11,8 +11,8 @@ import (
|
||||
"sort"
|
||||
"testing"
|
||||
|
||||
"github.com/ollama/ollama/x/internal/mlxtest"
|
||||
st "github.com/ollama/ollama/x/safetensors"
|
||||
st "github.com/ollama/ollama/fs/safetensors"
|
||||
"github.com/ollama/ollama/mlx/mlxtest"
|
||||
)
|
||||
|
||||
type captureStore struct{ blobs map[string][]byte }
|
||||
@@ -609,7 +609,7 @@ func preloadGenerateModel(ctx context.Context, t *testing.T, client *api.Client,
|
||||
// through and fail the test — we never want to mask a real Mac regression.
|
||||
//
|
||||
// The fingerprints are the exact wrapper strings produced by the MLX code
|
||||
// paths (see x/mlxrunner/server.go, x/mlxrunner/mlx/dynamic.go). Model-level errors
|
||||
// paths (see mlxrunner/server.go, mlx/dynamic.go). Model-level errors
|
||||
// (unsupported architecture, tensor mismatches, runtime failures) do not
|
||||
// contain these strings, so this helper will not mask them.
|
||||
func skipIfMLXUnsupported(t *testing.T, err error) {
|
||||
|
||||
+2
-2
@@ -55,8 +55,8 @@ For build prerequisites, platform notes, and backend selection, see the
|
||||
marker, or response cadence on paths Ollama parses directly.
|
||||
- Model and conversion surfaces: new architectures, tensor names, GGUF
|
||||
metadata, tokenizer behavior, speculative/MTP paths, sampler defaults, and
|
||||
server capabilities that may require updates under `convert/`, `model/`,
|
||||
`x/create/`, `llm/`, or `llama/compat/`. A model load alone is not enough;
|
||||
server capabilities that may require updates under `model/`,
|
||||
`create/`, `llm/`, or `llama/compat/`. A model load alone is not enough;
|
||||
affected paths should run a real request and assert the expected result.
|
||||
|
||||
### Compatibility patches
|
||||
|
||||
@@ -20,7 +20,7 @@ endif()
|
||||
include(FetchContent)
|
||||
|
||||
# Read MLX-C version from top-level file.
|
||||
file(READ "${CMAKE_CURRENT_LIST_DIR}/../../../MLX_C_VERSION" MLX_C_GIT_TAG)
|
||||
file(READ "${CMAKE_CURRENT_LIST_DIR}/../MLX_C_VERSION" MLX_C_GIT_TAG)
|
||||
string(STRIP "${MLX_C_GIT_TAG}" MLX_C_GIT_TAG)
|
||||
|
||||
FetchContent_Declare(
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"math"
|
||||
"testing"
|
||||
|
||||
"github.com/ollama/ollama/x/internal/mlxthreadtest"
|
||||
"github.com/ollama/ollama/mlx/mlxthread/mlxthreadtest"
|
||||
)
|
||||
|
||||
func TestGELUCompiledMatchesEager(t *testing.T) {
|
||||
@@ -3,7 +3,7 @@ package mlx
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/ollama/ollama/x/internal/mlxthreadtest"
|
||||
"github.com/ollama/ollama/mlx/mlxthread/mlxthreadtest"
|
||||
)
|
||||
|
||||
func TestFromValue(t *testing.T) {
|
||||
@@ -3,7 +3,7 @@ package mlx
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/ollama/ollama/x/internal/mlxthreadtest"
|
||||
"github.com/ollama/ollama/mlx/mlxthread/mlxthreadtest"
|
||||
)
|
||||
|
||||
func TestCompileFusion(t *testing.T) {
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/ollama/ollama/x/internal/mlxthreadtest"
|
||||
"github.com/ollama/ollama/mlx/mlxthread/mlxthreadtest"
|
||||
)
|
||||
|
||||
func TestDepthwiseConvSiLUMatchesGraph(t *testing.T) {
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"math"
|
||||
"testing"
|
||||
|
||||
"github.com/ollama/ollama/x/internal/mlxthreadtest"
|
||||
"github.com/ollama/ollama/mlx/mlxthread/mlxthreadtest"
|
||||
)
|
||||
|
||||
type gatedDeltaTestGeometry struct {
|
||||
@@ -9,4 +9,4 @@ Headers are automatically refreshed when you run a CMake build:
|
||||
cmake --preset 'MLX CUDA 13'
|
||||
```
|
||||
|
||||
See the [MLX Engine](../../../../../../../docs/development.md#mlx-engine-optional) section of the development docs for full build instructions.
|
||||
See the [MLX Engine](../../../../docs/development.md#mlx-engine-optional) section of the development docs for full build instructions.
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user