Skip to content

feat: explain solver failures on compiled DSL models - #382

Draft
mhovd wants to merge 1 commit into
mainfrom
feat/solver-failure-diagnostics
Draft

mhovd wants to merge 1 commit into
mainfrom
feat/solver-failure-diagnostics

Conversation

@mhovd

@mhovd mhovd commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator

Solver failures on compiled DSL models now carry a Diagnostics: section instead of only "Newton solver failed" / "step size collapsed".

  • Last RHS evaluation returned non-finite derivatives: names the states and shows the state that produced them.
  • Non-finite values in the last accepted state are listed by name.
  • Rescaling hint when the accepted state spans >= 8 orders of magnitude (shows the extreme states and atol).

Diagnostics are added only on failure. The RHS callback only records non-finite evaluations and never errors on them, so solver behavior is unchanged.

DSL backend only; the closure ODE path is untouched. Tests: unit tests in src/error/mod.rs and tests/dsl_solver_diagnostics.rs.

🤖 Generated with Claude Code

When diffsol gives up on a compiled model, the error now carries context
instead of only "Newton solver failed" / "step size collapsed":

- the last right-hand-side evaluation, if it returned non-finite
  derivatives, with the offending state names and the state that
  produced them (e.g. (c/x)^h turning NaN when x dips below zero)
- non-finite entries in the last accepted state
- a rescaling hint when the accepted state spans >= 8 orders of
  magnitude, reporting the extreme states and the active atol

Diagnostics are attached only on failure. The RHS callback never turns a
non-finite evaluation into an error by itself, so trial steps the solver
recovers from behave exactly as before.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.69281% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.85%. Comparing base (a2203f2) to head (eafa12d).

Files with missing lines Patch % Lines
src/error/mod.rs 98.34% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #382      +/-   ##
==========================================
+ Coverage   84.75%   84.85%   +0.10%     
==========================================
  Files          78       78              
  Lines       35818    35969     +151     
==========================================
+ Hits        30356    30522     +166     
+ Misses       5462     5447      -15     
Files with missing lines Coverage Δ
src/dsl/backend.rs 69.25% <100.00%> (+0.36%) ⬆️
src/error/mod.rs 86.86% <98.34%> (+19.33%) ⬆️

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Projectpharmsol
Branchfeat/solver-failure-diagnostics
Testbedmhovd-pgx

⚠️ WARNING: Truncated view!

The full continuous benchmarking report exceeds the maximum length allowed on this platform.

🚨 1 Alert

🐰 View full continuous benchmarking report in Bencher

This branch has not been deployed

No deployments
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.

2 participants