Convert formatting to use ruff instead of yapf + isort (#26247)
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
"""Tests Model Optimizer nvfp4 models against ground truth generation
|
||||
Note: these tests will only pass on B200
|
||||
"""
|
||||
|
||||
import os
|
||||
from typing import List
|
||||
|
||||
@@ -21,14 +22,14 @@ MODELS = ["nvidia/Llama-3.3-70B-Instruct-FP4"]
|
||||
|
||||
EXPECTED_STRS_MAP = {
|
||||
"nvidia/Llama-3.3-70B-Instruct-FP4": [
|
||||
'vLLM (Vectorized Large Language Model) is indeed a high-throughput and memory-efficient inference',
|
||||
'Here are the major milestones in the development of artificial intelligence (AI) from 1950 to ',
|
||||
'Artificial intelligence (AI) and human intelligence (HI) are two distinct forms of intelligence that process',
|
||||
'A neural network is a type of machine learning model inspired by the structure and function of the human brain',
|
||||
'In the heart of a cutting-edge robotics lab, a team of engineers had been working tirelessly to push',
|
||||
'The COVID-19 pandemic has had a profound impact on global economic structures and future business models, leading',
|
||||
'The Mona Lisa, painted by Leonardo da Vinci in the early 16th century, is one of',
|
||||
'Here are the translations:\n\n* Japanese: (Sasuga no tori ga miwa o ts'
|
||||
"vLLM (Vectorized Large Language Model) is indeed a high-throughput and memory-efficient inference",
|
||||
"Here are the major milestones in the development of artificial intelligence (AI) from 1950 to ",
|
||||
"Artificial intelligence (AI) and human intelligence (HI) are two distinct forms of intelligence that process",
|
||||
"A neural network is a type of machine learning model inspired by the structure and function of the human brain",
|
||||
"In the heart of a cutting-edge robotics lab, a team of engineers had been working tirelessly to push",
|
||||
"The COVID-19 pandemic has had a profound impact on global economic structures and future business models, leading",
|
||||
"The Mona Lisa, painted by Leonardo da Vinci in the early 16th century, is one of",
|
||||
"Here are the translations:\n\n* Japanese: (Sasuga no tori ga miwa o ts",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -39,11 +40,13 @@ EXPECTED_STRS_MAP = {
|
||||
# the hardware being run on.
|
||||
# Disabled to prevent it from breaking the build
|
||||
@pytest.mark.skip(
|
||||
reason=
|
||||
"Prevent unstable test based on golden strings from breaking the build "
|
||||
" and test input model being too large and hanging the system.")
|
||||
@pytest.mark.skipif(not is_quant_method_supported("modelopt_fp4"),
|
||||
reason="modelopt_fp4 is not supported on this GPU type.")
|
||||
reason="Prevent unstable test based on golden strings from breaking the build "
|
||||
" and test input model being too large and hanging the system."
|
||||
)
|
||||
@pytest.mark.skipif(
|
||||
not is_quant_method_supported("modelopt_fp4"),
|
||||
reason="modelopt_fp4 is not supported on this GPU type.",
|
||||
)
|
||||
@pytest.mark.parametrize("model_name", MODELS)
|
||||
def test_models(example_prompts, model_name) -> None:
|
||||
llm = LLM(
|
||||
@@ -56,12 +59,11 @@ def test_models(example_prompts, model_name) -> None:
|
||||
|
||||
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
||||
formatted_prompts = [
|
||||
tokenizer.apply_chat_template([{
|
||||
"role": "user",
|
||||
"content": prompt
|
||||
}],
|
||||
tokenize=False,
|
||||
add_generation_prompt=True)
|
||||
tokenizer.apply_chat_template(
|
||||
[{"role": "user", "content": prompt}],
|
||||
tokenize=False,
|
||||
add_generation_prompt=True,
|
||||
)
|
||||
for prompt in example_prompts
|
||||
]
|
||||
params = SamplingParams(max_tokens=20, temperature=0)
|
||||
@@ -79,4 +81,5 @@ def test_models(example_prompts, model_name) -> None:
|
||||
generated_str = generations[i]
|
||||
expected_str = expected_strs[i]
|
||||
assert expected_str == generated_str, (
|
||||
f"Test{i}:\nExpected: {expected_str!r}\nvLLM: {generated_str!r}")
|
||||
f"Test{i}:\nExpected: {expected_str!r}\nvLLM: {generated_str!r}"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user