Skip to content

Conversation

@MartinPavella
Copy link
Collaborator

@MartinPavella MartinPavella commented Sep 15, 2025

Summary

This PR updates the existing ExecuTorch graph visualization tool to suit NXP use-cases, and removes the old custom visualizer.

Test plan

N/A

cc @robert-kalmar @roman-janik-nxp @StrycekSimon @jirioc

@pytorch-bot
Copy link

pytorch-bot bot commented Sep 15, 2025

🔗 Helpful Links

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

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

⏳ No Failures, 118 Pending

As of commit 1c79d1b with merge base 82a2324 (image):
💚 Looks good so far! There are no failures yet. 💚

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 Sep 15, 2025
@MartinPavella
Copy link
Collaborator Author

@pytorchbot label "module: nxp" "release notes: nxp"

@pytorch-bot pytorch-bot bot added module: nxp Issues related to NXP Neutron NPU delegation and code under backends/nxp/ release notes: nxp Changes to the NXP Neutron backend delegate labels Sep 15, 2025
@robert-kalmar robert-kalmar self-assigned this Sep 16, 2025
StrycekSimon

This comment was marked as spam.

@jirioc jirioc self-requested a review September 16, 2025 12:35
@MartinPavella MartinPavella force-pushed the upstream/main-nxp/EIEX-527-analyze-the-existing-executorch-visualization-tool branch 2 times, most recently from 287a4eb to c1a4c8b Compare September 18, 2025 06:10
@MartinPavella
Copy link
Collaborator Author

The failing linting checks are related to imports from model_explorer. As far as I can tell, it is caused by missing stub files.
I checked all the 4 commits which modified this module before, and they all had MYPY linting errors. I don't know if I can fix it.
@Gasoonjia do you know of any way to fix this?

Copy link
Collaborator

@Erik-Lundell Erik-Lundell left a comment

Choose a reason for hiding this comment

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

Chiming in with some comments, hope that's ok.

@MartinPavella MartinPavella force-pushed the upstream/main-nxp/EIEX-527-analyze-the-existing-executorch-visualization-tool branch 2 times, most recently from 6a4ccae to e16565a Compare September 24, 2025 06:22
@MartinPavella
Copy link
Collaborator Author

MartinPavella commented Sep 24, 2025

Chiming in with some comments, hope that's ok.

Thank you for the review @Erik-Lundell .
I have renamed the function and added the callbacks as you suggested. The visualization is no longer just for NXP, and it can be used by any backend.
The model_explorer_cluster_style.json can be loaded in the Model Explorer GUI (by clicking the palette in the top right corner), to add colors to the QDQ clusters and partitions for better readability. (I have added a note to the commit message as you suggested)

Do you have any information regarding the MYPY import warnings (the failing lintrunner)?

I am attaching an example of the visualization.
image

@Erik-Lundell
Copy link
Collaborator

Thanks for your adjustments! I was probably not too clear what I meant with callback, I meant that the function takes a callback(Node) -> namespace, that makes it possible to use for any type of clustering. You can then include a new function that does the particular clustering you are interested in. But my main concerns are fixed, so I'll leave the rest of the review to someone who can actually approve.

Regarding mypy, I don't know, sorry. Maybe just add ignore markers?

@MartinPavella
Copy link
Collaborator Author

The failing linting checks are related to imports from model_explorer. As far as I can tell, it is caused by missing stub files. I checked all the 4 commits which modified this module before, and they all had MYPY linting errors. I don't know if I can fix it. @Gasoonjia do you know of any way to fix this?

@Gasoonjia pinging you in case you missed the comment.

Copy link
Collaborator

@robert-kalmar robert-kalmar left a comment

Choose a reason for hiding this comment

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

@MartinPavella, Implementation and concept wise looks good to me.

What I recommend:

  • Integrate it as example usage into nxp's aot_neutron_example where on the CLI argument e.g. --visualize=show|store the example would either show the visualization of the model or store it to a json file based on the input model name. This will give everyone an example use and context for the reviewers, especially @Gasoonjia as code owner.
  • In the example store/visualize the exported quantized graph (shows the QDQ cluster visualization) and final exported program with NeutronBackend node. Optionally you can also visualize/store the output of the partitioner, although it is a bit more difficult as the CLI argument must be propagated from example to the NeutronPartitioner (e.g. via neutron_compile_spec, although bit hacky). Or ExecuTorch's to_edge_transform_and_lower and/or to_edge must be extended to support:
    • either propagation of visualize argument, then the visualization can be done on the level of ExecuTorch for all the backends. Or
    • the aforementioned routines would return the partitioned graph .
  • Document the usage in a new md in docs\sources\ showing how to use the visualize_with_cluster, opening a model explorer, using the predefined color scheme.
  • There is no documentation available how to use the visualization at all. The docs/source/devtools-overview.md mentions the "visualization - Comming soon" is outdated, as the visualization is already here for some time :-). You spent time in investigation, so feel free to add short guideline how to use it, this will give you a prerequisity for the documentation of visualize_with_cluster and fill the gap with missing visualization documentation.
  • Move the color coding style definition (model_explorer_cluster_style.json) to a subfolder. This way, there will be a foundation for other backends to add their style definition to visualize their features.

@digantdesai , for the context, at our early development days we mentioned our visualization tool, based on .dot files, and discussed using the ExecuTorch visualizer instead. Martin worked out a proposal. Feel free to comment on the PR or my suggestions.

Copy link
Collaborator

@roman-janik-nxp roman-janik-nxp left a comment

Choose a reason for hiding this comment

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

Besides small adjustments and documentation it looks fine.

@MartinPavella MartinPavella force-pushed the upstream/main-nxp/EIEX-527-analyze-the-existing-executorch-visualization-tool branch from e16565a to 5ea9a0c Compare October 2, 2025 08:06
@MartinPavella MartinPavella force-pushed the upstream/main-nxp/EIEX-527-analyze-the-existing-executorch-visualization-tool branch 3 times, most recently from 79edf73 to b71ea03 Compare October 2, 2025 11:42
@MartinPavella
Copy link
Collaborator Author

@MartinPavella, Implementation and concept wise looks good to me.

What I recommend:

* Integrate it as example usage into nxp's `aot_neutron_example` where on the CLI argument e.g. `--visualize=show|store` the example would either show the visualization of the model or store it to a json file based on the input model name. This will give everyone an example use and context for the reviewers, especially @Gasoonjia as code owner.

* In the example store/visualize the exported quantized graph (shows the QDQ cluster visualization) and final exported program with NeutronBackend node. Optionally you can also visualize/store the output of the partitioner, although it is a bit more difficult as the CLI argument must be propagated from example to the NeutronPartitioner (e.g. via `neutron_compile_spec`, although bit hacky). Or ExecuTorch's `to_edge_transform_and_lower` and/or `to_edge` must be extended to support:
  
  * either propagation of visualize argument, then the visualization can be done on the level of ExecuTorch for all the backends. Or
  * the aforementioned routines would return the partitioned graph .

* Document the usage in a new `md` in `docs\sources\` showing how to use the `visualize_with_cluster`, opening a model explorer, using the predefined color scheme.

* There is no documentation available how to use the visualization at all. The `docs/source/devtools-overview.md` mentions the "visualization - Comming soon" is outdated, as the visualization is already here for some time :-). You spent time in investigation, so feel free to add short guideline how to use it, this will give you a prerequisity for the documentation of `visualize_with_cluster` and fill the gap with missing visualization documentation.

* Move the color coding style definition (`model_explorer_cluster_style.json`) to a subfolder. This way, there will be a foundation for other backends to add their style definition to visualize their features.

@digantdesai , for the context, at our early development days we mentioned our visualization tool, based on .dot files, and discussed using the ExecuTorch visualizer instead. Martin worked out a proposal. Feel free to comment on the PR or my suggestions.

Thank you for the suggestions. I have implemented the changes except for the visualization of the partitioning. I didn't want to make such a large change to the entire pipeline within this PR.

@MartinPavella MartinPavella force-pushed the upstream/main-nxp/EIEX-527-analyze-the-existing-executorch-visualization-tool branch 2 times, most recently from 0cdfb63 to 6b0cb03 Compare October 3, 2025 09:11
@MartinPavella MartinPavella force-pushed the upstream/main-nxp/EIEX-527-analyze-the-existing-executorch-visualization-tool branch 2 times, most recently from cdc1277 to ee6de30 Compare October 3, 2025 13:42
@MartinPavella MartinPavella force-pushed the upstream/main-nxp/EIEX-527-analyze-the-existing-executorch-visualization-tool branch 4 times, most recently from 07eb96f to 6986599 Compare October 13, 2025 06:51
@MartinPavella
Copy link
Collaborator Author

@Erik-Lundell, @mergennachin the PR has been updated recently to better document the Model Explorer visualization. Please feel free to review the changes.

Copy link
Collaborator

@StrycekSimon StrycekSimon left a comment

Choose a reason for hiding this comment

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

Have no comments here. Nice work!

@MartinPavella MartinPavella force-pushed the upstream/main-nxp/EIEX-527-analyze-the-existing-executorch-visualization-tool branch from 6986599 to 88a464e Compare October 14, 2025 09:11
./devtools/install_requirements.sh
```

## Visualize a model
Copy link
Contributor

Choose a reason for hiding this comment

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

@MartinPavella MartinPavella force-pushed the upstream/main-nxp/EIEX-527-analyze-the-existing-executorch-visualization-tool branch 2 times, most recently from 4ea6dbd to 5a52a1f Compare October 15, 2025 06:28
@MartinPavella
Copy link
Collaborator Author

The failing checks appear unrelated. Merging the PR.

@MartinPavella MartinPavella force-pushed the upstream/main-nxp/EIEX-527-analyze-the-existing-executorch-visualization-tool branch from 5a52a1f to 1c79d1b Compare October 15, 2025 12:36
@MartinPavella MartinPavella merged commit f0e8ea8 into pytorch:main Oct 15, 2025
132 of 134 checks passed
@@ -0,0 +1,144 @@
# Visualize a Model using ModelExplorer

The [visualization_utils.py](../../devtools/visualization/visualization_utils.py) contains functions for
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: this doesn't point to the code but becomes a download link.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. module: nxp Issues related to NXP Neutron NPU delegation and code under backends/nxp/ release notes: nxp Changes to the NXP Neutron backend delegate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants