Skip to content
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

remove nemo.collection.nlp imports from nemo2 #11904

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

dimapihtar
Copy link
Collaborator

What does this PR do ?

Add a one line overview of what this PR aims to accomplish.

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
# 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
  • 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 contains specific people who can review PRs to various areas.

Additional Information

  • Related to # (issue)

@dimapihtar dimapihtar changed the title Dpykhtar/nemo2 transition remove nemo.collection.nlp imports from nemo2 Jan 20, 2025
Copy link
Contributor

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


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

************* Module nemo.collections.llm.bert.data.core
nemo/collections/llm/bert/data/core.py:59:0: C0301: Line too long (120/119) (line-too-long)
nemo/collections/llm/bert/data/core.py:60:0: C0301: Line too long (173/119) (line-too-long)
nemo/collections/llm/bert/data/core.py:61:0: C0301: Line too long (156/119) (line-too-long)
nemo/collections/llm/bert/data/core.py:65:0: C0301: Line too long (157/119) (line-too-long)
nemo/collections/llm/bert/data/core.py:66:0: C0301: Line too long (121/119) (line-too-long)
nemo/collections/llm/bert/data/core.py:68:0: C0301: Line too long (247/119) (line-too-long)
nemo/collections/llm/bert/data/core.py:499:0: C0301: Line too long (123/119) (line-too-long)
nemo/collections/llm/bert/data/core.py:553:0: C0301: Line too long (132/119) (line-too-long)
nemo/collections/llm/bert/data/core.py:561:0: C0301: Line too long (140/119) (line-too-long)
nemo/collections/llm/bert/data/core.py:614:0: C0301: Line too long (183/119) (line-too-long)
nemo/collections/llm/bert/data/core.py:38:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/llm/bert/data/core.py:17:0: W0611: Unused multiprocessing imported as mp (unused-import)
nemo/collections/llm/bert/data/core.py:18:0: W0611: Unused import os (unused-import)

-----------------------------------
Your code has been rated at 9.66/10

Mitigation guide:

  • Add sensible and useful docstrings to functions and methods
  • For trivial methods like getter/setters, consider adding # pylint: disable=C0116 inside the function itself
  • To disable multiple functions/methods at once, put a # pylint: disable=C0116 before the first and a # pylint: enable=C0116 after the last.

By applying these rules, we reduce the occurance of this message in future.

Thank you for improving NeMo's documentation!

Copy link
Contributor

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.llm.gpt.model.base
nemo/collections/llm/gpt/model/base.py:245:0: C0301: Line too long (122/119) (line-too-long)
nemo/collections/llm/gpt/model/base.py:422:0: C0301: Line too long (126/119) (line-too-long)
nemo/collections/llm/gpt/model/base.py:56:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/model/base.py:99:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/model/base.py:120:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/model/base.py:131:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/model/base.py:139:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/model/base.py:147:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/model/base.py:157:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/model/base.py:167:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/llm/gpt/model/base.py:192:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/model/base.py:271:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/llm/gpt/model/base.py:283:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/llm/gpt/model/base.py:295:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/llm/gpt/model/base.py:307:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/llm/gpt/model/base.py:319:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/llm/gpt/model/base.py:331:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/llm/gpt/model/base.py:345:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/llm/gpt/model/base.py:363:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/model/base.py:367:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/model/base.py:390:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/model/base.py:393:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/model/base.py:396:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/model/base.py:400:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/model/base.py:405:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/model/base.py:436:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/model/base.py:443:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/model/base.py:450:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/llm/gpt/model/base.py:544:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/model/base.py:576:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/llm/gpt/model/base.py:698:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/model/base.py:730:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/model/base.py:758:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/model/base.py:48:4: W0611: Unused import fused_weight_gradient_mlp_cuda (unused-import)
************* Module nemo.collections.llm.gpt.model.gemma
nemo/collections/llm/gpt/model/gemma.py:41:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/llm/gpt/model/gemma.py:62:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/llm/gpt/model/gemma.py:71:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/llm/gpt/model/gemma.py:79:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/llm/gpt/model/gemma.py:83:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/llm/gpt/model/gemma.py:87:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/llm/gpt/model/gemma.py:107:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/llm/gpt/model/gemma.py:127:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/model/gemma.py:140:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/model/gemma.py:146:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/model/gemma.py:178:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/llm/gpt/model/gemma.py:197:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/model/gemma.py:210:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/model/gemma.py:214:4: C0116: Missing function or method docstring (missing-function-docstring)
************* Module nemo.collections.llm.gpt.model.gemma2
nemo/collections/llm/gpt/model/gemma2.py:192:0: C0301: Line too long (120/119) (line-too-long)
nemo/collections/llm/gpt/model/gemma2.py:193:0: C0301: Line too long (130/119) (line-too-long)
nemo/collections/llm/gpt/model/gemma2.py:269:0: C0301: Line too long (120/119) (line-too-long)
nemo/collections/llm/gpt/model/gemma2.py:270:0: C0301: Line too long (130/119) (line-too-long)
nemo/collections/llm/gpt/model/gemma2.py:54:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/model/gemma2.py:85:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/llm/gpt/model/gemma2.py:112:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/llm/gpt/model/gemma2.py:122:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/llm/gpt/model/gemma2.py:132:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/llm/gpt/model/gemma2.py:141:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/llm/gpt/model/gemma2.py:164:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/llm/gpt/model/gemma2.py:185:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/model/gemma2.py:200:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/model/gemma2.py:206:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/model/gemma2.py:243:0: C0115: Missing class docstring (missing-class-docstring)
nemo/collections/llm/gpt/model/gemma2.py:262:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/model/gemma2.py:277:4: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/gpt/model/gemma2.py:281:4: C0116: Missing function or method docstring (missing-function-docstring)
************* Module nemo.collections.llm.t5.model.t5
nemo/collections/llm/t5/model/t5.py:392:0: C0301: Line too long (142/119) (line-too-long)
nemo/collections/llm/t5/model/t5.py:393:0: C0301: Line too long (142/119) (line-too-long)
nemo/collections/llm/t5/model/t5.py:394:0: C0301: Line too long (120/119) (line-too-long)
nemo/collections/llm/t5/model/t5.py:399:0: C0301: Line too long (120/119) (line-too-long)
nemo/collections/llm/t5/model/t5.py:620:0: C0301: Line too long (142/119) (line-too-long)
nemo/collections/llm/t5/model/t5.py:621:0: C0301: Line too long (142/119) (line-too-long)
nemo/collections/llm/t5/model/t5.py:622:0: C0301: Line too long (120/119) (line-too-long)
nemo/collections/llm/t5/model/t5.py:627:0: C0301: Line too long (120/119) (line-too-long)
nemo/collections/llm/t5/model/t5.py:42:4: W0611: Unused import transformer_engine (unused-import)

-----------------------------------
Your code has been rated at 9.44/10

Mitigation guide:

  • Add sensible and useful docstrings to functions and methods
  • For trivial methods like getter/setters, consider adding # pylint: disable=C0116 inside the function itself
  • To disable multiple functions/methods at once, put a # pylint: disable=C0116 before the first and a # pylint: enable=C0116 after the last.

By applying these rules, we reduce the occurance of this message in future.

Thank you for improving NeMo's documentation!

@@ -12,15 +12,305 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import datetime
import json
import multiprocessing as mp

Check notice

Code scanning / CodeQL

Unused import Note

Import of 'mp' is not used.
import datetime
import json
import multiprocessing as mp
import os

Check notice

Code scanning / CodeQL

Unused import Note

Import of 'os' is not used.
attention_mask = [self._create_attention_mask2(max_length, len) for len in lengths]
attention_mask = torch.stack(attention_mask)
position_ids = [list(range(max_length)) for _ in batch]
position_ids = torch.LongTensor(position_ids)

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable position_ids is not used.
position_ids = [list(range(max_length)) for _ in batch]
position_ids = torch.LongTensor(position_ids)
input_ids = torch.LongTensor(self._collate_item(input_ids, max_length=max_length, pad_id=0))
lengths = torch.LongTensor(lengths) - 1 # subtract 1 to account for the eos token

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable lengths is not used.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant