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

Triton deployment improvements for in-framework models #9600

Merged
merged 15 commits into from
Jul 9, 2024

Conversation

jukim-nv
Copy link
Contributor

@jukim-nv jukim-nv commented Jul 3, 2024

What does this PR do ?

Adding better support for triton deployment of in-framework models using MegatronLLMDeployable.

Collection: [Note which collection this PR will affect]
scripts/deploy
tests/deploy

Changelog

  • Add NemoQueryLLMPyTorch class for easy query of MegatronLLMDeployable
  • Changes to nemo_export.py to accurately test MegatronLLMDeployable models
  • A separate deploy_inframework_triton.py deployment script to easily deploy MegatronLLMDeployable on a Triton server

Usage

python scripts/deploy/nlp/deploy_inframework_triton.py -nc <path to .nemo checkpoint> -tmn TritonModelName 

python tests/export/nemo_export.py --checkpoint_dir <path to .nemo checkpoint> --model_type gpt --min_tps 1 --max_output_len 24 --test_deployment False --in_framework True --model_name TritonModelName

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)

@jukim-nv jukim-nv changed the title Draft: Triton deployment improvements for in-framework models Triton deployment improvements for in-framework models Jul 4, 2024
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.

Ran this python tests/export/nemo_export.py --model_name LLAMA2-7B-base --existing_test_models --min_tps 1 --in_framework True and got the following error

[rank0]: Traceback (most recent call last):
[rank0]: File "/usr/local/lib/python3.10/dist-packages/pytriton/client/client.py", line 661, in _infer
[rank0]: response = self._infer_client.infer(
[rank0]: File "/usr/local/lib/python3.10/dist-packages/tritonclient/http/_client.py", line 1482, in infer
[rank0]: _raise_if_error(response)
[rank0]: File "/usr/local/lib/python3.10/dist-packages/tritonclient/http/_utils.py", line 69, in _raise_if_error
[rank0]: raise error
[rank0]: tritonclient.utils.InferenceServerException: [400] [request id: 0] unexpected shape for input 'max_length' for model 'LLAMA2-7B-base'. Expected [-1,1], got [1]. NOTE: Setting a non-zero max_batch_size in the model config requires a batch dimension to be prepended to each input shape. If you want to specify the full shape including the batch dim in your input dims config, try setting max_batch_size to zero. See the model configuration docs for more info on max_batch_size.

[rank0]: The above exception was the direct cause of the following exception:

[rank0]: Traceback (most recent call last):
[rank0]: File "/opt/NeMo/tests/export/nemo_export.py", line 909, in
[rank0]: run_inference_tests(args)
[rank0]: File "/opt/NeMo/tests/export/nemo_export.py", line 777, in run_inference_tests
[rank0]: result_dic[tps] = run_existing_checkpoints(
[rank0]: File "/opt/NeMo/tests/export/nemo_export.py", line 482, in run_existing_checkpoints
[rank0]: return run_in_framework_inference(
[rank0]: File "/opt/NeMo/tests/export/nemo_export.py", line 561, in run_in_framework_inference
[rank0]: output_deployed = nq.query_llm(
[rank0]: File "/opt/NeMo/nemo/deploy/nlp/query_llm.py", line 123, in query_llm
[rank0]: result_dict = client.infer_batch(**inputs)
[rank0]: File "/usr/local/lib/python3.10/dist-packages/pytriton/client/client.py", line 603, in infer_batch
[rank0]: return self._infer(inputs or named_inputs, parameters, headers)
[rank0]: File "/usr/local/lib/python3.10/dist-packages/pytriton/client/client.py", line 678, in _infer
[rank0]: raise PyTritonClientInferenceServerError(
[rank0]: pytriton.client.exceptions.PyTritonClientInferenceServerError: Error occurred during inference request. Message: [request id: 0] unexpected shape for input 'max_length' for model 'LLAMA2-7B-base'. Expected [-1,1], got [1]. NOTE: Setting a non-zero max_batch_size in the model config requires a batch dimension to be prepended to each input shape. If you want to specify the full shape including the batch dim in your input dims config, try setting max_batch_size to zero. See the model configuration docs for more info on max_batch_size.
Signal (2) received.

But this worked

python tests/export/nemo_export.py --model_name llama --model_type llama --min_tps 1 --checkpoint_dir /opt/checkpoints/LLAMA2-7B-base/LLAMA2-7B-base-1.nemo --in_framework True

@github-actions github-actions bot removed the NLP label Jul 6, 2024
Signed-off-by: jukim-nv <jukim-nv@users.noreply.github.com>
tests/export/nemo_export.py Dismissed Show resolved Hide resolved
scripts/deploy/nlp/query_inframework.py Fixed Show fixed Hide fixed
scripts/deploy/nlp/query_inframework.py Fixed Show fixed Hide fixed
tests/export/nemo_export.py Dismissed Show resolved Hide resolved
all_expected_outputs.append(expected_output)
all_actual_outputs.append(model_output)
if model is not None:
if isinstance(model, MegatronLLMDeployable):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't feel particularly good about using isinstance() here. Would be open to a better way to split the different paths.

tests/export/nemo_export.py Dismissed Show resolved Hide resolved
tests/export/nemo_export.py Dismissed Show resolved Hide resolved
@oyilmaz-nvidia
Copy link
Collaborator

Could you please address all of these CodeQL reviews?

@oyilmaz-nvidia oyilmaz-nvidia merged commit 8898b76 into NVIDIA:main Jul 9, 2024
113 checks passed
marcromeyn pushed a commit that referenced this pull request Jul 11, 2024
* add NemoQueryLLMPyTorch class for triton query of in-framework models

* nemo_export.py changes to better support in-framework models

* separate out in-framework version of triton deploy script

* add generate() function to MegatronLLMDeployable to allow for direct use in export tests

* use NemoQueryLLMPyTorch in deploy tests

* add warning message for when MegatronLLMDeployable overrides transformer_engine

* remove enable_streaming argument from deploy_inframework_triton.py since MegatronLLMDeployable does not support streaming
add query_inframework.py since original query.py does not work with in-framework deployments

* Apply isort and black reformatting

Signed-off-by: jukim-nv <jukim-nv@users.noreply.github.com>

* skip trtllm support check if in_framework testing

* remove unused imports

* run_existing_checkpoints was passing wrong prompts argument for in-framework mode

* fix unused import in query_inframework.py

---------

Signed-off-by: jukim-nv <jukim-nv@users.noreply.github.com>
Co-authored-by: jukim-nv <jukim-nv@users.noreply.github.com>
Co-authored-by: Onur Yilmaz <35306097+oyilmaz-nvidia@users.noreply.github.com>
marcromeyn pushed a commit that referenced this pull request Jul 11, 2024
* add NemoQueryLLMPyTorch class for triton query of in-framework models

* nemo_export.py changes to better support in-framework models

* separate out in-framework version of triton deploy script

* add generate() function to MegatronLLMDeployable to allow for direct use in export tests

* use NemoQueryLLMPyTorch in deploy tests

* add warning message for when MegatronLLMDeployable overrides transformer_engine

* remove enable_streaming argument from deploy_inframework_triton.py since MegatronLLMDeployable does not support streaming
add query_inframework.py since original query.py does not work with in-framework deployments

* Apply isort and black reformatting

Signed-off-by: jukim-nv <jukim-nv@users.noreply.github.com>

* skip trtllm support check if in_framework testing

* remove unused imports

* run_existing_checkpoints was passing wrong prompts argument for in-framework mode

* fix unused import in query_inframework.py

---------

Signed-off-by: jukim-nv <jukim-nv@users.noreply.github.com>
Co-authored-by: jukim-nv <jukim-nv@users.noreply.github.com>
Co-authored-by: Onur Yilmaz <35306097+oyilmaz-nvidia@users.noreply.github.com>
maanug-nv pushed a commit that referenced this pull request Jul 14, 2024
* add NemoQueryLLMPyTorch class for triton query of in-framework models

* nemo_export.py changes to better support in-framework models

* separate out in-framework version of triton deploy script

* add generate() function to MegatronLLMDeployable to allow for direct use in export tests

* use NemoQueryLLMPyTorch in deploy tests

* add warning message for when MegatronLLMDeployable overrides transformer_engine

* remove enable_streaming argument from deploy_inframework_triton.py since MegatronLLMDeployable does not support streaming
add query_inframework.py since original query.py does not work with in-framework deployments

* Apply isort and black reformatting

Signed-off-by: jukim-nv <jukim-nv@users.noreply.github.com>

* skip trtllm support check if in_framework testing

* remove unused imports

* run_existing_checkpoints was passing wrong prompts argument for in-framework mode

* fix unused import in query_inframework.py

---------

Signed-off-by: jukim-nv <jukim-nv@users.noreply.github.com>
Co-authored-by: jukim-nv <jukim-nv@users.noreply.github.com>
Co-authored-by: Onur Yilmaz <35306097+oyilmaz-nvidia@users.noreply.github.com>
ertkonuk pushed a commit that referenced this pull request Jul 19, 2024
* add NemoQueryLLMPyTorch class for triton query of in-framework models

* nemo_export.py changes to better support in-framework models

* separate out in-framework version of triton deploy script

* add generate() function to MegatronLLMDeployable to allow for direct use in export tests

* use NemoQueryLLMPyTorch in deploy tests

* add warning message for when MegatronLLMDeployable overrides transformer_engine

* remove enable_streaming argument from deploy_inframework_triton.py since MegatronLLMDeployable does not support streaming
add query_inframework.py since original query.py does not work with in-framework deployments

* Apply isort and black reformatting

Signed-off-by: jukim-nv <jukim-nv@users.noreply.github.com>

* skip trtllm support check if in_framework testing

* remove unused imports

* run_existing_checkpoints was passing wrong prompts argument for in-framework mode

* fix unused import in query_inframework.py

---------

Signed-off-by: jukim-nv <jukim-nv@users.noreply.github.com>
Co-authored-by: jukim-nv <jukim-nv@users.noreply.github.com>
Co-authored-by: Onur Yilmaz <35306097+oyilmaz-nvidia@users.noreply.github.com>
Signed-off-by: Tugrul Konuk <ertkonuk@gmail.com>
tonyjie pushed a commit to tonyjie/NeMo that referenced this pull request Aug 6, 2024
* add NemoQueryLLMPyTorch class for triton query of in-framework models

* nemo_export.py changes to better support in-framework models

* separate out in-framework version of triton deploy script

* add generate() function to MegatronLLMDeployable to allow for direct use in export tests

* use NemoQueryLLMPyTorch in deploy tests

* add warning message for when MegatronLLMDeployable overrides transformer_engine

* remove enable_streaming argument from deploy_inframework_triton.py since MegatronLLMDeployable does not support streaming
add query_inframework.py since original query.py does not work with in-framework deployments

* Apply isort and black reformatting

Signed-off-by: jukim-nv <jukim-nv@users.noreply.github.com>

* skip trtllm support check if in_framework testing

* remove unused imports

* run_existing_checkpoints was passing wrong prompts argument for in-framework mode

* fix unused import in query_inframework.py

---------

Signed-off-by: jukim-nv <jukim-nv@users.noreply.github.com>
Co-authored-by: jukim-nv <jukim-nv@users.noreply.github.com>
Co-authored-by: Onur Yilmaz <35306097+oyilmaz-nvidia@users.noreply.github.com>
Signed-off-by: tonyjie <jl4257@cornell.edu>
hainan-xv pushed a commit to hainan-xv/NeMo that referenced this pull request Nov 5, 2024
* add NemoQueryLLMPyTorch class for triton query of in-framework models

* nemo_export.py changes to better support in-framework models

* separate out in-framework version of triton deploy script

* add generate() function to MegatronLLMDeployable to allow for direct use in export tests

* use NemoQueryLLMPyTorch in deploy tests

* add warning message for when MegatronLLMDeployable overrides transformer_engine

* remove enable_streaming argument from deploy_inframework_triton.py since MegatronLLMDeployable does not support streaming
add query_inframework.py since original query.py does not work with in-framework deployments

* Apply isort and black reformatting

Signed-off-by: jukim-nv <jukim-nv@users.noreply.github.com>

* skip trtllm support check if in_framework testing

* remove unused imports

* run_existing_checkpoints was passing wrong prompts argument for in-framework mode

* fix unused import in query_inframework.py

---------

Signed-off-by: jukim-nv <jukim-nv@users.noreply.github.com>
Co-authored-by: jukim-nv <jukim-nv@users.noreply.github.com>
Co-authored-by: Onur Yilmaz <35306097+oyilmaz-nvidia@users.noreply.github.com>
Signed-off-by: Hainan Xu <hainanx@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants