Skip to content

fix: propagate throws from LanguageModel.newCache and adapt to mlx-swift-lm PR #62 - #167

Open
solderzzc wants to merge 3 commits into
mainfrom
fix/mlx-swift-lm-throwing-newcache
Open

solderzzc wants to merge 3 commits into
mainfrom
fix/mlx-swift-lm-throwing-newcache

Conversation

@solderzzc

Copy link
Copy Markdown
Member

Summary

  • Bump the mlx-swift-lm submodule to the merged PR fix(swiftbuddy): add MLXVLM and ModelArchitectureProbe to xcodeproj generator #62 commit (SharpAI/mlx-swift-lm#62, 460ff81) and adapt all call sites broken by its breaking API changes:
    • LanguageModel.newCache(parameters:) is now throws. Propagated try through every caller: DFlashRuntime's cache/generate chain (with a documented do/catch in generate() since a plain AsyncStream cannot re-throw), Gemma4MTPBench, InferenceEngine, and Server.swift.
    • GenerateCompletionInfo.totalDraftTokens was renamed/optional-ized to proposedDraftTokens/acceptedDraftTokens; updated InferenceEngine to unwrap safely.
    • ModelFactory is now a constrained typealias with primary associated types; ALMModelFactory/OmniModelFactory now conform to GenericModelFactory instead of inheriting, matching upstream's LLMModelFactory/VLMModelFactory pattern.
    • UserInput.audio renamed to audios; updated the genuine call sites.
    • Chat.Message's role cases restructured (audios: label, ToolCall-based tool calls, tool(_, id:)); rewrote toChatMessage() accordingly.
    • Generation gained .rejectedToolCall(RejectedToolCall); handled in all previously-exhaustive switches.
  • Repointed the submodule from the interim pin (348ff97) to the actual merged PR fix(swiftbuddy): add MLXVLM and ModelArchitectureProbe to xcodeproj generator #62 commit (460ff81) — confirmed a strict content superset via git diff --stat (81 files, +10594/-673), so no regression.

Test plan

  • swift build -c release — clean build, no errors (only pre-existing, unrelated warnings in Server.swift)
  • swift test --skip-build — 288 tests passed, 9 skipped, 0 failures

🤖 Generated with Claude Code

solderzzc and others added 3 commits September 19, 2026 08:26
…ift-lm PR #62 API changes

Bump the mlx-swift-lm submodule to 348ff97 (upstream-sync PR #62) and
update all call sites broken by its breaking API changes:

- LanguageModel.newCache(parameters:) is now `throws`. Propagated `try`
  through every caller: DFlashRuntime's makeTargetCache/generateStreaming/
  generateSync chain (with a documented do/catch in generate() since a
  plain AsyncStream cannot re-throw to its consumer), Gemma4MTPBench,
  InferenceEngine, and Server.swift.
- GenerateCompletionInfo.totalDraftTokens was renamed/optional-ized to
  proposedDraftTokens/acceptedDraftTokens; updated InferenceEngine to
  unwrap safely instead of assuming non-optional Int.
- ModelFactory is now a constrained typealias (GenericModelFactory<
  ModelContext, ModelContainer>) with primary associated types, which a
  class can no longer inherit from directly. ALMModelFactory and
  OmniModelFactory now conform to GenericModelFactory instead, matching
  upstream's own LLMModelFactory/VLMModelFactory pattern.
- UserInput.audio was renamed to audios; updated the three genuine call
  sites (left LMInput.audio/vlmInput.audio alone, which are unrelated,
  unrenamed types).
- Chat.Message's role cases were restructured (audios: label, ToolCall-
  based tool calls instead of raw dictionaries, tool(_, id:) instead of
  tool(_, toolCallId:)); rewrote toChatMessage() to build ToolCall values
  and decode JSON-string tool arguments into [String: JSONValue].
- Generation gained a new .rejectedToolCall(RejectedToolCall) case;
  added handling to all four previously-exhaustive switches, logging
  only reason/toolName/detail (never rawTextPreview, per its doc comment's
  privacy note).

Verified both ways: `swift build -c release` and `swift build
--build-tests` are clean (no errors) against the new pin (348ff97), and
also clean when the submodule is temporarily rolled back to the previous
pin (0e0cb47) with these same source changes in place (the added `try`
keywords are harmless there). Submodule is left at 348ff97.

TurboQuant C++ tests (9/9), SwiftLMTests (161/161), and SwiftBuddyTests
(127 executed, 9 skipped) all pass against the final state.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Point the mlx-swift-lm submodule at the actual merged PR #62 commit
(460ff81) instead of the interim pin (348ff97) this branch was
originally adapted against. 460ff81 is a strict content superset of
348ff97 (confirmed via diff --stat: 81 files changed, 10594
insertions, 673 deletions, including the same Gemma4Unified fixes and
extensive additional test coverage), so no regression from repointing.

Package.resolved's swift-syntax pin moved to 603.0.2 as a byproduct of
re-resolving against the new submodule state.

Verified: `swift build -c release` and `swift test --skip-build`
both pass (288 tests, 9 skipped, 0 failures).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…wn CI

mlx-swift-lm's Package.swift declares swift-tools-version 6.2 (already
true at the previous pin, 348ff97). SwiftLM's CI never selected a
newer Xcode, so it silently depended on the default macos-15 runner
image happening to ship a toolchain new enough — until this bump
surfaced it: `swift package resolve` failed with "package
'mlx-swift-lm' is using Swift tools version 6.2.0 but the installed
version is 6.1.0".

Added the same `xcode-select -s /Applications/Xcode_26.3.app` step
mlx-swift-lm's own ci.yml uses, to every job that resolves or builds
the package (build_and_unit_test, speculative-decoding,
dflash-speculative-decoding, speculative-decoding-eval, and
ssd-draft-memory-guard's artifact-missing fallback build).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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