Skip to content

Add info about property wrappers to porting guide #347

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

Merged

Conversation

DePasqualeOrg
Copy link
Contributor

Please revise this if necessary. I generated the section on property wrappers based on the existing models in this repo.

@xlab
Copy link

xlab commented Jul 2, 2025

I recommend adding a tricky case #340 (comment)
when a param doesn't exist during load, and must be computed. You want to differentiate a field for that, and that must not be confused with self._field.wrappedValue.

Example:

 @ParameterInfo(key: "correct_output_scale") var correctOutputScale: MLXArray
  private let _routerInputScale: MLXArray

// yes:
self._correctOutputScale.wrappedValue = MLXArray(...

// but:
self._routerInputScale = MLXArray(...

Copy link
Collaborator

@davidkoski davidkoski left a comment

Choose a reason for hiding this comment

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

Looks great, thank you!

@davidkoski davidkoski merged commit 42b0d21 into ml-explore:main Jul 8, 2025
4 checks passed
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.

3 participants