Repository navigation
Conversation
…or (lanl#1313) force_sparse_linear_solver on a model with no sparse Jacobian for KLU, and codegen=True on a model codegen declines, were a SimulationError and a RuntimeError a caller told from a crash only by their text: the path-agreement harness matched both, and a reworded message turned its SKIP or UNSUPPORTED into an EXCEPTION. - bngsim::SparseJacobianUnavailable (include/bngsim/refusals.hpp), thrown where cvode_simulator.cpp refuses, translated by the core to SparseJacobianUnavailableError(SimulationError), and passed through run(), run_batch's threads and each batch row untouched. - _codegen_refusal returns the exception: CodegenDeclinedError(BngsimError) for a decline, a plain RuntimeError for a failed build, which says nothing about the model. - Both exported; each subclasses what was raised before. - The harness reads both with isinstance. run_batch dropped force_dense_linear_solver and force_sparse_linear_solver from every row, which ran whatever the auto rule picked (KLU, on a 60-species chain asked for dense); run() honoured both. Found because the batch path never reached the refusal; each row now takes both.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1313.
What it adds
Two refusals bngsim makes by name now have types of their own. Each subclasses what was raised before, so an existing
exceptkeeps working.SparseJacobianUnavailableErrorforce_sparse_linear_solver=Trueon a model with no sparse Jacobian for KLUSimulationErrorCodegenDeclinedErrorcodegen=Trueon a model codegen declines (e.g. functions that read each other, #621)BngsimError, soRuntimeErrorThe sparse refusal is a C++ type,
bngsim::SparseJacobianUnavailable(newinclude/bngsim/refusals.hpp), thrown wherecvode_simulator.cpprefuses. The core's exception translator, which already mapsTimeoutErrortoSimulationTimeout, maps it to the Python type.run(),run_batch's threads and each batch row pass it through untouched, as they doSimulationTimeout.The codegen decline:
_codegen_refusalnow returns the exception. A decline isCodegenDeclinedError, a statement about the model. A failed build (a compiler error, a timeout) stays a plainRuntimeError, which says nothing about the model, as the issue asks. The messages are unchanged.The harness (
parity_checks/differential/_differential.py) reads both withisinstanceinstead of their text:_sparse_declined(e)isisinstance(e, SparseJacobianUnavailableError);_compiledcatchesCodegenDeclinedError.The baseline's notes (
_Declined: codegen=True requested, but codegen declined this model: …) are unchanged.A bug this found:
run_batchignored the linear-solver flagsThe batch test never reached the refusal:
run_batchran._run_single_batchcopiedjacobian, the tolerances and codegen onto each row's options, but neitherforce_dense_linear_solvernorforce_sparse_linear_solver. So every batch row ran whatever the auto rule picked. On a 60-species chain, a Simulator asked for the dense solver ran KLU in every row.run()always honoured both, and the steady-state batch already copies them. Each row now takes both:That has its own changelog fragment (
1313.fixed.md).Tests (
python/tests/test_typed_refusals.py)The positive tests fail on main because neither type exists. With the change:
CodegenDeclinedErroris not aSimulationError;force_sparse_linear_solver=True, jacobian="fd", raiseSparseJacobianUnavailableError, still aSimulationError;run_batchwith 2 threads arrives by its type, not as "Batch simulation 0 failed";CodegenDeclinedError;generate_combined_from_model) is aRuntimeError, not a decline;{1}(KLU) under the auto rule,{0}(dense) underforce_dense_linear_solver.Mutations, each caught:
run()wrapping it;run_batchdropping the flags: 2 fail.Suites:
python/testsandparity_checks/testsgive 17,325 passed, 171 skipped, 1 xfailed. clang-format 17.0.6 (the pinned hook) and ruff 0.14.0 are clean. The core stub is unchanged, since no binding changed.Docs: both types are in
docs/reference/api.md's exception list; changelog fragments1313.added.mdand1313.fixed.md.Conflicts: none. A trial merge with each open differential PR (#1315, #1318, #1319, #1320, #1321, #1322, #1323) is clean.