Fix memory allocation TODO in KenCarp step 2 and 4 by introducing chi…#691
Fix memory allocation TODO in KenCarp step 2 and 4 by introducing chi…#691Emanuele-Elias wants to merge 3 commits intoSciML:masterfrom
Conversation
|
Hi @ChrisRackauckas! Maybe I misunderstood the TODO😅 I read it as referring to z₄ being used as temporary storage for chi2 * g1 on the lines right below it, so I added a cache to replace that temporary z₄ usage. Maybe what you meant was that in the non-diagonal noise case, g1 is mutated via g1 .-= g4, which permanently overwrites it and ruins it for a repeated step? To fix this properly, should I revert the chi2g1 changes and instead add a gtmp::rateNoiseType to the cache so we can do @.. gtmp = g1 - g4 and preserve g1? Let me know and I'll push the updated commit |
|
It's about fixing the repeated computation. |
|
I've just pushed a new commit that corrects my previous chi2g1 changes. Instead, I wrapped g(g1, ...) in an if !repeat_step && !integrator.last_stepfail block to prevent the repeated computation. To make this work, I also added a gtmp cache to replace g1 .-= g4 with @.. gtmp = g1 - g4 in Step 4 so g1 isn't destroyed with step failure. let me know if now it's ok and thank you @ChrisRackauckas for the guidance!! |
| aliases = ODEAliasSpecifier() | ||
| if haskey(kwargs, :alias_u0) | ||
| message = "`alias_u0` keyword argument is deprecated, to set `alias_u0`, | ||
| if use_old_kwargs |
There was a problem hiding this comment.
why is this all changed?
|
To fix the formatting and add an appropriate test, your changes were pulled into #698 and merged. Thanks! |
Checklist
Additional context
Hi everyone! This is my first PR to SciML, aiming to prepare for GSoC.
I addressed the
TODOleft insrc/perform_step/kencarp.jlinsideperform_step!forSKenCarpCache.Previously,
z₄was being used as temporary storage forg1 * chi2during Step 2 and Step 4, which could lead to it being overwritten and failing to properly repeat on a step fail.Changes made:
chi2g1::uTypecache variable in theSKenCarpCachestruct.chi2g1 = similar(u)insidealg_cache.z₄withchi2g1inkencarp.jl.Runicto format the code to adhere to the SciML Style Guide.Note on checklist: No new tests or docs were added because this is an internal memory/cache optimization and the existing test suite already covers this algorithm. Local tests passed (the only failure was
EulerHeun sparse alloc, which seems to be a pre-existing issue on master).