fix: enhance model saving functionality to load multiple JSON configs present in diffusers#98
Merged
davidberenstein1957 merged 17 commits intomainfrom May 22, 2025
Conversation
feccf3a to
b2a57dc
Compare
begumcig
requested changes
May 15, 2025
…nfig files - Updated `save_pruna_model_to_hub` to load all JSON files in the model directory, ensuring `smash_config.json` is present. - Modified README template to reflect that model configuration is now stored in `*.json` files instead of a single `config.json` file. - Adjusted code examples for clarity and consistency.
- Changed the key used to retrieve the smash configuration from the config files to ensure compatibility with the updated file naming convention.
- Modified test cases in `test_load.py` to include new model names. - Updated `test_save.py` to parameterize the `repo_id` for saving models, allowing for testing with multiple model configurations.
- Added functionality to save the old smash configuration, including tokenizer and processor, before saving the model. - Improved handling of model types in the `original_save_fn` to ensure correct loading functions are appended for diffusers and transformers. - Updated tests to parameterize repository IDs for better model saving tests.
- Introduced a new marker "integration" in the pytest configuration to categorize integration tests.
- Updated test cases in `test_load.py` to reflect new repository names for models. - Enhanced `test_save.py` with new tests for saving both LLM and diffusers models to the Hugging Face Hub. - Added debugging breakpoints in `smash_config.py` and `test_load.py` for troubleshooting.
- Removed the debugging breakpoint (pdb.set_trace) from the SmashConfig class to clean up the code after troubleshooting.
… smash_config - Removed the debugging breakpoint from `test_load.py` to clean up the code. - Updated `smash_config` initialization in `test_save.py` to specify the device as "cpu".
- Removed unnecessary model attribute access in `register_inference_handler` to streamline the inference handler registration process.
- Eliminated the debugging breakpoint (pdb.set_trace) from the `register_inference_handler` function to clean up the code and improve readability.
- Removed redundant check for the presence of the smash configuration file in the model directory, simplifying the loading process. - Adjusted the handling of the model attribute in the original save function to improve clarity.
0c6888d to
4647bd8
Compare
- Enhanced the loading of the smash configuration by directly reading from the file instead of using a temporary dictionary. - Added logic to determine the library name based on the model's module for better clarity in the README. - Updated the README template to include a more informative loading instruction for the model, linking to the appropriate library documentation.
- Revised instructions in the model card template to clarify the use of the {library_name} for loading models, emphasizing that it may not include all optimizations by default.
- Added guidance to utilize the pruna library for loading models to ensure all optimizations are applied.
- Modified the `test_pruna_model_from_hub` to include the `force_download=True` parameter when loading models from the hub, ensuring that the latest model versions are retrieved during tests.
gsprochette
reviewed
May 16, 2025
Collaborator
gsprochette
left a comment
There was a problem hiding this comment.
Looks good already, but needs an iteration before it's good to go :) I left a couple of suggestions and there is the question about saving in SAVE_BEFORE_SMASH_CACHE_DIR which I didn't get.
- Removed the saving of the old smash configuration from the `save_pruna_model` function to streamline the saving process. - Updated test cases in `test_load.py` and `test_save.py` to reflect new repository names for models, ensuring consistency in naming conventions.
gsprochette
approved these changes
May 20, 2025
Collaborator
gsprochette
left a comment
There was a problem hiding this comment.
LGTM! Thanks for adressing all the comments 👍 ✨
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.
save_pruna_model_to_hubto load all JSON files in the model directory, ensuringsmash_config.jsonis present.*.jsonfiles instead of a singleconfig.jsonfile.SmashConfigdoes not have locally storedsmash_config.jsonin cache dir after loading from hubDescription
Error reproduction code using another branch
Related Issue
Fixes #96
Type of Change
How Has This Been Tested?
Checklist
Additional Notes