Skip to content

Fix dictionary key lookup in Module.update(parameters:)#363

Merged
davidkoski merged 1 commit intoml-explore:mainfrom
gzink:fix-dictionary-update
Feb 24, 2026
Merged

Fix dictionary key lookup in Module.update(parameters:)#363
davidkoski merged 1 commit intoml-explore:mainfrom
gzink:fix-dictionary-update

Conversation

@gzink
Copy link
Contributor

@gzink gzink commented Feb 22, 2026

Proposed changes

Fix incorrect dictionary key lookup in Module.update(parameters:verify:).
In the .dictionary, .dictionary case of the recursive apply function, values[key] uses the parent path component instead of values[dictionaryKey] (the current child key). This causes all parameters in [String: Module] or [String: MLXArray] dictionary properties to be silently skipped during updates.

-        if let valueItem = values[key] {
+        if let valueItem = values[dictionaryKey] {

Added testDictionaryParameters regression test in ModuleTests.swift.
Fixes #362

Checklist

Put an x in the boxes that apply.

  • I have read the CONTRIBUTING document
  • I have run pre-commit run --all-files to format my code / installed pre-commit prior to committing changes (swift-formatter instead)
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the necessary documentation (if needed)

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.

That is a really good find, thank you!

@davidkoski davidkoski merged commit a2f0d76 into ml-explore:main Feb 24, 2026
7 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.

[BUG] update(parameters:) uses wrong key for dictionary properties

2 participants