fix: add missing return in load_model_with_fallback#272
Closed
mikepixelmagic-dev wants to merge 1 commit intowaybarrios:mainfrom
Closed
fix: add missing return in load_model_with_fallback#272mikepixelmagic-dev wants to merge 1 commit intowaybarrios:mainfrom
mikepixelmagic-dev wants to merge 1 commit intowaybarrios:mainfrom
Conversation
When mlx_lm.load() succeeds without raising a ValueError, the function
falls through the try block without returning, implicitly returning None.
This causes a TypeError in MLXLanguageModel.load() which tries to unpack
the result:
self.model, self.tokenizer = load_model_with_fallback(...)
TypeError: cannot unpack non-iterable NoneType object
Add the missing `return model, tokenizer` after the successful load.
Fixes waybarrios#252, waybarrios#249
Contributor
Author
|
Closing as duplicate of #243 which has the same fix. 👍 on getting it merged. |
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.
Summary
load_model_with_fallback()inutils/tokenizer.pyis missing areturnstatement on the happy path. Whenmlx_lm.load()succeeds without raising aValueError, the function falls through thetryblock and implicitly returnsNone.This causes a
TypeErrorinMLXLanguageModel.load():The fix is a single line — adding
return model, tokenizerafter the successfulload()call.How to reproduce
Note: the bug only manifests when called inside an async context (e.g.,
asyncio.run()), which is how the server starts the engine viaSimpleEngine.start(). Direct calls outside async may work due to Python caching behaviour.Related issues
Fixes #252, #249
Test
Verified with Qwen3.5-35B-A3B (4-bit and 8-bit) on Apple M5 Max. Server starts and serves requests successfully after the fix.