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

Add context_logits for eval accuracy calculation in case of multi token prediction tasks #11753

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

Conversation

athitten
Copy link
Collaborator

@athitten athitten commented Jan 3, 2025

What does this PR do ?

This PR adds the following changes:

  1. Uses context_logits to compute logProbs in case of eval benchmarks that have multiple token prediction. For ex: arc_challenge, arc_easy, winogrande, copa etc., (where as MMLU, lambada are single token prediction benchmarks. Uses generation_logits for these benchmarks to avoid large payload from context_logits )

  2. In order to get context_logits for evals, the PR exposes gather_context_logits and output_context logits in export and deploy files similar to previously existed generation_logits

  3. Introduces requirements_eval.txt file to install lm-eval-harness in NeMo FW containers.

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)

@athitten athitten changed the base branch from main to athitten/eval_server_ready_check January 3, 2025 22:46
@athitten athitten force-pushed the athitten/add_context_logits branch from 630966e to 5fb26b1 Compare January 6, 2025 23:09
@athitten athitten force-pushed the athitten/eval_server_ready_check branch from 4bd6b47 to 8cbaef3 Compare January 7, 2025 00:42
Base automatically changed from athitten/eval_server_ready_check to main January 7, 2025 19:20
nemo/export/tensorrt_llm.py Fixed Show fixed Hide fixed
@athitten athitten force-pushed the athitten/add_context_logits branch from cd4e7e6 to 900ad07 Compare January 8, 2025 19:31
@athitten athitten changed the title Use context_logits for eval accuracy calculation Add context_logits for eval accuracy calculation in case of multi token prediction tasks Jan 8, 2025
Comment on lines +46 to +48
def _generate_tokens_logits(
self, payload, single_prediction_token, return_text: bool = False, return_logits: bool = False
):

Check notice

Code scanning / CodeQL

Explicit returns mixed with implicit (fall through) returns Note

Mixing implicit and explicit returns may indicate an error as implicit returns always return None.
athitten and others added 6 commits January 8, 2025 20:22
Uses bool generation_logits_available as inputs dict does not contain it

Signed-off-by: Abhishree <[email protected]>
Signed-off-by: Abhishree <[email protected]>
@athitten athitten force-pushed the athitten/add_context_logits branch from 07925a5 to f0c3cb3 Compare January 9, 2025 04:23
@athitten athitten marked this pull request as ready for review January 9, 2025 06:16
Copy link
Contributor

github-actions bot commented Jan 9, 2025

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.api
nemo/collections/llm/api.py:368:0: C0301: Line too long (121/119) (line-too-long)
nemo/collections/llm/api.py:369:0: C0301: Line too long (120/119) (line-too-long)
nemo/collections/llm/api.py:445:0: C0301: Line too long (130/119) (line-too-long)
nemo/collections/llm/api.py:572:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/collections/llm/api.py:15:0: W0611: Unused import os (unused-import)
************* Module nemo.deploy.nlp.query_llm
nemo/deploy/nlp/query_llm.py:29:0: C0115: Missing class docstring (missing-class-docstring)
nemo/deploy/nlp/query_llm.py:16:0: W0611: Unused abstractmethod imported from abc (unused-import)
************* Module nemo.export.trt_llm.tensorrt_llm_run
nemo/export/trt_llm/tensorrt_llm_run.py:506:0: C0301: Line too long (125/119) (line-too-long)
nemo/export/trt_llm/tensorrt_llm_run.py:510:0: C0301: Line too long (136/119) (line-too-long)
nemo/export/trt_llm/tensorrt_llm_run.py:514:0: C0301: Line too long (123/119) (line-too-long)
nemo/export/trt_llm/tensorrt_llm_run.py:557:0: C0301: Line too long (181/119) (line-too-long)
nemo/export/trt_llm/tensorrt_llm_run.py:844:0: C0301: Line too long (153/119) (line-too-long)
nemo/export/trt_llm/tensorrt_llm_run.py:524:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/export/trt_llm/tensorrt_llm_run.py:533:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/export/trt_llm/tensorrt_llm_run.py:591:0: C0116: Missing function or method docstring (missing-function-docstring)
nemo/export/trt_llm/tensorrt_llm_run.py:33:0: W0611: Unused Mapping imported from tensorrt_llm.mapping (unused-import)

-----------------------------------
Your code has been rated at 9.88/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
Collaborator

@oyilmaz-nvidia oyilmaz-nvidia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good but can you please run the examples here https://docs.nvidia.com/nemo-framework/user-guide/latest/deployment/llm/optimized/tensorrt_llm.html and make sure nothing is broken?

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

Successfully merging this pull request may close these issues.

2 participants