-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[TRTLLM-4721][test] Add qa test for llm-api #6727
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
Merged
Merged
Changes from all commits
Commits
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
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 |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| # Confirm that the default backend is changed | ||
| import os | ||
|
|
||
| from defs.common import venv_check_output | ||
|
|
||
| from ..conftest import llm_models_root | ||
Superjomn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| model_path = llm_models_root() + "/llama-models-v3/llama-v3-8b-instruct-hf" | ||
|
|
||
Superjomn marked this conversation as resolved.
Show resolved
Hide resolved
Superjomn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| class TestLlmDefaultBackend: | ||
| """ | ||
| Check that the default backend is PyTorch for v1.0 breaking change | ||
| """ | ||
|
|
||
| def test_llm_args_type_default(self, llm_root, llm_venv): | ||
| # Keep the complete example code here | ||
| from tensorrt_llm.llmapi import LLM, KvCacheConfig, TorchLlmArgs | ||
|
|
||
| kv_cache_config = KvCacheConfig(free_gpu_memory_fraction=0.4) | ||
| llm = LLM(model=model_path, kv_cache_config=kv_cache_config) | ||
|
|
||
| # The default backend should be PyTorch | ||
| assert llm.args.backend == "pytorch" | ||
| assert isinstance(llm.args, TorchLlmArgs) | ||
|
|
||
Superjomn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| for output in llm.generate(["Hello, world!"]): | ||
| print(output) | ||
|
|
||
| def test_llm_args_type_tensorrt(self, llm_root, llm_venv): | ||
| # Keep the complete example code here | ||
| from tensorrt_llm._tensorrt_engine import LLM | ||
| from tensorrt_llm.llmapi import KvCacheConfig, TrtLlmArgs | ||
|
|
||
| kv_cache_config = KvCacheConfig(free_gpu_memory_fraction=0.4) | ||
|
|
||
| llm = LLM(model=model_path, kv_cache_config=kv_cache_config) | ||
|
|
||
| # If the backend is TensorRT, the args should be TrtLlmArgs | ||
| assert llm.args.backend in ("tensorrt", None) | ||
| assert isinstance(llm.args, TrtLlmArgs) | ||
Superjomn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| for output in llm.generate(["Hello, world!"]): | ||
| print(output) | ||
|
|
||
| def test_llm_args_logging(self, llm_root, llm_venv): | ||
| # It should print the backend in the log | ||
| script_path = os.path.join(os.path.dirname(__file__), | ||
| "_run_llmapi_llm.py") | ||
| print(f"script_path: {script_path}") | ||
|
|
||
| # Test with pytorch backend | ||
| pytorch_cmd = [ | ||
| script_path, "--model_dir", model_path, "--backend", "pytorch" | ||
| ] | ||
|
|
||
Superjomn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| pytorch_output = venv_check_output(llm_venv, pytorch_cmd) | ||
|
|
||
| # Check that pytorch backend keyword appears in logs | ||
| assert "Using LLM with PyTorch backend" in pytorch_output, f"Expected 'pytorch' in logs, got: {pytorch_output}" | ||
|
|
||
| # Test with tensorrt backend | ||
| tensorrt_cmd = [ | ||
| script_path, "--model_dir", model_path, "--backend", "tensorrt" | ||
| ] | ||
|
|
||
| tensorrt_output = venv_check_output(llm_venv, tensorrt_cmd) | ||
|
|
||
| # Check that tensorrt backend keyword appears in logs | ||
| assert "Using LLM with TensorRT backend" in tensorrt_output, f"Expected 'tensorrt' in logs, got: {tensorrt_output}" | ||
Superjomn marked this conversation as resolved.
Show resolved
Hide resolved
Superjomn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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
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.