Skip to content

Vendored swift-transformers: add Sendable to Hub.Repo / Hub.RepoType (Swift 6 build fix) - #94

Closed
rcfa wants to merge 1 commit into
osaurus-ai:mainfrom
rcfa:fix/vendored-swift-transformers-sendable
Closed

Vendored swift-transformers: add Sendable to Hub.Repo / Hub.RepoType (Swift 6 build fix)#94
rcfa wants to merge 1 commit into
osaurus-ai:mainfrom
rcfa:fix/vendored-swift-transformers-sendable

Conversation

@rcfa

@rcfa rcfa commented Jun 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

Under Swift 6 strict concurrency, Hub.RepoType and Hub.Repo (in the vendored swift-transformers
copy under Vendors/) need Sendable to cross actor/task boundaries; without it, builds that touch
these types from concurrent contexts fail.

Both are trivially sendable (a String-raw enum and an all-let struct of Sendable fields). This
adds the conformance to the vendored copy so vmlx-swift builds clean under Swift 6 now, without
waiting on an upstream swift-transformers release + a vendor bump.

The same fix is now merged upstream at huggingface/swift-transformers#374 (merged 2026-06-28) — so
this vendored stopgap matches the accepted upstream change, and can be dropped on the next vendor sync
that picks it up. No behavior change.

@rcfa
rcfa force-pushed the fix/vendored-swift-transformers-sendable branch from b31a20c to 92a6b40 Compare June 28, 2026 10:19
@rcfa

rcfa commented Jun 28, 2026

Copy link
Copy Markdown
Collaborator Author

Upstream PR approved

@rcfa
rcfa marked this pull request as ready for review June 28, 2026 17:31
@rcfa
rcfa force-pushed the fix/vendored-swift-transformers-sendable branch 2 times, most recently from b90f9a4 to 8b020c8 Compare July 1, 2026 06:20
Under Swift 6 strict concurrency, `Hub.RepoType` and `Hub.Repo` need `Sendable`
to cross actor/task boundaries; without it, builds that touch these types from
concurrent contexts fail. Both are trivially sendable — a `String`-raw enum and
an all-`let` struct of `Sendable` fields. Adds the conformance to the vendored
copy so vmlx-swift builds clean under Swift 6 without waiting on an upstream
swift-transformers release + vendor bump. No behavior change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@rcfa
rcfa force-pushed the fix/vendored-swift-transformers-sendable branch from 8b020c8 to 958167a Compare July 1, 2026 06:46
@jjang-ai

Copy link
Copy Markdown
Contributor

Thanks — the conformance itself is correct (RepoType is a String-raw enum, Repo is all-let over Sendable fields), and it matches what upstream accepted. Two bits of context that aren't visible from outside the repo, though, and they change what we'd want to do with it:

1. We don't vendor from huggingface/swift-transformers. Per Vendors/README.md, Hub/Tokenizers/Generation/Models are copied from osaurus-ai/swift-transformers at revision 087a66b1. So patching the vendored copy in-tree means the next vendor sync overwrites it — the fix would silently disappear on a routine refresh, which is a worse failure than not having it (it'd come back as a mystery build break months later). The durable path is to land it in osaurus-ai/swift-transformers first and then bump the vendored revision here; at that point this diff becomes unnecessary rather than redundant.

2. The stated symptom doesn't reproduce on main. Hub.Repo / Hub.RepoType aren't referenced anywhere under Libraries/ or Sources/, and main builds clean today (MLXLMCommon is deliberately compiled in Swift 5 mode — see the long comment on that target in Package.swift — while the rest is Swift 6). So this isn't fixing a live break here; it's pre-emptive, or fixing something in a downstream consumer. That's fine, but it's worth saying plainly in the PR body, because "Swift 6 build fix" reads like the build is currently red and it isn't.

If you're hitting this from a downstream package, could you paste the actual compiler error and the context it fires in? If it's real for consumers we should fix it in the fork and re-vendor, which helps everyone rather than just this tree.

No objection to the change on its merits — it's the delivery mechanism that needs to move.

@rcfa

rcfa commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator Author

Agreed — closing this. Patching the vendored copy is the wrong delivery (a vendor sync would erase it), and on our side it turns out not to be a live break at all: MLXLMCommon is pinned to .v5, nothing in our tree references Hub.Repo/Hub.RepoType, and a strict-.v6 build compiles clean with the conformance removed (0 errors). The real fix is already merged upstream at huggingface/swift-transformers#374; I'll get it onto osaurus-ai/swift-transformers (currently ~2 months behind and missing it) so it flows in on the next vendored bump. Thanks for the careful trace.

@rcfa rcfa closed this Jul 15, 2026
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.

2 participants