Skip to content

Conversation

SaoirseARM
Copy link
Collaborator

@SaoirseARM SaoirseARM commented Jul 31, 2025

Summary

This PR removes TOSA v0.80 from the arm backend. This includes updates to:

  • operator node visitors
  • operator support
  • passes
  • test infrastructure
  • tosa specification and utils
  • removal of installation of v0.80 and patch scripts

cc @digantdesai @freddan80 @per @zingo @oscarandersson8218

Change-Id: Ie3442b53184ecf0fbf817b581b780d2456670c4f
Change-Id: I21503bcab233d813759132b4c5a33dc6f7ed4f13
Change-Id: I9ff98f6560c686527cba18c28ea98c00683a3c03
- Update test names to use INT/FP
- Update the test name checker script for INT/FP

Change-Id: I93acbd0e5f0c6bca6095fb39f267ed7a01bf0796
Change-Id: I183a1475ace4c4fe73ab325d615974464d3520d3
- Update README
- Remove tosa 0.80 schema
- Remove tosa 0.80 patches

Change-Id: I81f88d5af6e14681ac09c2c6d51f4adbfd081aeb
@SaoirseARM SaoirseARM requested a review from zingo July 31, 2025 12:34
@SaoirseARM SaoirseARM requested a review from digantdesai as a code owner July 31, 2025 12:34
Copy link

pytorch-bot bot commented Jul 31, 2025

🔗 Helpful Links

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

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

❌ 3 New Failures

As of commit 8c2af87 with merge base bedce91 (image):

NEW FAILURES - The following jobs have failed:

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

@meta-cla meta-cla 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 Jul 31, 2025
@SaoirseARM
Copy link
Collaborator Author

@pytorchbot label ciflow/trunk

@SaoirseARM
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 Jul 31, 2025
@SaoirseARM
Copy link
Collaborator Author

@pytorchbot label "release notes: none"

@pytorch-bot pytorch-bot bot added the release notes: none Do not include this in the release notes label Jul 31, 2025
@zingo
Copy link
Collaborator

zingo commented Jul 31, 2025

cortex-m fails independent of this and is related to C/C++ code size
llava/lama test is unrelated

@zingo zingo merged commit 2aa8084 into pytorch:main Jul 31, 2025
224 of 229 checks passed
)
elif isinstance(tosa_version, Tosa_1_00):
if isinstance(tosa_version, Tosa_1_00):
import tosa_reference_model as reference_model
Copy link
Contributor

Choose a reason for hiding this comment

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

Got error

>           import tosa_reference_model as reference_model
E           ModuleNotFoundError: No module named 'tosa_reference_model'

Copy link
Contributor

@digantdesai digantdesai Aug 5, 2025

Choose a reason for hiding this comment

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

yeah we shouldn't assume reference model is available, we should use it only if its "available"

@kirklandsign
Copy link
Contributor

Hi @zingo @SaoirseARM seems that this test is failing. Could you please take a look?

@zingo
Copy link
Collaborator

zingo commented Aug 4, 2025

Hi thanks for reporting, we will look into it, do you have a link to where you see the problem, we don't see it internally and when I look an the "hud" https://hud.pytorch.org/hud/pytorch/executorch/main it seem to not be a problems.

Are you running the tests locally, you might need to rerun setup.sh to re-setup all stuff after the removal maybe?
e.g.
examples/arm/setup.sh --i-agree-to-the-contained-eula

@kirklandsign
Copy link
Contributor

executorch/backends/arm/test  ARM_TEST_SEED=323055682  F

=================================== FAILURES ===================================
_________________ test_not_fuse_tensor_with_different_type_FP __________________

    def test_not_fuse_tensor_with_different_type_FP():
        module = NotFuseTensorWithDifferentType()
        data = (
            torch.rand(
                1,
            ),
            torch.randint(
                0,
                10,
                (1,),
                dtype=torch.int,
            ),
        )
        pipeline = TosaPipelineFP[input_t](
            module,
            data,
            aten_op=[],
        )
>       pipeline.run()

executorch/backends/arm/test/__fuse_equal_placeholders_ops_pass__/fuse_equal_placeholders_ops_pass#link-tree/executorch/backends/arm/test/passes/test_fuse_equal_placeholders_ops_pass.py:139: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
executorch/backends/arm/test/__fuse_equal_placeholders_ops_pass__/fuse_equal_placeholders_ops_pass#link-tree/executorch/backends/arm/test/tester/test_pipeline.py:271: in run
    raise e
executorch/backends/arm/test/__fuse_equal_placeholders_ops_pass__/fuse_equal_placeholders_ops_pass#link-tree/executorch/backends/arm/test/tester/test_pipeline.py:268: in run
    stage()
executorch/backends/arm/test/__fuse_equal_placeholders_ops_pass__/fuse_equal_placeholders_ops_pass#link-tree/executorch/backends/arm/test/tester/test_pipeline.py:85: in __call__
    self.func(*self.args, **self.kwargs)
executorch/backends/arm/test/__fuse_equal_placeholders_ops_pass__/fuse_equal_placeholders_ops_pass#link-tree/executorch/backends/arm/test/tester/arm_tester.py:521: in run_method_and_compare_outputs
    test_stage.run_artifact(reference_input)
executorch/backends/arm/test/__fuse_equal_placeholders_ops_pass__/fuse_equal_placeholders_ops_pass#link-tree/executorch/backends/arm/test/tester/arm_tester.py:226: in run_artifact
    return super().run_artifact(inputs)
executorch/backends/arm/test/__fuse_equal_placeholders_ops_pass__/fuse_equal_placeholders_ops_pass#link-tree/executorch/backends/test/harness/stages/stage.py:64: in run_artifact
    return self.artifact.exported_program().module()(*inputs)
executorch/backends/arm/test/__fuse_equal_placeholders_ops_pass__/fuse_equal_placeholders_ops_pass#link-tree/torch/fx/graph_module.py:850: in call_wrapped
    return self._wrapped_call(self, *args, **kwargs)
executorch/backends/arm/test/__fuse_equal_placeholders_ops_pass__/fuse_equal_placeholders_ops_pass#link-tree/torch/fx/graph_module.py:426: in __call__
    raise e
executorch/backends/arm/test/__fuse_equal_placeholders_ops_pass__/fuse_equal_placeholders_ops_pass#link-tree/torch/fx/graph_module.py:413: in __call__
    return super(self.cls, obj).__call__(*args, **kwargs)  # type: ignore[misc]
executorch/backends/arm/test/__fuse_equal_placeholders_ops_pass__/fuse_equal_placeholders_ops_pass#link-tree/torch/nn/modules/module.py:1773: in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
executorch/backends/arm/test/__fuse_equal_placeholders_ops_pass__/fuse_equal_placeholders_ops_pass#link-tree/torch/nn/modules/module.py:1879: in _call_impl
    return inner()
executorch/backends/arm/test/__fuse_equal_placeholders_ops_pass__/fuse_equal_placeholders_ops_pass#link-tree/torch/nn/modules/module.py:1827: in inner
    result = forward_call(*args, **kwargs)
<eval_with_key>.350:7: in forward
    executorch_call_delegate = torch.ops.higher_order.executorch_call_delegate(lowered_module_0, x, y);  lowered_module_0 = x = y = None
executorch/backends/arm/test/__fuse_equal_placeholders_ops_pass__/fuse_equal_placeholders_ops_pass#link-tree/torch/_higher_order_ops/executorch_call_delegate.py:33: in __call__
    return super().__call__(lowered_module, *args)
executorch/backends/arm/test/__fuse_equal_placeholders_ops_pass__/fuse_equal_placeholders_ops_pass#link-tree/torch/_ops.py:535: in __call__
    return wrapper()
executorch/backends/arm/test/__fuse_equal_placeholders_ops_pass__/fuse_equal_placeholders_ops_pass#link-tree/torch/_ops.py:526: in wrapper
    return torch.overrides.handle_torch_function(
executorch/backends/arm/test/__fuse_equal_placeholders_ops_pass__/fuse_equal_placeholders_ops_pass#link-tree/torch/overrides.py:1727: in handle_torch_function
    result = mode.__torch_function__(public_api, types, args, kwargs)
executorch/backends/arm/test/__fuse_equal_placeholders_ops_pass__/fuse_equal_placeholders_ops_pass#link-tree/executorch/backends/arm/test/runner_utils.py:208: in __torch_function__
    return self._tosa_dispatch(lowered_backend_module, args[1:])
executorch/backends/arm/test/__fuse_equal_placeholders_ops_pass__/fuse_equal_placeholders_ops_pass#link-tree/executorch/backends/arm/test/runner_utils.py:193: in _tosa_dispatch
    return run_tosa_graph(tosa_buffer, tosa_spec, inputs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

graph = b'\x0c\x00\x00\x00TOSA\x00\x00\x00\x00\xec\xff\xff\xff\x08\x00\x00\x004\x04\x00\x00\x01\x00\x00\x00\x0c\x00\x00\x00\x0...00\x00main\x00\x00
\x00\x10\x00\x0c\x00\x08\x00\x04\x00
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00'
tosa_version = TOSA-1.0+FP
inputs = (tensor([0.6266]), tensor([6], dtype=torch.int32))

    def run_tosa_graph(
        graph: Any,
        tosa_version: TosaSpecification,
        inputs: list[torch.Tensor],
    ) -> list[torch.Tensor]:
        """Runs the TOSA reference model with inputs and returns the result."""
        inputs_np = [input.numpy() for input in inputs]
        transpose_data_format(inputs_np, to="NHWC")
    
        if isinstance(tosa_version, Tosa_1_00):
>           import tosa_reference_model as reference_model
E           ModuleNotFoundError: No module named 'tosa_reference_model'

@kirklandsign
Copy link
Contributor

Hi @zingo any suggestions on this issue?

@zingo
Copy link
Collaborator

zingo commented Aug 5, 2025

Hi Im still trying to reprodude and for me this works, so I have to dig some deeper

╰─❯ pytest  --verbose --color=yes backends/arm/test/passes/test_fuse_equal_placeholders_ops_pass.py 
============================================================================================= test session starts =============================================================================================
platform linux -- Python 3.12.3, pytest-8.3.5, pluggy-1.5.0 -- /home/zinand01/Projects/ml/executorch/executorch/env/bin/python3
cachedir: .pytest_cache
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase(PosixPath('/home/zinand01/Projects/ml/executorch/executorch/.hypothesis/examples'))
rootdir: /home/zinand01/Projects/ml/executorch/executorch/backends/arm/test
configfile: pytest.ini
plugins: hydra-core-1.3.2, xdist-3.6.1, hypothesis-6.130.4, rerunfailures-15.0
collected 3 items                                                                                                                                                                                             

backends/arm/test/passes/test_fuse_equal_placeholders_ops_pass.py::test_fuse_equal_placeholders_constants_tosa_FP PASSED                                                                                [ 33%]
backends/arm/test/passes/test_fuse_equal_placeholders_ops_pass.py::test_fuse_equal_placeholders_state_dict_tosa_FP PASSED                                                                               [ 66%]
backends/arm/test/passes/test_fuse_equal_placeholders_ops_pass.py::test_not_fuse_tensor_with_different_type_FP PASSED  

============================================================================================== warnings summary ===============================================================================================
env/lib/python3.12/site-packages/executorch/exir/dialects/edge/_ops.py:9
  /home/zinand01/Projects/ml/executorch/executorch/env/lib/python3.12/site-packages/executorch/exir/dialects/edge/_ops.py:9: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
    import pkg_resources

env/lib/python3.12/site-packages/executorch/extension/pybindings/portable_lib.py:20
  /home/zinand01/Projects/ml/executorch/executorch/env/lib/python3.12/site-packages/executorch/extension/pybindings/portable_lib.py:20: ExperimentalWarning: This API is experimental and subject to change without notice.
    _warnings.warn(

passes/test_fuse_equal_placeholders_ops_pass.py::test_not_fuse_tensor_with_different_type_FP
passes/test_fuse_equal_placeholders_ops_pass.py::test_not_fuse_tensor_with_different_type_FP
  /home/zinand01/Projects/ml/executorch/executorch/env/lib/python3.12/site-packages/executorch/exir/_serialize/_flatbuffer.py:105: DeprecationWarning: read_binary is deprecated. Use files() instead. Refer to https://importlib-resources.readthedocs.io/en/latest/using.html#migrating-from-legacy for migration advice.
    self._files[name] = importlib.resources.read_binary(__package__, name)

passes/test_fuse_equal_placeholders_ops_pass.py::test_not_fuse_tensor_with_different_type_FP
  /home/zinand01/Projects/ml/executorch/executorch/env/lib/python3.12/site-packages/executorch/exir/_serialize/_flatbuffer.py:190: DeprecationWarning: is_resource is deprecated. Use files() instead. Refer to https://importlib-resources.readthedocs.io/en/latest/using.html#migrating-from-legacy for migration advice.
    if importlib.resources.is_resource(__package__, _FLATC_RESOURCE_NAME):

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
======================================================================================== 3 passed, 5 warnings in 7.09s ========================================================================================

Are you seeing this in a CI (or something that has been setup from scratch)? Or on a dev machine (that has migrated)
I wonder if there is a rest of some 0.80.1 somewhere in some pip-out folder or something else. rerunning our setup.sh should have installed the reference model.
e.g. maybe there are some scratch or build folder that got some old stuff mixed in and needs to be wiped.

@zingo
Copy link
Collaborator

zingo commented Aug 5, 2025

@kirklandsign do you get this on all tests? e.g. not only test_fuse_equal_placeholders_ops_pass.py

@SaoirseARM
Copy link
Collaborator Author

Hi @kirklandsign ,

It looks like the reference model has not installed correctly into the environment which seems to be why the serializer works and the reference model does not.

Do you use examples/arm/setup.sh --i-agree-to-the-contained-eula to set up the TOSA tools? If that is the case, I can provide a solution to ensure the reference model does indeed install.

Let me know if that would help.

Thanks,
Saoirse

@kirklandsign
Copy link
Contributor

Are you seeing this in a CI (or something that has been setup from scratch)? Or on a dev machine (that has migrated)

In a CI. I'm not sure how the setup is done.

@kirklandsign do you get this on all tests? e.g. not only test_fuse_equal_placeholders_ops_pass.py

I get this on all tests

Do you use examples/arm/setup.sh --i-agree-to-the-contained-eula to set up the TOSA tools? If that is the case, I can provide a solution to ensure the reference model does indeed install.

Sorry I'm not sure how it is set up. Maybe @digantdesai knows

@digantdesai
Copy link
Contributor

digantdesai commented Aug 5, 2025

@kirklandsign is it breaking CI internally?

@digantdesai
Copy link
Contributor

Let me fwd fix it

@zingo
Copy link
Collaborator

zingo commented Aug 6, 2025

Thanks, Im still trying to reproduce and also try to great some github jobs with this not installed.

Some reflection:
Does it really make sense to run the unit tests in the case when it's not installed ? Would the run.sh flow be good enough? Thinking that a reference model is more of the unit test requirement but for the end 2 end flow (setup.sh) it should/could still work without it.

Would be OK to share how you install all TOSA stuff and Ill try to make a github test as close as possible. Then maybe we can see and fix this kind of things before merging :)

We are using this in the project (and not github testing)
https://github.com/pytorch/executorch/blob/main/backends/arm/scripts/install_reference_model.sh

After running it I see

╰─❯ pip list | grep tosa
tosa-tools                     1.0.0rc0.post1.dev314+g1e6e452

@digantdesai
Copy link
Contributor

digantdesai commented Aug 6, 2025

Does it really make sense to run the unit tests in the case when it's not installed ?

Yes! Because we can test the lowering until the PTE generation. Adding the tosa_reference_model in our internal setup has been on my list for a while so hopefully soon.

Would be OK to share how you install all TOSA stuff and Ill try to make a github test as close as possible

We use buck internally, so can't use CMake. And can't use install_reference_model.sh either.

@digantdesai
Copy link
Contributor

FYI #13165 #13165

agrima1304 pushed a commit to agrima1304/executorch that referenced this pull request Aug 26, 2025
### Summary
This PR removes TOSA v0.80 from the arm backend. This includes updates
to:

- operator node visitors
- operator support 
- passes 
- test infrastructure
- tosa specification and utils
- removal of installation of v0.80 and patch scripts
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 release notes: none Do not include this in the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants