switch to swift 6 -- prevent concurrency issues, fix concurrency issues#165
Open
davidkoski wants to merge 2 commits intomainfrom
Open
switch to swift 6 -- prevent concurrency issues, fix concurrency issues#165davidkoski wants to merge 2 commits intomainfrom
davidkoski wants to merge 2 commits intomainfrom
Conversation
- some concurrency issues snuck in for test support - fix and prevent more from coming in by switching Package to swift 6 - depends on ml-explore/mlx-swift#379
davidkoski
commented
Mar 27, 2026
| /// concurrently with an active ``respond(to:role:images:videos:)`` or | ||
| /// ``streamResponse(_:)`` call on the same session. To persist the cache | ||
| /// across process launches, use ``saveCache(to:)`` instead. | ||
| public func currentCache() async -> [KVCache]? { |
Collaborator
Author
There was a problem hiding this comment.
This was a little too permissive -- it is added for test support so we can just switch it to an internal scoped visitor.
davidkoski
commented
Mar 27, 2026
| let session = ChatSession(model(), generateParameters: generationParameters) | ||
| await session.withCache { cache in | ||
| XCTAssertNil(cache) | ||
| } |
Collaborator
Author
There was a problem hiding this comment.
This is the pattern to fix the tests -- just use the visitor.
davidkoski
commented
Mar 27, 2026
|
|
||
| func testCurrentCacheAfterGeneration() async throws { | ||
| let session = ChatSession(model()) | ||
| let session = ChatSession(model(), generateParameters: generationParameters) |
Collaborator
Author
There was a problem hiding this comment.
See #128, those changes were in flight while these calls were added. This just syncs everything up -- this is needed to make the random weight token generation stop.
davidkoski
commented
Mar 27, 2026
| import Testing | ||
|
|
||
| private let cacheCreators: [() -> any KVCache] = [ | ||
| private let cacheCreators: [@Sendable () -> any KVCache] = [ |
Collaborator
Author
There was a problem hiding this comment.
Fix sendable issue
davidkoski
commented
Mar 27, 2026
| @@ -1,4 +1,4 @@ | |||
| // swift-tools-version: 5.12 | |||
| // swift-tools-version: 6.1 | |||
Collaborator
Author
There was a problem hiding this comment.
Switch to swift 6 -- prevent concurrency issues from making it past CI
davidkoski
commented
Mar 27, 2026
| "README.md" | ||
| ], | ||
| swiftSettings: [ | ||
| .enableExperimentalFeature("StrictConcurrency") |
Collaborator
Author
There was a problem hiding this comment.
No longer needed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes
Checklist
Put an
xin the boxes that apply.pre-commit run --all-filesto format my code / installed pre-commit prior to committing changes