Skip to content

Conversation

YufengShi-dudu
Copy link
Collaborator

@YufengShi-dudu YufengShi-dudu commented Jul 7, 2025

  • Add module tests for two text encoders: CLIP and T5
  • Add module tests for VAE autoencoder
  • Add module tests for SD3Transformer2DModel
  • Add flag to exmaples/arm/setup.sh for installing Stable Diffusion dependencies
  • Handle int64 inputs to aten.slice_copy.Tensor using pass InsertCastForOpsWithInt64InputPass

Change-Id: I4389e87749cfb4e40f837cc6bfa8a59a73fb3a3a

cc @digantdesai @freddan80 @per @zingo @oscarandersson8218

@YufengShi-dudu YufengShi-dudu requested a review from freddan80 July 7, 2025 13:18
@YufengShi-dudu YufengShi-dudu added partner: arm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Arm ciflow/trunk release notes: arm Changes to the ARM backend delegate labels Jul 7, 2025
Copy link

pytorch-bot bot commented Jul 7, 2025

🔗 Helpful Links

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

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

✅ You can merge normally! (2 Unrelated Failures)

As of commit f52a160 with merge base b0dda93 (image):

FLAKY - The following job failed but was likely due to flakiness present on trunk:

BROKEN TRUNK - The following job failed but was present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

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

Hi @digantdesai,

We added some test configs to stable_diffusion_module_test_configs.py. They're mostly copy-pasted from the diffusers library to initialize different modules for testing.

We've included license notice and copyright attribution, and also links to the original source files for reference,

Please let us know if you have any concerns.

@freddan80
Copy link
Collaborator

Hi @digantdesai,

We added some test configs to stable_diffusion_module_test_configs.py. They're mostly copy-pasted from the diffusers library to initialize different modules for testing.

We've included license notice and copyright attribution, and also links to the original source files for reference,

Please let us know if you have any concerns.

Thx for highlighting this @YufengShi-dudu. With the proper attributions in place and a clear separation (separate file), it should be fine. But pls @digantdesai or @mergennachin - pls confirm.

- Add module tests for two text encoders: CLIP and T5
- Add module tests for VAE autoencoder
- Add module tests for SD3Transformer2DModel
- Add flag to exmaples/arm/setup.sh for installing Stable Diffusion
  dependencies
- Handle int64 inputs to aten.slice_copy.Tensor using pass
  InsertCastForOpsWithInt64InputPass

Change-Id: I4389e87749cfb4e40f837cc6bfa8a59a73fb3a3a
Signed-off-by: Yufeng Shi <yufeng.shi@arm.com>
@YufengShi-dudu YufengShi-dudu force-pushed the stable-diffusion-module-tests branch from 53447d4 to 42a4656 Compare July 25, 2025 12:25
@YufengShi-dudu
Copy link
Collaborator Author

Hi @digantdesai,
Could you please review this PR?
Thanks!

Copy link
Contributor

@digantdesai digantdesai left a comment

Choose a reason for hiding this comment

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

Great to see this test working :)

In order to lower this to TOSA and int64->int32 cast need to be injected. This pass need to run very early in the lowering process and can be passed in to the to_edge_transform_and_lower() function call as an optional parameter. See example in: backends/arm/test/models/test_llama.py.
By doing this aten.embedding will be decomposed into to aten.index_select which can handle int32 indices.
Note that this additional step is only needed for pure float models. With quantization this is automatically handled during annotation before the export stage.
The current TOSA version does not support int64. However, int64 is commonly used in many models. In order to lower the operators with int64 inputs and/or outputs to TOSA, a few passes have been developed to handle the int64-related issues. The main idea behind these passes is to replace the uses of int64 with int32 where feasible.
Copy link
Contributor

Choose a reason for hiding this comment

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

this is also the case with xnnpack and other backends, perhaps we should share this pass.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This pass currently has some tosa-specific code/log info. Could we refactor it to exir in a follow up PR if needed by other backends?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Issue created: #12957

- Extract the logic of inserting int32 cast node into a helper
  function in pass InsertCastForOpsWithInt64InputPass

Change-Id: I748d53921981d43c3a913c4e7a15f3daf33c836e
Signed-off-by: Yufeng Shi <yufeng.shi@arm.com>
Copy link
Collaborator

@Sebastian-Larsson Sebastian-Larsson left a comment

Choose a reason for hiding this comment

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

Unrelated CI failures. Approved.

@Sebastian-Larsson Sebastian-Larsson merged commit 119c28c into pytorch:main Jul 29, 2025
210 of 212 checks passed
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: arm Changes to the ARM backend delegate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants