Fix config parsing for Nemotron-H checkpoints saved by transformers - #1857
Merged
michalk8 merged 4 commits intoSep 17, 2026
Merged
Conversation
Loading or converting a Nemotron-H checkpoint written by a recent
transformers release fails in three separate places:
- num_hidden_layers is a property of layers_block_type in transformers,
so it never appears in the saved config and ModelArgs raises
"missing 1 required positional argument: 'num_hidden_layers'".
Derive the layer count from the block list instead, accept layer_types
as an alias for layers_block_type, map both the current and the legacy
block-type spellings, and raise a listed-values error for unknown ones.
- transformers tags non-finite floats, e.g. {"__float__": "Infinity"},
so that config.json stays valid JSON for every parser. load_config
passed the tag through untouched, so time_step_limit reached mx.clip
as a dict. Decode the tags on load and re-encode them on save, which
keeps a converted config readable by both libraries.
- A config missing a required key surfaced as a bare __init__ TypeError
naming only the first missing argument and no model type. Report the
model type and every missing key instead.
Each new test fails on main with the corresponding error.
michalk8
approved these changes
Sep 11, 2026
michalk8
left a comment
Collaborator
There was a problem hiding this comment.
I've reverted the change in ModelArgs.__init__, as it's out-of-scope of this PR. Otherwise, LGTM!
# Conflicts: # mlx_lm/utils.py
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.
Loading or converting a Nemotron-H checkpoint written by a recent transformers release fails in three separate places:
num_hidden_layersis a property oflayers_block_typein transformers, so it never appears in the saved config and ModelArgs raises "missing 1 required positional argument: 'num_hidden_layers'". Derive the layer count from the block list instead, acceptlayer_typesas an alias forlayers_block_type, map both the current and the legacy block-type spellings, and raise a listed-values error for unknown ones.transformers tags non-finite floats, e.g.
{"__float__": "Infinity"}, so that config.json stays valid JSON for every parser. load_config passed the tag through untouched, so time_step_limit reached mx.clip as a dict. Decode the tags on load and re-encode them on save, which keeps a converted config readable by both libraries.A config missing a required key surfaced as a bare
__init__TypeErrornaming only the first missing argument and no model type. Report the model type and every missing key instead.Each new test fails on main with the corresponding error.
The patch was co-written with Claude Code under my directions. Manual reviews and live tests were performed.