Skip to content

[Tests]: Adding dummy causal models for testing in regular CI run #427

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

Open
wants to merge 23 commits into
base: main
Choose a base branch
from

Conversation

abukhoy
Copy link
Contributor

@abukhoy abukhoy commented May 29, 2025

Purpose of this PR:

This update aims to reduce test execution time for causal language model inference. Previously, tests were run using full-scale models with one or two layers, which was inefficient and time-consuming. Refactoring CLI api testing for independent testing and redundant conftest code.

What’s Changed:

Introduced dummy models with significantly smaller configurations by adjusting parameters such as max_position_embeddings, num_hidden_layers, num_attention_heads, hidden_size, intermediate_size, vocab_size and additional_params.
These lightweight models are used exclusively for testing purposes to ensure faster execution without compromising test coverage.

And CLI testing has two test scripts one is for export, compile, and execute, another is for infer cli api.

Note: This optimization is applied only to causal language models.

abukhoy added 9 commits May 30, 2025 06:34
Signed-off-by: Abukhoyer Shaik <[email protected]>
Signed-off-by: Abukhoyer Shaik <[email protected]>
Signed-off-by: Abukhoyer Shaik <[email protected]>
Signed-off-by: Abukhoyer Shaik <[email protected]>
Signed-off-by: Abukhoyer Shaik <[email protected]>
Signed-off-by: Abukhoyer Shaik <[email protected]>
"hpcai-tech/grok-1",
]

test_dummy_model_configs = [
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we move this outside this file? may be we can maintain a CSV file for better readability.

"hpcai-tech/grok-1",
]

test_dummy_model_configs = [
# model_name, model_type, max_position_embeddings, num_hidden_layers, num_attention_heads, hidden_size, intermediate_size, vocab_size, additional_params
("TinyLlama/TinyLlama-1.1B-Chat-v1.0", "llama", 128, 1, 2, 64, 256, 32000, {"num_key_value_heads": 1}),
Copy link
Contributor

Choose a reason for hiding this comment

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

are we following any criteria for selecting these configs?


if model_hf is None:
model_hf, _ = load_causal_lm_model(model_config)
model_hf_cb = copy.deepcopy(model_hf)
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need this?

@pytest.mark.cli
@pytest.mark.parametrize("config", configs)
def test_export_compile_execute_qnn_fb(mocker, config):
# testing export -> compile -> infer with full_batch_size in QNN enviroment
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo in "enviroment"

@pytest.mark.qnn
@pytest.mark.cli
@pytest.mark.parametrize("config", configs)
def test_export_compile_execute_qnn(mocker, config):
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. Both test_export_compile_execute_qnn and test_export_compile_execute_qnn_fb is currently having same configs right? Ideally in test_export_compile_execute_qnn we should be providing BS and in test_export_compile_execute_qnn_fb we should be providing FBS.
  2. Rename test_export_compile_execute_qnn_fb -> test_export_compile_execute_qnn_fbs for better readability
  3. Typo in 'enviroment'

)
check_infer(mocker=mocker, generation_len=20, **local_config)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we have a vlm qnn test as well?

mxfp6=ms.mxfp6,
mxint8=ms.mxint8,
full_batch_size=ms.full_batch_size,
enable_qnn=ms.enable_qnn,
image_url=kwargs["image_url"],
)
Copy link
Contributor

Choose a reason for hiding this comment

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

how can we make sure the infer is running as expected? Please include proper asset for checking, export, compile and generation is running proper.

# testing for CB models
model_hf, _ = load_causal_lm_model(model_config)
model_hf = model_hf_cb
model_hf.eval()
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need model_hf.eval()?

``Mandatory`` Args:
:model_name (str): Hugging Face Model Card name, Example: ``gpt2``
"""
if test_dummy_model_name in {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should avoid putting such constants. May be have a separate test for quantized models

@@ -292,6 +515,35 @@ def test_causal_lm_pytorch_vs_kv_vs_ort_vs_ai100_qnn(model_name):


@pytest.mark.skip() # remove when the SDK 1.20.0 issue solved for compiling this model
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we remove it now? same on line 545 as well

Signed-off-by: Abukhoyer Shaik <[email protected]>
Signed-off-by: Abukhoyer Shaik <[email protected]>
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.

3 participants