-
Notifications
You must be signed in to change notification settings - Fork 56
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
add alibi position embedding and support baichuan #54
base: main
Are you sure you want to change the base?
Conversation
add alibi position embedding
Cool! It may take some time to review 🙃 |
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.
I'll review again once you solve the comments.
megatron/model/transformer.py
Outdated
@@ -471,10 +542,24 @@ def __init__(self, init_method, | |||
self.core_attention = CoreAttention(self.layer_number, | |||
self.attn_mask_type) | |||
self.checkpoint_core_attention = args.recompute_granularity == 'selective' | |||
|
|||
self.apply_query_key_layer_scaling = args.apply_query_key_layer_scaling | |||
world_size = mpu.get_tensor_model_parallel_world_size() |
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.
tensor_parallel_size
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.
tensor_parallel_size
sorry, I didn't get it. Do you mean the variance name should be tensor_parallel_size?
@li-yi-dong Thanks for your time and cautious review. I have made the necessary changes and addressed the comments you mentioned. Please take another look at the updated version at your convenience. |
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.
Big thanks to your efforts and patience.
I added some comments to resolve.
@@ -1222,11 +1286,106 @@ def set_input_tensor(self, input_tensor): | |||
forward_step_func""" | |||
self.input_tensor = input_tensor | |||
|
|||
def _build_alibi_tensor(self, tensor, max_seq_len, num_attention_heads): |
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.
Placing this func together with alibi_mask_func
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 func requires the internal variable first_run, so it cannot be placed in the utils.
This adds the ALiBi method and its flash attention version (using triton) for positional information. And it supports baichuan model trainig by porting over the implementation from baichuan-inc/Baichuan2-13B-Base .