feat: enhance model saving functionality with pro support#200
Merged
davidberenstein1957 merged 8 commits intomainfrom Jul 1, 2025
Merged
feat: enhance model saving functionality with pro support#200davidberenstein1957 merged 8 commits intomainfrom
davidberenstein1957 merged 8 commits intomainfrom
Conversation
begumcig
reviewed
Jun 18, 2025
There was a problem hiding this comment.
Bug: Model Saving Fails with Invalid Object
The save_pruna_model_to_hub function accesses self.__module__ and self.__class__.__name__ without validation. As self is typed Union["PrunaModel", Any], passing an object that lacks these attributes or has __module__ as None will cause an AttributeError.
src/pruna/engine/save.py#L164-L171
Was this report helpful? Give feedback by reacting with 👍 or 👎
Added an optional parameter `is_pro` to the `save_pruna_model_to_hub` function to differentiate between models from the pruna and pruna-pro libraries. Updated the model card template to reflect the correct library and model class based on this parameter.
Modified the `save_pruna_model_to_hub` function to accept a `PrunaModel` instance instead of separate model and smash_config parameters. Adjusted the model card template to format the library name correctly. This change enhances the clarity and usability of the model saving process.
Updated the module reference in the `save_pruna_model_to_hub` function to access the model's module directly, ensuring accurate identification of the library name for model saving.
Revised the type hints in the `save_pruna_model_to_hub` function for clarity, ensuring `pruna_model` is correctly defined as `Union["PrunaModel", Any]`. Updated the model card template to consistently reference `pruna_model_class` instead of `model_class` for improved accuracy in loading models.
Updated the `save_pruna_model_to_hub` function to accept `self`, `model`, and `smash_config` as parameters, improving clarity and consistency in the model saving process. Adjusted the internal logic to directly reference these parameters, ensuring accurate handling of model and configuration data.
Updated the `save_pruna_model_to_hub` function to enhance parameter descriptions and streamline module references. Changed the self parameter description to specify it as a `PrunaModel` object and optimized the library name determination logic for better readability and consistency.
Renamed the `self` parameter to `instance` in the `save_pruna_model_to_hub` function for improved clarity. Updated related type hints and internal references to ensure consistency and better readability in the model saving process.
8691406 to
3e1fd1b
Compare
Enhanced the test_save_to_hub_path_types function by incorporating a PrunaModel instance. This update ensures that the model saving functionality is tested with the correct instance type, improving the accuracy and reliability of the tests.
johannaSommer
approved these changes
Jul 1, 2025
Member
johannaSommer
left a comment
There was a problem hiding this comment.
Perfect! Very concise now and really good extension, thanks David 🌻
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.
Added an optional parameter
is_proto thesave_pruna_model_to_hubfunction to differentiate between models from the pruna and pruna-pro libraries. Updated the model card template to reflect the correct library and model class based on this parameter.Description
Linked Pruna Pro PR https://github.com/PrunaAI/prunatree/pull/129
Related Issue
Fixes #(issue number)
Type of Change
How Has This Been Tested?
Checklist
Additional Notes