Dyad 3.0 slower Transient Analysis

Hi

I just got greeted in VSCode with a message that made me update to Dyad 3.0… After using the AI to update my models I now realized that the TransientAnalysis is now much slower that before. (5min instead of 3min maybe)

I am simulating a Vienna Rectifier that has some switches switching at 50kHz, so I am not expecting something super fast, but this feels easily double the time than before.

Honestly I am not sure how to get back to the previous Dyad Release, otherwise I would love to share some real numbers.

I published the code here if it helps: https://gitlab.com/gruemel/julia/dyad_vienna_afe There is a commit " Updated the model to Dyad 3.0" for the updated code

I tried setting optimize = OptimizationLevel.Basic(), and optimize = OptimizationLevel.Agressive(), but these are not working due to some errors.

Anything I can do to get more insights where this is coming from?

Tomorrow I will try again with a windows laptop still running the old version, to get some concrete values.

It’s not perfect since it is not the same machine, but I think it gives the picture:

Linux dyad 3.0: 239.544428 seconds (122.03 M allocations: 80.717 GiB, 10.04% gc time, 0.00% compilation time: 100% of which was recompilation)

Windows dyad 2.3: 14.381151 seconds (23.07M allocations: 4.706 GiB, 19.00% gc time, 0.00% compilation time)

Yup that’s gives a picture. We can look into it.

That was a quick reply! Thank you Chris!

If I can do anything to help debug, let me know.

Thanks for sharing these examples. I’m just adding a link to the circuit topology, since I didn’t know it:

I also find a schematic in your repo, but it’s not obvious is the same a the one on Wikipedia.

Figured out what it is. It looks like this is due to the enabling of inline linear SCC passes without the rest of the new compiler framework being released (the other part is scheduled for the upcoming 3.1.0 release).

We’d either need a 3.0.1 to allow for temporarily disabling inline linear SCCs or just wait for the 3.1.0 which includes the new compiler passes to make these non-allocating. The problem with disabling is that it can change the state selection, which in particular makes the model require a lot more guesses, so it would be a breaking change and a pretty bad quality of life thing to have this turned off. So the best thing to do for this model is probably to just have the regression fixed in the 3.1.0 with the new compiler codegen. That’s not the most ideal answer but since that is already scheduled for the very near future it’s almost as fast as a patch release would be, that is the way to do this that’s the most future-proofed.

In the meantime, if you’re willing to get a bit manual, you can get around this by disabling the linear SCC inlining by taking the mtkcompile command directly and doing:

ModelingToolkit.StructuralTransformations.DefaultReassembleAlgorithm(;
      inline_linear_sccs = true, analytical_linear_scc_limit = 1)
  sys = mtkcompile(model; additional_passes = passes, reassemble_alg)

Hi Chris,

since I am currently “just scratching an itch” and I need to also work around the maxiters topic, for me doing it manually is just fine.

You decide which solution is best from business/process point of view :wink:

BR
Johannes