use ReerCodable macro to allow for default values#106
Open
davidkoski wants to merge 6 commits intomainfrom
Open
use ReerCodable macro to allow for default values#106davidkoski wants to merge 6 commits intomainfrom
davidkoski wants to merge 6 commits intomainfrom
Conversation
davidkoski
commented
Feb 12, 2026
Libraries/MLXLLM/Models/Cohere.swift
Outdated
| import ReerCodable | ||
|
|
||
| // port of https://github.com/ml-explore/mlx-examples/blob/main/llms/mlx_lm/models/cohere.py | ||
| // port of https://github.com/ml-explore/mlx-lm/tree/main/mlx_lm/models/cohere.py |
davidkoski
commented
Feb 12, 2026
| if let mlpBias = try container.decodeIfPresent(Bool.self, forKey: .mlpBias) { | ||
| self.mlpBias = mlpBias | ||
| } | ||
| public func didDecode(from decoder: any Decoder) throws { |
Collaborator
Author
There was a problem hiding this comment.
This is an interesting one because it has some logic to post-process the configuration.
67ab686 to
5532058
Compare
5532058 to
144cc81
Compare
3 tasks
Collaborator
Author
|
This is on hold for now -- I like the approach but am not ready to commit yet. |
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
Looking at moving to a Codable macro that makes it easier to integrate with JSON configuration files. Specifically:
These are both possible with standard Swift Coding but are unwieldy in the quantity we need here. See:
For an example. This changes:
to this:
The downside is that we are using macros (there is some additional build cost).
There was a previous attempt here: ml-explore/mlx-swift-examples#316. This is roughly the same approach but doesn't attempt to port all the configuration at once. Keeping that up-to-date was too much. Once this is in we can migrate the configuration in chunks.
Checklist
Put an
xin the boxes that apply.pre-commit run --all-filesto format my code / installed pre-commit prior to committing changes