Skip to content

feat: mlx-swift-lm 3.32 upgrade, real Stop, native tool calling, KV-cache settings (v6.4.0) - #8

Merged
kochj23 merged 3 commits into
mainfrom
feat/mlx-2026-refresh
Nov 6, 2026
Merged

kochj23 merged 3 commits into
mainfrom
feat/mlx-2026-refresh

Conversation

@kochj23

@kochj23 kochj23 commented Nov 6, 2026

Copy link
Copy Markdown
Owner

Summary

This brings MLX Code up to date with mlx-swift-lm 3.x and fixes the Stop button. Full detail is in CHANGELOG.md, under 6.4.0.

A. Bugs and breaking changes

  1. Dependencies. mlx-swift-lm goes from 2.30.3 to 3.32.3 (the latest 3.x tag). mlx-swift goes from 0.30.3 to 0.32.3.
    • mlx-swift 0.33.x isn't possible yet. mlx-swift-lm 3.32.3 declares mlx-swift upToNextMinor(0.32.3), and only untagged main moves to 0.33.
    • The code follows the upstream upgrade guide:
      • HubApi/defaultHubApi became HubClient.
      • loadContainer(hub:) became loadContainer(from: URL, using: #huggingFaceTokenizerLoader()).
      • The project adds the MLXHuggingFace, HuggingFace (swift-huggingface 0.13.0) and Tokenizers (swift-transformers 1.4.0) products.
      • The code never called decode(tokens:), so that rename needed no change.
    • Package.resolved is now committed, with a .gitignore exception.
  2. Downloads. The download patterns now live in MLXService.downloadPatterns and add *.jinja, *.txt and *.model.
    • Downloads use HubClient(cache: nil) and write straight into <modelsPath>/models/<org>/<repo>. That's the same layout 2.x used, and nothing goes to ~/.cache/huggingface.
  3. Stop.
    • Generation runs in a stored, cancellable Task.
    • MLXService checks for cancellation in the stream loop. Ending the stream cancels mlx-swift-lm's own generation task, and the busy flag is cleared in a defer.
    • After Stop, the agentic tool loop doesn't continue, and the balancer doesn't fail over to another model.
    • The repetition and length guards now actually stop the model.
    • topK, minP and repetitionContextSize are now passed to the sampler.
    • The repetition-penalty default drops from 1.8 to 1.1, and persisted 1.8 values are migrated.
  4. Python cleanup.
    • Removed mlx_inference.py, mlx_daemon.py, huggingface_downloader.py and rag_system.py. No Swift code referenced any of them.
    • Removed the Python/=* junk files, their Resources entries and the add_python_scripts.rb helper.
    • setup.sh now quotes its version specifiers.
    • The daemon-protocol tests were replaced.

B. Features

  1. Native tool calling.
    • ToolSpecBuilder turns ToolRegistry into [ToolSpec], which is passed in UserInput and to generate.
    • Each Generation.toolCall is rendered as a <tool>{json}</tool> block, so the existing approval and execution flow handles it unchanged. Several calls in one response work.
    • The </tool> text parser remains as a fallback.
  2. Model catalog.
    • New entries: Qwen3.5 9B (the new default), Qwen3-Coder 30B-A3B, Devstral Small 2 24B, Qwen3.6 35B-A3B, Qwen3.6 27B, Gemma 4 E4B and Qwen3.5 2B. Qwen 2.5 7B stays as a legacy entry.
    • Every repo was checked on huggingface.co, and every model_type is registered in LLMModelFactory 3.32.3.
    • The context window is now read from text_config as well as the top level.
  3. KV-cache settings (Settings → Model): quantization (none / 8-bit / 4-bit), max KV size, and prefill step size, which defaults to 512. All map into GenerateParameters.
    • Reusing the KV cache across turns was not done.

C. Tests

  • The new InferenceGenerator protocol plus a mock covers:
    • parameter mapping (all fields);
    • Stop/cancel resetting state, in both the service and ChatViewModel;
    • the download patterns;
    • catalog IDs;
    • nested text_config parsing;
    • ToolRegistry → ToolSpec;
    • tool-call mapping, including two calls in one response.
  • There's also an opt-in integration test (MLXCODE_INTEGRATION=1 plus MLXCODE_MODEL_PATH).
  • Results:
    • Branch: 574 tests, 0 failures, 1 skipped (the integration test).
    • main: 546 tests, 0 failures.
    • The integration test passed locally against qwen2.5-0.5b-4bit.

D. Docs and CI

  • CHANGELOG and README are updated: features, a new inference-path Mermaid diagram, the updated architecture and data-flow diagrams, version history, and Xcode 26+ / -skipMacroValidation build notes.
  • CI now passes -skipMacroValidation -skipPackagePluginValidation, which the MLXHuggingFace macros need.
  • MARKETING_VERSION is 6.4.0, build 9. The Xcode extension is 1.1, build 2.
  • gitleaks detect --no-git finds no leaks.

Things to check

  • mlx-swift-lm 3.x needs swift-tools 6.2, so Xcode 26 or later. If the macos-15 runner's default Xcode is older, CI will fail at package resolution, and the workflow will need macos-26 or an xcode-select step.

🤖 Generated with Claude Code

kochj23 and others added 3 commits November 6, 2026 10:58
…ache settings (v6.4.0)

Bugs / breaking changes
- Upgrade mlx-swift-lm 2.30.3 -> 3.32.3 and mlx-swift 0.30.3 -> 0.32.3
  (3.32.3 requires mlx-swift upToNextMinor(0.32.3); 0.33.x is only on
  untagged main). Migrate to HubClient + #huggingFaceTokenizerLoader();
  add MLXHuggingFace, HuggingFace (swift-huggingface 0.13) and Tokenizers
  (swift-transformers 1.4) products. Commit Package.resolved.
- Download *.jinja, *.txt and *.model too (MLXService.downloadPatterns).
- Stop now cancels the generation Task; MLXService checks cancellation,
  ends the mlx-swift-lm stream and always resets its busy flag. Pass topK,
  minP and repetitionContextSize; default repetition penalty 1.8 -> 1.1
  (legacy persisted 1.8 migrated).
- Remove dead Python scripts, junk Python/=* files and their Resources
  entries; quote pip specifiers in setup.sh; replace daemon-protocol tests.

Features
- Native tool calling: ToolRegistry -> [ToolSpec] in UserInput;
  Generation.toolCall mapped into the existing <tool> approval flow
  (multiple calls per turn); </tool> text parser kept as fallback.
- Model catalog refresh (Qwen3.5 9B default, Qwen3-Coder 30B-A3B,
  Devstral Small 2, Qwen3.6 27B / 35B-A3B, Gemma 4 E4B, Qwen3.5 2B);
  context window read from nested text_config.
- KV-cache settings (bits none/8/4, max KV size, prefill step) mapped
  into GenerateParameters.

Tests: InferenceEngineTests + rewritten MLXServiceTests with a mock
InferenceGenerator (no model download), plus an opt-in real-model
integration test (MLXCODE_INTEGRATION=1).

Docs/CI: CHANGELOG, README (features, inference-path Mermaid diagram,
version history), -skipMacroValidation in CI. MARKETING_VERSION 6.4.0,
build 9 (extension 1.1 / build 2).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…needs Swift 6.3+)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The repo's Actions policy allows only GitHub-owned and verified actions,
so maxim-lobanov/setup-xcode caused a startup_failure.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kochj23
kochj23 merged commit 9fdba17 into main Nov 6, 2026
1 check passed
@kochj23
kochj23 deleted the feat/mlx-2026-refresh branch November 6, 2026 19:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant