-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Engine side fix for loading llama checkpoint fine-tuned with zero3 #3981
Merged
Conversation
This file contains 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
minjiaz
requested review from
RezaYazdaniAminabadi,
jeffra,
mrwyattii,
awan-10,
cmikeh2 and
arashb
as code owners
July 18, 2023 19:01
mrwyattii
reviewed
Jul 18, 2023
Hi, the DeepSpeed Team, I encountered the same issue while enabling HybridEngine for the LLaMA model with ZeRO-3. After several hours of debugging, I found a similar fix: def get_hidden_heads(self):
- return self.client_module.self_attn.q_proj.weight.shape[1], \
+ return self.client_module.self_attn.q_proj.in_features, \
self.client_module.self_attn.num_heads, \
self.client_module.input_layernorm.variance_epsilon, \
- self.client_module.mlp.gate_proj.weight.shape[0]
+ self.client_module.mlp.gate_proj.out_features |
XuehaiPan
reviewed
Jul 24, 2023
Comment on lines
125
to
134
try: # for zero stage 3 | ||
return self.client_module.self_attn.q_proj.weight.ds_shape[1], \ | ||
self.client_module.self_attn.num_heads, \ | ||
self.client_module.input_layernorm.variance_epsilon, \ | ||
self.client_module.mlp.gate_proj.weight.ds_shape[0] | ||
except: | ||
return self.client_module.self_attn.q_proj.weight.shape[1], \ | ||
self.client_module.self_attn.num_heads, \ | ||
self.client_module.input_layernorm.variance_epsilon, \ | ||
self.client_module.mlp.gate_proj.weight.shape[0] |
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.
It would be nicer with temp variable + getattr
.
Suggested change
try: # for zero stage 3 | |
return self.client_module.self_attn.q_proj.weight.ds_shape[1], \ | |
self.client_module.self_attn.num_heads, \ | |
self.client_module.input_layernorm.variance_epsilon, \ | |
self.client_module.mlp.gate_proj.weight.ds_shape[0] | |
except: | |
return self.client_module.self_attn.q_proj.weight.shape[1], \ | |
self.client_module.self_attn.num_heads, \ | |
self.client_module.input_layernorm.variance_epsilon, \ | |
self.client_module.mlp.gate_proj.weight.shape[0] | |
q_proj_weight = self.client_module.self_attn.q_proj.weight | |
gate_proj_weight = self.client_module.mlp.gate_proj.weight | |
return getattr(q_proj_weight, "ds_shape", q_proj_weight.shape)[1], \ | |
self.client_module.self_attn.num_heads, \ | |
self.client_module.input_layernorm.variance_epsilon, \ | |
getattr(gate_proj_weight, "ds_shape", gate_proj_weight.shape)[0] |
XuehaiPan
reviewed
Jul 25, 2023
mrwyattii
approved these changes
Jul 26, 2023
polisettyvarma
pushed a commit
to polisettyvarma/DeepSpeed
that referenced
this pull request
Aug 7, 2023
…icrosoft#3981) * Engine side fix for loading llama checkpoint fine-tuned with zero3 * Fixes to support llama fine-tuning in ds-chat * Refactored the code to avoid using an except block. * formatting * revert permissions change --------- Co-authored-by: Michael Wyatt <michaelwyatt@microsoft.com>
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.
The loading of the Llama checkpoint is broken if we fine-tune it with zero-3. This issue prevents the loading of the Llama fine-tuned actor and critic models in DS-Chat for PPO stage 3 fine-tuning. The problem has been resolved by making the Llama container policy aware of zero-3.