-
Notifications
You must be signed in to change notification settings - Fork 121
Sendable Config #189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Sendable Config #189
Conversation
This is looking good so far @piotrkowalczuk! |
@@ -34,75 +34,6 @@ public extension Hub { | |||
} | |||
} | |||
|
|||
// MARK: - Configuration files with dynamic lookup | |||
|
|||
@dynamicMemberLookup |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might be planning this already but @dynamicMemberLookup
seems to be missing from your new config struct. Would be nice to keep some of the dot syntax for properties that were previously defined like vocab
, also general syntactic sugar vs string based access pattern - in your original proposal it was included #172 (comment), has your thinking changed to where that is no longer the case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can certainly revert the change. My initial experience with the codebase was confusing because it was difficult to quickly determine whether a property was statically defined or dynamically accessed. Using explicit subscript notation clarified this distinction and increased my confidence in relying on the type system for accuracy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll let @FL33TW00D @pcuenca et al. weigh in, my main concern besides syntax is backwards compatibility if any public properties (that may be accessed in projects that import this one) become inaccessible from this change.
For example, this was possible via public methods before this PR:
config.tokenizerData.model.vocab
and if merged these errors will propagate and require updating
Value of type 'Config' has no member 'model'
Perhaps a path forward could be making those objects with defined properties serializable (and probably defining more common properties that were previously dynamic) and leaving the remaining dynamic properties to your subscript pattern, just one idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is no further input on this topic, I will revert to the original behavior.
95551e5
to
c8ec50a
Compare
@pcuenca @FL33TW00D @ZachNagengast you might want to have a look :) |
@piotrkowalczuk Could you resolve the conflicts first? <3 |
6c105e1
to
8411210
Compare
ConfigTests, BinaryDistinctDictionary removed, Config JSON serialization/deserialization, Config compatible with jinja templating system @dynamicMemberLookup brought back for backward compatibility, ConfigTests/ConfigEquatable, Condig.Data equality improved @dynamicMemberLookup dot notation used in favour of the subscript formatting rebase Test cleanup Test fix
8411210
to
b45f775
Compare
@FL33TW00D done |
Sorry @piotrkowalczuk could you format it with the following instructions: https://github.com/huggingface/swift-transformers/actions/runs/14204745034/attempts/2#summary-39804901716 Will make this process smoother shortly. |
@FL33TW00D done. Apparently
|
I changed the package manifest. Here is where my ability to debug the CI build ends. @FL33TW00D could you help me? |
@piotrkowalczuk so |
@piotrkowalczuk The CI runners are using this workflow on this image: https://github.com/actions/runner-images/blob/macos-14-arm64/20250324.1158/images/macos/macos-14-arm64-Readme.md which uses Xcode 15.4 by default. To get the tests you may need to make some edits such that it can build on that version of xcode. There are some apps that make it easier to switch between versions in your local development environment like https://github.com/XcodesOrg/xcodes or it can also be downloaded directly from the Apple's website. |
I experimented with several options locally using https://github.com/XcodesOrg/xcodes and found that all versions of the I also attempted to explicitly import Available options:
@FL33TW00D I'll wait for the verdict regarding the toolchain. |
I'm really not keen on dropping support for Swift <6, as Swift 6 only came out 6 months ago it seems premature. |
This PR is a follow-up for #172 , it introduces a
Sendable
Config
, built aroundBinaryDistinctString
andBinaryDistinctCharacter
.Motivation
Config
conforms toSendable
.@dynamicMemberLookup
.TODO
Config
, particularly in chat template contexts.Config
dict values.Open Questions
BinaryDistinctString
andBinaryDistinctCharacter
be adopted more widely across the package, replacingString
andNSString
where applicable?String
already contains all the necessary information for binary-distinct comparisons.==
operator affects serialization, deserialization, and hashing for uniqueness.Sendable
would require deep changes to the Tokenizers package. What other improvements should be incorporated next to the Experimental: tokenizers with and without templates #168?Follow-ups
Hub
package, particularly by makingDownloader
conform toSendable
so the entire target can be marked as Swift6 compatible.Tokenizers
package.