Repository navigation
Don't specialize on build, take 2 - #2652
Conversation
|
Some stats. Currently we do FullSpecialize. I give the wall time , the time it takes ribasim.exe as reported in my shell, and the computation time as reported by Ribasim. The computation time often includes compilation for the first timestep, especially for FullSpecialize it seems. I'm somewhat surprised to see a speedup on NoSpecialize for all cases, even a large model. It could be that for the full LHM this will still go the other way but probably not by much. For users working with small models the 28s to 10s speedup will be great, so I'm inclined to disable specialization. Rather than changing the setting we can also just rip out the Preferences setting specialize. EDIT: this needs a better check, but it seems at LHM scale this does negatively affect performance of possibly up to 2x longer ETA. We could also add a solver option for this, and use NoSpecialize by default. We could also still check AutoSpecialize. And it might be wise to do these checks on top of #2624. |
|
There's a finetuning option as well, most of the specialize time comes from introducing a chunk-like number (forgot the exact name), that is determined automatically based on the size of the problem. We could hardcode it for all/specific models? Would be good to print that number for different problem sizes. Not sure if this is all that specialize influences, but this is the chunksize argument: https://github.com/Deltares/Ribasim/pull/2114/files#diff-50a3f887d6d4b8517e8faf1ceaddb02c23149fe7bf4b9199c8f56d52bed6c6f2R303 |
|
Yeah that is a good point. I don't have time to look into chunksizes right now, so we can keep the specialize argument to the solver which also controls the chunk size. I made a separate issue for chunksize. |
4bb93c4 to
59efa04
Compare
Replaces #2643 Make specialize configurable from TOML
| sparse = true # optional, default true | ||
| autodiff = true # optional, default true | ||
| evaporate_mass = true # optional, default true to simulate a correct mass balance | ||
| specialize = false # optional, default true |
There was a problem hiding this comment.
Thanks, fixed. To be clear, the comment on the default was wrong.
| The `evaporate_mass = true` setting determines whether mass is lost due to evaporation in water quality calculations, by default set to true. | ||
| While physically incorrect, it is useful for a first correctness check on a model in terms of mass balance (Continuity tracer should always have a concentration of 1). To simulate increasing concentrations (e.g. salinity) due to evaporation, change the setting to `false`. | ||
|
|
||
| Finally there's `specialize = false`. By default it is turned off to reduce the time it takes to initialize fully. It can be enabled for long-running simulations, trading initialization speed for simulation speed. Concretely, enabling it will set the [specialization level](https://docs.sciml.ai/SciMLBase/stable/interfaces/Problems/#Specialization-Levels) to NoSpecialize for false, and FullSpecialize for true. Additionally setting it to true also fixes the [autodiff chunk size](https://juliadiff.org/ForwardDiff.jl/stable/user/advanced/#Configuring-Chunk-Size) to 1, making a similar tradeoff as the specialization level. |
There was a problem hiding this comment.
Enabling it => setting it
And the chunk size is 1 when specialize is false, not true.
|
Nice, Test Ribasim Binaries went from 15 to 8 minutes on Linux, and a similar improvement on Windows. |
…" (#2667) This reverts commit e179af0. #2624 provides a great performance speedup for very large models, but I now see this is too much at the expense of small models. For instance after #2652 (comment) we got down to an acceptable 10s wall time for `tabulated_rating_curve_control` from ribasim.exe. It seems #2624 brings that up to 1m11s. This can be reduced by setting the number of threads to 1, though only partially. ``` tabulated_rating_curve_control NoSpecialize: 10s total, Computation time: 21 milliseconds tabulated_rating_curve_control NoSpecialize+2624: 1m11s total, Computation time: 10 seconds tabulated_rating_curve_control NoSpecialize+2624-t1: 46s total, Computation time: 10 seconds ``` Since for the upcoming courses no-one is going to be running the LHM I feel we should revert this now, giving us time to find ways to make #2624 quicker to start.
Replaces #2643