QK logits clipping (non-split version) - #1929
Conversation
Signed-off-by: Boxiang Wang <boxiangw@nvidia.com>
Signed-off-by: Boxiang Wang <boxiangw@nvidia.com>
Signed-off-by: Boxiang Wang <boxiangw@nvidia.com>
Signed-off-by: Boxiang Wang <boxiangw@nvidia.com>
Signed-off-by: Boxiang Wang <boxiangw@nvidia.com>
Signed-off-by: Boxiang Wang <boxiangw@nvidia.com>
Signed-off-by: Boxiang Wang <boxiangw@nvidia.com>
Signed-off-by: Boxiang Wang <boxiangw@nvidia.com>
Signed-off-by: Boxiang Wang <boxiangw@nvidia.com>
Signed-off-by: Boxiang Wang <boxiangw@nvidia.com>
|
TE's NVIDIA/TransformerEngine#2195 (2.9.0) is needed for this PR |
Signed-off-by: Boxiang Wang <boxiangw@nvidia.com>
Signed-off-by: Boxiang Wang <boxiangw@nvidia.com>
Signed-off-by: Boxiang Wang <boxiangw@nvidia.com>
It has been merged. |
|
/ok to test 7917e68 |
|
/ok to test b63c573 |
Signed-off-by: Boxiang Wang <boxiangw@nvidia.com>
| if config.qk_clip and is_te_min_version("2.9.0"): | ||
| # TE 2.9.0 introduces return_max_logit for qk-clip getting the max attention logits | ||
| extra_kwargs["return_max_logit"] = True | ||
| self.current_max_attn_logits = None |
There was a problem hiding this comment.
what if not is_te_min_version but config.qk_clip? might raise an error
There was a problem hiding this comment.
Right now it will raise an error if te version is wrong
| """ | ||
|
|
||
| log_max_attention_logit = 0 | ||
| for model_chunk in model: |
There was a problem hiding this comment.
i dont remember, is model always a list?
There was a problem hiding this comment.
According to https://github.com/NVIDIA/Megatron-LM/pull/1929/files#diff-7fc2a91343e49be3c1705b8237bbe437029132d8826e5c963e1b0b84d457bc38L1250. I think it is true for MLM, is it true for MBridge as well?
Signed-off-by: Boxiang Wang <boxiangw@nvidia.com>
Signed-off-by: Boxiang Wang <boxiangw@nvidia.com>
Signed-off-by: Boxiang Wang <boxiangw@nvidia.com>
Signed-off-by: Boxiang Wang <boxiangw@nvidia.com>
|
/ok to test 95fdba3 |
|
Can we re-name this PR? It should just be "QK logits clipping" or something similar? |
|
|
||
| import torch | ||
|
|
||
| from megatron.core import mpu |
There was a problem hiding this comment.
Should use parrallel_state, mpu is a legacy name.
There was a problem hiding this comment.
Thanks for catching this, changed to parrallel_state instead
| torch.distributed.all_reduce( | ||
| transformer_layer.self_attention.core_attention.current_max_attn_logits, | ||
| op=torch.distributed.ReduceOp.MAX, | ||
| group=mpu.get_data_parallel_group(with_context_parallel=True), |
There was a problem hiding this comment.
Is there any way to get this group in via args? We are trying to move away from global process groups.
Signed-off-by: Boxiang Wang <boxiangw@nvidia.com>
|
/ok to test 6562a52 |
|
/ok to test a2e7407 |
|
/ok to test d83c38e |
|
/ok to test dd82679 |
|
/ok to test eed3c2d |
|
/ok to test 99c7631 |
|
/ok to test 24e6c88 |
Added MLA and MHA(GQA) clipping support