Skip to content

feat: enhance model saving functionality with pro support#200

Merged
davidberenstein1957 merged 8 commits intomainfrom
feat/add-pro-suport-push-to-hub
Jul 1, 2025
Merged

feat: enhance model saving functionality with pro support#200
davidberenstein1957 merged 8 commits intomainfrom
feat/add-pro-suport-push-to-hub

Conversation

@davidberenstein1957
Copy link
Copy Markdown
Member

@davidberenstein1957 davidberenstein1957 commented Jun 10, 2025

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.

Description

Linked Pruna Pro PR https://github.com/PrunaAI/prunatree/pull/129

Related Issue

Fixes #(issue number)

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Additional Notes

@davidberenstein1957 davidberenstein1957 changed the title feat: enhance model saving functionality feat: enhance model saving functionality with pro support Jun 10, 2025
@davidberenstein1957 davidberenstein1957 requested review from begumcig, johannaSommer, johnrachwan123 and sharpenb and removed request for sharpenb June 11, 2025 16:16
Copy link
Copy Markdown
Member

@johnrachwan123 johnrachwan123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

Comment thread src/pruna/engine/save.py Outdated
Comment thread src/pruna/engine/save.py Outdated
cursor[bot]

This comment was marked as outdated.

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

https://github.com/PrunaAI/pruna/blob/2d5c0403d9b9831955450b100f77f74c6b3523ba/src/pruna/engine/save.py#L164-L171

Fix in Cursor


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.
@davidberenstein1957 davidberenstein1957 force-pushed the feat/add-pro-suport-push-to-hub branch from 8691406 to 3e1fd1b Compare June 24, 2025 06:45
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.
Copy link
Copy Markdown
Member

@johannaSommer johannaSommer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect! Very concise now and really good extension, thanks David 🌻

@davidberenstein1957 davidberenstein1957 merged commit e9741fb into main Jul 1, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants