-
Notifications
You must be signed in to change notification settings - Fork 9
Converters refactor [transformers-utils]: Generalize model utilities for broader transformer support #103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: features/converters/utils-updates
Are you sure you want to change the base?
Conversation
📦 Build Artifacts Available |
4403a77
to
d7ec38f
Compare
f8de1f7
to
622462c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors transformer utilities from Eagle-specific implementations to comprehensive, generalized utilities. It extracts and enhances existing functionality into a dedicated transformers_utils
module that supports multiple weight formats, authentication, caching, and robust error handling while maintaining backward compatibility.
- Generalized utilities: Replaced Eagle-specific functions with enhanced, reusable transformer utilities
- Enhanced functionality: Added support for SafeTensors, authentication, caching, and model instances
- Comprehensive testing: Replaced Eagle-specific tests with expanded test coverage for the new utilities
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
src/speculators/utils/transformers_utils.py |
New comprehensive module with generalized transformer utilities |
src/speculators/utils/__init__.py |
Export new transformer utility functions |
tests/unit/utils/test_transformers_utils.py |
Comprehensive test suite for new utilities |
tests/unit/convert/test_eagle_utils.py |
Removed Eagle-specific tests |
src/speculators/convert/eagle/utils.py |
Removed Eagle-specific utility functions |
Comments suppressed due to low confidence (1)
tests/unit/utils/test_transformers_utils.py:1
- The noqa comment indicates a linting issue that should be addressed. The comment references SIM118 which suggests using dict comprehension instead of iterating over keys.
"""
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
4f47c07
to
c67c12f
Compare
dea8e9a
to
26eebee
Compare
Signed-off-by: Mark Kurtz <[email protected]>
Co-authored-by: Copilot <[email protected]> Signed-off-by: Mark Kurtz <[email protected]>
Signed-off-by: Mark Kurtz <[email protected]>
Signed-off-by: Mark Kurtz <[email protected]>
50eb873
to
a3c0f80
Compare
Signed-off-by: Mark Kurtz <[email protected]>
# Register default mock model | ||
factory, patched = mock_pretrained_factory | ||
|
||
return factory.register(), patched[ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!
Summary
Refactors transformer utilities from Eagle-specific implementations to comprehensive, generalized utilities. Extracts and enhances existing functionality into a dedicated
transformers_utils
module that supports multiple weight formats, authentication, caching, and robust error handling while maintaining backward compatibility.Details
src/speculators/convert/eagle/utils.py
in favor ofsrc/speculators/utils/transformers_utils.py
module:download_checkpoint_from_hub()
,ensure_checkpoint_is_local()
,load_checkpoint_config()
,load_checkpoint_weights()
,detect_fusion_bias_and_layernorms()
download_model_checkpoint_from_hub()
- Enhanced downloading with authentication, caching, and revision supportcheck_download_model_checkpoint()
- Smart path/model instance handling with automatic downloadscheck_download_model_config()
- Flexible config loading from various sourcesload_model_config()
- Unified config loading with AutoConfig integrationload_model_checkpoint_config_dict()
- Dictionary-based config loadingload_model_checkpoint_weight_files()
- Multi-format weight file discoveryload_model_checkpoint_index_weight_files()
- Indexed/sharded weight file supportload_model_checkpoint_state_dict()
- Complete state dictionary loading with format detectiontransformers_utils
:Test Plan
Related Issues
N/A