This repository was archived by the owner on Sep 10, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 248
remove model.model in ckpt loading #1176
Closed
Closed
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3f2cf36
remove model.model in ckpt loading
Gasoonjia 28c02bd
revert tune version back
Gasoonjia bd8ff07
update gguf model loading
Gasoonjia d18da59
expose internal model attribute:
Gasoonjia b9d1621
avoid inf recursive
Gasoonjia 6831cc6
get around gguf issue
Gasoonjia bcb414f
added doc string for _load_model_state_dict
Gasoonjia 96b51be
Merge branch 'main' into rm-modle.model
Gasoonjia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -442,6 +442,8 @@ def __init__(self, config: ModelArgs) -> None: | |
| # It should be assigned in the actual model implementation, if any. | ||
| self.text_transformer_args = None | ||
|
|
||
| self._register_load_state_dict_pre_hook(self._load_model_state_dict) | ||
|
|
||
| def build_model(self) -> nn.Module: | ||
| """ | ||
| Builds a model based on the provided configuration. | ||
|
|
@@ -468,6 +470,13 @@ def _replace_known_params(self, params): | |
| params[key] = patterns[value] | ||
| return params | ||
|
|
||
| def _load_model_state_dict(self, state_dict, prefix, local_metadata, strict, missing_keys, unexpected_keys, error_msgs): | ||
| # 修改 state dict 中的键值 | ||
|
||
| for key in list(state_dict.keys()): | ||
| new_key = 'model.' + key | ||
| state_dict[new_key] = state_dict.pop(key) | ||
| return state_dict | ||
|
|
||
| @abstractmethod | ||
| def forward(self, *args, **kwargs): | ||
| raise NotImplementedError("forward method is not implemented") | ||
|
|
||
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
Oops, something went wrong.
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.
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.
Comment on what the hook does