Skip to content

Conversation

@davidkoski
Copy link
Collaborator

@davidkoski davidkoski commented May 14, 2025

use ReerCodable macro to allow for default values

  • make all configuration Sendable and public var as well

import MLXNN

public struct PoolingConfiguration: Codable {
public struct PoolingConfiguration: Codable, Sendable {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of these should be Sendable as well

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
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the urls -- these moved to the new mlx-lm repo

@CodingKey("layer_norm_eps") public var ropeTheta: Float = 8000000.0
@CodingKey("logit_scale") public var ropeTraditional: Bool = true
@CodingKey("rope_traditional") public var ropeScaling: [String: StringOrNumber]? = nil
@CodingKey("rope_scaling") public var logitScale: Float = 0.0625
Copy link
Collaborator Author

@davidkoski davidkoski May 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the typical change: use @CodingKey and the defaults just work

@ml-explore ml-explore deleted a comment from codingkey May 14, 2025
@davidkoski davidkoski marked this pull request as ready for review May 15, 2025 21:18
@davidkoski davidkoski requested a review from awni May 15, 2025 21:18
swift --version
find . -name Package.resolved -exec rm {} \;
xcodebuild test -scheme mlx-libraries-Package -destination 'platform=OS X'
xcodebuild test -scheme mlx-libraries-Package -destination 'platform=OS X' -skipMacroValidation
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is how we tell CI to trust the macro package -- it runs in a sandbox but still requires some permission.

@davidkoski
Copy link
Collaborator Author

davidkoski commented Jun 27, 2025

@DePasqualeOrg since you implement a lot of models what do you think about this change? It makes it much easier to add defaults in configuration at the cost of using a macro.

Note: I think it requires a bit of work to be back in building shape after a recent merge up from main but you can see what the changes look like.

@ml-explore ml-explore deleted a comment from codingkey Jun 27, 2025
@DePasqualeOrg
Copy link
Contributor

That looks nice! This has always been difficult for me to get right.

@davidkoski davidkoski force-pushed the codable-macro branch 3 times, most recently from 11bdc9f to b76f9e4 Compare September 25, 2025 19:45
- make all configuration Sendable and public var as well
@davidkoski
Copy link
Collaborator Author

@awni I think this is ready for review when you have time.

This makes it much easier to write the code to read configs and in particular have default values.

@codingkey
Copy link

codingkey commented Sep 26, 2025 via email

@davidkoski davidkoski mentioned this pull request Sep 29, 2025
@rudrankriyam
Copy link
Contributor

Saw this after the Qwen 3 VL port; this will be pretty cool to have!

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.

5 participants