modularml / max

A collection of sample programs, notebooks, and tools which highlight the power of the MAX Platform
https://www.modular.com
Other
202 stars 31 forks source link

[BUG]: Hanging Netron Visualizazion #116

Closed suahelen closed 3 months ago

suahelen commented 3 months ago

Bug description

I was tinkering around with the following model. https://github.com/openvinotoolkit/anomalib/tree/main/src/anomalib/models/image/fastflow

Running the model with the max engine seems to be fine as far as I can tell. Albeit, with the limited performance others have experienced on Windows so far.

When trying to visualize the graph with netron I get a warning that I am tring to visualize a model with a large number of nodes. Is that normal? When continuing the app hangs and does not seem to open the model. Visualizing the onnx file works fine.

Steps to reproduce

Here are the models I used: https://drive.google.com/drive/u/1/folders/17vKQe1kRtWYfkfJ5lflZc1-TIXniLobt

System information

- What OS did you do install MAX on ?
> WSL Ubuntu

- Provide version information for MAX by pasting the output of max -v`
> max 24.1.0 (c176f84d)
- Provide version information for Mojo by pasting the output of mojo -v`
> mojo 24.1.0 (c176f84d)
- Provide Modular CLI version by pasting the output of `modular -v`
> Modular version 24.1.0-c176f84d-release
ehsanmok commented 3 months ago

That's normal in netron rendering large graphs. Please raise issues in the netron repo.

suahelen commented 3 months ago

I was more wodering about the reason why the Graph is much larger when I compile a model with MAX.

ehsanmok commented 3 months ago

Could you share the disk size difference pre and after compilation of the model?

suahelen commented 3 months ago

Sure thing: test.onnx -> 93395 KB torch_jit.maxviz -> 2241KB

The file was generated with max visualize test.onnx

ehsanmok commented 3 months ago

Thanks for the feedback. We’re working on enabling our maxviz graphs to be vizualized with a larger number of nodes. We’ll add this to our feature request map.

Also to confirm, the numbers you pasted above show that the torch_jit.maxviz is much smaller, 41 times (93395 / 2241) because maxviz contains the graph only and not weights.

maxviz which we visualize is lower level than ONNX - e.g. it makes all casts and broadcasts explicit which can result in a significant increase of nodes numbers, so this is somewhat not surprising that netron can visualize the original onnx model, but can’t visualize our IR.

For more details, please check out our doc here

suahelen commented 3 months ago

Yes, I can confirm that the .maxviz is much smaller.

With Graph I was referring to the visualization that netron would show. I guess it makes sense that this would be larger if you show the operations in more detail.

Thanks for the feedback.