Fix compression_config dropped when loading compressed models from JSON config#333
Merged
Merged
Conversation
parse_json_full_config built the compression config but omitted compression_config= from the returned FullConfig, so models loaded via Engine.prepare_model (which reads angelslim_config.json) always received compression_config=None. As a result from_pretrained was called with compress_config=None, breaking the compressed-model save/load round-trip. The YAML parser already passes compression_config correctly; this aligns the JSON parser with it. Also remove a verbatim-duplicated calibrate/transform parsing block and raise a descriptive error for missing required JSON sections. Add CPU-only regression tests covering the round-trip and the missing-section path. Signed-off-by: supermario_leo <leo.stack@outlook.com>
yghstill
approved these changes
Jun 7, 2026
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
parse_json_full_config()parses thecompression_configsection into a localcomp_config, but the returnedFullConfig(...)omits thecompression_config=argument. Because
FullConfig.compression_configdefaults toNone, every configloaded through this function comes back without any compression metadata,
silently discarding the parsing work.
This is the path used when reloading a previously compressed model:
So the compressed-model save → load round-trip loses the compression
configuration. The YAML parser (
SlimConfigParser._get_configs) already passescompression_configcorrectly — this change brings the JSON parser in line with it.Changes
compression_config=comp_configtoFullConfig(...)inparse_json_full_config.function (the second copy recomputed identical values).
ValueErrorfor a missing required JSON section(
model_config/compression_config) instead of a bareKeyError, matchingthe validation style of the YAML parser.
tests/test_config_parser.py) covering theround-trip and the missing-section path. They need neither a GPU nor model
weights.
Testing
pre-commit run --all-filespasses (black / isort / flake8) on the changed files.