-
Notifications
You must be signed in to change notification settings - Fork 8
Integration tests for NeMo FW #240
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
Closed
Closed
Changes from 16 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
a6df150
add integration test for nemo2+triton deployment
marta-sd b405090
use full flags for better readibility
marta-sd 3466df3
add integration test for nemo2+ray deployment
marta-sd 9f21a5d
reuse duplicated code + use tmp_path fixture
marta-sd fdf5460
add integration test for hf+ray deployment
marta-sd 296763e
set autouse=true for deployment
marta-sd 8974ffe
comment out logprob test for HF - not supported
marta-sd f587764
add test for notebooks
marta-sd a430324
update for new export-deploy version
marta-sd ef186cc
move e2e EF testing to functional tests
marta-sd dcaf409
add cp headers
marta-sd 524305f
update uv.lock
marta-sd 720c9e6
fix for uv
marta-sd 11ddd69
mock sys.modules instead of actually removing the package
marta-sd 0430632
add script for launching the test
marta-sd 25d15bd
remove obsolete set_env_vars fixture
marta-sd bbf4de7
set TRANSFORMERS_OFFLINE=1 and create symlink needed to run notebooks
marta-sd 5bffef0
Fix coverage file name
marta-sd de47a88
Merge branch 'main' into martas/nemo-fw-tests
marta-sd 78fa6fa
set env vars for all test scripts (HF offline)
marta-sd 06c57d9
don't capture output for easier debugging
marta-sd 4f99f56
Merge branch 'main' into martas/nemo-fw-tests
marta-sd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,6 +27,7 @@ | |
| from pathlib import Path | ||
|
|
||
| import pytest | ||
|
|
||
| from nemo_evaluator.logging.utils import logger | ||
|
|
||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| # Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| set -xeuo pipefail # Exit immediately if a command exits with a non-zero status | ||
|
|
||
| export CUDA_VISIBLE_DEVICES="0" | ||
| export HF_HOME="/home/TestData/HF_HOME" | ||
| export HF_DATASETS_OFFLINE="1" | ||
| export HF_DATASETS_CACHE="${HF_HOME}/datasets" | ||
|
|
||
|
|
||
| SCRIPT_DIR=$(dirname "$0") | ||
| PROJECT_DIR=$SCRIPT_DIR/../../ | ||
| cd $PROJECT_DIR | ||
|
|
||
| coverage run \ | ||
| --data-file=.coverage.functional_tests \ | ||
| --source=src/ \ | ||
| -m pytest \ | ||
| -o log_cli=true \ | ||
| -o log_cli_level=INFO \ | ||
| -m "not pleasefixme" \ | ||
| tests/integration_tests | ||
| coverage combine -q | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,135 @@ | ||
| # Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| import logging | ||
| import os | ||
| import signal | ||
| import subprocess | ||
|
|
||
| import pytest | ||
| from nemo_evaluator.api import check_endpoint, evaluate | ||
| from nemo_evaluator.api.api_dataclasses import ( | ||
| ApiEndpoint, | ||
| ConfigParams, | ||
| EvaluationConfig, | ||
| EvaluationResult, | ||
| EvaluationTarget, | ||
| ) | ||
|
|
||
| # FIXME(martas): EF packages pre 25.09 use old imports from nvidia_eval_commons | ||
| from nvidia_eval_commons.api.api_dataclasses import ( | ||
| EvaluationResult as LegacyEvaluationResult, | ||
| ) | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| @pytest.fixture(scope="module", autouse=True) | ||
| def deployment_process(): | ||
| """Fixture to deploy the HF model on Ray server.""" | ||
| hf_model_id = "meta-llama/Llama-3.2-1B-Instruct" | ||
| model_name = "hf_model" | ||
| port = 8886 | ||
| # Run deployment | ||
| deploy_proc = subprocess.Popen( | ||
| [ | ||
| "python", | ||
| "/opt/Export-Deploy/scripts/deploy/nlp/deploy_ray_hf.py", | ||
| "--model_path", | ||
| hf_model_id, | ||
| "--model_id", | ||
| model_name, | ||
| "--port", | ||
| str(port), | ||
| ] | ||
| ) | ||
|
|
||
| completions_ready = check_endpoint( | ||
| endpoint_url=f"http://0.0.0.0:{port}/v1/completions/", | ||
| endpoint_type="completions", | ||
| model_name=model_name, | ||
| max_retries=600, | ||
| ) | ||
| assert completions_ready, ( | ||
| "Completions endpoint is not ready. Please look at the deploy process log for the error" | ||
| ) | ||
|
|
||
| chat_ready = check_endpoint( | ||
| endpoint_url=f"http://0.0.0.0:{port}/v1/chat/completions", | ||
| endpoint_type="chat", | ||
| model_name=model_name, | ||
| max_retries=600, | ||
| ) | ||
| assert chat_ready, ( | ||
| "Chat endpoint is not ready. Please look at the deploy process log for the error" | ||
| ) | ||
|
|
||
| yield deploy_proc # We only need the process reference for cleanup | ||
|
|
||
| deploy_proc.send_signal(signal.SIGINT) | ||
| try: | ||
| deploy_proc.wait(timeout=30) | ||
| except subprocess.TimeoutExpired: | ||
| try: | ||
| os.killpg(deploy_proc.pid, signal.SIGKILL) | ||
| except ProcessLookupError: | ||
| pass | ||
| finally: | ||
| subprocess.run(["pkill", f"-{signal.SIGTERM}", "tritonserver"], check=False) | ||
|
|
||
|
|
||
| @pytest.mark.run_only_on("GPU") | ||
| @pytest.mark.parametrize( | ||
| "eval_type,endpoint_type,eval_params", | ||
| [ | ||
| ("gsm8k", "completions", {"limit_samples": 1, "request_timeout": 360}), | ||
| # TODO(martas): enable once logprobs are supported | ||
| # ( | ||
| # "arc_challenge", | ||
| # "completions", | ||
| # { | ||
| # "limit_samples": 1, | ||
| # "request_timeout": 360, | ||
| # "extra": { | ||
| # "tokenizer_backend": "huggingface", | ||
| # "tokenizer": "meta-llama/Llama-3.2-1B-Instruct", | ||
| # }, | ||
| # }, | ||
| # ), | ||
| ("ifeval", "chat", {"limit_samples": 1, "request_timeout": 360}), | ||
| ], | ||
| ) | ||
| def test_evaluation(eval_type, endpoint_type, eval_params, tmp_path): | ||
| """ | ||
| Test evaluation of a nemo model deployed with triton backend. | ||
| """ | ||
| port = 8886 | ||
| if endpoint_type == "completions": | ||
| url = f"http://0.0.0.0:{port}/v1/completions/" | ||
| elif endpoint_type == "chat": | ||
| url = f"http://0.0.0.0:{port}/v1/chat/completions" | ||
| else: | ||
| raise ValueError(f"Invalid endpoint type: {endpoint_type}") | ||
|
|
||
| api_endpoint = ApiEndpoint(url=url, type=endpoint_type, model_id="megatron_model") | ||
| eval_target = EvaluationTarget(api_endpoint=api_endpoint) | ||
| eval_config = EvaluationConfig( | ||
| type=eval_type, params=ConfigParams(**eval_params), output_dir=str(tmp_path) | ||
| ) | ||
| results = evaluate(target_cfg=eval_target, eval_cfg=eval_config) | ||
| # FIXME(martas): EF packages pre 25.09 use old imports from nvidia_eval_commons | ||
| assert isinstance(results, EvaluationResult) or isinstance( | ||
| results, LegacyEvaluationResult | ||
| ) | ||
| logger.info("Evaluation completed.") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,140 @@ | ||
| # Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| import logging | ||
| import os | ||
| import signal | ||
| import subprocess | ||
|
|
||
| import pytest | ||
| from nemo_evaluator.api import check_endpoint, evaluate | ||
| from nemo_evaluator.api.api_dataclasses import ( | ||
| ApiEndpoint, | ||
| ConfigParams, | ||
| EvaluationConfig, | ||
| EvaluationResult, | ||
| EvaluationTarget, | ||
| ) | ||
|
|
||
| # FIXME(martas): EF packages pre 25.09 use old imports from nvidia_eval_commons | ||
| from nvidia_eval_commons.api.api_dataclasses import ( | ||
| EvaluationResult as LegacyEvaluationResult, | ||
| ) | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| @pytest.fixture(scope="module", autouse=True) | ||
| def deployment_process(): | ||
| """Fixture to deploy the nemo checkpoint on Ray server.""" | ||
| nemo2_ckpt_path = "/home/TestData/nemo2_ckpt/llama-3_2-1b-instruct_v2.0" | ||
| model_name = "megatron_model" | ||
| port = 8886 | ||
| # Run deployment | ||
| deploy_proc = subprocess.Popen( | ||
| [ | ||
| "python", | ||
| "/opt/Export-Deploy/scripts/deploy/nlp/deploy_ray_inframework.py", | ||
| "--nemo_checkpoint", | ||
| nemo2_ckpt_path, | ||
| "--num_gpus", | ||
| "1", | ||
| "--tensor_model_parallel_size", | ||
| "1", | ||
| "--pipeline_model_parallel_size", | ||
| "1", | ||
| "--model_id", | ||
| model_name, | ||
| "--port", | ||
| str(port), | ||
| ] | ||
| ) | ||
|
|
||
| completions_ready = check_endpoint( | ||
| endpoint_url=f"http://0.0.0.0:{port}/v1/completions/", | ||
| endpoint_type="completions", | ||
| model_name=model_name, | ||
| max_retries=600, | ||
| ) | ||
| assert completions_ready, ( | ||
| "Completions endpoint is not ready. Please look at the deploy process log for the error" | ||
| ) | ||
|
|
||
| chat_ready = check_endpoint( | ||
| endpoint_url=f"http://0.0.0.0:{port}/v1/chat/completions", | ||
| endpoint_type="chat", | ||
| model_name=model_name, | ||
| max_retries=600, | ||
| ) | ||
| assert chat_ready, ( | ||
| "Chat endpoint is not ready. Please look at the deploy process log for the error" | ||
| ) | ||
|
|
||
| yield deploy_proc # We only need the process reference for cleanup | ||
|
|
||
| deploy_proc.send_signal(signal.SIGINT) | ||
| try: | ||
| deploy_proc.wait(timeout=30) | ||
| except subprocess.TimeoutExpired: | ||
| try: | ||
| os.killpg(deploy_proc.pid, signal.SIGKILL) | ||
| except ProcessLookupError: | ||
| pass | ||
| finally: | ||
| subprocess.run(["pkill", f"-{signal.SIGTERM}", "tritonserver"], check=False) | ||
|
|
||
|
|
||
| @pytest.mark.run_only_on("GPU") | ||
| @pytest.mark.parametrize( | ||
| "eval_type,endpoint_type,eval_params", | ||
| [ | ||
| ("gsm8k", "completions", {"limit_samples": 1, "request_timeout": 360}), | ||
| ( | ||
| "arc_challenge", | ||
| "completions", | ||
| { | ||
| "limit_samples": 1, | ||
| "request_timeout": 360, | ||
| "extra": { | ||
| "tokenizer_backend": "huggingface", | ||
| "tokenizer": "/home/TestData/nemo2_ckpt/llama-3_2-1b-instruct_v2.0/context/nemo_tokenizer", | ||
| }, | ||
| }, | ||
| ), | ||
| ("ifeval", "chat", {"limit_samples": 1, "request_timeout": 360}), | ||
| ], | ||
| ) | ||
| def test_evaluation(eval_type, endpoint_type, eval_params, tmp_path): | ||
| """ | ||
| Test evaluation of a nemo model deployed with triton backend. | ||
| """ | ||
| port = 8886 | ||
| if endpoint_type == "completions": | ||
| url = f"http://0.0.0.0:{port}/v1/completions/" | ||
| elif endpoint_type == "chat": | ||
| url = f"http://0.0.0.0:{port}/v1/chat/completions" | ||
| else: | ||
| raise ValueError(f"Invalid endpoint type: {endpoint_type}") | ||
|
|
||
| api_endpoint = ApiEndpoint(url=url, type=endpoint_type, model_id="megatron_model") | ||
| eval_target = EvaluationTarget(api_endpoint=api_endpoint) | ||
| eval_config = EvaluationConfig( | ||
| type=eval_type, params=ConfigParams(**eval_params), output_dir=str(tmp_path) | ||
| ) | ||
| results = evaluate(target_cfg=eval_target, eval_cfg=eval_config) | ||
| # FIXME(martas): EF packages pre 25.09 use old imports from nvidia_eval_commons | ||
| assert isinstance(results, EvaluationResult) or isinstance( | ||
| results, LegacyEvaluationResult | ||
| ) | ||
| logger.info("Evaluation completed.") |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.