Add `attention_bias` argument in transformer block and transformer layer modules, addressing change in MCore
State: closed | Pull request: yes
Labels: name: NLP

name: Run CICD

name: skip-docs

# What does this PR do ?

https://gitlab-master.nvidia.com/ADLR/megatron-lm/-/merge_requests/2293
we need to fix all occurances in NeMo where TransformerBlock is using a non-mcore TransformerLayer. Otherwise the forward interface between Block and Layer will not match anymore and so NeMo will break

**Collection**: [Note which collection this PR will affect]

# Changelog 
- Add specific line by line info of high level changes in this PR.

# Usage
* You can potentially add a usage example below

```python
# Add a code snippet demonstrating how to use this 
```

# GitHub Actions CI

The Jenkins CI system has been replaced by GitHub Actions self-hosted runners.

The GitHub Actions CI will run automatically when the "Run CICD" label is added to the PR.
To re-run CI remove and add the label again.
To run CI on an untrusted fork, a NeMo user with write access must first click "Approve and run".

# Before your PR is "Ready for review"
**Pre checks**:
- [ ] Make sure you read and followed [Contributor guidelines](https://github.com/NVIDIA/NeMo/blob/main/CONTRIBUTING.md)
- [ ] Did you write any new necessary tests?
- [ ] Did you add or update any necessary documentation?
- [ ] Does the PR affect components that are optional to install? (Ex: Numba, Pynini, Apex etc)
  - [ ] Reviewer: Does the PR have correct import guards for all optional libraries?
  
**PR Type**:
- [ ] New Feature
- [ ] Bugfix
- [ ] Documentation

If you haven't finished some of the above items you can still open "Draft" PR.


## Who can review?

Anyone in the community is free to review the PR once the checks have passed. 
[Contributor guidelines](https://github.com/NVIDIA/NeMo/blob/main/CONTRIBUTING.md) contains specific people who can review PRs to various areas.

# Additional Information
* Related to # (issue)


[🤖]: Hi @yaoyu-33 👋,

We wanted to let you know that a [CICD pipeline](https://github.com/NVIDIA/NeMo/actions/runs/11860414730) for this PR just finished successfully

So it might be time to merge this PR or get some approvals

I'm just a bot so I'll leave it you what to do next.

//cc @pablo-garay @ko3n1g

<!-- pylint-output-strict-mode-false -->

beep boop 🤖: 🙏 The following files have warnings. In case you are familiar with these, please try helping us to improve the code base.

---

Your code was analyzed with PyLint. The following annotations have been identified:

```
************* Module nemo.collections.nlp.models.language_modeling.megatron.bert.bert_model
nemo/collections/nlp/models/language_modeling/megatron/bert/bert_model.py:82:0: C0301: Line too long (121/119) (line-too-long)
nemo/collections/nlp/models/language_modeling/megatron/bert/bert_model.py:70:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/nlp/models/language_modeling/megatron/bert/bert_model.py:128:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/nlp/models/language_modeling/megatron/bert/bert_model.py:144:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/nlp/models/language_modeling/megatron/bert/bert_model.py:177:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/nlp/models/language_modeling/megatron/bert/bert_model.py:184:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/nlp/models/language_modeling/megatron/bert/bert_model.py:202:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/nlp/models/language_modeling/megatron/bert/bert_model.py:296:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/nlp/models/language_modeling/megatron/bert/bert_model.py:306:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/nlp/models/language_modeling/megatron/bert/bert_model.py:335:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/nlp/models/language_modeling/megatron/bert/bert_model.py:570:4: C0116: Missing function or method docstring (missing-function-docstring)
************* Module nemo.collections.nlp.models.language_modeling.megatron.falcon.falcon_decoder_layer
nemo/collections/nlp/models/language_modeling/megatron/falcon/falcon_decoder_layer.py:70:0: C0301: Line too long (149/119) (line-too-long)
nemo/collections/nlp/models/language_modeling/megatron/falcon/falcon_decoder_layer.py:102:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/nlp/models/language_modeling/megatron/falcon/falcon_decoder_layer.py:18:4: W0611: Unused parallel_state imported from megatron.core (unused-import)
nemo/collections/nlp/models/language_modeling/megatron/falcon/falcon_decoder_layer.py:19:4: W0611: Unused ShardedObject imported from megatron.core.dist_checkpointing.mapping (unused-import)
nemo/collections/nlp/models/language_modeling/megatron/falcon/falcon_decoder_layer.py:19:4: W0611: Unused ShardedTensor imported from megatron.core.dist_checkpointing.mapping (unused-import)
************* Module nemo.collections.nlp.models.language_modeling.megatron.gpt_full_te_layer_autocast_spec
nemo/collections/nlp/models/language_modeling/megatron/gpt_full_te_layer_autocast_spec.py:51:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/nlp/models/language_modeling/megatron/gpt_full_te_layer_autocast_spec.py:147:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/nlp/models/language_modeling/megatron/gpt_full_te_layer_autocast_spec.py:179:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/nlp/models/language_modeling/megatron/gpt_full_te_layer_autocast_spec.py:303:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/nlp/models/language_modeling/megatron/gpt_full_te_layer_autocast_spec.py:336:0: C0116: Missing function or method docstring (missing-function-docstring)
************* Module nemo.collections.nlp.modules.common.megatron.adapters.mcore_mixins
nemo/collections/nlp/modules/common/megatron/adapters/mcore_mixins.py:140:0: C0301: Line too long (120/119) (line-too-long)
nemo/collections/nlp/modules/common/megatron/adapters/mcore_mixins.py:142:0: C0301: Line too long (147/119) (line-too-long)
nemo/collections/nlp/modules/common/megatron/adapters/mcore_mixins.py:60:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/nlp/modules/common/megatron/adapters/mcore_mixins.py:69:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/nlp/modules/common/megatron/adapters/mcore_mixins.py:76:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/nlp/modules/common/megatron/adapters/mcore_mixins.py:108:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/nlp/modules/common/megatron/adapters/mcore_mixins.py:226:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/nlp/modules/common/megatron/adapters/mcore_mixins.py:326:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/nlp/modules/common/megatron/adapters/mcore_mixins.py:352:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/nlp/modules/common/megatron/adapters/mcore_mixins.py:436:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/nlp/modules/common/megatron/adapters/mcore_mixins.py:443:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/nlp/modules/common/megatron/adapters/mcore_mixins.py:467:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/nlp/modules/common/megatron/adapters/mcore_mixins.py:474:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/nlp/modules/common/megatron/adapters/mcore_mixins.py:492:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/nlp/modules/common/megatron/adapters/mcore_mixins.py:499:4: C0116: Missing function or method docstring (missing-function-docstring)

-----------------------------------
Your code has been rated at 9.42/10
```

---

Thank you for improving NeMo's documentation!

<!-- pylint-output-strict-mode-true -->

beep boop 🤖: 🚨 The following files must be fixed before merge!

---

Your code was analyzed with PyLint. The following annotations have been identified:

```

------------------------------------
Your code has been rated at 10.00/10
```

---

Thank you for improving NeMo's documentation!

<!-- pylint-output-strict-mode-true -->

beep boop 🤖: 🚨 The following files must be fixed before merge!

---

Your code was analyzed with PyLint. The following annotations have been identified:

```

------------------------------------
Your code has been rated at 10.00/10
```

---

Thank you for improving NeMo's documentation!

<!-- pylint-output-strict-mode-false -->

beep boop 🤖: 🙏 The following files have warnings. In case you are familiar with these, please try helping us to improve the code base.

---

Your code was analyzed with PyLint. The following annotations have been identified:

```
************* Module nemo.collections.nlp.models.language_modeling.megatron.bert.bert_model
nemo/collections/nlp/models/language_modeling/megatron/bert/bert_model.py:82:0: C0301: Line too long (121/119) (line-too-long)
nemo/collections/nlp/models/language_modeling/megatron/bert/bert_model.py:70:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/nlp/models/language_modeling/megatron/bert/bert_model.py:128:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/nlp/models/language_modeling/megatron/bert/bert_model.py:144:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/nlp/models/language_modeling/megatron/bert/bert_model.py:177:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/nlp/models/language_modeling/megatron/bert/bert_model.py:184:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/nlp/models/language_modeling/megatron/bert/bert_model.py:202:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/nlp/models/language_modeling/megatron/bert/bert_model.py:296:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/nlp/models/language_modeling/megatron/bert/bert_model.py:306:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/nlp/models/language_modeling/megatron/bert/bert_model.py:335:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/nlp/models/language_modeling/megatron/bert/bert_model.py:570:4: C0116: Missing function or method docstring (missing-function-docstring)
************* Module nemo.collections.nlp.models.language_modeling.megatron.falcon.falcon_decoder_layer
nemo/collections/nlp/models/language_modeling/megatron/falcon/falcon_decoder_layer.py:70:0: C0301: Line too long (149/119) (line-too-long)
nemo/collections/nlp/models/language_modeling/megatron/falcon/falcon_decoder_layer.py:102:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/nlp/models/language_modeling/megatron/falcon/falcon_decoder_layer.py:18:4: W0611: Unused parallel_state imported from megatron.core (unused-import)
nemo/collections/nlp/models/language_modeling/megatron/falcon/falcon_decoder_layer.py:19:4: W0611: Unused ShardedObject imported from megatron.core.dist_checkpointing.mapping (unused-import)
nemo/collections/nlp/models/language_modeling/megatron/falcon/falcon_decoder_layer.py:19:4: W0611: Unused ShardedTensor imported from megatron.core.dist_checkpointing.mapping (unused-import)
************* Module nemo.collections.nlp.models.language_modeling.megatron.gpt_full_te_layer_autocast_spec
nemo/collections/nlp/models/language_modeling/megatron/gpt_full_te_layer_autocast_spec.py:51:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/nlp/models/language_modeling/megatron/gpt_full_te_layer_autocast_spec.py:147:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/nlp/models/language_modeling/megatron/gpt_full_te_layer_autocast_spec.py:179:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/nlp/models/language_modeling/megatron/gpt_full_te_layer_autocast_spec.py:303:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/nlp/models/language_modeling/megatron/gpt_full_te_layer_autocast_spec.py:336:0: C0116: Missing function or method docstring (missing-function-docstring)
************* Module nemo.collections.nlp.modules.common.megatron.adapters.mcore_mixins
nemo/collections/nlp/modules/common/megatron/adapters/mcore_mixins.py:140:0: C0301: Line too long (120/119) (line-too-long)
nemo/collections/nlp/modules/common/megatron/adapters/mcore_mixins.py:142:0: C0301: Line too long (147/119) (line-too-long)
nemo/collections/nlp/modules/common/megatron/adapters/mcore_mixins.py:60:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/nlp/modules/common/megatron/adapters/mcore_mixins.py:69:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/nlp/modules/common/megatron/adapters/mcore_mixins.py:76:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/nlp/modules/common/megatron/adapters/mcore_mixins.py:108:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/nlp/modules/common/megatron/adapters/mcore_mixins.py:226:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/nlp/modules/common/megatron/adapters/mcore_mixins.py:326:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/nlp/modules/common/megatron/adapters/mcore_mixins.py:352:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/nlp/modules/common/megatron/adapters/mcore_mixins.py:436:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/nlp/modules/common/megatron/adapters/mcore_mixins.py:443:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/nlp/modules/common/megatron/adapters/mcore_mixins.py:467:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/nlp/modules/common/megatron/adapters/mcore_mixins.py:474:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/nlp/modules/common/megatron/adapters/mcore_mixins.py:492:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/nlp/modules/common/megatron/adapters/mcore_mixins.py:499:4: C0116: Missing function or method docstring (missing-function-docstring)

-----------------------------------
Your code has been rated at 9.42/10
```

---

Thank you for improving NeMo's documentation!

[🤖]: Hi @yaoyu-33 👋,

We wanted to let you know that a [CICD pipeline](https://github.com/NVIDIA/NeMo/actions/runs/11897810177) for this PR just finished successfully

So it might be time to merge this PR or get some approvals

I'm just a bot so I'll leave it you what to do next.

//cc @pablo-garay @ko3n1g