Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update values before klu_factor #157

Merged
merged 2 commits into from
Jul 17, 2022
Merged

update values before klu_factor #157

merged 2 commits into from
Jul 17, 2022

Conversation

ChrisRackauckas
Copy link
Member

@ChrisRackauckas ChrisRackauckas commented Jul 16, 2022

Otherwise it's just using the values from before!

BTW, why do we need to klu_factor before klu!, instead of just klu!? Don't that do the factorization as well?

Fixes SciML/OrdinaryDiffEq.jl#1701

Otherwise it's just using the values from before!

BTW, why do we need to klu_factor before klu!, instead of just klu!? Don't that do the factorization as well?
@ChrisRackauckas
Copy link
Member Author

@Wimmerer do you know why after that change we'd suddenly get https://github.com/SciML/ModelingToolkit.jl/runs/7370823848?check_suite_focus=true#step:6:739 ?

#156

It was never dispatching to that solve before.

@rayegun
Copy link
Collaborator

rayegun commented Jul 16, 2022

I'm going to have to step through this code to be sure this is what we want. The refactor occurs in this line:

fact = KLU.klu!(cache.cacheval, A)
, which is also where fact.nzval is updated to be the same as A.nzval.

Why exactly are we hitting the singular error? Is A being changed between init_cacheval and solve?

First thing I want to try here is actually running klu in init_cacheval rather than just constructing the factorization. I'll make a PR to do that. That way we know we have a factorization to refactor with rather than relying on internal fields to check for that.

The KLU refactor method also needs several exceptions checked and handled gracefully now that I look at it.

@rayegun
Copy link
Collaborator

rayegun commented Jul 16, 2022

For UMFPACK I recall there were some changes recently which fixed some things in UMFPACK refactors. We may just disable resolves temporarily until 1.9 if I'm correct. I'll try to figure out a way to test that manually.

@rayegun
Copy link
Collaborator

rayegun commented Jul 16, 2022

Or rather, the question is: is A being created at init_cacheval time with a singular matrix, then set_A is being used to make the actual matrix?

@codecov
Copy link

codecov bot commented Jul 16, 2022

Codecov Report

Merging #157 (cd582d9) into main (c5168f3) will increase coverage by 0.05%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #157      +/-   ##
==========================================
+ Coverage   65.66%   65.71%   +0.05%     
==========================================
  Files           9        9              
  Lines         632      633       +1     
==========================================
+ Hits          415      416       +1     
  Misses        217      217              
Impacted Files Coverage Δ
src/factorization.jl 77.35% <100.00%> (+0.10%) ⬆️

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

@ChrisRackauckas
Copy link
Member Author

Or rather, the question is: is A being created at init_cacheval time with a singular matrix, then set_A is being used to make the actual matrix?

Yes, it's creating in OrdinaryDiffEq.jl with a zero matrix matching the same sparsity pattern at the initialization time, and then when solving it updates the value to the Jacobian and factorizes. So I think #158 would error (and we should try to capture this in tests).

The refactor occurs in this line:

Then what does klu_factor do? Sounds like we can just cut that line and directly go to the klu! call?

@ChrisRackauckas
Copy link
Member Author

I'm going to merge this so downstream is fixed, but we should continue to discuss.

@ChrisRackauckas ChrisRackauckas merged commit af6bb7c into main Jul 17, 2022
@ChrisRackauckas ChrisRackauckas deleted the klu_update_vals branch July 17, 2022 10:51
@rayegun
Copy link
Collaborator

rayegun commented Jul 17, 2022

Okay that's the issue then. In order to refactor KLU requires an existing factorization (unlike UMFPACK AFAIK). So we need to detect that, or set some flag to ignore the first matrix.

Or perhaps klu!(fact, A) should solve with A even if fact wasn't solved originally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SingularException error with KLUFactorization for doc example
2 participants