-
Notifications
You must be signed in to change notification settings - Fork 6.2k
[wip][core] parallel loading of shards #12028
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: main
Are you sure you want to change the base?
Conversation
@@ -310,6 +311,130 @@ def load_model_dict_into_meta( | |||
return offload_index, state_dict_index | |||
|
|||
|
|||
def check_support_param_buffer_assignment(model_to_load, state_dict, start_prefix=""): |
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.
Moved it here from modeling_utils.py
.
return offload_index, state_dict_index, mismatched_keys, error_msgs | ||
|
||
|
||
def _find_mismatched_keys( |
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.
Same. Moved it out of modeling_utils.py
.
if len(resolved_model_file) > 1: | ||
resolved_model_file = logging.tqdm(resolved_model_file, desc="Loading checkpoint shards") | ||
|
||
mismatched_keys = [] | ||
assign_to_params_buffers = None | ||
error_msgs = [] | ||
|
||
for shard_file in resolved_model_file: | ||
state_dict = load_state_dict(shard_file, dduf_entries=dduf_entries) | ||
mismatched_keys += _find_mismatched_keys( | ||
state_dict, model_state_dict, loaded_keys, ignore_mismatched_sizes |
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.
This has been moved to load_shard_file()
.
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
What does this PR do?
Similar to huggingface/transformers#36835.
`main`: time: 8.162s this branch: time: 5.663s
code