From 2e036e7cdf7baccca93045a2e313b5d8d7730ae9 Mon Sep 17 00:00:00 2001 From: Jesse Gross Date: Tue, 15 Sep 2026 19:11:36 -0700 Subject: [PATCH] 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/ mlxrunner/model/ 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. --- .github/scripts/prepare_mlx_darwin.sh | 6 +-- .github/workflows/test.yaml | 21 +++++----- .golangci.yaml | 5 +++ Dockerfile | 5 +-- cmake/local.cmake | 8 ++-- cmake/mlx/CMakeLists.txt | 6 +-- cmd/cmd.go | 40 +++++++++---------- {x/create => create}/blockfp8.go | 0 {x/create => create}/blockfp8_test.go | 0 {x/create => create}/classify.go | 2 +- {x/create => create}/classify_test.go | 0 {x/create => create}/client/create.go | 8 ++-- {x/create => create}/client/create_test.go | 2 +- {x/create => create}/client/remote.go | 4 +- {x/create => create}/client/remote_test.go | 0 {x/create => create}/cohere2moe.go | 0 {x/create => create}/create.go | 2 +- {x/create => create}/create_test.go | 2 +- {x/create => create}/draft.go | 0 {x/create => create}/draft_test.go | 2 +- {x/create => create}/gemma4.go | 0 {x/create => create}/gemma4_test.go | 0 {x/create => create}/glimmer.go | 0 {x/create => create}/glimmer_test.go | 0 {x/create => create}/inventory.go | 2 +- {x/create => create}/inventory_test.go | 2 +- {x/create => create}/laguna.go | 0 {x/create => create}/laguna_test.go | 0 {x/create => create}/manifest.go | 0 {x/create => create}/manifest_test.go | 0 {x/create => create}/metadata.go | 0 {x/create => create}/metadata_test.go | 0 {x/create => create}/mlxthread.go | 4 +- {x/create => create}/nemotron_h.go | 0 {x/create => create}/nemotron_h_test.go | 0 {x/create => create}/pipeline.go | 0 {x/create => create}/pipeline_test.go | 2 +- {x/create => create}/plan.go | 0 {x/create => create}/plan_test.go | 0 {x/create => create}/prequant.go | 0 {x/create => create}/prequant_test.go | 0 {x/create => create}/quantize.go | 4 +- {x/create => create}/quantpolicy.go | 0 {x/create => create}/qwen35.go | 0 {x/create => create}/qwen4_exp.go | 0 {x/create => create}/qwen4_exp_test.go | 0 {x/create => create}/transform.go | 2 +- {x/create => create}/verify.go | 2 +- {x/create => create}/verify_test.go | 0 {x/create => create}/writer.go | 2 +- {x/create => create}/writer_test.go | 4 +- {x => fs}/safetensors/extractor.go | 0 {x => fs}/safetensors/extractor_test.go | 0 integration/utils_test.go | 2 +- llama/README.md | 4 +- {x/mlxrunner/mlx => mlx}/.gitignore | 0 {x/mlxrunner/mlx => mlx}/CMakeLists.txt | 2 +- {x/mlxrunner/mlx => mlx}/act.go | 0 {x/mlxrunner/mlx => mlx}/act_test.go | 2 +- {x/mlxrunner/mlx => mlx}/array.go | 0 {x/mlxrunner/mlx => mlx}/array_test.go | 2 +- .../0001-mlx-c-qmm-global-scale.patch | 0 {x/mlxrunner/mlx => mlx}/compile.go | 0 {x/mlxrunner/mlx => mlx}/compile_test.go | 2 +- {x/mlxrunner/mlx => mlx}/depthwise_conv.go | 0 .../mlx => mlx}/depthwise_conv_test.go | 2 +- {x/mlxrunner/mlx => mlx}/dtype.go | 0 {x/mlxrunner/mlx => mlx}/dynamic.c | 0 {x/mlxrunner/mlx => mlx}/dynamic.go | 0 {x/mlxrunner/mlx => mlx}/dynamic.h | 0 {x/mlxrunner/mlx => mlx}/dynamic_darwin.go | 0 {x/mlxrunner/mlx => mlx}/dynamic_other.go | 0 {x/mlxrunner/mlx => mlx}/fast.go | 0 {x/mlxrunner/mlx => mlx}/gated_delta.go | 0 {x/mlxrunner/mlx => mlx}/gated_delta_test.go | 2 +- {x/mlxrunner/mlx => mlx}/generated.c | 0 {x/mlxrunner/mlx => mlx}/generated.h | 0 .../mlx => mlx}/generator/generated.c.gotmpl | 0 .../mlx => mlx}/generator/generated.h.gotmpl | 0 {x/mlxrunner/mlx => mlx}/generator/main.go | 0 {x/mlxrunner/mlx => mlx}/gpu_kernel.go | 0 .../mlx => mlx}/include/mlx/c/README.md | 2 +- .../mlx => mlx}/include/mlx/c/array.h | 0 .../mlx => mlx}/include/mlx/c/closure.h | 0 .../mlx => mlx}/include/mlx/c/compile.h | 0 {x/mlxrunner/mlx => mlx}/include/mlx/c/cuda.h | 0 .../mlx => mlx}/include/mlx/c/device.h | 0 .../mlx => mlx}/include/mlx/c/distributed.h | 0 .../include/mlx/c/distributed_group.h | 0 .../mlx => mlx}/include/mlx/c/error.h | 0 .../mlx => mlx}/include/mlx/c/export.h | 0 {x/mlxrunner/mlx => mlx}/include/mlx/c/fast.h | 0 {x/mlxrunner/mlx => mlx}/include/mlx/c/fft.h | 0 .../mlx => mlx}/include/mlx/c/graph_utils.h | 0 {x/mlxrunner/mlx => mlx}/include/mlx/c/half.h | 0 {x/mlxrunner/mlx => mlx}/include/mlx/c/io.h | 0 .../mlx => mlx}/include/mlx/c/io_types.h | 0 .../mlx => mlx}/include/mlx/c/linalg.h | 0 {x/mlxrunner/mlx => mlx}/include/mlx/c/map.h | 0 .../mlx => mlx}/include/mlx/c/memory.h | 0 .../mlx => mlx}/include/mlx/c/metal.h | 0 {x/mlxrunner/mlx => mlx}/include/mlx/c/mlx.h | 0 {x/mlxrunner/mlx => mlx}/include/mlx/c/ops.h | 0 .../mlx => mlx}/include/mlx/c/optional.h | 0 .../mlx => mlx}/include/mlx/c/random.h | 0 .../mlx => mlx}/include/mlx/c/stream.h | 0 .../mlx => mlx}/include/mlx/c/string.h | 0 .../mlx => mlx}/include/mlx/c/transforms.h | 0 .../include/mlx/c/transforms_impl.h | 0 .../mlx => mlx}/include/mlx/c/vector.h | 0 .../mlx => mlx}/include/mlx/c/version.h | 0 {x/mlxrunner/mlx => mlx}/io.go | 0 {x/mlxrunner/mlx => mlx}/io_test.go | 2 +- {x/mlxrunner/mlx => mlx}/kernel_test.go | 0 {x/mlxrunner/mlx => mlx}/mamba2_scan.go | 0 .../mlx => mlx}/mamba_kernels_test.go | 2 +- {x/mlxrunner/mlx => mlx}/memory.go | 0 {x/mlxrunner/mlx => mlx}/memory_test.go | 2 +- {x/mlxrunner/mlx => mlx}/mlx.go | 2 +- {x/internal => mlx}/mlxtest/mlxtest.go | 6 +-- .../mlxthread}/mlxthreadtest/mlxthreadtest.go | 2 +- .../mlxthreadtest/mlxthreadtest_test.go | 0 .../mlxthreadtest/threadid_darwin.go | 0 .../mlxthreadtest/threadid_linux.go | 0 .../mlxthreadtest/threadid_other.go | 0 .../mlxthreadtest/threadid_windows.go | 0 {x/internal => mlx}/mlxthread/thread.go | 0 .../mlxthread/thread_affinity_test.go | 0 {x/internal => mlx}/mlxthread/thread_test.go | 0 .../mlxthread/threadid_darwin_test.go | 0 .../mlxthread/threadid_linux_test.go | 0 {x/mlxrunner/mlx => mlx}/nn.go | 0 {x/mlxrunner/mlx => mlx}/ops.go | 0 {x/mlxrunner/mlx => mlx}/ops_extra.go | 0 {x/mlxrunner/mlx => mlx}/ops_extra_test.go | 2 +- {x => mlx}/quant/quant.go | 0 {x => mlx}/quant/quant_test.go | 0 {x/mlxrunner/mlx => mlx}/random.go | 0 {x/mlxrunner/mlx => mlx}/scope.go | 0 {x/mlxrunner/mlx => mlx}/scope_test.go | 2 +- {x/mlxrunner/mlx => mlx}/slice.go | 0 {x/mlxrunner/mlx => mlx}/stream.go | 0 {x/mlxrunner/mlx => mlx}/thread_test.go | 2 +- {x/mlxrunner => mlxrunner}/batch/batch.go | 2 +- {x/mlxrunner => mlxrunner}/cache/cache.go | 2 +- .../cache/cache_test.go | 6 +-- {x/mlxrunner => mlxrunner}/cache/kvcache.go | 6 +-- {x/mlxrunner => mlxrunner}/cache/lazy_test.go | 4 +- {x/mlxrunner => mlxrunner}/cache/recurrent.go | 6 +-- .../cache/recurrent_test.go | 8 ++-- {x/mlxrunner => mlxrunner}/cache/rotating.go | 6 +-- .../cache/rotating_attention_test.go | 8 ++-- .../cache/rotating_multiturn_test.go | 10 ++--- .../cache/snapshot_capture_test.go | 4 +- {x/mlxrunner => mlxrunner}/cache_trie.go | 2 +- {x/mlxrunner => mlxrunner}/cache_trie_test.go | 2 +- {x/mlxrunner => mlxrunner}/client.go | 2 +- {x/mlxrunner => mlxrunner}/client_test.go | 0 {x/mlxrunner => mlxrunner}/dflash.go | 6 +-- {x/mlxrunner => mlxrunner}/dflash_test.go | 12 +++--- {x/mlxrunner => mlxrunner}/grammar.go | 6 +-- .../grammar_mask_test.go | 6 +-- {x/mlxrunner => mlxrunner}/grammar_test.go | 10 ++--- {x/mlxrunner => mlxrunner}/media.go | 6 +-- {x/mlxrunner => mlxrunner}/media_test.go | 6 +-- .../model/architectures/architectures.go | 16 ++++++++ .../model/audio/audio.go | 0 .../model/audio/audio_test.go | 0 {x/mlxrunner => mlxrunner}/model/base/base.go | 10 ++--- .../model/base/media.go | 2 +- .../model}/cohere2_moe/cohere2_moe.go | 14 +++---- .../model}/cohere2_moe/cohere2_moe_test.go | 4 +- .../model}/dflash/dflash.go | 12 +++--- {x/mlxrunner => mlxrunner}/model/embedding.go | 4 +- .../model/embedding_test.go | 6 +-- .../model}/gemma4/assistant.go | 12 +++--- {x/models => mlxrunner/model}/gemma4/audio.go | 6 +-- .../model}/gemma4/audio_test.go | 6 +-- .../model}/gemma4/gemma4.go | 14 +++---- .../model}/gemma4/gemma4_moe_test.go | 4 +- .../model}/gemma4/gemma4_test.go | 4 +- {x/models => mlxrunner/model}/gemma4/media.go | 10 ++--- .../model}/gemma4/media_test.go | 8 ++-- .../model}/gemma4/process_audio.go | 2 +- .../model}/gemma4/process_audio_test.go | 0 .../model}/gemma4/process_image.go | 0 .../model}/gemma4/vision.go | 6 +-- .../model}/gemma4/vision_test.go | 6 +-- .../model}/glimmer/glimmer.go | 14 +++---- .../model}/glimmer/glimmer_test.go | 10 ++--- .../model}/glimmer/media.go | 6 +-- .../model}/glimmer/media_test.go | 2 +- .../model}/glimmer/vision.go | 6 +-- .../model}/glm4_moe_lite/config_test.go | 4 +- .../model}/glm4_moe_lite/glm4_moe_lite.go | 14 +++---- .../model}/glm4_moe_lite/parser.go | 0 .../model}/glm4_moe_lite/parser_test.go | 0 .../model}/glm4_moe_lite/render.go | 0 .../model}/glm4_moe_lite/render_test.go | 0 .../model}/laguna/laguna.go | 14 +++---- .../model}/laguna/laguna_test.go | 10 ++--- {x/mlxrunner => mlxrunner}/model/linear.go | 4 +- {x/models => mlxrunner/model}/llama/llama.go | 14 +++---- .../model}/nemotron_h/nemotron_h.go | 14 +++---- .../model}/nemotron_h/nemotron_h_test.go | 8 ++-- {x/mlxrunner => mlxrunner}/model/quant.go | 6 +-- .../model/quant_global_scale_test.go | 4 +- {x/models => mlxrunner/model}/qwen3/qwen3.go | 14 +++---- .../model}/qwen3_5/gdn_projections.go | 4 +- .../model}/qwen3_5/gdn_projections_test.go | 6 +-- .../model}/qwen3_5/process_image.go | 0 .../model}/qwen3_5/qwen3_5.go | 14 +++---- .../model}/qwen3_5/qwen3_5_test.go | 6 +-- .../model}/qwen3_5/vision.go | 10 ++--- .../model}/qwen3_5/vision_test.go | 6 +-- .../model}/qwen3_5_moe/qwen3_5_moe.go | 4 +- .../model}/qwen4_exp/blocks.go | 8 ++-- .../model}/qwen4_exp/config.go | 0 .../model}/qwen4_exp/config_test.go | 0 .../model}/qwen4_exp/engram.go | 4 +- .../model}/qwen4_exp/engram_cache.go | 6 +-- .../model}/qwen4_exp/engram_test.go | 6 +-- .../model}/qwen4_exp/hyper_connection.go | 2 +- .../model}/qwen4_exp/hyper_connection_test.go | 6 +-- .../model}/qwen4_exp/qsa.go | 6 +-- .../model}/qwen4_exp/qsa_test.go | 8 ++-- .../model}/qwen4_exp/qwen4_exp.go | 16 ++++---- .../model}/qwen4_exp/weights.go | 8 ++-- {x/mlxrunner => mlxrunner}/model/root.go | 0 {x/mlxrunner => mlxrunner}/mtp.go | 6 +-- {x/mlxrunner => mlxrunner}/mtp_test.go | 14 +++---- {x/models => mlxrunner}/nn/nn.go | 2 +- {x/models => mlxrunner}/nn/nn_test.go | 4 +- {x/models => mlxrunner}/nn/recurrent.go | 4 +- {x/models => mlxrunner}/nn/recurrent_test.go | 6 +-- {x/models => mlxrunner}/nn/rope.go | 2 +- {x/models => mlxrunner}/nn/sdpa.go | 4 +- {x/models => mlxrunner}/nn/sdpa_test.go | 6 +-- {x/mlxrunner => mlxrunner}/pipeline.go | 12 +++--- {x/mlxrunner => mlxrunner}/pipeline_test.go | 10 ++--- {x/mlxrunner => mlxrunner}/prefix_cache.go | 4 +- .../prefix_cache_scenario_test.go | 2 +- .../prefix_cache_test.go | 6 +-- {x/mlxrunner => mlxrunner}/runner.go | 17 ++++---- .../sample/logprob_test.go | 4 +- {x/mlxrunner => mlxrunner}/sample/sample.go | 2 +- .../sample/sample_test.go | 4 +- {x/mlxrunner => mlxrunner}/server.go | 6 +-- {x/mlxrunner => mlxrunner}/speculate.go | 10 ++--- {x/mlxrunner => mlxrunner}/speculate_depth.go | 0 .../speculate_depth_test.go | 0 {x/mlxrunner => mlxrunner}/speculate_stats.go | 0 {x/mlxrunner => mlxrunner}/status_memory.go | 0 .../status_memory_test.go | 0 .../tokenizer}/testdata/llama3.2/encoder.json | 0 .../tokenizer}/testdata/llama3.2/vocab.bpe | 0 .../tokenizer/testdata/mini_llama.json | 0 {x => mlxrunner}/tokenizer/tokenizer.go | 0 .../tokenizer/tokenizer_benchmark_test.go | 0 {x => mlxrunner}/tokenizer/tokenizer_bpe.go | 0 .../tokenizer/tokenizer_correctness_test.go | 0 .../tokenizer/tokenizer_decode.go | 0 .../tokenizer/tokenizer_encode.go | 0 .../tokenizer/tokenizer_ggml_parity_test.go | 2 +- {x => mlxrunner}/tokenizer/tokenizer_load.go | 0 .../tokenizer/tokenizer_load_test.go | 0 {x/mlxrunner => mlxrunner}/utf8_buffer.go | 0 .../utf8_buffer_test.go | 0 {x/mlxrunner => mlxrunner}/verify.go | 2 +- {x/mlxrunner => mlxrunner}/verify_test.go | 2 +- {x/mlxrunner => mlxrunner}/xgrammar/dynamic.c | 0 {x/mlxrunner => mlxrunner}/xgrammar/dynamic.h | 0 .../xgrammar/native/xgrammar.cpp | 0 .../xgrammar/native/xgrammar.h | 0 .../xgrammar/xgrammar.go | 0 .../xgrammar/xgrammar_test.go | 4 +- model/renderers/qwen38_test.go | 2 +- server/create.go | 30 +++++++------- server/images.go | 2 +- server/routes_create_test.go | 18 ++++----- server/sched.go | 2 +- x/mlxrunner/imports.go | 16 -------- x/server/show.go | 2 +- 283 files changed, 460 insertions(+), 456 deletions(-) rename {x/create => create}/blockfp8.go (100%) rename {x/create => create}/blockfp8_test.go (100%) rename {x/create => create}/classify.go (99%) rename {x/create => create}/classify_test.go (100%) rename {x/create => create}/client/create.go (97%) rename {x/create => create}/client/create_test.go (99%) rename {x/create => create}/client/remote.go (98%) rename {x/create => create}/client/remote_test.go (100%) rename {x/create => create}/cohere2moe.go (100%) rename {x/create => create}/create.go (99%) rename {x/create => create}/create_test.go (99%) rename {x/create => create}/draft.go (100%) rename {x/create => create}/draft_test.go (99%) rename {x/create => create}/gemma4.go (100%) rename {x/create => create}/gemma4_test.go (100%) rename {x/create => create}/glimmer.go (100%) rename {x/create => create}/glimmer_test.go (100%) rename {x/create => create}/inventory.go (99%) rename {x/create => create}/inventory_test.go (99%) rename {x/create => create}/laguna.go (100%) rename {x/create => create}/laguna_test.go (100%) rename {x/create => create}/manifest.go (100%) rename {x/create => create}/manifest_test.go (100%) rename {x/create => create}/metadata.go (100%) rename {x/create => create}/metadata_test.go (100%) rename {x/create => create}/mlxthread.go (91%) rename {x/create => create}/nemotron_h.go (100%) rename {x/create => create}/nemotron_h_test.go (100%) rename {x/create => create}/pipeline.go (100%) rename {x/create => create}/pipeline_test.go (99%) rename {x/create => create}/plan.go (100%) rename {x/create => create}/plan_test.go (100%) rename {x/create => create}/prequant.go (100%) rename {x/create => create}/prequant_test.go (100%) rename {x/create => create}/quantize.go (99%) rename {x/create => create}/quantpolicy.go (100%) rename {x/create => create}/qwen35.go (100%) rename {x/create => create}/qwen4_exp.go (100%) rename {x/create => create}/qwen4_exp_test.go (100%) rename {x/create => create}/transform.go (98%) rename {x/create => create}/verify.go (97%) rename {x/create => create}/verify_test.go (100%) rename {x/create => create}/writer.go (99%) rename {x/create => create}/writer_test.go (99%) rename {x => fs}/safetensors/extractor.go (100%) rename {x => fs}/safetensors/extractor_test.go (100%) rename {x/mlxrunner/mlx => mlx}/.gitignore (100%) rename {x/mlxrunner/mlx => mlx}/CMakeLists.txt (96%) rename {x/mlxrunner/mlx => mlx}/act.go (100%) rename {x/mlxrunner/mlx => mlx}/act_test.go (97%) rename {x/mlxrunner/mlx => mlx}/array.go (100%) rename {x/mlxrunner/mlx => mlx}/array_test.go (98%) rename mlx/compat/{ => mlx-c}/0001-mlx-c-qmm-global-scale.patch (100%) rename {x/mlxrunner/mlx => mlx}/compile.go (100%) rename {x/mlxrunner/mlx => mlx}/compile_test.go (98%) rename {x/mlxrunner/mlx => mlx}/depthwise_conv.go (100%) rename {x/mlxrunner/mlx => mlx}/depthwise_conv_test.go (95%) rename {x/mlxrunner/mlx => mlx}/dtype.go (100%) rename {x/mlxrunner/mlx => mlx}/dynamic.c (100%) rename {x/mlxrunner/mlx => mlx}/dynamic.go (100%) rename {x/mlxrunner/mlx => mlx}/dynamic.h (100%) rename {x/mlxrunner/mlx => mlx}/dynamic_darwin.go (100%) rename {x/mlxrunner/mlx => mlx}/dynamic_other.go (100%) rename {x/mlxrunner/mlx => mlx}/fast.go (100%) rename {x/mlxrunner/mlx => mlx}/gated_delta.go (100%) rename {x/mlxrunner/mlx => mlx}/gated_delta_test.go (99%) rename {x/mlxrunner/mlx => mlx}/generated.c (100%) rename {x/mlxrunner/mlx => mlx}/generated.h (100%) rename {x/mlxrunner/mlx => mlx}/generator/generated.c.gotmpl (100%) rename {x/mlxrunner/mlx => mlx}/generator/generated.h.gotmpl (100%) rename {x/mlxrunner/mlx => mlx}/generator/main.go (100%) rename {x/mlxrunner/mlx => mlx}/gpu_kernel.go (100%) rename {x/mlxrunner/mlx => mlx}/include/mlx/c/README.md (65%) rename {x/mlxrunner/mlx => mlx}/include/mlx/c/array.h (100%) rename {x/mlxrunner/mlx => mlx}/include/mlx/c/closure.h (100%) rename {x/mlxrunner/mlx => mlx}/include/mlx/c/compile.h (100%) rename {x/mlxrunner/mlx => mlx}/include/mlx/c/cuda.h (100%) rename {x/mlxrunner/mlx => mlx}/include/mlx/c/device.h (100%) rename {x/mlxrunner/mlx => mlx}/include/mlx/c/distributed.h (100%) rename {x/mlxrunner/mlx => mlx}/include/mlx/c/distributed_group.h (100%) rename {x/mlxrunner/mlx => mlx}/include/mlx/c/error.h (100%) rename {x/mlxrunner/mlx => mlx}/include/mlx/c/export.h (100%) rename {x/mlxrunner/mlx => mlx}/include/mlx/c/fast.h (100%) rename {x/mlxrunner/mlx => mlx}/include/mlx/c/fft.h (100%) rename {x/mlxrunner/mlx => mlx}/include/mlx/c/graph_utils.h (100%) rename {x/mlxrunner/mlx => mlx}/include/mlx/c/half.h (100%) rename {x/mlxrunner/mlx => mlx}/include/mlx/c/io.h (100%) rename {x/mlxrunner/mlx => mlx}/include/mlx/c/io_types.h (100%) rename {x/mlxrunner/mlx => mlx}/include/mlx/c/linalg.h (100%) rename {x/mlxrunner/mlx => mlx}/include/mlx/c/map.h (100%) rename {x/mlxrunner/mlx => mlx}/include/mlx/c/memory.h (100%) rename {x/mlxrunner/mlx => mlx}/include/mlx/c/metal.h (100%) rename {x/mlxrunner/mlx => mlx}/include/mlx/c/mlx.h (100%) rename {x/mlxrunner/mlx => mlx}/include/mlx/c/ops.h (100%) rename {x/mlxrunner/mlx => mlx}/include/mlx/c/optional.h (100%) rename {x/mlxrunner/mlx => mlx}/include/mlx/c/random.h (100%) rename {x/mlxrunner/mlx => mlx}/include/mlx/c/stream.h (100%) rename {x/mlxrunner/mlx => mlx}/include/mlx/c/string.h (100%) rename {x/mlxrunner/mlx => mlx}/include/mlx/c/transforms.h (100%) rename {x/mlxrunner/mlx => mlx}/include/mlx/c/transforms_impl.h (100%) rename {x/mlxrunner/mlx => mlx}/include/mlx/c/vector.h (100%) rename {x/mlxrunner/mlx => mlx}/include/mlx/c/version.h (100%) rename {x/mlxrunner/mlx => mlx}/io.go (100%) rename {x/mlxrunner/mlx => mlx}/io_test.go (96%) rename {x/mlxrunner/mlx => mlx}/kernel_test.go (100%) rename {x/mlxrunner/mlx => mlx}/mamba2_scan.go (100%) rename {x/mlxrunner/mlx => mlx}/mamba_kernels_test.go (99%) rename {x/mlxrunner/mlx => mlx}/memory.go (100%) rename {x/mlxrunner/mlx => mlx}/memory_test.go (96%) rename {x/mlxrunner/mlx => mlx}/mlx.go (99%) rename {x/internal => mlx}/mlxtest/mlxtest.go (89%) rename {x/internal => mlx/mlxthread}/mlxthreadtest/mlxthreadtest.go (98%) rename {x/internal => mlx/mlxthread}/mlxthreadtest/mlxthreadtest_test.go (100%) rename {x/internal => mlx/mlxthread}/mlxthreadtest/threadid_darwin.go (100%) rename {x/internal => mlx/mlxthread}/mlxthreadtest/threadid_linux.go (100%) rename {x/internal => mlx/mlxthread}/mlxthreadtest/threadid_other.go (100%) rename {x/internal => mlx/mlxthread}/mlxthreadtest/threadid_windows.go (100%) rename {x/internal => mlx}/mlxthread/thread.go (100%) rename {x/internal => mlx}/mlxthread/thread_affinity_test.go (100%) rename {x/internal => mlx}/mlxthread/thread_test.go (100%) rename {x/internal => mlx}/mlxthread/threadid_darwin_test.go (100%) rename {x/internal => mlx}/mlxthread/threadid_linux_test.go (100%) rename {x/mlxrunner/mlx => mlx}/nn.go (100%) rename {x/mlxrunner/mlx => mlx}/ops.go (100%) rename {x/mlxrunner/mlx => mlx}/ops_extra.go (100%) rename {x/mlxrunner/mlx => mlx}/ops_extra_test.go (99%) rename {x => mlx}/quant/quant.go (100%) rename {x => mlx}/quant/quant_test.go (100%) rename {x/mlxrunner/mlx => mlx}/random.go (100%) rename {x/mlxrunner/mlx => mlx}/scope.go (100%) rename {x/mlxrunner/mlx => mlx}/scope_test.go (98%) rename {x/mlxrunner/mlx => mlx}/slice.go (100%) rename {x/mlxrunner/mlx => mlx}/stream.go (100%) rename {x/mlxrunner/mlx => mlx}/thread_test.go (96%) rename {x/mlxrunner => mlxrunner}/batch/batch.go (97%) rename {x/mlxrunner => mlxrunner}/cache/cache.go (99%) rename {x/mlxrunner => mlxrunner}/cache/cache_test.go (98%) rename {x/mlxrunner => mlxrunner}/cache/kvcache.go (98%) rename {x/mlxrunner => mlxrunner}/cache/lazy_test.go (99%) rename {x/mlxrunner => mlxrunner}/cache/recurrent.go (98%) rename {x/mlxrunner => mlxrunner}/cache/recurrent_test.go (97%) rename {x/mlxrunner => mlxrunner}/cache/rotating.go (99%) rename {x/mlxrunner => mlxrunner}/cache/rotating_attention_test.go (98%) rename {x/mlxrunner => mlxrunner}/cache/rotating_multiturn_test.go (97%) rename {x/mlxrunner => mlxrunner}/cache/snapshot_capture_test.go (99%) rename {x/mlxrunner => mlxrunner}/cache_trie.go (99%) rename {x/mlxrunner => mlxrunner}/cache_trie_test.go (99%) rename {x/mlxrunner => mlxrunner}/client.go (99%) rename {x/mlxrunner => mlxrunner}/client_test.go (100%) rename {x/mlxrunner => mlxrunner}/dflash.go (97%) rename {x/mlxrunner => mlxrunner}/dflash_test.go (97%) rename {x/mlxrunner => mlxrunner}/grammar.go (98%) rename {x/mlxrunner => mlxrunner}/grammar_mask_test.go (98%) rename {x/mlxrunner => mlxrunner}/grammar_test.go (98%) rename {x/mlxrunner => mlxrunner}/media.go (98%) rename {x/mlxrunner => mlxrunner}/media_test.go (97%) create mode 100644 mlxrunner/model/architectures/architectures.go rename {x/mlxrunner => mlxrunner}/model/audio/audio.go (100%) rename {x/mlxrunner => mlxrunner}/model/audio/audio_test.go (100%) rename {x/mlxrunner => mlxrunner}/model/base/base.go (96%) rename {x/mlxrunner => mlxrunner}/model/base/media.go (98%) rename {x/models => mlxrunner/model}/cohere2_moe/cohere2_moe.go (98%) rename {x/models => mlxrunner/model}/cohere2_moe/cohere2_moe_test.go (94%) rename {x/models => mlxrunner/model}/dflash/dflash.go (98%) rename {x/mlxrunner => mlxrunner}/model/embedding.go (93%) rename {x/mlxrunner => mlxrunner}/model/embedding_test.go (96%) rename {x/models => mlxrunner/model}/gemma4/assistant.go (97%) rename {x/models => mlxrunner/model}/gemma4/audio.go (99%) rename {x/models => mlxrunner/model}/gemma4/audio_test.go (97%) rename {x/models => mlxrunner/model}/gemma4/gemma4.go (99%) rename {x/models => mlxrunner/model}/gemma4/gemma4_moe_test.go (99%) rename {x/models => mlxrunner/model}/gemma4/gemma4_test.go (99%) rename {x/models => mlxrunner/model}/gemma4/media.go (97%) rename {x/models => mlxrunner/model}/gemma4/media_test.go (97%) rename {x/models => mlxrunner/model}/gemma4/process_audio.go (99%) rename {x/models => mlxrunner/model}/gemma4/process_audio_test.go (100%) rename {x/models => mlxrunner/model}/gemma4/process_image.go (100%) rename {x/models => mlxrunner/model}/gemma4/vision.go (99%) rename {x/models => mlxrunner/model}/gemma4/vision_test.go (98%) rename {x/models => mlxrunner/model}/glimmer/glimmer.go (98%) rename {x/models => mlxrunner/model}/glimmer/glimmer_test.go (97%) rename {x/models => mlxrunner/model}/glimmer/media.go (97%) rename {x/models => mlxrunner/model}/glimmer/media_test.go (97%) rename {x/models => mlxrunner/model}/glimmer/vision.go (99%) rename {x/models => mlxrunner/model}/glm4_moe_lite/config_test.go (96%) rename {x/models => mlxrunner/model}/glm4_moe_lite/glm4_moe_lite.go (98%) rename {x/models => mlxrunner/model}/glm4_moe_lite/parser.go (100%) rename {x/models => mlxrunner/model}/glm4_moe_lite/parser_test.go (100%) rename {x/models => mlxrunner/model}/glm4_moe_lite/render.go (100%) rename {x/models => mlxrunner/model}/glm4_moe_lite/render_test.go (100%) rename {x/models => mlxrunner/model}/laguna/laguna.go (99%) rename {x/models => mlxrunner/model}/laguna/laguna_test.go (99%) rename {x/mlxrunner => mlxrunner}/model/linear.go (96%) rename {x/models => mlxrunner/model}/llama/llama.go (96%) rename {x/models => mlxrunner/model}/nemotron_h/nemotron_h.go (99%) rename {x/models => mlxrunner/model}/nemotron_h/nemotron_h_test.go (98%) rename {x/mlxrunner => mlxrunner}/model/quant.go (97%) rename {x/mlxrunner => mlxrunner}/model/quant_global_scale_test.go (98%) rename {x/models => mlxrunner/model}/qwen3/qwen3.go (97%) rename {x/models => mlxrunner/model}/qwen3_5/gdn_projections.go (98%) rename {x/models => mlxrunner/model}/qwen3_5/gdn_projections_test.go (97%) rename {x/models => mlxrunner/model}/qwen3_5/process_image.go (100%) rename {x/models => mlxrunner/model}/qwen3_5/qwen3_5.go (99%) rename {x/models => mlxrunner/model}/qwen3_5/qwen3_5_test.go (99%) rename {x/models => mlxrunner/model}/qwen3_5/vision.go (98%) rename {x/models => mlxrunner/model}/qwen3_5/vision_test.go (97%) rename {x/models => mlxrunner/model}/qwen3_5_moe/qwen3_5_moe.go (78%) rename {x/models => mlxrunner/model}/qwen4_exp/blocks.go (97%) rename {x/models => mlxrunner/model}/qwen4_exp/config.go (100%) rename {x/models => mlxrunner/model}/qwen4_exp/config_test.go (100%) rename {x/models => mlxrunner/model}/qwen4_exp/engram.go (98%) rename {x/models => mlxrunner/model}/qwen4_exp/engram_cache.go (97%) rename {x/models => mlxrunner/model}/qwen4_exp/engram_test.go (96%) rename {x/models => mlxrunner/model}/qwen4_exp/hyper_connection.go (97%) rename {x/models => mlxrunner/model}/qwen4_exp/hyper_connection_test.go (96%) rename {x/models => mlxrunner/model}/qwen4_exp/qsa.go (98%) rename {x/models => mlxrunner/model}/qwen4_exp/qsa_test.go (95%) rename {x/models => mlxrunner/model}/qwen4_exp/qwen4_exp.go (95%) rename {x/models => mlxrunner/model}/qwen4_exp/weights.go (98%) rename {x/mlxrunner => mlxrunner}/model/root.go (100%) rename {x/mlxrunner => mlxrunner}/mtp.go (98%) rename {x/mlxrunner => mlxrunner}/mtp_test.go (99%) rename {x/models => mlxrunner}/nn/nn.go (99%) rename {x/models => mlxrunner}/nn/nn_test.go (98%) rename {x/models => mlxrunner}/nn/recurrent.go (99%) rename {x/models => mlxrunner}/nn/recurrent_test.go (99%) rename {x/models => mlxrunner}/nn/rope.go (98%) rename {x/models => mlxrunner}/nn/sdpa.go (99%) rename {x/models => mlxrunner}/nn/sdpa_test.go (99%) rename {x/mlxrunner => mlxrunner}/pipeline.go (98%) rename {x/mlxrunner => mlxrunner}/pipeline_test.go (96%) rename {x/mlxrunner => mlxrunner}/prefix_cache.go (99%) rename {x/mlxrunner => mlxrunner}/prefix_cache_scenario_test.go (99%) rename {x/mlxrunner => mlxrunner}/prefix_cache_test.go (99%) rename {x/mlxrunner => mlxrunner}/runner.go (95%) rename {x/mlxrunner => mlxrunner}/sample/logprob_test.go (98%) rename {x/mlxrunner => mlxrunner}/sample/sample.go (99%) rename {x/mlxrunner => mlxrunner}/sample/sample_test.go (99%) rename {x/mlxrunner => mlxrunner}/server.go (97%) rename {x/mlxrunner => mlxrunner}/speculate.go (98%) rename {x/mlxrunner => mlxrunner}/speculate_depth.go (100%) rename {x/mlxrunner => mlxrunner}/speculate_depth_test.go (100%) rename {x/mlxrunner => mlxrunner}/speculate_stats.go (100%) rename {x/mlxrunner => mlxrunner}/status_memory.go (100%) rename {x/mlxrunner => mlxrunner}/status_memory_test.go (100%) rename {tokenizer => mlxrunner/tokenizer}/testdata/llama3.2/encoder.json (100%) rename {tokenizer => mlxrunner/tokenizer}/testdata/llama3.2/vocab.bpe (100%) rename {x => mlxrunner}/tokenizer/testdata/mini_llama.json (100%) rename {x => mlxrunner}/tokenizer/tokenizer.go (100%) rename {x => mlxrunner}/tokenizer/tokenizer_benchmark_test.go (100%) rename {x => mlxrunner}/tokenizer/tokenizer_bpe.go (100%) rename {x => mlxrunner}/tokenizer/tokenizer_correctness_test.go (100%) rename {x => mlxrunner}/tokenizer/tokenizer_decode.go (100%) rename {x => mlxrunner}/tokenizer/tokenizer_encode.go (100%) rename {x => mlxrunner}/tokenizer/tokenizer_ggml_parity_test.go (98%) rename {x => mlxrunner}/tokenizer/tokenizer_load.go (100%) rename {x => mlxrunner}/tokenizer/tokenizer_load_test.go (100%) rename {x/mlxrunner => mlxrunner}/utf8_buffer.go (100%) rename {x/mlxrunner => mlxrunner}/utf8_buffer_test.go (100%) rename {x/mlxrunner => mlxrunner}/verify.go (88%) rename {x/mlxrunner => mlxrunner}/verify_test.go (86%) rename {x/mlxrunner => mlxrunner}/xgrammar/dynamic.c (100%) rename {x/mlxrunner => mlxrunner}/xgrammar/dynamic.h (100%) rename {x/mlxrunner => mlxrunner}/xgrammar/native/xgrammar.cpp (100%) rename {x/mlxrunner => mlxrunner}/xgrammar/native/xgrammar.h (100%) rename {x/mlxrunner => mlxrunner}/xgrammar/xgrammar.go (100%) rename {x/mlxrunner => mlxrunner}/xgrammar/xgrammar_test.go (99%) delete mode 100644 x/mlxrunner/imports.go diff --git a/.github/scripts/prepare_mlx_darwin.sh b/.github/scripts/prepare_mlx_darwin.sh index 6e8a19d92..d153e34bd 100755 --- a/.github/scripts/prepare_mlx_darwin.sh +++ b/.github/scripts/prepare_mlx_darwin.sh @@ -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. diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index e1ebd0bdc..f7ea8bf56 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -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 diff --git a/.golangci.yaml b/.golangci.yaml index 2b843b6ce..5c532d23e 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -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 diff --git a/Dockerfile b/Dockerfile index 3a6abc331..6c629077e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/cmake/local.cmake b/cmake/local.cmake index 3535a5556..2fb9b8429 100644 --- a/cmake/local.cmake +++ b/cmake/local.cmake @@ -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" diff --git a/cmake/mlx/CMakeLists.txt b/cmake/mlx/CMakeLists.txt index 997577d0f..984b06572 100644 --- a/cmake/mlx/CMakeLists.txt +++ b/cmake/mlx/CMakeLists.txt @@ -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}") diff --git a/cmd/cmd.go b/cmd/cmd.go index bd529fc1d..baba019c1 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -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 { diff --git a/x/create/blockfp8.go b/create/blockfp8.go similarity index 100% rename from x/create/blockfp8.go rename to create/blockfp8.go diff --git a/x/create/blockfp8_test.go b/create/blockfp8_test.go similarity index 100% rename from x/create/blockfp8_test.go rename to create/blockfp8_test.go diff --git a/x/create/classify.go b/create/classify.go similarity index 99% rename from x/create/classify.go rename to create/classify.go index e8fc28e2c..26d914d0f 100644 --- a/x/create/classify.go +++ b/create/classify.go @@ -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 diff --git a/x/create/classify_test.go b/create/classify_test.go similarity index 100% rename from x/create/classify_test.go rename to create/classify_test.go diff --git a/x/create/client/create.go b/create/client/create.go similarity index 97% rename from x/create/client/create.go rename to create/client/create.go index 9d5ac9762..80986ce13 100644 --- a/x/create/client/create.go +++ b/create/client/create.go @@ -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, diff --git a/x/create/client/create_test.go b/create/client/create_test.go similarity index 99% rename from x/create/client/create_test.go rename to create/client/create_test.go index 4acbadc43..f5e67f9bc 100644 --- a/x/create/client/create_test.go +++ b/create/client/create_test.go @@ -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) { diff --git a/x/create/client/remote.go b/create/client/remote.go similarity index 98% rename from x/create/client/remote.go rename to create/client/remote.go index 038e3bd28..515e6484e 100644 --- a/x/create/client/remote.go +++ b/create/client/remote.go @@ -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 { diff --git a/x/create/client/remote_test.go b/create/client/remote_test.go similarity index 100% rename from x/create/client/remote_test.go rename to create/client/remote_test.go diff --git a/x/create/cohere2moe.go b/create/cohere2moe.go similarity index 100% rename from x/create/cohere2moe.go rename to create/cohere2moe.go diff --git a/x/create/create.go b/create/create.go similarity index 99% rename from x/create/create.go rename to create/create.go index f75fa90b9..f8236eb7c 100644 --- a/x/create/create.go +++ b/create/create.go @@ -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 diff --git a/x/create/create_test.go b/create/create_test.go similarity index 99% rename from x/create/create_test.go rename to create/create_test.go index ebc53ea44..993b812a9 100644 --- a/x/create/create_test.go +++ b/create/create_test.go @@ -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) { diff --git a/x/create/draft.go b/create/draft.go similarity index 100% rename from x/create/draft.go rename to create/draft.go diff --git a/x/create/draft_test.go b/create/draft_test.go similarity index 99% rename from x/create/draft_test.go rename to create/draft_test.go index 4df89067e..c0ef587c2 100644 --- a/x/create/draft_test.go +++ b/create/draft_test.go @@ -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 diff --git a/x/create/gemma4.go b/create/gemma4.go similarity index 100% rename from x/create/gemma4.go rename to create/gemma4.go diff --git a/x/create/gemma4_test.go b/create/gemma4_test.go similarity index 100% rename from x/create/gemma4_test.go rename to create/gemma4_test.go diff --git a/x/create/glimmer.go b/create/glimmer.go similarity index 100% rename from x/create/glimmer.go rename to create/glimmer.go diff --git a/x/create/glimmer_test.go b/create/glimmer_test.go similarity index 100% rename from x/create/glimmer_test.go rename to create/glimmer_test.go diff --git a/x/create/inventory.go b/create/inventory.go similarity index 99% rename from x/create/inventory.go rename to create/inventory.go index efe02b312..eea8a2e5a 100644 --- a/x/create/inventory.go +++ b/create/inventory.go @@ -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 diff --git a/x/create/inventory_test.go b/create/inventory_test.go similarity index 99% rename from x/create/inventory_test.go rename to create/inventory_test.go index 085916777..4c0a157d4 100644 --- a/x/create/inventory_test.go +++ b/create/inventory_test.go @@ -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) { diff --git a/x/create/laguna.go b/create/laguna.go similarity index 100% rename from x/create/laguna.go rename to create/laguna.go diff --git a/x/create/laguna_test.go b/create/laguna_test.go similarity index 100% rename from x/create/laguna_test.go rename to create/laguna_test.go diff --git a/x/create/manifest.go b/create/manifest.go similarity index 100% rename from x/create/manifest.go rename to create/manifest.go diff --git a/x/create/manifest_test.go b/create/manifest_test.go similarity index 100% rename from x/create/manifest_test.go rename to create/manifest_test.go diff --git a/x/create/metadata.go b/create/metadata.go similarity index 100% rename from x/create/metadata.go rename to create/metadata.go diff --git a/x/create/metadata_test.go b/create/metadata_test.go similarity index 100% rename from x/create/metadata_test.go rename to create/metadata_test.go diff --git a/x/create/mlxthread.go b/create/mlxthread.go similarity index 91% rename from x/create/mlxthread.go rename to create/mlxthread.go index e0c56bce7..7b9000f64 100644 --- a/x/create/mlxthread.go +++ b/create/mlxthread.go @@ -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 ( diff --git a/x/create/nemotron_h.go b/create/nemotron_h.go similarity index 100% rename from x/create/nemotron_h.go rename to create/nemotron_h.go diff --git a/x/create/nemotron_h_test.go b/create/nemotron_h_test.go similarity index 100% rename from x/create/nemotron_h_test.go rename to create/nemotron_h_test.go diff --git a/x/create/pipeline.go b/create/pipeline.go similarity index 100% rename from x/create/pipeline.go rename to create/pipeline.go diff --git a/x/create/pipeline_test.go b/create/pipeline_test.go similarity index 99% rename from x/create/pipeline_test.go rename to create/pipeline_test.go index c558d0e9b..9d4f244f9 100644 --- a/x/create/pipeline_test.go +++ b/create/pipeline_test.go @@ -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) diff --git a/x/create/plan.go b/create/plan.go similarity index 100% rename from x/create/plan.go rename to create/plan.go diff --git a/x/create/plan_test.go b/create/plan_test.go similarity index 100% rename from x/create/plan_test.go rename to create/plan_test.go diff --git a/x/create/prequant.go b/create/prequant.go similarity index 100% rename from x/create/prequant.go rename to create/prequant.go diff --git a/x/create/prequant_test.go b/create/prequant_test.go similarity index 100% rename from x/create/prequant_test.go rename to create/prequant_test.go diff --git a/x/create/quantize.go b/create/quantize.go similarity index 99% rename from x/create/quantize.go rename to create/quantize.go index 2c7ee5a32..2f4e2d171 100644 --- a/x/create/quantize.go +++ b/create/quantize.go @@ -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 diff --git a/x/create/quantpolicy.go b/create/quantpolicy.go similarity index 100% rename from x/create/quantpolicy.go rename to create/quantpolicy.go diff --git a/x/create/qwen35.go b/create/qwen35.go similarity index 100% rename from x/create/qwen35.go rename to create/qwen35.go diff --git a/x/create/qwen4_exp.go b/create/qwen4_exp.go similarity index 100% rename from x/create/qwen4_exp.go rename to create/qwen4_exp.go diff --git a/x/create/qwen4_exp_test.go b/create/qwen4_exp_test.go similarity index 100% rename from x/create/qwen4_exp_test.go rename to create/qwen4_exp_test.go diff --git a/x/create/transform.go b/create/transform.go similarity index 98% rename from x/create/transform.go rename to create/transform.go index ceb761cc8..99847011f 100644 --- a/x/create/transform.go +++ b/create/transform.go @@ -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 diff --git a/x/create/verify.go b/create/verify.go similarity index 97% rename from x/create/verify.go rename to create/verify.go index 30e870b8b..3a55dd435 100644 --- a/x/create/verify.go +++ b/create/verify.go @@ -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") diff --git a/x/create/verify_test.go b/create/verify_test.go similarity index 100% rename from x/create/verify_test.go rename to create/verify_test.go diff --git a/x/create/writer.go b/create/writer.go similarity index 99% rename from x/create/writer.go rename to create/writer.go index 5e483ae8d..ae4e4a570 100644 --- a/x/create/writer.go +++ b/create/writer.go @@ -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 diff --git a/x/create/writer_test.go b/create/writer_test.go similarity index 99% rename from x/create/writer_test.go rename to create/writer_test.go index 79d1764d6..5b82b7ab9 100644 --- a/x/create/writer_test.go +++ b/create/writer_test.go @@ -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 } diff --git a/x/safetensors/extractor.go b/fs/safetensors/extractor.go similarity index 100% rename from x/safetensors/extractor.go rename to fs/safetensors/extractor.go diff --git a/x/safetensors/extractor_test.go b/fs/safetensors/extractor_test.go similarity index 100% rename from x/safetensors/extractor_test.go rename to fs/safetensors/extractor_test.go diff --git a/integration/utils_test.go b/integration/utils_test.go index 7ac356f22..0d7a4973e 100644 --- a/integration/utils_test.go +++ b/integration/utils_test.go @@ -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) { diff --git a/llama/README.md b/llama/README.md index bd2e6e209..21ed7dae3 100644 --- a/llama/README.md +++ b/llama/README.md @@ -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 diff --git a/x/mlxrunner/mlx/.gitignore b/mlx/.gitignore similarity index 100% rename from x/mlxrunner/mlx/.gitignore rename to mlx/.gitignore diff --git a/x/mlxrunner/mlx/CMakeLists.txt b/mlx/CMakeLists.txt similarity index 96% rename from x/mlxrunner/mlx/CMakeLists.txt rename to mlx/CMakeLists.txt index 5e52498bd..919a693de 100644 --- a/x/mlxrunner/mlx/CMakeLists.txt +++ b/mlx/CMakeLists.txt @@ -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( diff --git a/x/mlxrunner/mlx/act.go b/mlx/act.go similarity index 100% rename from x/mlxrunner/mlx/act.go rename to mlx/act.go diff --git a/x/mlxrunner/mlx/act_test.go b/mlx/act_test.go similarity index 97% rename from x/mlxrunner/mlx/act_test.go rename to mlx/act_test.go index c2c8ff5dc..68539496c 100644 --- a/x/mlxrunner/mlx/act_test.go +++ b/mlx/act_test.go @@ -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) { diff --git a/x/mlxrunner/mlx/array.go b/mlx/array.go similarity index 100% rename from x/mlxrunner/mlx/array.go rename to mlx/array.go diff --git a/x/mlxrunner/mlx/array_test.go b/mlx/array_test.go similarity index 98% rename from x/mlxrunner/mlx/array_test.go rename to mlx/array_test.go index 4387fa27d..06870e6df 100644 --- a/x/mlxrunner/mlx/array_test.go +++ b/mlx/array_test.go @@ -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) { diff --git a/mlx/compat/0001-mlx-c-qmm-global-scale.patch b/mlx/compat/mlx-c/0001-mlx-c-qmm-global-scale.patch similarity index 100% rename from mlx/compat/0001-mlx-c-qmm-global-scale.patch rename to mlx/compat/mlx-c/0001-mlx-c-qmm-global-scale.patch diff --git a/x/mlxrunner/mlx/compile.go b/mlx/compile.go similarity index 100% rename from x/mlxrunner/mlx/compile.go rename to mlx/compile.go diff --git a/x/mlxrunner/mlx/compile_test.go b/mlx/compile_test.go similarity index 98% rename from x/mlxrunner/mlx/compile_test.go rename to mlx/compile_test.go index 956b7a7c6..34501ca16 100644 --- a/x/mlxrunner/mlx/compile_test.go +++ b/mlx/compile_test.go @@ -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) { diff --git a/x/mlxrunner/mlx/depthwise_conv.go b/mlx/depthwise_conv.go similarity index 100% rename from x/mlxrunner/mlx/depthwise_conv.go rename to mlx/depthwise_conv.go diff --git a/x/mlxrunner/mlx/depthwise_conv_test.go b/mlx/depthwise_conv_test.go similarity index 95% rename from x/mlxrunner/mlx/depthwise_conv_test.go rename to mlx/depthwise_conv_test.go index 57c74c50f..3cc2c3bd6 100644 --- a/x/mlxrunner/mlx/depthwise_conv_test.go +++ b/mlx/depthwise_conv_test.go @@ -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) { diff --git a/x/mlxrunner/mlx/dtype.go b/mlx/dtype.go similarity index 100% rename from x/mlxrunner/mlx/dtype.go rename to mlx/dtype.go diff --git a/x/mlxrunner/mlx/dynamic.c b/mlx/dynamic.c similarity index 100% rename from x/mlxrunner/mlx/dynamic.c rename to mlx/dynamic.c diff --git a/x/mlxrunner/mlx/dynamic.go b/mlx/dynamic.go similarity index 100% rename from x/mlxrunner/mlx/dynamic.go rename to mlx/dynamic.go diff --git a/x/mlxrunner/mlx/dynamic.h b/mlx/dynamic.h similarity index 100% rename from x/mlxrunner/mlx/dynamic.h rename to mlx/dynamic.h diff --git a/x/mlxrunner/mlx/dynamic_darwin.go b/mlx/dynamic_darwin.go similarity index 100% rename from x/mlxrunner/mlx/dynamic_darwin.go rename to mlx/dynamic_darwin.go diff --git a/x/mlxrunner/mlx/dynamic_other.go b/mlx/dynamic_other.go similarity index 100% rename from x/mlxrunner/mlx/dynamic_other.go rename to mlx/dynamic_other.go diff --git a/x/mlxrunner/mlx/fast.go b/mlx/fast.go similarity index 100% rename from x/mlxrunner/mlx/fast.go rename to mlx/fast.go diff --git a/x/mlxrunner/mlx/gated_delta.go b/mlx/gated_delta.go similarity index 100% rename from x/mlxrunner/mlx/gated_delta.go rename to mlx/gated_delta.go diff --git a/x/mlxrunner/mlx/gated_delta_test.go b/mlx/gated_delta_test.go similarity index 99% rename from x/mlxrunner/mlx/gated_delta_test.go rename to mlx/gated_delta_test.go index 81a2034a6..dc3758d8d 100644 --- a/x/mlxrunner/mlx/gated_delta_test.go +++ b/mlx/gated_delta_test.go @@ -5,7 +5,7 @@ import ( "math" "testing" - "github.com/ollama/ollama/x/internal/mlxthreadtest" + "github.com/ollama/ollama/mlx/mlxthread/mlxthreadtest" ) type gatedDeltaTestGeometry struct { diff --git a/x/mlxrunner/mlx/generated.c b/mlx/generated.c similarity index 100% rename from x/mlxrunner/mlx/generated.c rename to mlx/generated.c diff --git a/x/mlxrunner/mlx/generated.h b/mlx/generated.h similarity index 100% rename from x/mlxrunner/mlx/generated.h rename to mlx/generated.h diff --git a/x/mlxrunner/mlx/generator/generated.c.gotmpl b/mlx/generator/generated.c.gotmpl similarity index 100% rename from x/mlxrunner/mlx/generator/generated.c.gotmpl rename to mlx/generator/generated.c.gotmpl diff --git a/x/mlxrunner/mlx/generator/generated.h.gotmpl b/mlx/generator/generated.h.gotmpl similarity index 100% rename from x/mlxrunner/mlx/generator/generated.h.gotmpl rename to mlx/generator/generated.h.gotmpl diff --git a/x/mlxrunner/mlx/generator/main.go b/mlx/generator/main.go similarity index 100% rename from x/mlxrunner/mlx/generator/main.go rename to mlx/generator/main.go diff --git a/x/mlxrunner/mlx/gpu_kernel.go b/mlx/gpu_kernel.go similarity index 100% rename from x/mlxrunner/mlx/gpu_kernel.go rename to mlx/gpu_kernel.go diff --git a/x/mlxrunner/mlx/include/mlx/c/README.md b/mlx/include/mlx/c/README.md similarity index 65% rename from x/mlxrunner/mlx/include/mlx/c/README.md rename to mlx/include/mlx/c/README.md index 1d693359d..6b42f9729 100644 --- a/x/mlxrunner/mlx/include/mlx/c/README.md +++ b/mlx/include/mlx/c/README.md @@ -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. diff --git a/x/mlxrunner/mlx/include/mlx/c/array.h b/mlx/include/mlx/c/array.h similarity index 100% rename from x/mlxrunner/mlx/include/mlx/c/array.h rename to mlx/include/mlx/c/array.h diff --git a/x/mlxrunner/mlx/include/mlx/c/closure.h b/mlx/include/mlx/c/closure.h similarity index 100% rename from x/mlxrunner/mlx/include/mlx/c/closure.h rename to mlx/include/mlx/c/closure.h diff --git a/x/mlxrunner/mlx/include/mlx/c/compile.h b/mlx/include/mlx/c/compile.h similarity index 100% rename from x/mlxrunner/mlx/include/mlx/c/compile.h rename to mlx/include/mlx/c/compile.h diff --git a/x/mlxrunner/mlx/include/mlx/c/cuda.h b/mlx/include/mlx/c/cuda.h similarity index 100% rename from x/mlxrunner/mlx/include/mlx/c/cuda.h rename to mlx/include/mlx/c/cuda.h diff --git a/x/mlxrunner/mlx/include/mlx/c/device.h b/mlx/include/mlx/c/device.h similarity index 100% rename from x/mlxrunner/mlx/include/mlx/c/device.h rename to mlx/include/mlx/c/device.h diff --git a/x/mlxrunner/mlx/include/mlx/c/distributed.h b/mlx/include/mlx/c/distributed.h similarity index 100% rename from x/mlxrunner/mlx/include/mlx/c/distributed.h rename to mlx/include/mlx/c/distributed.h diff --git a/x/mlxrunner/mlx/include/mlx/c/distributed_group.h b/mlx/include/mlx/c/distributed_group.h similarity index 100% rename from x/mlxrunner/mlx/include/mlx/c/distributed_group.h rename to mlx/include/mlx/c/distributed_group.h diff --git a/x/mlxrunner/mlx/include/mlx/c/error.h b/mlx/include/mlx/c/error.h similarity index 100% rename from x/mlxrunner/mlx/include/mlx/c/error.h rename to mlx/include/mlx/c/error.h diff --git a/x/mlxrunner/mlx/include/mlx/c/export.h b/mlx/include/mlx/c/export.h similarity index 100% rename from x/mlxrunner/mlx/include/mlx/c/export.h rename to mlx/include/mlx/c/export.h diff --git a/x/mlxrunner/mlx/include/mlx/c/fast.h b/mlx/include/mlx/c/fast.h similarity index 100% rename from x/mlxrunner/mlx/include/mlx/c/fast.h rename to mlx/include/mlx/c/fast.h diff --git a/x/mlxrunner/mlx/include/mlx/c/fft.h b/mlx/include/mlx/c/fft.h similarity index 100% rename from x/mlxrunner/mlx/include/mlx/c/fft.h rename to mlx/include/mlx/c/fft.h diff --git a/x/mlxrunner/mlx/include/mlx/c/graph_utils.h b/mlx/include/mlx/c/graph_utils.h similarity index 100% rename from x/mlxrunner/mlx/include/mlx/c/graph_utils.h rename to mlx/include/mlx/c/graph_utils.h diff --git a/x/mlxrunner/mlx/include/mlx/c/half.h b/mlx/include/mlx/c/half.h similarity index 100% rename from x/mlxrunner/mlx/include/mlx/c/half.h rename to mlx/include/mlx/c/half.h diff --git a/x/mlxrunner/mlx/include/mlx/c/io.h b/mlx/include/mlx/c/io.h similarity index 100% rename from x/mlxrunner/mlx/include/mlx/c/io.h rename to mlx/include/mlx/c/io.h diff --git a/x/mlxrunner/mlx/include/mlx/c/io_types.h b/mlx/include/mlx/c/io_types.h similarity index 100% rename from x/mlxrunner/mlx/include/mlx/c/io_types.h rename to mlx/include/mlx/c/io_types.h diff --git a/x/mlxrunner/mlx/include/mlx/c/linalg.h b/mlx/include/mlx/c/linalg.h similarity index 100% rename from x/mlxrunner/mlx/include/mlx/c/linalg.h rename to mlx/include/mlx/c/linalg.h diff --git a/x/mlxrunner/mlx/include/mlx/c/map.h b/mlx/include/mlx/c/map.h similarity index 100% rename from x/mlxrunner/mlx/include/mlx/c/map.h rename to mlx/include/mlx/c/map.h diff --git a/x/mlxrunner/mlx/include/mlx/c/memory.h b/mlx/include/mlx/c/memory.h similarity index 100% rename from x/mlxrunner/mlx/include/mlx/c/memory.h rename to mlx/include/mlx/c/memory.h diff --git a/x/mlxrunner/mlx/include/mlx/c/metal.h b/mlx/include/mlx/c/metal.h similarity index 100% rename from x/mlxrunner/mlx/include/mlx/c/metal.h rename to mlx/include/mlx/c/metal.h diff --git a/x/mlxrunner/mlx/include/mlx/c/mlx.h b/mlx/include/mlx/c/mlx.h similarity index 100% rename from x/mlxrunner/mlx/include/mlx/c/mlx.h rename to mlx/include/mlx/c/mlx.h diff --git a/x/mlxrunner/mlx/include/mlx/c/ops.h b/mlx/include/mlx/c/ops.h similarity index 100% rename from x/mlxrunner/mlx/include/mlx/c/ops.h rename to mlx/include/mlx/c/ops.h diff --git a/x/mlxrunner/mlx/include/mlx/c/optional.h b/mlx/include/mlx/c/optional.h similarity index 100% rename from x/mlxrunner/mlx/include/mlx/c/optional.h rename to mlx/include/mlx/c/optional.h diff --git a/x/mlxrunner/mlx/include/mlx/c/random.h b/mlx/include/mlx/c/random.h similarity index 100% rename from x/mlxrunner/mlx/include/mlx/c/random.h rename to mlx/include/mlx/c/random.h diff --git a/x/mlxrunner/mlx/include/mlx/c/stream.h b/mlx/include/mlx/c/stream.h similarity index 100% rename from x/mlxrunner/mlx/include/mlx/c/stream.h rename to mlx/include/mlx/c/stream.h diff --git a/x/mlxrunner/mlx/include/mlx/c/string.h b/mlx/include/mlx/c/string.h similarity index 100% rename from x/mlxrunner/mlx/include/mlx/c/string.h rename to mlx/include/mlx/c/string.h diff --git a/x/mlxrunner/mlx/include/mlx/c/transforms.h b/mlx/include/mlx/c/transforms.h similarity index 100% rename from x/mlxrunner/mlx/include/mlx/c/transforms.h rename to mlx/include/mlx/c/transforms.h diff --git a/x/mlxrunner/mlx/include/mlx/c/transforms_impl.h b/mlx/include/mlx/c/transforms_impl.h similarity index 100% rename from x/mlxrunner/mlx/include/mlx/c/transforms_impl.h rename to mlx/include/mlx/c/transforms_impl.h diff --git a/x/mlxrunner/mlx/include/mlx/c/vector.h b/mlx/include/mlx/c/vector.h similarity index 100% rename from x/mlxrunner/mlx/include/mlx/c/vector.h rename to mlx/include/mlx/c/vector.h diff --git a/x/mlxrunner/mlx/include/mlx/c/version.h b/mlx/include/mlx/c/version.h similarity index 100% rename from x/mlxrunner/mlx/include/mlx/c/version.h rename to mlx/include/mlx/c/version.h diff --git a/x/mlxrunner/mlx/io.go b/mlx/io.go similarity index 100% rename from x/mlxrunner/mlx/io.go rename to mlx/io.go diff --git a/x/mlxrunner/mlx/io_test.go b/mlx/io_test.go similarity index 96% rename from x/mlxrunner/mlx/io_test.go rename to mlx/io_test.go index 9a90046c2..c273efb43 100644 --- a/x/mlxrunner/mlx/io_test.go +++ b/mlx/io_test.go @@ -7,7 +7,7 @@ import ( "path/filepath" "testing" - "github.com/ollama/ollama/x/internal/mlxthreadtest" + "github.com/ollama/ollama/mlx/mlxthread/mlxthreadtest" ) func TestSaveSafetensorsWithMetadataDeterministic(t *testing.T) { diff --git a/x/mlxrunner/mlx/kernel_test.go b/mlx/kernel_test.go similarity index 100% rename from x/mlxrunner/mlx/kernel_test.go rename to mlx/kernel_test.go diff --git a/x/mlxrunner/mlx/mamba2_scan.go b/mlx/mamba2_scan.go similarity index 100% rename from x/mlxrunner/mlx/mamba2_scan.go rename to mlx/mamba2_scan.go diff --git a/x/mlxrunner/mlx/mamba_kernels_test.go b/mlx/mamba_kernels_test.go similarity index 99% rename from x/mlxrunner/mlx/mamba_kernels_test.go rename to mlx/mamba_kernels_test.go index 67518f4af..724bdfce1 100644 --- a/x/mlxrunner/mlx/mamba_kernels_test.go +++ b/mlx/mamba_kernels_test.go @@ -5,7 +5,7 @@ import ( "math" "testing" - "github.com/ollama/ollama/x/internal/mlxthreadtest" + "github.com/ollama/ollama/mlx/mlxthread/mlxthreadtest" ) func TestMamba2ScanMatchesReference(t *testing.T) { diff --git a/x/mlxrunner/mlx/memory.go b/mlx/memory.go similarity index 100% rename from x/mlxrunner/mlx/memory.go rename to mlx/memory.go diff --git a/x/mlxrunner/mlx/memory_test.go b/mlx/memory_test.go similarity index 96% rename from x/mlxrunner/mlx/memory_test.go rename to mlx/memory_test.go index 5e54c39cc..3367f0745 100644 --- a/x/mlxrunner/mlx/memory_test.go +++ b/mlx/memory_test.go @@ -7,7 +7,7 @@ import ( "slices" "testing" - "github.com/ollama/ollama/x/internal/mlxthreadtest" + "github.com/ollama/ollama/mlx/mlxthread/mlxthreadtest" ) func TestSetWiredLimitRejectsOversizeWithoutChangingLimit(t *testing.T) { diff --git a/x/mlxrunner/mlx/mlx.go b/mlx/mlx.go similarity index 99% rename from x/mlxrunner/mlx/mlx.go rename to mlx/mlx.go index 141ba9cc2..8f66f3e7e 100644 --- a/x/mlxrunner/mlx/mlx.go +++ b/mlx/mlx.go @@ -2,7 +2,7 @@ // // MLX keeps stream and backend state in thread-locals, so all calls into this // package must come from a single goroutine locked to its OS thread (see -// x/internal/mlxthread). +// mlx/mlxthread). package mlx //go:generate go run generator/main.go -output=. ./include/mlx/c/*.h diff --git a/x/internal/mlxtest/mlxtest.go b/mlx/mlxtest/mlxtest.go similarity index 89% rename from x/internal/mlxtest/mlxtest.go rename to mlx/mlxtest/mlxtest.go index d19fa1892..506125614 100644 --- a/x/internal/mlxtest/mlxtest.go +++ b/mlx/mlxtest/mlxtest.go @@ -1,13 +1,13 @@ // Package mlxtest provides shared scaffolding for tests that exercise MLX -// through the cgo wrapper in x/mlxrunner/mlx. +// through the cgo wrapper in mlx. package mlxtest import ( "sync" "testing" - "github.com/ollama/ollama/x/internal/mlxthreadtest" - "github.com/ollama/ollama/x/mlxrunner/mlx" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlx/mlxthread/mlxthreadtest" ) var testThread = sync.OnceValues(func() (*mlxthreadtest.Thread, error) { diff --git a/x/internal/mlxthreadtest/mlxthreadtest.go b/mlx/mlxthread/mlxthreadtest/mlxthreadtest.go similarity index 98% rename from x/internal/mlxthreadtest/mlxthreadtest.go rename to mlx/mlxthread/mlxthreadtest/mlxthreadtest.go index 5e43ea384..2ee75d512 100644 --- a/x/internal/mlxthreadtest/mlxthreadtest.go +++ b/mlx/mlxthread/mlxthreadtest/mlxthreadtest.go @@ -5,7 +5,7 @@ import ( "context" "testing" - "github.com/ollama/ollama/x/internal/mlxthread" + "github.com/ollama/ollama/mlx/mlxthread" ) // Thread is a pinned worker used by MLX tests. diff --git a/x/internal/mlxthreadtest/mlxthreadtest_test.go b/mlx/mlxthread/mlxthreadtest/mlxthreadtest_test.go similarity index 100% rename from x/internal/mlxthreadtest/mlxthreadtest_test.go rename to mlx/mlxthread/mlxthreadtest/mlxthreadtest_test.go diff --git a/x/internal/mlxthreadtest/threadid_darwin.go b/mlx/mlxthread/mlxthreadtest/threadid_darwin.go similarity index 100% rename from x/internal/mlxthreadtest/threadid_darwin.go rename to mlx/mlxthread/mlxthreadtest/threadid_darwin.go diff --git a/x/internal/mlxthreadtest/threadid_linux.go b/mlx/mlxthread/mlxthreadtest/threadid_linux.go similarity index 100% rename from x/internal/mlxthreadtest/threadid_linux.go rename to mlx/mlxthread/mlxthreadtest/threadid_linux.go diff --git a/x/internal/mlxthreadtest/threadid_other.go b/mlx/mlxthread/mlxthreadtest/threadid_other.go similarity index 100% rename from x/internal/mlxthreadtest/threadid_other.go rename to mlx/mlxthread/mlxthreadtest/threadid_other.go diff --git a/x/internal/mlxthreadtest/threadid_windows.go b/mlx/mlxthread/mlxthreadtest/threadid_windows.go similarity index 100% rename from x/internal/mlxthreadtest/threadid_windows.go rename to mlx/mlxthread/mlxthreadtest/threadid_windows.go diff --git a/x/internal/mlxthread/thread.go b/mlx/mlxthread/thread.go similarity index 100% rename from x/internal/mlxthread/thread.go rename to mlx/mlxthread/thread.go diff --git a/x/internal/mlxthread/thread_affinity_test.go b/mlx/mlxthread/thread_affinity_test.go similarity index 100% rename from x/internal/mlxthread/thread_affinity_test.go rename to mlx/mlxthread/thread_affinity_test.go diff --git a/x/internal/mlxthread/thread_test.go b/mlx/mlxthread/thread_test.go similarity index 100% rename from x/internal/mlxthread/thread_test.go rename to mlx/mlxthread/thread_test.go diff --git a/x/internal/mlxthread/threadid_darwin_test.go b/mlx/mlxthread/threadid_darwin_test.go similarity index 100% rename from x/internal/mlxthread/threadid_darwin_test.go rename to mlx/mlxthread/threadid_darwin_test.go diff --git a/x/internal/mlxthread/threadid_linux_test.go b/mlx/mlxthread/threadid_linux_test.go similarity index 100% rename from x/internal/mlxthread/threadid_linux_test.go rename to mlx/mlxthread/threadid_linux_test.go diff --git a/x/mlxrunner/mlx/nn.go b/mlx/nn.go similarity index 100% rename from x/mlxrunner/mlx/nn.go rename to mlx/nn.go diff --git a/x/mlxrunner/mlx/ops.go b/mlx/ops.go similarity index 100% rename from x/mlxrunner/mlx/ops.go rename to mlx/ops.go diff --git a/x/mlxrunner/mlx/ops_extra.go b/mlx/ops_extra.go similarity index 100% rename from x/mlxrunner/mlx/ops_extra.go rename to mlx/ops_extra.go diff --git a/x/mlxrunner/mlx/ops_extra_test.go b/mlx/ops_extra_test.go similarity index 99% rename from x/mlxrunner/mlx/ops_extra_test.go rename to mlx/ops_extra_test.go index fe06562ac..12be6fbb5 100644 --- a/x/mlxrunner/mlx/ops_extra_test.go +++ b/mlx/ops_extra_test.go @@ -4,7 +4,7 @@ import ( "math" "testing" - "github.com/ollama/ollama/x/internal/mlxthreadtest" + "github.com/ollama/ollama/mlx/mlxthread/mlxthreadtest" ) // mlxForm converts checkpoint multipliers to MLX's global-scale diff --git a/x/quant/quant.go b/mlx/quant/quant.go similarity index 100% rename from x/quant/quant.go rename to mlx/quant/quant.go diff --git a/x/quant/quant_test.go b/mlx/quant/quant_test.go similarity index 100% rename from x/quant/quant_test.go rename to mlx/quant/quant_test.go diff --git a/x/mlxrunner/mlx/random.go b/mlx/random.go similarity index 100% rename from x/mlxrunner/mlx/random.go rename to mlx/random.go diff --git a/x/mlxrunner/mlx/scope.go b/mlx/scope.go similarity index 100% rename from x/mlxrunner/mlx/scope.go rename to mlx/scope.go diff --git a/x/mlxrunner/mlx/scope_test.go b/mlx/scope_test.go similarity index 98% rename from x/mlxrunner/mlx/scope_test.go rename to mlx/scope_test.go index 641e6ddc7..efb21c767 100644 --- a/x/mlxrunner/mlx/scope_test.go +++ b/mlx/scope_test.go @@ -3,7 +3,7 @@ package mlx import ( "testing" - "github.com/ollama/ollama/x/internal/mlxthreadtest" + "github.com/ollama/ollama/mlx/mlxthread/mlxthreadtest" ) // A function scope frees what was created in it. What fn returns moves to the diff --git a/x/mlxrunner/mlx/slice.go b/mlx/slice.go similarity index 100% rename from x/mlxrunner/mlx/slice.go rename to mlx/slice.go diff --git a/x/mlxrunner/mlx/stream.go b/mlx/stream.go similarity index 100% rename from x/mlxrunner/mlx/stream.go rename to mlx/stream.go diff --git a/x/mlxrunner/mlx/thread_test.go b/mlx/thread_test.go similarity index 96% rename from x/mlxrunner/mlx/thread_test.go rename to mlx/thread_test.go index 0cebb04a9..7fcc29677 100644 --- a/x/mlxrunner/mlx/thread_test.go +++ b/mlx/thread_test.go @@ -6,7 +6,7 @@ import ( "sync" "testing" - "github.com/ollama/ollama/x/internal/mlxthreadtest" + "github.com/ollama/ollama/mlx/mlxthread/mlxthreadtest" ) var testThread = sync.OnceValues(func() (*mlxthreadtest.Thread, error) { diff --git a/x/mlxrunner/batch/batch.go b/mlxrunner/batch/batch.go similarity index 97% rename from x/mlxrunner/batch/batch.go rename to mlxrunner/batch/batch.go index 509ec41f6..a96153ef7 100644 --- a/x/mlxrunner/batch/batch.go +++ b/mlxrunner/batch/batch.go @@ -1,6 +1,6 @@ package batch -import "github.com/ollama/ollama/x/mlxrunner/mlx" +import "github.com/ollama/ollama/mlx" // Batch is the per-forward-pass input handed to a model. type Batch struct { diff --git a/x/mlxrunner/cache/cache.go b/mlxrunner/cache/cache.go similarity index 99% rename from x/mlxrunner/cache/cache.go rename to mlxrunner/cache/cache.go index be404a92f..c75c63ade 100644 --- a/x/mlxrunner/cache/cache.go +++ b/mlxrunner/cache/cache.go @@ -3,7 +3,7 @@ package cache import ( "fmt" - "github.com/ollama/ollama/x/mlxrunner/mlx" + "github.com/ollama/ollama/mlx" ) // Cache is common state management shared by every cache kind. Writers diff --git a/x/mlxrunner/cache/cache_test.go b/mlxrunner/cache/cache_test.go similarity index 98% rename from x/mlxrunner/cache/cache_test.go rename to mlxrunner/cache/cache_test.go index 408aa7da6..a3846460a 100644 --- a/x/mlxrunner/cache/cache_test.go +++ b/mlxrunner/cache/cache_test.go @@ -3,9 +3,9 @@ package cache import ( "testing" - "github.com/ollama/ollama/x/internal/mlxtest" - "github.com/ollama/ollama/x/mlxrunner/batch" - "github.com/ollama/ollama/x/mlxrunner/mlx" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlx/mlxtest" + "github.com/ollama/ollama/mlxrunner/batch" ) // newKVBatch builds a B=1 batch at SeqOffsets=off with all-real diff --git a/x/mlxrunner/cache/kvcache.go b/mlxrunner/cache/kvcache.go similarity index 98% rename from x/mlxrunner/cache/kvcache.go rename to mlxrunner/cache/kvcache.go index 68afac07c..78a47f7e0 100644 --- a/x/mlxrunner/cache/kvcache.go +++ b/mlxrunner/cache/kvcache.go @@ -3,9 +3,9 @@ package cache import ( "slices" - "github.com/ollama/ollama/x/mlxrunner/batch" - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/models/nn" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlxrunner/batch" + "github.com/ollama/ollama/mlxrunner/nn" ) // Attention is the contract for caches that back attention layers diff --git a/x/mlxrunner/cache/lazy_test.go b/mlxrunner/cache/lazy_test.go similarity index 99% rename from x/mlxrunner/cache/lazy_test.go rename to mlxrunner/cache/lazy_test.go index 01232a610..309093f02 100644 --- a/x/mlxrunner/cache/lazy_test.go +++ b/mlxrunner/cache/lazy_test.go @@ -3,8 +3,8 @@ package cache import ( "testing" - "github.com/ollama/ollama/x/internal/mlxtest" - "github.com/ollama/ollama/x/mlxrunner/mlx" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlx/mlxtest" ) // distinctKV builds a [1, H, L, D] keys/values pair whose values encode the diff --git a/x/mlxrunner/cache/recurrent.go b/mlxrunner/cache/recurrent.go similarity index 98% rename from x/mlxrunner/cache/recurrent.go rename to mlxrunner/cache/recurrent.go index 80c45daad..ea8ee3980 100644 --- a/x/mlxrunner/cache/recurrent.go +++ b/mlxrunner/cache/recurrent.go @@ -3,9 +3,9 @@ package cache import ( "fmt" - "github.com/ollama/ollama/x/mlxrunner/batch" - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/models/nn" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlxrunner/batch" + "github.com/ollama/ollama/mlxrunner/nn" ) // RecurrentCache stores state for linear-recurrent layers. diff --git a/x/mlxrunner/cache/recurrent_test.go b/mlxrunner/cache/recurrent_test.go similarity index 97% rename from x/mlxrunner/cache/recurrent_test.go rename to mlxrunner/cache/recurrent_test.go index 4a4624d51..56b6d775a 100644 --- a/x/mlxrunner/cache/recurrent_test.go +++ b/mlxrunner/cache/recurrent_test.go @@ -4,10 +4,10 @@ import ( "math" "testing" - "github.com/ollama/ollama/x/internal/mlxtest" - "github.com/ollama/ollama/x/mlxrunner/batch" - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/models/nn" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlx/mlxtest" + "github.com/ollama/ollama/mlxrunner/batch" + "github.com/ollama/ollama/mlxrunner/nn" ) // TestRecurrentCacheRestoreExactOffset verifies that RecurrentCache restore diff --git a/x/mlxrunner/cache/rotating.go b/mlxrunner/cache/rotating.go similarity index 99% rename from x/mlxrunner/cache/rotating.go rename to mlxrunner/cache/rotating.go index 8aa3f9c2d..d862dc0fc 100644 --- a/x/mlxrunner/cache/rotating.go +++ b/mlxrunner/cache/rotating.go @@ -5,9 +5,9 @@ import ( "slices" "github.com/ollama/ollama/logutil" - "github.com/ollama/ollama/x/mlxrunner/batch" - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/models/nn" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlxrunner/batch" + "github.com/ollama/ollama/mlxrunner/nn" ) // RotatingKVCache implements sliding window attention with bounded memory. diff --git a/x/mlxrunner/cache/rotating_attention_test.go b/mlxrunner/cache/rotating_attention_test.go similarity index 98% rename from x/mlxrunner/cache/rotating_attention_test.go rename to mlxrunner/cache/rotating_attention_test.go index 6d2d6d318..769268842 100644 --- a/x/mlxrunner/cache/rotating_attention_test.go +++ b/mlxrunner/cache/rotating_attention_test.go @@ -4,10 +4,10 @@ import ( "math" "testing" - "github.com/ollama/ollama/x/internal/mlxtest" - "github.com/ollama/ollama/x/mlxrunner/batch" - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/models/nn" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlx/mlxtest" + "github.com/ollama/ollama/mlxrunner/batch" + "github.com/ollama/ollama/mlxrunner/nn" ) // TestRotatingKVCacheDecodeParity drives a rotating cache past its diff --git a/x/mlxrunner/cache/rotating_multiturn_test.go b/mlxrunner/cache/rotating_multiturn_test.go similarity index 97% rename from x/mlxrunner/cache/rotating_multiturn_test.go rename to mlxrunner/cache/rotating_multiturn_test.go index 2b6ce30c0..99f6fbc1f 100644 --- a/x/mlxrunner/cache/rotating_multiturn_test.go +++ b/mlxrunner/cache/rotating_multiturn_test.go @@ -3,8 +3,8 @@ package cache import ( "testing" - "github.com/ollama/ollama/x/internal/mlxtest" - "github.com/ollama/ollama/x/mlxrunner/mlx" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlx/mlxtest" ) // singleTokenKV and multiTokenKV fabricate [B=1, H=1, L, D=2] key/value @@ -107,7 +107,7 @@ func TestRotatingKVCacheConcatMidRotationPreservesContext(t *testing.T) { // TestRotatingKVCacheConcatAlignedInvariant: with an aligned buffer // (c.idx == Dim), an L>1 concat keeps the last (maxSize-1) pre-existing // tokens plus the full new batch. This is the chunked-prefill contract -// x/mlxrunner/pipeline.go relies on. +// mlxrunner/pipeline.go relies on. func TestRotatingKVCacheConcatAlignedInvariant(t *testing.T) { mlxtest.Run(t, func(t *mlxtest.T) { const window = 4 @@ -165,7 +165,7 @@ func TestRotatingKVCacheConcatAfterDecodeGrowsBuffer(t *testing.T) { }) } -// TestRotatingKVCacheConcatAfterLiveRewind: x/mlxrunner/cache.go calls +// TestRotatingKVCacheConcatAfterLiveRewind: mlxrunner/cache.go calls // Restore(nil, target) between conversation turns to rewind the cache to // the matched prefix. Restore moves c.offset/c.idx without trimming the // underlying buffer, so slots [c.idx, Dim) still hold stale pre-rewind @@ -222,7 +222,7 @@ func TestRotatingKVCacheConcatGrowingBuffer(t *testing.T) { } // TestRotatingKVCacheRunnerChunkedPrefill mirrors the -// x/mlxrunner/pipeline.go prefill loop: a long prompt fed through +// mlxrunner/pipeline.go prefill loop: a long prompt fed through // repeated L>1 Update() calls on a single cache. Scaled-down proxy for // the Gemma 4 26B case (sliding_window=1024, prefillChunkSize=2048). func TestRotatingKVCacheRunnerChunkedPrefill(t *testing.T) { diff --git a/x/mlxrunner/cache/snapshot_capture_test.go b/mlxrunner/cache/snapshot_capture_test.go similarity index 99% rename from x/mlxrunner/cache/snapshot_capture_test.go rename to mlxrunner/cache/snapshot_capture_test.go index eb81df1a3..b972d90c6 100644 --- a/x/mlxrunner/cache/snapshot_capture_test.go +++ b/mlxrunner/cache/snapshot_capture_test.go @@ -4,8 +4,8 @@ import ( "slices" "testing" - "github.com/ollama/ollama/x/internal/mlxtest" - "github.com/ollama/ollama/x/mlxrunner/mlx" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlx/mlxtest" ) // fillKV writes n single-token steps into c, one Update per token, so the diff --git a/x/mlxrunner/cache_trie.go b/mlxrunner/cache_trie.go similarity index 99% rename from x/mlxrunner/cache_trie.go rename to mlxrunner/cache_trie.go index 535a0a2cd..cb187733d 100644 --- a/x/mlxrunner/cache_trie.go +++ b/mlxrunner/cache_trie.go @@ -5,7 +5,7 @@ import ( "slices" "time" - "github.com/ollama/ollama/x/mlxrunner/cache" + "github.com/ollama/ollama/mlxrunner/cache" ) // trieKey encodes a token for trie matching (see prefixCache.key). diff --git a/x/mlxrunner/cache_trie_test.go b/mlxrunner/cache_trie_test.go similarity index 99% rename from x/mlxrunner/cache_trie_test.go rename to mlxrunner/cache_trie_test.go index 2232af41e..7f30a26cf 100644 --- a/x/mlxrunner/cache_trie_test.go +++ b/mlxrunner/cache_trie_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - "github.com/ollama/ollama/x/mlxrunner/cache" + "github.com/ollama/ollama/mlxrunner/cache" ) func newTestTrie(tokens []trieKey) *trieNode { diff --git a/x/mlxrunner/client.go b/mlxrunner/client.go similarity index 99% rename from x/mlxrunner/client.go rename to mlxrunner/client.go index 081c2708b..9787a01cc 100644 --- a/x/mlxrunner/client.go +++ b/mlxrunner/client.go @@ -26,8 +26,8 @@ import ( "github.com/ollama/ollama/format" "github.com/ollama/ollama/llm" "github.com/ollama/ollama/ml" + "github.com/ollama/ollama/mlx" "github.com/ollama/ollama/x/imagegen/manifest" - "github.com/ollama/ollama/x/mlxrunner/mlx" ) // Client wraps an MLX runner subprocess to implement llm.LlamaServer for LLM models. diff --git a/x/mlxrunner/client_test.go b/mlxrunner/client_test.go similarity index 100% rename from x/mlxrunner/client_test.go rename to mlxrunner/client_test.go diff --git a/x/mlxrunner/dflash.go b/mlxrunner/dflash.go similarity index 97% rename from x/mlxrunner/dflash.go rename to mlxrunner/dflash.go index 628c0bf43..b4b383e44 100644 --- a/x/mlxrunner/dflash.go +++ b/mlxrunner/dflash.go @@ -3,9 +3,9 @@ package mlxrunner import ( "fmt" - "github.com/ollama/ollama/x/mlxrunner/batch" - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/mlxrunner/model/base" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlxrunner/batch" + "github.com/ollama/ollama/mlxrunner/model/base" ) // dflashPendingFlushTokens bounds the held feature rows between flushes. diff --git a/x/mlxrunner/dflash_test.go b/mlxrunner/dflash_test.go similarity index 97% rename from x/mlxrunner/dflash_test.go rename to mlxrunner/dflash_test.go index 3f4a89f1c..bdcc4e090 100644 --- a/x/mlxrunner/dflash_test.go +++ b/mlxrunner/dflash_test.go @@ -6,12 +6,12 @@ import ( "testing" "github.com/ollama/ollama/api" - "github.com/ollama/ollama/x/internal/mlxtest" - "github.com/ollama/ollama/x/mlxrunner/batch" - "github.com/ollama/ollama/x/mlxrunner/cache" - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/mlxrunner/model/base" - sampler "github.com/ollama/ollama/x/mlxrunner/sample" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlx/mlxtest" + "github.com/ollama/ollama/mlxrunner/batch" + "github.com/ollama/ollama/mlxrunner/cache" + "github.com/ollama/ollama/mlxrunner/model/base" + sampler "github.com/ollama/ollama/mlxrunner/sample" ) // fakeBlockDraft is a block-diffusion draft: one Draft call ingests context diff --git a/x/mlxrunner/grammar.go b/mlxrunner/grammar.go similarity index 98% rename from x/mlxrunner/grammar.go rename to mlxrunner/grammar.go index e4c49f901..8e45ddc56 100644 --- a/x/mlxrunner/grammar.go +++ b/mlxrunner/grammar.go @@ -16,9 +16,9 @@ import ( "unicode/utf8" "github.com/ollama/ollama/api" - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/mlxrunner/xgrammar" - "github.com/ollama/ollama/x/tokenizer" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlxrunner/tokenizer" + "github.com/ollama/ollama/mlxrunner/xgrammar" ) const ( diff --git a/x/mlxrunner/grammar_mask_test.go b/mlxrunner/grammar_mask_test.go similarity index 98% rename from x/mlxrunner/grammar_mask_test.go rename to mlxrunner/grammar_mask_test.go index 7541d8f25..dc77f8303 100644 --- a/x/mlxrunner/grammar_mask_test.go +++ b/mlxrunner/grammar_mask_test.go @@ -8,9 +8,9 @@ import ( "slices" "testing" - "github.com/ollama/ollama/x/internal/mlxtest" - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/mlxrunner/xgrammar" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlx/mlxtest" + "github.com/ollama/ollama/mlxrunner/xgrammar" ) func TestApplyTokenMask(t *testing.T) { diff --git a/x/mlxrunner/grammar_test.go b/mlxrunner/grammar_test.go similarity index 98% rename from x/mlxrunner/grammar_test.go rename to mlxrunner/grammar_test.go index b86de6bd4..1efdeb452 100644 --- a/x/mlxrunner/grammar_test.go +++ b/mlxrunner/grammar_test.go @@ -13,11 +13,11 @@ import ( "testing" "github.com/ollama/ollama/api" - "github.com/ollama/ollama/x/internal/mlxtest" - "github.com/ollama/ollama/x/mlxrunner/batch" - "github.com/ollama/ollama/x/mlxrunner/mlx" - sampler "github.com/ollama/ollama/x/mlxrunner/sample" - "github.com/ollama/ollama/x/mlxrunner/xgrammar" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlx/mlxtest" + "github.com/ollama/ollama/mlxrunner/batch" + sampler "github.com/ollama/ollama/mlxrunner/sample" + "github.com/ollama/ollama/mlxrunner/xgrammar" ) // schemaTag wraps a JSON Schema into the structural tag the MLX client diff --git a/x/mlxrunner/media.go b/mlxrunner/media.go similarity index 98% rename from x/mlxrunner/media.go rename to mlxrunner/media.go index 03d0ff8cc..a48b3216a 100644 --- a/x/mlxrunner/media.go +++ b/mlxrunner/media.go @@ -10,9 +10,9 @@ import ( "strconv" "github.com/ollama/ollama/llm" - "github.com/ollama/ollama/x/mlxrunner/batch" - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/mlxrunner/model/base" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlxrunner/batch" + "github.com/ollama/ollama/mlxrunner/model/base" ) var imgTagPattern = regexp.MustCompile(`\[img-(\d+)\]`) diff --git a/x/mlxrunner/media_test.go b/mlxrunner/media_test.go similarity index 97% rename from x/mlxrunner/media_test.go rename to mlxrunner/media_test.go index ab150f8c5..f84023cb4 100644 --- a/x/mlxrunner/media_test.go +++ b/mlxrunner/media_test.go @@ -4,9 +4,9 @@ import ( "slices" "testing" - "github.com/ollama/ollama/x/internal/mlxtest" - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/mlxrunner/model/base" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlx/mlxtest" + "github.com/ollama/ollama/mlxrunner/model/base" ) func TestEffectiveKeyTokens(t *testing.T) { diff --git a/mlxrunner/model/architectures/architectures.go b/mlxrunner/model/architectures/architectures.go new file mode 100644 index 000000000..168a5bb62 --- /dev/null +++ b/mlxrunner/model/architectures/architectures.go @@ -0,0 +1,16 @@ +package architectures + +import ( + _ "github.com/ollama/ollama/mlxrunner/model/cohere2_moe" + _ "github.com/ollama/ollama/mlxrunner/model/dflash" + _ "github.com/ollama/ollama/mlxrunner/model/gemma4" + _ "github.com/ollama/ollama/mlxrunner/model/glimmer" + _ "github.com/ollama/ollama/mlxrunner/model/glm4_moe_lite" + _ "github.com/ollama/ollama/mlxrunner/model/laguna" + _ "github.com/ollama/ollama/mlxrunner/model/llama" + _ "github.com/ollama/ollama/mlxrunner/model/nemotron_h" + _ "github.com/ollama/ollama/mlxrunner/model/qwen3" + _ "github.com/ollama/ollama/mlxrunner/model/qwen3_5" + _ "github.com/ollama/ollama/mlxrunner/model/qwen3_5_moe" + _ "github.com/ollama/ollama/mlxrunner/model/qwen4_exp" +) diff --git a/x/mlxrunner/model/audio/audio.go b/mlxrunner/model/audio/audio.go similarity index 100% rename from x/mlxrunner/model/audio/audio.go rename to mlxrunner/model/audio/audio.go diff --git a/x/mlxrunner/model/audio/audio_test.go b/mlxrunner/model/audio/audio_test.go similarity index 100% rename from x/mlxrunner/model/audio/audio_test.go rename to mlxrunner/model/audio/audio_test.go diff --git a/x/mlxrunner/model/base/base.go b/mlxrunner/model/base/base.go similarity index 96% rename from x/mlxrunner/model/base/base.go rename to mlxrunner/model/base/base.go index f5aac8eac..468a46e02 100644 --- a/x/mlxrunner/model/base/base.go +++ b/mlxrunner/model/base/base.go @@ -6,11 +6,11 @@ import ( "log/slog" "sync" - "github.com/ollama/ollama/x/mlxrunner/batch" - "github.com/ollama/ollama/x/mlxrunner/cache" - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/mlxrunner/model" - "github.com/ollama/ollama/x/tokenizer" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlxrunner/batch" + "github.com/ollama/ollama/mlxrunner/cache" + "github.com/ollama/ollama/mlxrunner/model" + "github.com/ollama/ollama/mlxrunner/tokenizer" ) // Model is the interface that model implementations must satisfy. diff --git a/x/mlxrunner/model/base/media.go b/mlxrunner/model/base/media.go similarity index 98% rename from x/mlxrunner/model/base/media.go rename to mlxrunner/model/base/media.go index 513add66f..b14318504 100644 --- a/x/mlxrunner/model/base/media.go +++ b/mlxrunner/model/base/media.go @@ -9,7 +9,7 @@ import ( _ "golang.org/x/image/webp" - "github.com/ollama/ollama/x/mlxrunner/mlx" + "github.com/ollama/ollama/mlx" ) // Segment is one run of the prompt in stream order: either a tokenized text diff --git a/x/models/cohere2_moe/cohere2_moe.go b/mlxrunner/model/cohere2_moe/cohere2_moe.go similarity index 98% rename from x/models/cohere2_moe/cohere2_moe.go rename to mlxrunner/model/cohere2_moe/cohere2_moe.go index 884afb173..37fd67f07 100644 --- a/x/models/cohere2_moe/cohere2_moe.go +++ b/mlxrunner/model/cohere2_moe/cohere2_moe.go @@ -19,13 +19,13 @@ import ( "fmt" "math" - "github.com/ollama/ollama/x/mlxrunner/batch" - "github.com/ollama/ollama/x/mlxrunner/cache" - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/mlxrunner/model" - "github.com/ollama/ollama/x/mlxrunner/model/base" - "github.com/ollama/ollama/x/models/nn" - "github.com/ollama/ollama/x/tokenizer" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlxrunner/batch" + "github.com/ollama/ollama/mlxrunner/cache" + "github.com/ollama/ollama/mlxrunner/model" + "github.com/ollama/ollama/mlxrunner/model/base" + "github.com/ollama/ollama/mlxrunner/nn" + "github.com/ollama/ollama/mlxrunner/tokenizer" ) func init() { diff --git a/x/models/cohere2_moe/cohere2_moe_test.go b/mlxrunner/model/cohere2_moe/cohere2_moe_test.go similarity index 94% rename from x/models/cohere2_moe/cohere2_moe_test.go rename to mlxrunner/model/cohere2_moe/cohere2_moe_test.go index 099d38c8d..9a7c6f459 100644 --- a/x/models/cohere2_moe/cohere2_moe_test.go +++ b/mlxrunner/model/cohere2_moe/cohere2_moe_test.go @@ -4,8 +4,8 @@ import ( "fmt" "testing" - "github.com/ollama/ollama/x/internal/mlxtest" - "github.com/ollama/ollama/x/mlxrunner/mlx" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlx/mlxtest" ) func TestLoadPerExpertGlobalScale(t *testing.T) { diff --git a/x/models/dflash/dflash.go b/mlxrunner/model/dflash/dflash.go similarity index 98% rename from x/models/dflash/dflash.go rename to mlxrunner/model/dflash/dflash.go index e64ebe363..a3aa7ab54 100644 --- a/x/models/dflash/dflash.go +++ b/mlxrunner/model/dflash/dflash.go @@ -8,12 +8,12 @@ import ( "fmt" "math" - "github.com/ollama/ollama/x/mlxrunner/batch" - "github.com/ollama/ollama/x/mlxrunner/cache" - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/mlxrunner/model" - "github.com/ollama/ollama/x/mlxrunner/model/base" - "github.com/ollama/ollama/x/models/nn" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlxrunner/batch" + "github.com/ollama/ollama/mlxrunner/cache" + "github.com/ollama/ollama/mlxrunner/model" + "github.com/ollama/ollama/mlxrunner/model/base" + "github.com/ollama/ollama/mlxrunner/nn" ) func init() { diff --git a/x/mlxrunner/model/embedding.go b/mlxrunner/model/embedding.go similarity index 93% rename from x/mlxrunner/model/embedding.go rename to mlxrunner/model/embedding.go index 021ef3044..1683b6056 100644 --- a/x/mlxrunner/model/embedding.go +++ b/mlxrunner/model/embedding.go @@ -1,8 +1,8 @@ package model import ( - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/models/nn" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlxrunner/nn" ) // MakeEmbeddingLayer constructs an embedding layer from a tensor map. diff --git a/x/mlxrunner/model/embedding_test.go b/mlxrunner/model/embedding_test.go similarity index 96% rename from x/mlxrunner/model/embedding_test.go rename to mlxrunner/model/embedding_test.go index 8ef08652f..3560a44a2 100644 --- a/x/mlxrunner/model/embedding_test.go +++ b/mlxrunner/model/embedding_test.go @@ -3,9 +3,9 @@ package model import ( "testing" - "github.com/ollama/ollama/x/internal/mlxtest" - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/models/nn" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlx/mlxtest" + "github.com/ollama/ollama/mlxrunner/nn" ) func TestMakeEmbeddingLayerDense(t *testing.T) { diff --git a/x/models/gemma4/assistant.go b/mlxrunner/model/gemma4/assistant.go similarity index 97% rename from x/models/gemma4/assistant.go rename to mlxrunner/model/gemma4/assistant.go index 9d942c849..3ef69b46b 100644 --- a/x/models/gemma4/assistant.go +++ b/mlxrunner/model/gemma4/assistant.go @@ -4,12 +4,12 @@ import ( "encoding/json" "fmt" - "github.com/ollama/ollama/x/mlxrunner/batch" - "github.com/ollama/ollama/x/mlxrunner/cache" - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/mlxrunner/model" - "github.com/ollama/ollama/x/mlxrunner/model/base" - "github.com/ollama/ollama/x/models/nn" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlxrunner/batch" + "github.com/ollama/ollama/mlxrunner/cache" + "github.com/ollama/ollama/mlxrunner/model" + "github.com/ollama/ollama/mlxrunner/model/base" + "github.com/ollama/ollama/mlxrunner/nn" ) var _ base.DraftModel = (*AssistantModel)(nil) diff --git a/x/models/gemma4/audio.go b/mlxrunner/model/gemma4/audio.go similarity index 99% rename from x/models/gemma4/audio.go rename to mlxrunner/model/gemma4/audio.go index 53a150dab..0c8d89561 100644 --- a/x/models/gemma4/audio.go +++ b/mlxrunner/model/gemma4/audio.go @@ -4,9 +4,9 @@ import ( "fmt" "math" - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/mlxrunner/model" - "github.com/ollama/ollama/x/models/nn" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlxrunner/model" + "github.com/ollama/ollama/mlxrunner/nn" ) type AudioConfig struct { diff --git a/x/models/gemma4/audio_test.go b/mlxrunner/model/gemma4/audio_test.go similarity index 97% rename from x/models/gemma4/audio_test.go rename to mlxrunner/model/gemma4/audio_test.go index 0dacf30ff..80028f67f 100644 --- a/x/models/gemma4/audio_test.go +++ b/mlxrunner/model/gemma4/audio_test.go @@ -4,10 +4,10 @@ import ( "strings" "testing" - "github.com/ollama/ollama/x/internal/mlxtest" + "github.com/ollama/ollama/mlx/mlxtest" - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/mlxrunner/model/base" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlxrunner/model/base" ) func newAudioTestModel() *Model { diff --git a/x/models/gemma4/gemma4.go b/mlxrunner/model/gemma4/gemma4.go similarity index 99% rename from x/models/gemma4/gemma4.go rename to mlxrunner/model/gemma4/gemma4.go index badaaacb3..e61addc16 100644 --- a/x/models/gemma4/gemma4.go +++ b/mlxrunner/model/gemma4/gemma4.go @@ -7,13 +7,13 @@ import ( "math" "strings" - "github.com/ollama/ollama/x/mlxrunner/batch" - "github.com/ollama/ollama/x/mlxrunner/cache" - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/mlxrunner/model" - "github.com/ollama/ollama/x/mlxrunner/model/base" - "github.com/ollama/ollama/x/models/nn" - "github.com/ollama/ollama/x/tokenizer" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlxrunner/batch" + "github.com/ollama/ollama/mlxrunner/cache" + "github.com/ollama/ollama/mlxrunner/model" + "github.com/ollama/ollama/mlxrunner/model/base" + "github.com/ollama/ollama/mlxrunner/nn" + "github.com/ollama/ollama/mlxrunner/tokenizer" ) func init() { diff --git a/x/models/gemma4/gemma4_moe_test.go b/mlxrunner/model/gemma4/gemma4_moe_test.go similarity index 99% rename from x/models/gemma4/gemma4_moe_test.go rename to mlxrunner/model/gemma4/gemma4_moe_test.go index 2f8371d5b..8bd6144da 100644 --- a/x/models/gemma4/gemma4_moe_test.go +++ b/mlxrunner/model/gemma4/gemma4_moe_test.go @@ -4,8 +4,8 @@ import ( "fmt" "testing" - "github.com/ollama/ollama/x/internal/mlxtest" - "github.com/ollama/ollama/x/mlxrunner/mlx" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlx/mlxtest" ) // onesLike creates a tensor of the given shape filled with a small constant. diff --git a/x/models/gemma4/gemma4_test.go b/mlxrunner/model/gemma4/gemma4_test.go similarity index 99% rename from x/models/gemma4/gemma4_test.go rename to mlxrunner/model/gemma4/gemma4_test.go index 385b5b6ea..f1f1dd0e4 100644 --- a/x/models/gemma4/gemma4_test.go +++ b/mlxrunner/model/gemma4/gemma4_test.go @@ -5,8 +5,8 @@ import ( "slices" "testing" - "github.com/ollama/ollama/x/internal/mlxtest" - "github.com/ollama/ollama/x/mlxrunner/mlx" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlx/mlxtest" ) func TestParseSuppressTokens(t *testing.T) { diff --git a/x/models/gemma4/media.go b/mlxrunner/model/gemma4/media.go similarity index 97% rename from x/models/gemma4/media.go rename to mlxrunner/model/gemma4/media.go index eb8f8c68a..40103101d 100644 --- a/x/models/gemma4/media.go +++ b/mlxrunner/model/gemma4/media.go @@ -5,11 +5,11 @@ import ( "fmt" "log/slog" - "github.com/ollama/ollama/x/mlxrunner/batch" - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/mlxrunner/model" - "github.com/ollama/ollama/x/mlxrunner/model/base" - "github.com/ollama/ollama/x/models/nn" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlxrunner/batch" + "github.com/ollama/ollama/mlxrunner/model" + "github.com/ollama/ollama/mlxrunner/model/base" + "github.com/ollama/ollama/mlxrunner/nn" ) // multimodalConfig carries the top-level config.json fields the text_config diff --git a/x/models/gemma4/media_test.go b/mlxrunner/model/gemma4/media_test.go similarity index 97% rename from x/models/gemma4/media_test.go rename to mlxrunner/model/gemma4/media_test.go index 31cabb1e9..2b41e5e1a 100644 --- a/x/models/gemma4/media_test.go +++ b/mlxrunner/model/gemma4/media_test.go @@ -6,11 +6,11 @@ import ( "image/png" "testing" - "github.com/ollama/ollama/x/internal/mlxtest" + "github.com/ollama/ollama/mlx/mlxtest" - "github.com/ollama/ollama/x/mlxrunner/batch" - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/mlxrunner/model/base" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlxrunner/batch" + "github.com/ollama/ollama/mlxrunner/model/base" ) func TestParseMultimodalConfig(t *testing.T) { diff --git a/x/models/gemma4/process_audio.go b/mlxrunner/model/gemma4/process_audio.go similarity index 99% rename from x/models/gemma4/process_audio.go rename to mlxrunner/model/gemma4/process_audio.go index 62658ce25..225060fba 100644 --- a/x/models/gemma4/process_audio.go +++ b/mlxrunner/model/gemma4/process_audio.go @@ -6,7 +6,7 @@ import ( "math/cmplx" "sync" - "github.com/ollama/ollama/x/mlxrunner/model/audio" + "github.com/ollama/ollama/mlxrunner/model/audio" ) // Audio front-end constants from the reference Gemma4AudioFeatureExtractor diff --git a/x/models/gemma4/process_audio_test.go b/mlxrunner/model/gemma4/process_audio_test.go similarity index 100% rename from x/models/gemma4/process_audio_test.go rename to mlxrunner/model/gemma4/process_audio_test.go diff --git a/x/models/gemma4/process_image.go b/mlxrunner/model/gemma4/process_image.go similarity index 100% rename from x/models/gemma4/process_image.go rename to mlxrunner/model/gemma4/process_image.go diff --git a/x/models/gemma4/vision.go b/mlxrunner/model/gemma4/vision.go similarity index 99% rename from x/models/gemma4/vision.go rename to mlxrunner/model/gemma4/vision.go index ed2f8a0bb..aee4400e5 100644 --- a/x/models/gemma4/vision.go +++ b/mlxrunner/model/gemma4/vision.go @@ -6,9 +6,9 @@ import ( "slices" "strings" - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/mlxrunner/model" - "github.com/ollama/ollama/x/models/nn" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlxrunner/model" + "github.com/ollama/ollama/mlxrunner/nn" ) // VisionConfig holds configuration for the Gemma 4 vision path: the diff --git a/x/models/gemma4/vision_test.go b/mlxrunner/model/gemma4/vision_test.go similarity index 98% rename from x/models/gemma4/vision_test.go rename to mlxrunner/model/gemma4/vision_test.go index b999f32da..23bce1146 100644 --- a/x/models/gemma4/vision_test.go +++ b/mlxrunner/model/gemma4/vision_test.go @@ -6,10 +6,10 @@ import ( "slices" "testing" - "github.com/ollama/ollama/x/internal/mlxtest" + "github.com/ollama/ollama/mlx/mlxtest" - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/models/nn" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlxrunner/nn" ) func TestVisionTargetSize(t *testing.T) { diff --git a/x/models/glimmer/glimmer.go b/mlxrunner/model/glimmer/glimmer.go similarity index 98% rename from x/models/glimmer/glimmer.go rename to mlxrunner/model/glimmer/glimmer.go index 5098b8811..557f304fc 100644 --- a/x/models/glimmer/glimmer.go +++ b/mlxrunner/model/glimmer/glimmer.go @@ -7,13 +7,13 @@ import ( "math" "slices" - "github.com/ollama/ollama/x/mlxrunner/batch" - "github.com/ollama/ollama/x/mlxrunner/cache" - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/mlxrunner/model" - "github.com/ollama/ollama/x/mlxrunner/model/base" - "github.com/ollama/ollama/x/models/nn" - "github.com/ollama/ollama/x/tokenizer" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlxrunner/batch" + "github.com/ollama/ollama/mlxrunner/cache" + "github.com/ollama/ollama/mlxrunner/model" + "github.com/ollama/ollama/mlxrunner/model/base" + "github.com/ollama/ollama/mlxrunner/nn" + "github.com/ollama/ollama/mlxrunner/tokenizer" ) func init() { diff --git a/x/models/glimmer/glimmer_test.go b/mlxrunner/model/glimmer/glimmer_test.go similarity index 97% rename from x/models/glimmer/glimmer_test.go rename to mlxrunner/model/glimmer/glimmer_test.go index 3827f006e..d1c35ee8f 100644 --- a/x/models/glimmer/glimmer_test.go +++ b/mlxrunner/model/glimmer/glimmer_test.go @@ -8,11 +8,11 @@ import ( "strings" "testing" - "github.com/ollama/ollama/x/internal/mlxtest" - "github.com/ollama/ollama/x/mlxrunner/cache" - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/models/nn" - "github.com/ollama/ollama/x/tokenizer" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlx/mlxtest" + "github.com/ollama/ollama/mlxrunner/cache" + "github.com/ollama/ollama/mlxrunner/nn" + "github.com/ollama/ollama/mlxrunner/tokenizer" ) func testConfig() Config { diff --git a/x/models/glimmer/media.go b/mlxrunner/model/glimmer/media.go similarity index 97% rename from x/models/glimmer/media.go rename to mlxrunner/model/glimmer/media.go index 97ea6f2d4..803c3d85d 100644 --- a/x/models/glimmer/media.go +++ b/mlxrunner/model/glimmer/media.go @@ -11,9 +11,9 @@ import ( "golang.org/x/image/draw" - "github.com/ollama/ollama/x/mlxrunner/batch" - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/mlxrunner/model/base" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlxrunner/batch" + "github.com/ollama/ollama/mlxrunner/model/base" ) // The reference processor uses the full 4096-token budget for still images. diff --git a/x/models/glimmer/media_test.go b/mlxrunner/model/glimmer/media_test.go similarity index 97% rename from x/models/glimmer/media_test.go rename to mlxrunner/model/glimmer/media_test.go index 380fcf0de..0c027db7f 100644 --- a/x/models/glimmer/media_test.go +++ b/mlxrunner/model/glimmer/media_test.go @@ -6,7 +6,7 @@ import ( "image/png" "testing" - "github.com/ollama/ollama/x/mlxrunner/model/base" + "github.com/ollama/ollama/mlxrunner/model/base" ) func testVisionModel() *Model { diff --git a/x/models/glimmer/vision.go b/mlxrunner/model/glimmer/vision.go similarity index 99% rename from x/models/glimmer/vision.go rename to mlxrunner/model/glimmer/vision.go index 737e8e6f5..d13f31160 100644 --- a/x/models/glimmer/vision.go +++ b/mlxrunner/model/glimmer/vision.go @@ -4,9 +4,9 @@ import ( "fmt" "math" - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/mlxrunner/model" - "github.com/ollama/ollama/x/models/nn" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlxrunner/model" + "github.com/ollama/ollama/mlxrunner/nn" ) type VisionEncoder struct { diff --git a/x/models/glm4_moe_lite/config_test.go b/mlxrunner/model/glm4_moe_lite/config_test.go similarity index 96% rename from x/models/glm4_moe_lite/config_test.go rename to mlxrunner/model/glm4_moe_lite/config_test.go index a8d932648..36c676ad3 100644 --- a/x/models/glm4_moe_lite/config_test.go +++ b/mlxrunner/model/glm4_moe_lite/config_test.go @@ -5,8 +5,8 @@ import ( "math" "testing" - "github.com/ollama/ollama/x/internal/mlxtest" - "github.com/ollama/ollama/x/mlxrunner/mlx" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlx/mlxtest" ) func TestConfigNestedRopeTheta(t *testing.T) { diff --git a/x/models/glm4_moe_lite/glm4_moe_lite.go b/mlxrunner/model/glm4_moe_lite/glm4_moe_lite.go similarity index 98% rename from x/models/glm4_moe_lite/glm4_moe_lite.go rename to mlxrunner/model/glm4_moe_lite/glm4_moe_lite.go index 911934675..de6efdf84 100644 --- a/x/models/glm4_moe_lite/glm4_moe_lite.go +++ b/mlxrunner/model/glm4_moe_lite/glm4_moe_lite.go @@ -7,13 +7,13 @@ import ( "fmt" "math" - "github.com/ollama/ollama/x/mlxrunner/batch" - "github.com/ollama/ollama/x/mlxrunner/cache" - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/mlxrunner/model" - "github.com/ollama/ollama/x/mlxrunner/model/base" - "github.com/ollama/ollama/x/models/nn" - "github.com/ollama/ollama/x/tokenizer" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlxrunner/batch" + "github.com/ollama/ollama/mlxrunner/cache" + "github.com/ollama/ollama/mlxrunner/model" + "github.com/ollama/ollama/mlxrunner/model/base" + "github.com/ollama/ollama/mlxrunner/nn" + "github.com/ollama/ollama/mlxrunner/tokenizer" ) func init() { diff --git a/x/models/glm4_moe_lite/parser.go b/mlxrunner/model/glm4_moe_lite/parser.go similarity index 100% rename from x/models/glm4_moe_lite/parser.go rename to mlxrunner/model/glm4_moe_lite/parser.go diff --git a/x/models/glm4_moe_lite/parser_test.go b/mlxrunner/model/glm4_moe_lite/parser_test.go similarity index 100% rename from x/models/glm4_moe_lite/parser_test.go rename to mlxrunner/model/glm4_moe_lite/parser_test.go diff --git a/x/models/glm4_moe_lite/render.go b/mlxrunner/model/glm4_moe_lite/render.go similarity index 100% rename from x/models/glm4_moe_lite/render.go rename to mlxrunner/model/glm4_moe_lite/render.go diff --git a/x/models/glm4_moe_lite/render_test.go b/mlxrunner/model/glm4_moe_lite/render_test.go similarity index 100% rename from x/models/glm4_moe_lite/render_test.go rename to mlxrunner/model/glm4_moe_lite/render_test.go diff --git a/x/models/laguna/laguna.go b/mlxrunner/model/laguna/laguna.go similarity index 99% rename from x/models/laguna/laguna.go rename to mlxrunner/model/laguna/laguna.go index 202df40c4..e1e353cf9 100644 --- a/x/models/laguna/laguna.go +++ b/mlxrunner/model/laguna/laguna.go @@ -8,13 +8,13 @@ import ( "slices" "strings" - "github.com/ollama/ollama/x/mlxrunner/batch" - "github.com/ollama/ollama/x/mlxrunner/cache" - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/mlxrunner/model" - "github.com/ollama/ollama/x/mlxrunner/model/base" - "github.com/ollama/ollama/x/models/nn" - "github.com/ollama/ollama/x/tokenizer" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlxrunner/batch" + "github.com/ollama/ollama/mlxrunner/cache" + "github.com/ollama/ollama/mlxrunner/model" + "github.com/ollama/ollama/mlxrunner/model/base" + "github.com/ollama/ollama/mlxrunner/nn" + "github.com/ollama/ollama/mlxrunner/tokenizer" ) func init() { diff --git a/x/models/laguna/laguna_test.go b/mlxrunner/model/laguna/laguna_test.go similarity index 99% rename from x/models/laguna/laguna_test.go rename to mlxrunner/model/laguna/laguna_test.go index 02c727300..ecbcd9353 100644 --- a/x/models/laguna/laguna_test.go +++ b/mlxrunner/model/laguna/laguna_test.go @@ -5,11 +5,11 @@ import ( "strings" "testing" - "github.com/ollama/ollama/x/internal/mlxtest" - "github.com/ollama/ollama/x/mlxrunner/batch" - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/mlxrunner/model" - "github.com/ollama/ollama/x/models/nn" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlx/mlxtest" + "github.com/ollama/ollama/mlxrunner/batch" + "github.com/ollama/ollama/mlxrunner/model" + "github.com/ollama/ollama/mlxrunner/nn" ) func TestParseConfigLagunaXS(t *testing.T) { diff --git a/x/mlxrunner/model/linear.go b/mlxrunner/model/linear.go similarity index 96% rename from x/mlxrunner/model/linear.go rename to mlxrunner/model/linear.go index 34dbfe8b4..bbc0eb26d 100644 --- a/x/mlxrunner/model/linear.go +++ b/mlxrunner/model/linear.go @@ -1,8 +1,8 @@ package model import ( - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/models/nn" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlxrunner/nn" ) // LinearFactory builds linear layers using shared tensor maps and quant defaults. diff --git a/x/models/llama/llama.go b/mlxrunner/model/llama/llama.go similarity index 96% rename from x/models/llama/llama.go rename to mlxrunner/model/llama/llama.go index d38b68e4d..8b2d62374 100644 --- a/x/models/llama/llama.go +++ b/mlxrunner/model/llama/llama.go @@ -6,13 +6,13 @@ import ( "fmt" "math" - "github.com/ollama/ollama/x/mlxrunner/batch" - "github.com/ollama/ollama/x/mlxrunner/cache" - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/mlxrunner/model" - "github.com/ollama/ollama/x/mlxrunner/model/base" - "github.com/ollama/ollama/x/models/nn" - "github.com/ollama/ollama/x/tokenizer" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlxrunner/batch" + "github.com/ollama/ollama/mlxrunner/cache" + "github.com/ollama/ollama/mlxrunner/model" + "github.com/ollama/ollama/mlxrunner/model/base" + "github.com/ollama/ollama/mlxrunner/nn" + "github.com/ollama/ollama/mlxrunner/tokenizer" ) func init() { diff --git a/x/models/nemotron_h/nemotron_h.go b/mlxrunner/model/nemotron_h/nemotron_h.go similarity index 99% rename from x/models/nemotron_h/nemotron_h.go rename to mlxrunner/model/nemotron_h/nemotron_h.go index a64efe8e0..ce7e27af3 100644 --- a/x/models/nemotron_h/nemotron_h.go +++ b/mlxrunner/model/nemotron_h/nemotron_h.go @@ -9,13 +9,13 @@ import ( "strconv" "strings" - "github.com/ollama/ollama/x/mlxrunner/batch" - "github.com/ollama/ollama/x/mlxrunner/cache" - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/mlxrunner/model" - "github.com/ollama/ollama/x/mlxrunner/model/base" - "github.com/ollama/ollama/x/models/nn" - "github.com/ollama/ollama/x/tokenizer" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlxrunner/batch" + "github.com/ollama/ollama/mlxrunner/cache" + "github.com/ollama/ollama/mlxrunner/model" + "github.com/ollama/ollama/mlxrunner/model/base" + "github.com/ollama/ollama/mlxrunner/nn" + "github.com/ollama/ollama/mlxrunner/tokenizer" ) func init() { diff --git a/x/models/nemotron_h/nemotron_h_test.go b/mlxrunner/model/nemotron_h/nemotron_h_test.go similarity index 98% rename from x/models/nemotron_h/nemotron_h_test.go rename to mlxrunner/model/nemotron_h/nemotron_h_test.go index 1d3d404d3..2b0e46627 100644 --- a/x/models/nemotron_h/nemotron_h_test.go +++ b/mlxrunner/model/nemotron_h/nemotron_h_test.go @@ -6,10 +6,10 @@ import ( "strings" "testing" - "github.com/ollama/ollama/x/internal/mlxtest" - "github.com/ollama/ollama/x/mlxrunner/cache" - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/models/nn" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlx/mlxtest" + "github.com/ollama/ollama/mlxrunner/cache" + "github.com/ollama/ollama/mlxrunner/nn" ) func TestParseConfigNestedWrapper(t *testing.T) { diff --git a/x/mlxrunner/model/quant.go b/mlxrunner/model/quant.go similarity index 97% rename from x/mlxrunner/model/quant.go rename to mlxrunner/model/quant.go index 611b9e6b9..99bab3771 100644 --- a/x/mlxrunner/model/quant.go +++ b/mlxrunner/model/quant.go @@ -1,8 +1,8 @@ package model import ( - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/quant" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlx/quant" ) // Import rewrites every vendor spelling to ".global_scale"; "_scale_2" is @@ -92,7 +92,7 @@ func SameGlobalScales(a, b *mlx.Array) bool { } // QuantizationParams returns default groupSize, bits, and mode for a -// quantization type. The values live in the shared x/quant package so the +// quantization type. The values live in the shared mlx/quant package so the // importer, the runtime loader, and `ollama show` agree on them. func QuantizationParams(quantization string) (groupSize, bits int, mode string) { return quant.Params(quantization) diff --git a/x/mlxrunner/model/quant_global_scale_test.go b/mlxrunner/model/quant_global_scale_test.go similarity index 98% rename from x/mlxrunner/model/quant_global_scale_test.go rename to mlxrunner/model/quant_global_scale_test.go index c19af46e9..72c9424fa 100644 --- a/x/mlxrunner/model/quant_global_scale_test.go +++ b/mlxrunner/model/quant_global_scale_test.go @@ -5,8 +5,8 @@ import ( "slices" "testing" - "github.com/ollama/ollama/x/internal/mlxtest" - "github.com/ollama/ollama/x/mlxrunner/mlx" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlx/mlxtest" ) // ToMLXGlobalScale converts and flattens; PrepareGatherQMMGlobalScale only diff --git a/x/models/qwen3/qwen3.go b/mlxrunner/model/qwen3/qwen3.go similarity index 97% rename from x/models/qwen3/qwen3.go rename to mlxrunner/model/qwen3/qwen3.go index ba78bc1f4..f87b4ff17 100644 --- a/x/models/qwen3/qwen3.go +++ b/mlxrunner/model/qwen3/qwen3.go @@ -6,13 +6,13 @@ import ( "fmt" "math" - "github.com/ollama/ollama/x/mlxrunner/batch" - "github.com/ollama/ollama/x/mlxrunner/cache" - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/mlxrunner/model" - "github.com/ollama/ollama/x/mlxrunner/model/base" - "github.com/ollama/ollama/x/models/nn" - "github.com/ollama/ollama/x/tokenizer" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlxrunner/batch" + "github.com/ollama/ollama/mlxrunner/cache" + "github.com/ollama/ollama/mlxrunner/model" + "github.com/ollama/ollama/mlxrunner/model/base" + "github.com/ollama/ollama/mlxrunner/nn" + "github.com/ollama/ollama/mlxrunner/tokenizer" ) func init() { diff --git a/x/models/qwen3_5/gdn_projections.go b/mlxrunner/model/qwen3_5/gdn_projections.go similarity index 98% rename from x/models/qwen3_5/gdn_projections.go rename to mlxrunner/model/qwen3_5/gdn_projections.go index 1deb3dcdd..3f246b7df 100644 --- a/x/models/qwen3_5/gdn_projections.go +++ b/mlxrunner/model/qwen3_5/gdn_projections.go @@ -4,8 +4,8 @@ import ( "fmt" "log/slog" - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/models/nn" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlxrunner/nn" ) // The runtime keeps one layout for the linear-attention input projections: diff --git a/x/models/qwen3_5/gdn_projections_test.go b/mlxrunner/model/qwen3_5/gdn_projections_test.go similarity index 97% rename from x/models/qwen3_5/gdn_projections_test.go rename to mlxrunner/model/qwen3_5/gdn_projections_test.go index 0b9203c90..a54e8b603 100644 --- a/x/models/qwen3_5/gdn_projections_test.go +++ b/mlxrunner/model/qwen3_5/gdn_projections_test.go @@ -4,9 +4,9 @@ import ( "math" "testing" - "github.com/ollama/ollama/x/internal/mlxtest" - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/models/nn" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlx/mlxtest" + "github.com/ollama/ollama/mlxrunner/nn" ) func gdnTestConfig() *Config { diff --git a/x/models/qwen3_5/process_image.go b/mlxrunner/model/qwen3_5/process_image.go similarity index 100% rename from x/models/qwen3_5/process_image.go rename to mlxrunner/model/qwen3_5/process_image.go diff --git a/x/models/qwen3_5/qwen3_5.go b/mlxrunner/model/qwen3_5/qwen3_5.go similarity index 99% rename from x/models/qwen3_5/qwen3_5.go rename to mlxrunner/model/qwen3_5/qwen3_5.go index 85a7a03bd..ecf06f3a7 100644 --- a/x/models/qwen3_5/qwen3_5.go +++ b/mlxrunner/model/qwen3_5/qwen3_5.go @@ -8,13 +8,13 @@ import ( "math" "strings" - "github.com/ollama/ollama/x/mlxrunner/batch" - "github.com/ollama/ollama/x/mlxrunner/cache" - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/mlxrunner/model" - "github.com/ollama/ollama/x/mlxrunner/model/base" - "github.com/ollama/ollama/x/models/nn" - "github.com/ollama/ollama/x/tokenizer" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlxrunner/batch" + "github.com/ollama/ollama/mlxrunner/cache" + "github.com/ollama/ollama/mlxrunner/model" + "github.com/ollama/ollama/mlxrunner/model/base" + "github.com/ollama/ollama/mlxrunner/nn" + "github.com/ollama/ollama/mlxrunner/tokenizer" ) func init() { diff --git a/x/models/qwen3_5/qwen3_5_test.go b/mlxrunner/model/qwen3_5/qwen3_5_test.go similarity index 99% rename from x/models/qwen3_5/qwen3_5_test.go rename to mlxrunner/model/qwen3_5/qwen3_5_test.go index b667567a4..5db6ce87a 100644 --- a/x/models/qwen3_5/qwen3_5_test.go +++ b/mlxrunner/model/qwen3_5/qwen3_5_test.go @@ -4,9 +4,9 @@ import ( "math" "testing" - "github.com/ollama/ollama/x/internal/mlxtest" - "github.com/ollama/ollama/x/mlxrunner/cache" - "github.com/ollama/ollama/x/mlxrunner/mlx" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlx/mlxtest" + "github.com/ollama/ollama/mlxrunner/cache" ) func TestSanitizeConvWeight(t *testing.T) { diff --git a/x/models/qwen3_5/vision.go b/mlxrunner/model/qwen3_5/vision.go similarity index 98% rename from x/models/qwen3_5/vision.go rename to mlxrunner/model/qwen3_5/vision.go index df664b4df..1c41591e4 100644 --- a/x/models/qwen3_5/vision.go +++ b/mlxrunner/model/qwen3_5/vision.go @@ -5,11 +5,11 @@ import ( "fmt" "math" - "github.com/ollama/ollama/x/mlxrunner/batch" - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/mlxrunner/model" - "github.com/ollama/ollama/x/mlxrunner/model/base" - "github.com/ollama/ollama/x/models/nn" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlxrunner/batch" + "github.com/ollama/ollama/mlxrunner/model" + "github.com/ollama/ollama/mlxrunner/model/base" + "github.com/ollama/ollama/mlxrunner/nn" ) // VisionConfig holds the qwen3.5 vision tower configuration. diff --git a/x/models/qwen3_5/vision_test.go b/mlxrunner/model/qwen3_5/vision_test.go similarity index 97% rename from x/models/qwen3_5/vision_test.go rename to mlxrunner/model/qwen3_5/vision_test.go index 0099a84a7..9668df77b 100644 --- a/x/models/qwen3_5/vision_test.go +++ b/mlxrunner/model/qwen3_5/vision_test.go @@ -7,9 +7,9 @@ import ( "strings" "testing" - "github.com/ollama/ollama/x/internal/mlxtest" - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/mlxrunner/model/base" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlx/mlxtest" + "github.com/ollama/ollama/mlxrunner/model/base" ) func TestVisionAdapterWeightsAreCollectable(t *testing.T) { diff --git a/x/models/qwen3_5_moe/qwen3_5_moe.go b/mlxrunner/model/qwen3_5_moe/qwen3_5_moe.go similarity index 78% rename from x/models/qwen3_5_moe/qwen3_5_moe.go rename to mlxrunner/model/qwen3_5_moe/qwen3_5_moe.go index a505b458e..8975b2ad8 100644 --- a/x/models/qwen3_5_moe/qwen3_5_moe.go +++ b/mlxrunner/model/qwen3_5_moe/qwen3_5_moe.go @@ -2,8 +2,8 @@ package qwen3_5_moe import ( - "github.com/ollama/ollama/x/mlxrunner/model/base" - "github.com/ollama/ollama/x/models/qwen3_5" + "github.com/ollama/ollama/mlxrunner/model/base" + "github.com/ollama/ollama/mlxrunner/model/qwen3_5" ) func init() { diff --git a/x/models/qwen4_exp/blocks.go b/mlxrunner/model/qwen4_exp/blocks.go similarity index 97% rename from x/models/qwen4_exp/blocks.go rename to mlxrunner/model/qwen4_exp/blocks.go index f48046762..760c36751 100644 --- a/x/models/qwen4_exp/blocks.go +++ b/mlxrunner/model/qwen4_exp/blocks.go @@ -3,10 +3,10 @@ package qwen4_exp import ( "math" - "github.com/ollama/ollama/x/mlxrunner/batch" - "github.com/ollama/ollama/x/mlxrunner/cache" - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/models/nn" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlxrunner/batch" + "github.com/ollama/ollama/mlxrunner/cache" + "github.com/ollama/ollama/mlxrunner/nn" ) func (l *Layer) Forward(x *mlx.Array, b *batch.Batch, c, side cache.Cache, positions, ropePositions *mlx.Array, cfg *Config) *mlx.Array { diff --git a/x/models/qwen4_exp/config.go b/mlxrunner/model/qwen4_exp/config.go similarity index 100% rename from x/models/qwen4_exp/config.go rename to mlxrunner/model/qwen4_exp/config.go diff --git a/x/models/qwen4_exp/config_test.go b/mlxrunner/model/qwen4_exp/config_test.go similarity index 100% rename from x/models/qwen4_exp/config_test.go rename to mlxrunner/model/qwen4_exp/config_test.go diff --git a/x/models/qwen4_exp/engram.go b/mlxrunner/model/qwen4_exp/engram.go similarity index 98% rename from x/models/qwen4_exp/engram.go rename to mlxrunner/model/qwen4_exp/engram.go index 1e6f5d8c9..ddb787304 100644 --- a/x/models/qwen4_exp/engram.go +++ b/mlxrunner/model/qwen4_exp/engram.go @@ -3,8 +3,8 @@ package qwen4_exp import ( "math" - "github.com/ollama/ollama/x/mlxrunner/batch" - "github.com/ollama/ollama/x/mlxrunner/mlx" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlxrunner/batch" ) func (n *streamRMSNorm) Forward(x *mlx.Array, eps float32) *mlx.Array { diff --git a/x/models/qwen4_exp/engram_cache.go b/mlxrunner/model/qwen4_exp/engram_cache.go similarity index 97% rename from x/models/qwen4_exp/engram_cache.go rename to mlxrunner/model/qwen4_exp/engram_cache.go index 1cfce5d98..cc840a52b 100644 --- a/x/models/qwen4_exp/engram_cache.go +++ b/mlxrunner/model/qwen4_exp/engram_cache.go @@ -3,9 +3,9 @@ package qwen4_exp import ( "fmt" - "github.com/ollama/ollama/x/mlxrunner/batch" - "github.com/ollama/ollama/x/mlxrunner/cache" - "github.com/ollama/ollama/x/mlxrunner/mlx" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlxrunner/batch" + "github.com/ollama/ollama/mlxrunner/cache" ) // engramCache keeps the two raw token IDs and nine normalized diff --git a/x/models/qwen4_exp/engram_test.go b/mlxrunner/model/qwen4_exp/engram_test.go similarity index 96% rename from x/models/qwen4_exp/engram_test.go rename to mlxrunner/model/qwen4_exp/engram_test.go index f356e911c..0b7a3ce93 100644 --- a/x/models/qwen4_exp/engram_test.go +++ b/mlxrunner/model/qwen4_exp/engram_test.go @@ -4,9 +4,9 @@ import ( "slices" "testing" - "github.com/ollama/ollama/x/internal/mlxtest" - "github.com/ollama/ollama/x/mlxrunner/batch" - "github.com/ollama/ollama/x/mlxrunner/mlx" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlx/mlxtest" + "github.com/ollama/ollama/mlxrunner/batch" ) func TestEngramHashes(t *testing.T) { diff --git a/x/models/qwen4_exp/hyper_connection.go b/mlxrunner/model/qwen4_exp/hyper_connection.go similarity index 97% rename from x/models/qwen4_exp/hyper_connection.go rename to mlxrunner/model/qwen4_exp/hyper_connection.go index 85c1c3421..333b3af9f 100644 --- a/x/models/qwen4_exp/hyper_connection.go +++ b/mlxrunner/model/qwen4_exp/hyper_connection.go @@ -1,6 +1,6 @@ package qwen4_exp -import "github.com/ollama/ollama/x/mlxrunner/mlx" +import "github.com/ollama/ollama/mlx" type hyperConnectionState struct { residual *mlx.Array diff --git a/x/models/qwen4_exp/hyper_connection_test.go b/mlxrunner/model/qwen4_exp/hyper_connection_test.go similarity index 96% rename from x/models/qwen4_exp/hyper_connection_test.go rename to mlxrunner/model/qwen4_exp/hyper_connection_test.go index e6c93950b..4564da917 100644 --- a/x/models/qwen4_exp/hyper_connection_test.go +++ b/mlxrunner/model/qwen4_exp/hyper_connection_test.go @@ -4,9 +4,9 @@ import ( "math" "testing" - "github.com/ollama/ollama/x/internal/mlxtest" - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/models/nn" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlx/mlxtest" + "github.com/ollama/ollama/mlxrunner/nn" ) func TestHyperConnectionMatchesReferenceFormula(t *testing.T) { diff --git a/x/models/qwen4_exp/qsa.go b/mlxrunner/model/qwen4_exp/qsa.go similarity index 98% rename from x/models/qwen4_exp/qsa.go rename to mlxrunner/model/qwen4_exp/qsa.go index f70040082..5f8e3cf13 100644 --- a/x/models/qwen4_exp/qsa.go +++ b/mlxrunner/model/qwen4_exp/qsa.go @@ -3,9 +3,9 @@ package qwen4_exp import ( "math" - "github.com/ollama/ollama/x/mlxrunner/batch" - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/models/nn" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlxrunner/batch" + "github.com/ollama/ollama/mlxrunner/nn" ) // canonicalRopePositionRows returns exact [B, 1, L, 3] position rows. MRoPE diff --git a/x/models/qwen4_exp/qsa_test.go b/mlxrunner/model/qwen4_exp/qsa_test.go similarity index 95% rename from x/models/qwen4_exp/qsa_test.go rename to mlxrunner/model/qwen4_exp/qsa_test.go index f86dde497..10046a52a 100644 --- a/x/models/qwen4_exp/qsa_test.go +++ b/mlxrunner/model/qwen4_exp/qsa_test.go @@ -5,10 +5,10 @@ import ( "slices" "testing" - "github.com/ollama/ollama/x/internal/mlxtest" - "github.com/ollama/ollama/x/mlxrunner/batch" - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/models/nn" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlx/mlxtest" + "github.com/ollama/ollama/mlxrunner/batch" + "github.com/ollama/ollama/mlxrunner/nn" ) func TestQSASelectsCompressedBlocksAndCausalTail(t *testing.T) { diff --git a/x/models/qwen4_exp/qwen4_exp.go b/mlxrunner/model/qwen4_exp/qwen4_exp.go similarity index 95% rename from x/models/qwen4_exp/qwen4_exp.go rename to mlxrunner/model/qwen4_exp/qwen4_exp.go index 069ca2eba..88df62a15 100644 --- a/x/models/qwen4_exp/qwen4_exp.go +++ b/mlxrunner/model/qwen4_exp/qwen4_exp.go @@ -4,14 +4,14 @@ package qwen4_exp import ( "fmt" - "github.com/ollama/ollama/x/mlxrunner/batch" - "github.com/ollama/ollama/x/mlxrunner/cache" - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/mlxrunner/model" - "github.com/ollama/ollama/x/mlxrunner/model/base" - "github.com/ollama/ollama/x/models/nn" - "github.com/ollama/ollama/x/models/qwen3_5" - "github.com/ollama/ollama/x/tokenizer" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlxrunner/batch" + "github.com/ollama/ollama/mlxrunner/cache" + "github.com/ollama/ollama/mlxrunner/model" + "github.com/ollama/ollama/mlxrunner/model/base" + "github.com/ollama/ollama/mlxrunner/model/qwen3_5" + "github.com/ollama/ollama/mlxrunner/nn" + "github.com/ollama/ollama/mlxrunner/tokenizer" ) func init() { diff --git a/x/models/qwen4_exp/weights.go b/mlxrunner/model/qwen4_exp/weights.go similarity index 98% rename from x/models/qwen4_exp/weights.go rename to mlxrunner/model/qwen4_exp/weights.go index eece909c9..9efc91b3c 100644 --- a/x/models/qwen4_exp/weights.go +++ b/mlxrunner/model/qwen4_exp/weights.go @@ -3,10 +3,10 @@ package qwen4_exp import ( "fmt" - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/mlxrunner/model" - "github.com/ollama/ollama/x/models/nn" - "github.com/ollama/ollama/x/models/qwen3_5" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlxrunner/model" + "github.com/ollama/ollama/mlxrunner/model/qwen3_5" + "github.com/ollama/ollama/mlxrunner/nn" ) type hyperConnection struct { diff --git a/x/mlxrunner/model/root.go b/mlxrunner/model/root.go similarity index 100% rename from x/mlxrunner/model/root.go rename to mlxrunner/model/root.go diff --git a/x/mlxrunner/mtp.go b/mlxrunner/mtp.go similarity index 98% rename from x/mlxrunner/mtp.go rename to mlxrunner/mtp.go index aed607f31..e7e91f192 100644 --- a/x/mlxrunner/mtp.go +++ b/mlxrunner/mtp.go @@ -4,9 +4,9 @@ import ( "fmt" "slices" - "github.com/ollama/ollama/x/mlxrunner/batch" - "github.com/ollama/ollama/x/mlxrunner/mlx" - sampler "github.com/ollama/ollama/x/mlxrunner/sample" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlxrunner/batch" + sampler "github.com/ollama/ollama/mlxrunner/sample" ) // mtpPendingFlushTokens caps how many committed look-ahead tokens wait in the diff --git a/x/mlxrunner/mtp_test.go b/mlxrunner/mtp_test.go similarity index 99% rename from x/mlxrunner/mtp_test.go rename to mlxrunner/mtp_test.go index 43142fa25..45404c27f 100644 --- a/x/mlxrunner/mtp_test.go +++ b/mlxrunner/mtp_test.go @@ -12,13 +12,13 @@ import ( "time" "github.com/ollama/ollama/api" - "github.com/ollama/ollama/x/internal/mlxtest" - "github.com/ollama/ollama/x/mlxrunner/batch" - "github.com/ollama/ollama/x/mlxrunner/cache" - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/mlxrunner/model/base" - sampler "github.com/ollama/ollama/x/mlxrunner/sample" - "github.com/ollama/ollama/x/tokenizer" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlx/mlxtest" + "github.com/ollama/ollama/mlxrunner/batch" + "github.com/ollama/ollama/mlxrunner/cache" + "github.com/ollama/ollama/mlxrunner/model/base" + sampler "github.com/ollama/ollama/mlxrunner/sample" + "github.com/ollama/ollama/mlxrunner/tokenizer" ) // The MTP fakes make hidden state and logits the same tensor (Forward returns diff --git a/x/models/nn/nn.go b/mlxrunner/nn/nn.go similarity index 99% rename from x/models/nn/nn.go rename to mlxrunner/nn/nn.go index f1f2d9783..90f918faf 100644 --- a/x/models/nn/nn.go +++ b/mlxrunner/nn/nn.go @@ -1,6 +1,6 @@ package nn -import "github.com/ollama/ollama/x/mlxrunner/mlx" +import "github.com/ollama/ollama/mlx" // Layer is the interface for neural network layers with a Forward method. type Layer interface { diff --git a/x/models/nn/nn_test.go b/mlxrunner/nn/nn_test.go similarity index 98% rename from x/models/nn/nn_test.go rename to mlxrunner/nn/nn_test.go index 6d6e5c911..c31cb2db6 100644 --- a/x/models/nn/nn_test.go +++ b/mlxrunner/nn/nn_test.go @@ -4,8 +4,8 @@ import ( "math" "testing" - "github.com/ollama/ollama/x/internal/mlxtest" - "github.com/ollama/ollama/x/mlxrunner/mlx" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlx/mlxtest" ) func approxEqual(a, b, tol float32) bool { diff --git a/x/models/nn/recurrent.go b/mlxrunner/nn/recurrent.go similarity index 99% rename from x/models/nn/recurrent.go rename to mlxrunner/nn/recurrent.go index 39ed099c5..ded8b55e7 100644 --- a/x/models/nn/recurrent.go +++ b/mlxrunner/nn/recurrent.go @@ -3,8 +3,8 @@ package nn import ( "slices" - "github.com/ollama/ollama/x/mlxrunner/batch" - "github.com/ollama/ollama/x/mlxrunner/mlx" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlxrunner/batch" ) // RecurrentOption configures a call to CausalConv1D, GatedDelta or Mamba2Scan. diff --git a/x/models/nn/recurrent_test.go b/mlxrunner/nn/recurrent_test.go similarity index 99% rename from x/models/nn/recurrent_test.go rename to mlxrunner/nn/recurrent_test.go index 2860ecb0a..4eef031f0 100644 --- a/x/models/nn/recurrent_test.go +++ b/mlxrunner/nn/recurrent_test.go @@ -4,9 +4,9 @@ import ( "math" "testing" - "github.com/ollama/ollama/x/internal/mlxtest" - "github.com/ollama/ollama/x/mlxrunner/batch" - "github.com/ollama/ollama/x/mlxrunner/mlx" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlx/mlxtest" + "github.com/ollama/ollama/mlxrunner/batch" ) // lastState returns the forward-end state — the last boundary the recurrent diff --git a/x/models/nn/rope.go b/mlxrunner/nn/rope.go similarity index 98% rename from x/models/nn/rope.go rename to mlxrunner/nn/rope.go index 39d9dab19..c8ce30c7c 100644 --- a/x/models/nn/rope.go +++ b/mlxrunner/nn/rope.go @@ -3,7 +3,7 @@ package nn import ( "math" - "github.com/ollama/ollama/x/mlxrunner/mlx" + "github.com/ollama/ollama/mlx" ) // RopeParameters carries common RoPE metadata embedded in model configs. diff --git a/x/models/nn/sdpa.go b/mlxrunner/nn/sdpa.go similarity index 99% rename from x/models/nn/sdpa.go rename to mlxrunner/nn/sdpa.go index 3aaa2a908..6ead98248 100644 --- a/x/models/nn/sdpa.go +++ b/mlxrunner/nn/sdpa.go @@ -4,8 +4,8 @@ import ( "encoding/binary" "math" - "github.com/ollama/ollama/x/mlxrunner/batch" - "github.com/ollama/ollama/x/mlxrunner/mlx" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlxrunner/batch" ) // SDPAOption configures a call to ScaledDotProductAttention. diff --git a/x/models/nn/sdpa_test.go b/mlxrunner/nn/sdpa_test.go similarity index 99% rename from x/models/nn/sdpa_test.go rename to mlxrunner/nn/sdpa_test.go index b225110ea..9845c2667 100644 --- a/x/models/nn/sdpa_test.go +++ b/mlxrunner/nn/sdpa_test.go @@ -4,9 +4,9 @@ import ( "math" "testing" - "github.com/ollama/ollama/x/internal/mlxtest" - "github.com/ollama/ollama/x/mlxrunner/batch" - "github.com/ollama/ollama/x/mlxrunner/mlx" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlx/mlxtest" + "github.com/ollama/ollama/mlxrunner/batch" ) // newBatch constructs a synthetic batch for mask/SDPA tests. diff --git a/x/mlxrunner/pipeline.go b/mlxrunner/pipeline.go similarity index 98% rename from x/mlxrunner/pipeline.go rename to mlxrunner/pipeline.go index 188f3610b..05a5d6039 100644 --- a/x/mlxrunner/pipeline.go +++ b/mlxrunner/pipeline.go @@ -11,12 +11,12 @@ import ( "github.com/ollama/ollama/llm" "github.com/ollama/ollama/logutil" - "github.com/ollama/ollama/x/mlxrunner/batch" - "github.com/ollama/ollama/x/mlxrunner/cache" - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/mlxrunner/model/base" - sampler "github.com/ollama/ollama/x/mlxrunner/sample" - "github.com/ollama/ollama/x/tokenizer" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlxrunner/batch" + "github.com/ollama/ollama/mlxrunner/cache" + "github.com/ollama/ollama/mlxrunner/model/base" + sampler "github.com/ollama/ollama/mlxrunner/sample" + "github.com/ollama/ollama/mlxrunner/tokenizer" ) func prefillChunkSize() int { diff --git a/x/mlxrunner/pipeline_test.go b/mlxrunner/pipeline_test.go similarity index 96% rename from x/mlxrunner/pipeline_test.go rename to mlxrunner/pipeline_test.go index a80fce634..5d0bcf787 100644 --- a/x/mlxrunner/pipeline_test.go +++ b/mlxrunner/pipeline_test.go @@ -7,11 +7,11 @@ import ( "testing" "github.com/ollama/ollama/llm" - "github.com/ollama/ollama/x/mlxrunner/batch" - "github.com/ollama/ollama/x/mlxrunner/cache" - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/mlxrunner/model/base" - "github.com/ollama/ollama/x/tokenizer" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlxrunner/batch" + "github.com/ollama/ollama/mlxrunner/cache" + "github.com/ollama/ollama/mlxrunner/model/base" + "github.com/ollama/ollama/mlxrunner/tokenizer" ) // textOnlyModel satisfies base.Model but not base.MediaModel. diff --git a/x/mlxrunner/prefix_cache.go b/mlxrunner/prefix_cache.go similarity index 99% rename from x/mlxrunner/prefix_cache.go rename to mlxrunner/prefix_cache.go index 9a75e5761..0cf0742be 100644 --- a/x/mlxrunner/prefix_cache.go +++ b/mlxrunner/prefix_cache.go @@ -36,8 +36,8 @@ import ( "time" "github.com/ollama/ollama/logutil" - "github.com/ollama/ollama/x/mlxrunner/cache" - "github.com/ollama/ollama/x/mlxrunner/mlx" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlxrunner/cache" ) const maxPagedOutBytes int64 = 8 << 30 // 8 GiB eviction threshold for paged-out snapshot memory diff --git a/x/mlxrunner/prefix_cache_scenario_test.go b/mlxrunner/prefix_cache_scenario_test.go similarity index 99% rename from x/mlxrunner/prefix_cache_scenario_test.go rename to mlxrunner/prefix_cache_scenario_test.go index 4f560c6db..62979262f 100644 --- a/x/mlxrunner/prefix_cache_scenario_test.go +++ b/mlxrunner/prefix_cache_scenario_test.go @@ -8,7 +8,7 @@ import ( "strings" "testing" - "github.com/ollama/ollama/x/mlxrunner/cache" + "github.com/ollama/ollama/mlxrunner/cache" ) // Scenario tests drive prefixCache through multi-request timelines on the diff --git a/x/mlxrunner/prefix_cache_test.go b/mlxrunner/prefix_cache_test.go similarity index 99% rename from x/mlxrunner/prefix_cache_test.go rename to mlxrunner/prefix_cache_test.go index b870fd7ea..4beff3151 100644 --- a/x/mlxrunner/prefix_cache_test.go +++ b/mlxrunner/prefix_cache_test.go @@ -5,9 +5,9 @@ import ( "testing" "time" - "github.com/ollama/ollama/x/mlxrunner/cache" - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/mlxrunner/model/base" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlxrunner/cache" + "github.com/ollama/ollama/mlxrunner/model/base" ) // snapshotTracker records every fakeSnapshot created and every Close() call diff --git a/x/mlxrunner/runner.go b/mlxrunner/runner.go similarity index 95% rename from x/mlxrunner/runner.go rename to mlxrunner/runner.go index 4814edfd5..a8eeb9303 100644 --- a/x/mlxrunner/runner.go +++ b/mlxrunner/runner.go @@ -13,14 +13,15 @@ import ( "golang.org/x/sync/errgroup" "github.com/ollama/ollama/api" - "github.com/ollama/ollama/x/internal/mlxthread" - "github.com/ollama/ollama/x/mlxrunner/batch" - "github.com/ollama/ollama/x/mlxrunner/cache" - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/mlxrunner/model" - "github.com/ollama/ollama/x/mlxrunner/model/base" - "github.com/ollama/ollama/x/mlxrunner/sample" - "github.com/ollama/ollama/x/tokenizer" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlx/mlxthread" + "github.com/ollama/ollama/mlxrunner/batch" + "github.com/ollama/ollama/mlxrunner/cache" + "github.com/ollama/ollama/mlxrunner/model" + _ "github.com/ollama/ollama/mlxrunner/model/architectures" + "github.com/ollama/ollama/mlxrunner/model/base" + "github.com/ollama/ollama/mlxrunner/sample" + "github.com/ollama/ollama/mlxrunner/tokenizer" ) // Request is a short-lived struct that carries a completion request through diff --git a/x/mlxrunner/sample/logprob_test.go b/mlxrunner/sample/logprob_test.go similarity index 98% rename from x/mlxrunner/sample/logprob_test.go rename to mlxrunner/sample/logprob_test.go index 97abf343b..bc3aeb25a 100644 --- a/x/mlxrunner/sample/logprob_test.go +++ b/mlxrunner/sample/logprob_test.go @@ -5,8 +5,8 @@ import ( "sort" "testing" - "github.com/ollama/ollama/x/internal/mlxtest" - "github.com/ollama/ollama/x/mlxrunner/mlx" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlx/mlxtest" ) // logprobEntry is the (token id, logprob) pair returned by the sampler's diff --git a/x/mlxrunner/sample/sample.go b/mlxrunner/sample/sample.go similarity index 99% rename from x/mlxrunner/sample/sample.go rename to mlxrunner/sample/sample.go index 4e85778b4..573f026a4 100644 --- a/x/mlxrunner/sample/sample.go +++ b/mlxrunner/sample/sample.go @@ -5,7 +5,7 @@ import ( "math" "slices" - "github.com/ollama/ollama/x/mlxrunner/mlx" + "github.com/ollama/ollama/mlx" ) type Options struct { diff --git a/x/mlxrunner/sample/sample_test.go b/mlxrunner/sample/sample_test.go similarity index 99% rename from x/mlxrunner/sample/sample_test.go rename to mlxrunner/sample/sample_test.go index 30edfca80..13e2b12d5 100644 --- a/x/mlxrunner/sample/sample_test.go +++ b/mlxrunner/sample/sample_test.go @@ -5,8 +5,8 @@ import ( "slices" "testing" - "github.com/ollama/ollama/x/internal/mlxtest" - "github.com/ollama/ollama/x/mlxrunner/mlx" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlx/mlxtest" ) // slotLogits builds a [1, V] logits tensor for a single-slot Sample call. diff --git a/x/mlxrunner/server.go b/mlxrunner/server.go similarity index 97% rename from x/mlxrunner/server.go rename to mlxrunner/server.go index 0d3b6b1dd..0470f599b 100644 --- a/x/mlxrunner/server.go +++ b/mlxrunner/server.go @@ -17,9 +17,9 @@ import ( "github.com/ollama/ollama/api" "github.com/ollama/ollama/envconfig" "github.com/ollama/ollama/logutil" - "github.com/ollama/ollama/x/internal/mlxthread" - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/mlxrunner/sample" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlx/mlxthread" + "github.com/ollama/ollama/mlxrunner/sample" ) func Execute(args []string) error { diff --git a/x/mlxrunner/speculate.go b/mlxrunner/speculate.go similarity index 98% rename from x/mlxrunner/speculate.go rename to mlxrunner/speculate.go index 2aa2ca491..0f75aa6fe 100644 --- a/x/mlxrunner/speculate.go +++ b/mlxrunner/speculate.go @@ -5,11 +5,11 @@ import ( "fmt" "time" - "github.com/ollama/ollama/x/mlxrunner/batch" - "github.com/ollama/ollama/x/mlxrunner/cache" - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/mlxrunner/model/base" - sampler "github.com/ollama/ollama/x/mlxrunner/sample" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlxrunner/batch" + "github.com/ollama/ollama/mlxrunner/cache" + "github.com/ollama/ollama/mlxrunner/model/base" + sampler "github.com/ollama/ollama/mlxrunner/sample" ) // draftSession proposes speculative tokens for one request, learning the diff --git a/x/mlxrunner/speculate_depth.go b/mlxrunner/speculate_depth.go similarity index 100% rename from x/mlxrunner/speculate_depth.go rename to mlxrunner/speculate_depth.go diff --git a/x/mlxrunner/speculate_depth_test.go b/mlxrunner/speculate_depth_test.go similarity index 100% rename from x/mlxrunner/speculate_depth_test.go rename to mlxrunner/speculate_depth_test.go diff --git a/x/mlxrunner/speculate_stats.go b/mlxrunner/speculate_stats.go similarity index 100% rename from x/mlxrunner/speculate_stats.go rename to mlxrunner/speculate_stats.go diff --git a/x/mlxrunner/status_memory.go b/mlxrunner/status_memory.go similarity index 100% rename from x/mlxrunner/status_memory.go rename to mlxrunner/status_memory.go diff --git a/x/mlxrunner/status_memory_test.go b/mlxrunner/status_memory_test.go similarity index 100% rename from x/mlxrunner/status_memory_test.go rename to mlxrunner/status_memory_test.go diff --git a/tokenizer/testdata/llama3.2/encoder.json b/mlxrunner/tokenizer/testdata/llama3.2/encoder.json similarity index 100% rename from tokenizer/testdata/llama3.2/encoder.json rename to mlxrunner/tokenizer/testdata/llama3.2/encoder.json diff --git a/tokenizer/testdata/llama3.2/vocab.bpe b/mlxrunner/tokenizer/testdata/llama3.2/vocab.bpe similarity index 100% rename from tokenizer/testdata/llama3.2/vocab.bpe rename to mlxrunner/tokenizer/testdata/llama3.2/vocab.bpe diff --git a/x/tokenizer/testdata/mini_llama.json b/mlxrunner/tokenizer/testdata/mini_llama.json similarity index 100% rename from x/tokenizer/testdata/mini_llama.json rename to mlxrunner/tokenizer/testdata/mini_llama.json diff --git a/x/tokenizer/tokenizer.go b/mlxrunner/tokenizer/tokenizer.go similarity index 100% rename from x/tokenizer/tokenizer.go rename to mlxrunner/tokenizer/tokenizer.go diff --git a/x/tokenizer/tokenizer_benchmark_test.go b/mlxrunner/tokenizer/tokenizer_benchmark_test.go similarity index 100% rename from x/tokenizer/tokenizer_benchmark_test.go rename to mlxrunner/tokenizer/tokenizer_benchmark_test.go diff --git a/x/tokenizer/tokenizer_bpe.go b/mlxrunner/tokenizer/tokenizer_bpe.go similarity index 100% rename from x/tokenizer/tokenizer_bpe.go rename to mlxrunner/tokenizer/tokenizer_bpe.go diff --git a/x/tokenizer/tokenizer_correctness_test.go b/mlxrunner/tokenizer/tokenizer_correctness_test.go similarity index 100% rename from x/tokenizer/tokenizer_correctness_test.go rename to mlxrunner/tokenizer/tokenizer_correctness_test.go diff --git a/x/tokenizer/tokenizer_decode.go b/mlxrunner/tokenizer/tokenizer_decode.go similarity index 100% rename from x/tokenizer/tokenizer_decode.go rename to mlxrunner/tokenizer/tokenizer_decode.go diff --git a/x/tokenizer/tokenizer_encode.go b/mlxrunner/tokenizer/tokenizer_encode.go similarity index 100% rename from x/tokenizer/tokenizer_encode.go rename to mlxrunner/tokenizer/tokenizer_encode.go diff --git a/x/tokenizer/tokenizer_ggml_parity_test.go b/mlxrunner/tokenizer/tokenizer_ggml_parity_test.go similarity index 98% rename from x/tokenizer/tokenizer_ggml_parity_test.go rename to mlxrunner/tokenizer/tokenizer_ggml_parity_test.go index ee9b68f38..cd26fec76 100644 --- a/x/tokenizer/tokenizer_ggml_parity_test.go +++ b/mlxrunner/tokenizer/tokenizer_ggml_parity_test.go @@ -18,7 +18,7 @@ func llama32GGMLFixturePath(tb testing.TB, file string) string { tb.Fatal("failed to resolve test file path") } - return filepath.Join(filepath.Dir(filename), "..", "..", "tokenizer", "testdata", "llama3.2", file) + return filepath.Join(filepath.Dir(filename), "testdata", "llama3.2", file) } func loadLlama32FromGGMLFixture(tb testing.TB) *Tokenizer { diff --git a/x/tokenizer/tokenizer_load.go b/mlxrunner/tokenizer/tokenizer_load.go similarity index 100% rename from x/tokenizer/tokenizer_load.go rename to mlxrunner/tokenizer/tokenizer_load.go diff --git a/x/tokenizer/tokenizer_load_test.go b/mlxrunner/tokenizer/tokenizer_load_test.go similarity index 100% rename from x/tokenizer/tokenizer_load_test.go rename to mlxrunner/tokenizer/tokenizer_load_test.go diff --git a/x/mlxrunner/utf8_buffer.go b/mlxrunner/utf8_buffer.go similarity index 100% rename from x/mlxrunner/utf8_buffer.go rename to mlxrunner/utf8_buffer.go diff --git a/x/mlxrunner/utf8_buffer_test.go b/mlxrunner/utf8_buffer_test.go similarity index 100% rename from x/mlxrunner/utf8_buffer_test.go rename to mlxrunner/utf8_buffer_test.go diff --git a/x/mlxrunner/verify.go b/mlxrunner/verify.go similarity index 88% rename from x/mlxrunner/verify.go rename to mlxrunner/verify.go index e7313c65a..85bd44331 100644 --- a/x/mlxrunner/verify.go +++ b/mlxrunner/verify.go @@ -1,7 +1,7 @@ package mlxrunner import ( - "github.com/ollama/ollama/x/mlxrunner/model/base" + "github.com/ollama/ollama/mlxrunner/model/base" ) // SupportsArchitecture reports whether the MLX runner has a constructor for arch. diff --git a/x/mlxrunner/verify_test.go b/mlxrunner/verify_test.go similarity index 86% rename from x/mlxrunner/verify_test.go rename to mlxrunner/verify_test.go index 5bc543eec..35eebd0a6 100644 --- a/x/mlxrunner/verify_test.go +++ b/mlxrunner/verify_test.go @@ -3,7 +3,7 @@ package mlxrunner import ( "testing" - "github.com/ollama/ollama/x/mlxrunner/mlx" + "github.com/ollama/ollama/mlx" ) func TestCheckRuntimeRequiresLoadedLibrary(t *testing.T) { diff --git a/x/mlxrunner/xgrammar/dynamic.c b/mlxrunner/xgrammar/dynamic.c similarity index 100% rename from x/mlxrunner/xgrammar/dynamic.c rename to mlxrunner/xgrammar/dynamic.c diff --git a/x/mlxrunner/xgrammar/dynamic.h b/mlxrunner/xgrammar/dynamic.h similarity index 100% rename from x/mlxrunner/xgrammar/dynamic.h rename to mlxrunner/xgrammar/dynamic.h diff --git a/x/mlxrunner/xgrammar/native/xgrammar.cpp b/mlxrunner/xgrammar/native/xgrammar.cpp similarity index 100% rename from x/mlxrunner/xgrammar/native/xgrammar.cpp rename to mlxrunner/xgrammar/native/xgrammar.cpp diff --git a/x/mlxrunner/xgrammar/native/xgrammar.h b/mlxrunner/xgrammar/native/xgrammar.h similarity index 100% rename from x/mlxrunner/xgrammar/native/xgrammar.h rename to mlxrunner/xgrammar/native/xgrammar.h diff --git a/x/mlxrunner/xgrammar/xgrammar.go b/mlxrunner/xgrammar/xgrammar.go similarity index 100% rename from x/mlxrunner/xgrammar/xgrammar.go rename to mlxrunner/xgrammar/xgrammar.go diff --git a/x/mlxrunner/xgrammar/xgrammar_test.go b/mlxrunner/xgrammar/xgrammar_test.go similarity index 99% rename from x/mlxrunner/xgrammar/xgrammar_test.go rename to mlxrunner/xgrammar/xgrammar_test.go index ddb4fd50d..3bb771888 100644 --- a/x/mlxrunner/xgrammar/xgrammar_test.go +++ b/mlxrunner/xgrammar/xgrammar_test.go @@ -8,8 +8,8 @@ import ( "strings" "testing" - "github.com/ollama/ollama/x/mlxrunner/mlx" - "github.com/ollama/ollama/x/mlxrunner/xgrammar" + "github.com/ollama/ollama/mlx" + "github.com/ollama/ollama/mlxrunner/xgrammar" ) const ( diff --git a/model/renderers/qwen38_test.go b/model/renderers/qwen38_test.go index 971e5e776..3d3c93bae 100644 --- a/model/renderers/qwen38_test.go +++ b/model/renderers/qwen38_test.go @@ -10,7 +10,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/ollama/ollama/api" - "github.com/ollama/ollama/x/tokenizer" + "github.com/ollama/ollama/mlxrunner/tokenizer" ) const ( diff --git a/server/create.go b/server/create.go index 991cb0008..45c39f139 100644 --- a/server/create.go +++ b/server/create.go @@ -24,15 +24,15 @@ import ( "github.com/gin-gonic/gin" "github.com/ollama/ollama/api" + "github.com/ollama/ollama/create" "github.com/ollama/ollama/envconfig" "github.com/ollama/ollama/format" "github.com/ollama/ollama/fs/gguf" "github.com/ollama/ollama/manifest" + "github.com/ollama/ollama/mlx/quant" + "github.com/ollama/ollama/mlxrunner" "github.com/ollama/ollama/types/errtypes" "github.com/ollama/ollama/types/model" - xcreate "github.com/ollama/ollama/x/create" - "github.com/ollama/ollama/x/mlxrunner" - "github.com/ollama/ollama/x/quant" ) var ( @@ -87,7 +87,7 @@ func (s *Server) CreateHandler(c *gin.Context) { c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": errAdaptersUnsupported.Error()}) return } - if _, err := xcreate.LicenseStrings(r.License); err != nil { + if _, err := create.LicenseStrings(r.License); err != nil { c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": err.Error()}) return } @@ -257,7 +257,7 @@ func (s *Server) CreateHandler(c *gin.Context) { } if err := createModel(reqCtx, r, name, baseLayers, config, fn); err != nil { - if errors.Is(err, xcreate.ErrBadTemplate) || errors.Is(err, xcreate.ErrInvalidRequires) || errors.Is(err, xcreate.ErrInvalidLicense) || errors.Is(err, errInvalidSplitGGUF) { + if errors.Is(err, create.ErrBadTemplate) || errors.Is(err, create.ErrInvalidRequires) || errors.Is(err, create.ErrInvalidLicense) || errors.Is(err, errInvalidSplitGGUF) { send(gin.H{"error": err.Error(), "status": http.StatusBadRequest}) return } @@ -297,7 +297,7 @@ func recoverCreatePanic(send func(any) bool) { } // createSafetensorsModel imports uploaded raw safetensors source files by -// staging them as a normal model directory and running the shared x/create +// staging them as a normal model directory and running the shared create // pipeline on the server. func createSafetensorsModel(ctx context.Context, r api.CreateRequest, name model.Name, fn func(resp api.ProgressResponse)) error { if len(r.Files) == 0 { @@ -326,7 +326,7 @@ func createSafetensorsModel(ctx context.Context, r api.CreateRequest, name model progressFn := func(status string) { fn(api.ProgressResponse{Status: status}) } - store := xcreate.ManifestBlobStore{} + store := create.ManifestBlobStore{} var draftDir string var draftCleanup func() @@ -341,7 +341,7 @@ func createSafetensorsModel(ctx context.Context, r api.CreateRequest, name model defer draftCleanup() } - return xcreate.Create(ctx, name.String(), modelDir, xcreate.PipelineOptions{ + return create.Create(ctx, name.String(), modelDir, create.PipelineOptions{ Quantize: cmp.Or(r.Quantize, r.Quantization), Parser: r.Parser, Renderer: r.Renderer, @@ -358,7 +358,7 @@ func createSafetensorsErrorResponse(err error) gin.H { } status := http.StatusInternalServerError - for _, badReq := range []error{errNoFilesProvided, errFilePath, errSafetensorsFrom, errInvalidCreateInfo, manifest.ErrInvalidDigestFormat, xcreate.ErrBadTemplate, xcreate.ErrInvalidRequires, xcreate.ErrInvalidLicense, xcreate.ErrUnsupportedMLXArchitecture, os.ErrNotExist} { + for _, badReq := range []error{errNoFilesProvided, errFilePath, errSafetensorsFrom, errInvalidCreateInfo, manifest.ErrInvalidDigestFormat, create.ErrBadTemplate, create.ErrInvalidRequires, create.ErrInvalidLicense, create.ErrUnsupportedMLXArchitecture, os.ErrNotExist} { if errors.Is(err, badReq) { status = http.StatusBadRequest break @@ -367,9 +367,9 @@ func createSafetensorsErrorResponse(err error) gin.H { return gin.H{"error": err.Error(), "status": status} } -func writeSafetensorsManifest(r api.CreateRequest, draftDir string, fn func(resp api.ProgressResponse)) xcreate.ManifestWriter { - next := xcreate.NewSafetensorsManifestWriter(xcreate.SafetensorsManifestOptions{ - MinVersion: xcreate.SafetensorsMinOllamaVersion, +func writeSafetensorsManifest(r api.CreateRequest, draftDir string, fn func(resp api.ProgressResponse)) create.ManifestWriter { + next := create.NewSafetensorsManifestWriter(create.SafetensorsManifestOptions{ + MinVersion: create.SafetensorsMinOllamaVersion, DraftDir: draftDir, Template: r.Template, System: r.System, @@ -378,7 +378,7 @@ func writeSafetensorsManifest(r api.CreateRequest, draftDir string, fn func(resp Messages: r.Messages, BeforeWriteManifest: func() { fn(api.ProgressResponse{Status: "writing manifest"}) }, }) - return func(ctx context.Context, modelName string, info xcreate.ManifestInfo) error { + return func(ctx context.Context, modelName string, info create.ManifestInfo) error { if len(info.ModelConfig.Capabilities) == 0 { info.ModelConfig.Capabilities = []string{"completion"} } @@ -470,7 +470,7 @@ func linkOrCopyFile(ctx context.Context, src, dst string) error { if err != nil { return err } - _, copyErr := io.Copy(out, xcreate.ReaderWithContext(ctx, in)) + _, copyErr := io.Copy(out, create.ReaderWithContext(ctx, in)) closeErr := out.Close() if copyErr != nil { return copyErr @@ -844,7 +844,7 @@ func createModel(ctx context.Context, r api.CreateRequest, name model.Name, base } } - layers, err = xcreate.ApplyModelfileLayers(layers, xcreate.ModelfileLayerOptions{ + layers, err = create.ApplyModelfileLayers(layers, create.ModelfileLayerOptions{ Template: r.Template, System: r.System, License: r.License, diff --git a/server/images.go b/server/images.go index 383a23840..56fe712ca 100644 --- a/server/images.go +++ b/server/images.go @@ -24,13 +24,13 @@ import ( "github.com/ollama/ollama/api" "github.com/ollama/ollama/envconfig" "github.com/ollama/ollama/manifest" + "github.com/ollama/ollama/mlx" "github.com/ollama/ollama/model/parsers" "github.com/ollama/ollama/parser" "github.com/ollama/ollama/template" "github.com/ollama/ollama/thinking" "github.com/ollama/ollama/types/model" "github.com/ollama/ollama/version" - "github.com/ollama/ollama/x/mlxrunner/mlx" "github.com/ollama/ollama/x/transfer" ) diff --git a/server/routes_create_test.go b/server/routes_create_test.go index d1a30a0c0..2d7ef0654 100644 --- a/server/routes_create_test.go +++ b/server/routes_create_test.go @@ -25,13 +25,13 @@ import ( gocmpopts "github.com/google/go-cmp/cmp/cmpopts" "github.com/ollama/ollama/api" + "github.com/ollama/ollama/create" "github.com/ollama/ollama/fs/gguf" + st "github.com/ollama/ollama/fs/safetensors" gguftest "github.com/ollama/ollama/internal/testutil/gguf" "github.com/ollama/ollama/manifest" + "github.com/ollama/ollama/mlxrunner" "github.com/ollama/ollama/types/model" - xcreate "github.com/ollama/ollama/x/create" - "github.com/ollama/ollama/x/mlxrunner" - st "github.com/ollama/ollama/x/safetensors" ) var stream bool = false @@ -2083,9 +2083,9 @@ func createTestSafetensorsBlob(t *testing.T, tensors []*st.TensorData) string { return createTestBlob(t, data) } -func createTestLayerInfo(t *testing.T, name, mediaType string, data []byte) xcreate.LayerInfo { +func createTestLayerInfo(t *testing.T, name, mediaType string, data []byte) create.LayerInfo { t.Helper() - return xcreate.LayerInfo{ + return create.LayerInfo{ Name: name, MediaType: mediaType, Digest: createTestBlob(t, data), @@ -2113,7 +2113,7 @@ func TestCreateSafetensorsRejectsUnsupportedArchitecture(t *testing.T) { if w.Code != http.StatusBadRequest { t.Fatalf("status = %d, want %d: %s", w.Code, http.StatusBadRequest, w.Body.String()) } - if !strings.Contains(w.Body.String(), xcreate.ErrUnsupportedMLXArchitecture.Error()) { + if !strings.Contains(w.Body.String(), create.ErrUnsupportedMLXArchitecture.Error()) { t.Fatalf("response = %s, want unsupported architecture error", w.Body.String()) } if _, err := manifest.ParseNamedManifest(model.ParseName("unsupported-safetensors")); !errors.Is(err, os.ErrNotExist) { @@ -2223,7 +2223,7 @@ func TestWriteSafetensorsManifestPreservesRequestMetadata(t *testing.T) { tensorData := []byte("tensor") configData := []byte(`{"architectures":["TestModel"]}`) tokenizerData := []byte(`{"version":"1.0"}`) - info := xcreate.ManifestInfo{Layers: []xcreate.LayerInfo{ + info := create.ManifestInfo{Layers: []create.LayerInfo{ createTestLayerInfo(t, "model.embed_tokens.weight", manifest.MediaTypeImageTensor, tensorData), createTestLayerInfo(t, "config.json", "application/vnd.ollama.image.json", configData), createTestLayerInfo(t, "tokenizer.json", "application/vnd.ollama.image.json", tokenizerData), @@ -2331,7 +2331,7 @@ func TestWriteSafetensorsManifestIncludesDraft(t *testing.T) { mainData := []byte("main tensor") draftData := []byte("draft tensor") draftConfig := []byte(`{"architectures":["TestDraftModel"]}`) - info := xcreate.ManifestInfo{Layers: []xcreate.LayerInfo{ + info := create.ManifestInfo{Layers: []create.LayerInfo{ createTestLayerInfo(t, "model.embed_tokens.weight", manifest.MediaTypeImageTensor, mainData), createTestLayerInfo(t, "draft.model.embed_tokens.weight", manifest.MediaTypeImageTensor, draftData), createTestLayerInfo(t, "draft/config.json", "application/vnd.ollama.image.json", draftConfig), @@ -2478,7 +2478,7 @@ func TestCreateRejectsInvalidLicense(t *testing.T) { if w.Code != http.StatusBadRequest { t.Fatalf("status = %d, want %d: %s", w.Code, http.StatusBadRequest, w.Body.String()) } - if !strings.Contains(w.Body.String(), xcreate.ErrInvalidLicense.Error()) { + if !strings.Contains(w.Body.String(), create.ErrInvalidLicense.Error()) { t.Fatalf("response = %s, want invalid license error", w.Body.String()) } }) diff --git a/server/sched.go b/server/sched.go index e31fedc57..535491349 100644 --- a/server/sched.go +++ b/server/sched.go @@ -23,8 +23,8 @@ import ( "github.com/ollama/ollama/llm" "github.com/ollama/ollama/logutil" "github.com/ollama/ollama/ml" + "github.com/ollama/ollama/mlxrunner" "github.com/ollama/ollama/types/model" - "github.com/ollama/ollama/x/mlxrunner" ) type LlmRequest struct { diff --git a/x/mlxrunner/imports.go b/x/mlxrunner/imports.go deleted file mode 100644 index 540d8352d..000000000 --- a/x/mlxrunner/imports.go +++ /dev/null @@ -1,16 +0,0 @@ -package mlxrunner - -import ( - _ "github.com/ollama/ollama/x/models/cohere2_moe" - _ "github.com/ollama/ollama/x/models/dflash" - _ "github.com/ollama/ollama/x/models/gemma4" - _ "github.com/ollama/ollama/x/models/glimmer" - _ "github.com/ollama/ollama/x/models/glm4_moe_lite" - _ "github.com/ollama/ollama/x/models/laguna" - _ "github.com/ollama/ollama/x/models/llama" - _ "github.com/ollama/ollama/x/models/nemotron_h" - _ "github.com/ollama/ollama/x/models/qwen3" - _ "github.com/ollama/ollama/x/models/qwen3_5" - _ "github.com/ollama/ollama/x/models/qwen3_5_moe" - _ "github.com/ollama/ollama/x/models/qwen4_exp" -) diff --git a/x/server/show.go b/x/server/show.go index f1985e3f2..4576b2ffb 100644 --- a/x/server/show.go +++ b/x/server/show.go @@ -12,8 +12,8 @@ import ( "github.com/ollama/ollama/api" "github.com/ollama/ollama/manifest" + "github.com/ollama/ollama/mlx/quant" "github.com/ollama/ollama/types/model" - "github.com/ollama/ollama/x/quant" ) func canonicalQuantType(quantType string) string {