Skip to content

Commit

Permalink
updated test to mark as potential failure
Browse files Browse the repository at this point in the history
  • Loading branch information
nnshah1 committed Jun 5, 2024
1 parent d576d25 commit 1f50b6e
Showing 1 changed file with 113 additions and 0 deletions.
113 changes: 113 additions & 0 deletions src/c++/perf_analyzer/genai-perf/tests/test_llm_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,119 @@ def test_llm_inputs_with_defaults(self, default_configured_url):
dataset_json = LlmInputs._convert_input_url_dataset_to_generic_json(
dataset=dataset
)
pa_json = LlmInputs._convert_generic_json_to_output_format(
output_format=OutputFormat.OPENAI_CHAT_COMPLETIONS,
generic_dataset=dataset_json,
add_model_name=False,
add_stream=False,
extra_inputs={},
output_tokens_mean=LlmInputs.DEFAULT_OUTPUT_TOKENS_MEAN,
output_tokens_stddev=LlmInputs.DEFAULT_OUTPUT_TOKENS_STDDEV,
output_tokens_deterministic=False,
)

assert pa_json is not None
assert len(pa_json["data"]) == LlmInputs.DEFAULT_LENGTH

@pytest.mark.xfail(
reason="Download from huggingface may fail due to server issues",
raises=GenAIPerfException,
)
def test_create_openai_llm_inputs_cnn_dailymail(self):
"""
Test CNN_DAILYMAIL can be accessed
"""
pa_json = LlmInputs.create_llm_inputs(
input_type=PromptSource.DATASET,
dataset_name=CNN_DAILY_MAIL,
output_format=OutputFormat.OPENAI_CHAT_COMPLETIONS,
)

os.remove(DEFAULT_INPUT_DATA_JSON)

assert pa_json is not None
assert len(pa_json["data"]) == LlmInputs.DEFAULT_LENGTH

def test_write_to_file(self):
"""
Test that write to file is working correctly
"""
pa_json = LlmInputs.create_llm_inputs(
input_type=PromptSource.DATASET,
dataset_name=OPEN_ORCA,
output_format=OutputFormat.OPENAI_CHAT_COMPLETIONS,
model_name="open_orca",
add_model_name=True,
add_stream=True,
)
try:
with open(DEFAULT_INPUT_DATA_JSON, "r") as f:
json_str = f.read()
finally:
os.remove(DEFAULT_INPUT_DATA_JSON)

assert pa_json == json.loads(json_str)

def test_create_openai_to_vllm(self):
"""
Test conversion of openai to vllm
"""
pa_json = LlmInputs.create_llm_inputs(
input_type=PromptSource.DATASET,
output_format=OutputFormat.VLLM,
dataset_name=OPEN_ORCA,
add_model_name=False,
add_stream=True,
)

os.remove(DEFAULT_INPUT_DATA_JSON)

assert pa_json is not None
assert len(pa_json["data"]) == LlmInputs.DEFAULT_LENGTH

def test_create_openai_to_completions(self):
"""
Test conversion of openai to completions
"""
pa_json = LlmInputs.create_llm_inputs(
input_type=PromptSource.DATASET,
output_format=OutputFormat.OPENAI_COMPLETIONS,
dataset_name=OPEN_ORCA,
add_model_name=False,
add_stream=True,
)

os.remove(DEFAULT_INPUT_DATA_JSON)

assert pa_json is not None
assert len(pa_json["data"]) == LlmInputs.DEFAULT_LENGTH
# NIM legacy completion endpoint only supports string and not
# array of strings. Verify that the prompt is of type string
# not list
assert isinstance(pa_json["data"][0]["payload"][0]["prompt"], str)

def test_create_openai_to_trtllm(self):
"""
Test conversion of openai to trtllm
"""
pa_json = LlmInputs.create_llm_inputs(
input_type=PromptSource.DATASET,
output_format=OutputFormat.TENSORRTLLM,
dataset_name=OPEN_ORCA,
add_model_name=False,
add_stream=True,
)

os.remove(DEFAULT_INPUT_DATA_JSON)

assert pa_json is not None
assert len(pa_json["data"]) == LlmInputs.DEFAULT_LENGTH

def test_random_synthetic_no_stddev(self, default_tokenizer):
"""
Test that we can produce an exact number of random synthetic tokens
"""
random.seed(1)

assert dataset_json is not None
assert len(dataset_json["rows"]) == TEST_LENGTH
Expand Down

0 comments on commit 1f50b6e

Please sign in to comment.