Skip to content

Arm backend: Add initial Llama model test case #8679

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 9 commits into from
Mar 19, 2025
Merged

Conversation

mansnils
Copy link
Collaborator

@mansnils mansnils commented Feb 25, 2025

Adds Llama model test case for TOSA-0.80+MI.
Handles Add and Mul where inputs have different ranks. New unit test parameters --llama_inputs added, without it test will be skipped. Tested with smaller stories, see examples/models/llama/UTILS.md. Adds get_llama_model() to export_llama_lib used in test case.

cc @digantdesai @freddan80 @per @zingo @oscarandersson8218

Adds Llama model test case for TOSA-0.80+MI.
Handles Add and Mul where inputs have different ranks.
New unit test parameters --llama_inputs added, without it test will be
skipped. Tested with smaller stories, see examples/models/llama/UTILS.md.
Adds get_llama_model() to export_llama_lib used in test case.

Change-Id: I003bbcee8f0cc35193d793a4af9b031453114e71
Copy link

pytorch-bot bot commented Feb 25, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/8679

Note: Links to docs will display an error until the docs builds have been completed.

❌ 1 Cancelled Job

As of commit d523b6f with merge base 022a946 (image):

CANCELLED JOB - The following job was cancelled. Please retry:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Feb 25, 2025
@mansnils
Copy link
Collaborator Author

@pytorchbot label partner/arm

Copy link

pytorch-bot bot commented Feb 25, 2025

Didn't find following labels among repository labels: partner/arm

@mansnils
Copy link
Collaborator Author

@pytorchbot label "partner: arm"

@pytorch-bot pytorch-bot bot added the partner: arm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Arm label Feb 25, 2025
@mansnils
Copy link
Collaborator Author

@pytorchbot label ciflow/trunk

Copy link

pytorch-bot bot commented Feb 25, 2025

To add these label(s) (ciflow/trunk) to the PR, please first approve the workflows that are awaiting approval (scroll to the bottom of this page).

This helps ensure we don't trigger CI on this PR until it is actually authorized to do so. Please ping one of the reviewers if you do not have access to approve and run workflows.

Copy link

pytorch-bot bot commented Feb 25, 2025

To add the ciflow label ciflow/trunk please first approve the workflows that are awaiting approval (scroll to the bottom of this page).

This helps ensure we don't trigger CI on this PR until it is actually authorized to do so. Please ping one of the reviewers if you do not have access to approve and run workflows.

@mansnils
Copy link
Collaborator Author

topic: not user facing

@mansnils
Copy link
Collaborator Author

topic: "not user facing"

@zingo zingo changed the title Arm: Add initial Llama model test case Arm backend: Add initial Llama model test case Feb 25, 2025
@@ -0,0 +1,125 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
Copy link
Contributor

Choose a reason for hiding this comment

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

I will take a look but just a nit
s/test_llama_arm.py/test_llama.py/

Copy link
Collaborator

@zingo zingo Feb 26, 2025

Choose a reason for hiding this comment

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

I will take a look ...

Merge time? :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Renamed to test_llama.py

@zingo
Copy link
Collaborator

zingo commented Feb 26, 2025

MacOs fails are unrelated

@@ -9,3 +9,5 @@
git config --global user.email "[email protected]"
git config --global user.name "Github Executorch"
bash examples/arm/setup.sh --i-agree-to-the-contained-eula

./examples/models/llama3_2_vision/install_requirements.sh
Copy link
Contributor

Choose a reason for hiding this comment

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

is this the best place to put this?

Copy link
Collaborator

Choose a reason for hiding this comment

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

The idea was to have it in place before the testing but thinking about it now I think you are right
Having it as part of all the steps that use pytest in the file
backends/arm/test/test_arm_baremetal.sh
(or create a prepare test step)
Might be better and easier for anyone to just run the test and they will install needed dependencies them self.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

@@ -32,9 +32,11 @@ def define_node(
output: TosaArg,
) -> None:

# See slice_copy_support.py
assert len(inputs) == 4 or (len(inputs) == 5 and inputs[4].number == 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: add an error message

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

.check_count({"torch.ops.higher_order.executorch_call_delegate": 14})
.to_executorch()
.run_method_and_compare_outputs(
inputs=llama_inputs, atol=1.8, rtol=0.01
Copy link
Contributor

@digantdesai digantdesai Feb 27, 2025

Choose a reason for hiding this comment

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

how did we come up with atol? Also this is running on MI + tosa-ref w/o quantization, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The tolerance is really bad here. This is just to get the test passing. It it something we need to investigate. Added a TODO.
Yes this is testing reference vs TOSA without quantization.

@mansnils
Copy link
Collaborator Author

mansnils commented Mar 5, 2025

ping @digantdesai

@shoumikhin
Copy link
Contributor

@digantdesai how do we want to proceed with this?

@kimishpatel
Copy link
Contributor

@digantdesai how do we want to proceed with this?

Digant is on pat leave right now, so expect delays

@digantdesai
Copy link
Contributor

LGTM.

@zingo
Copy link
Collaborator

zingo commented Mar 19, 2025

MacOS fails unrelated

@zingo zingo merged commit 4c54bab into pytorch:main Mar 19, 2025
162 of 163 checks passed
@kirklandsign
Copy link
Contributor

Sorry @zingo we probably need to revert this and import and run internal tests before landing.

executorch/backends/arm/test:cast_int64_pass - main

executorch/backends/arm/test/conftest.py:47: in pytest_configure
    pytest._test_options["llama_inputs"] = config.option.llama_inputs  # type: ignore[attr-defined]
E   AttributeError: 'Namespace' object has no attribute 'llama_inputs'

This line:

pytest._test_options["llama_inputs"] = config.option.llama_inputs  # type: ignore[attr-defined]

probably need to use getattr to check?

@larryliu0820
Copy link
Contributor

@kirklandsign @digantdesai is it possible to add the tests into unittest-buck CI job?

@kirklandsign
Copy link
Contributor

@kirklandsign @digantdesai is it possible to add the tests into unittest-buck CI job?

Oh are these tests triggered on GH right now? Seems like some config missing issue?

@larryliu0820
Copy link
Contributor

@kirklandsign @digantdesai is it possible to add the tests into unittest-buck CI job?

Oh are these tests triggered on GH right now? Seems like some config missing issue?

Created #9476 to track this.

oscarandersson8218 pushed a commit to oscarandersson8218/executorch that referenced this pull request Mar 21, 2025
Adds Llama model test case for TOSA-0.80+MI.
Handles Add and Mul where inputs have different ranks. New unit test
parameters --llama_inputs added, without it test will be skipped. Tested
with smaller stories, see examples/models/llama/UTILS.md. Adds
get_llama_model() to export_llama_lib used in test case.
DannyYuyang-quic pushed a commit to CodeLinaro/executorch that referenced this pull request Apr 2, 2025
Adds Llama model test case for TOSA-0.80+MI.
Handles Add and Mul where inputs have different ranks. New unit test
parameters --llama_inputs added, without it test will be skipped. Tested
with smaller stories, see examples/models/llama/UTILS.md. Adds
get_llama_model() to export_llama_lib used in test case.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ciflow/trunk CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. partner: arm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Arm topic: not user facing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants