Skip to content

System.eval accepts any point precision; mixed time/space precisions throw (closes #377) - #387

Open
ofloveandhate wants to merge 1 commit into
bertiniteam:developfrom
ofloveandhate:feature/eval-precision-tolerant
Open

System.eval accepts any point precision; mixed time/space precisions throw (closes #377)#387
ofloveandhate wants to merge 1 commit into
bertiniteam:developfrom
ofloveandhate:feature/eval-precision-tolerant

Conversation

@ofloveandhate

Copy link
Copy Markdown
Contributor

Closes #377.

The footgun

System::SetVariables threw whenever a multiprecision point's precision differed from the system's internal precision. Since the ambient default precision drifts (most notably after an adaptive-precision solve), every consumer of System::Eval eventually hit

precision of input point in SetVariables (40) must match the precision of the system (30).

at a call site that did nothing wrong. The cellular/NID layers had grown repeated align-then-eval workarounds; each new eval call site re-discovered the crash.

The contract now

Evaluation is stateless (blocks are value-in; the SLP is the evaluator), so the input defines the working precision:

  • SetVariables changes the system's internal precision to match the incoming point — in both directions. A caller evaluating at precision p gets the evaluation at precision p; the system's previous precision is not their concern. Precision-managing callers (the trackers) always match already and take the fast path unchanged.
  • Time and variables are different in kind: both are supplied in the same call, so a precision mismatch between them is caller incoherence, not internal-state drift. EvalInPlace / JacobianInPlace (the funnels for every point+time evaluation) now throw with a message naming both precisions and instructing the caller to align them. Previously SetPathVariable checked nothing, so mixed time slipped in silently.
  • BERTINI_DISABLE_PRECISION_CHECKS builds behave as before (no checks, no alignment).

Tests

  • C++ (test_classes): system_evaluate_mpfr_any_point_precision — a precision-30 system follows a 50-digit point up (result precision 50, values exact) and a 20-digit point down; Jacobian too. system_evaluate_mixed_time_precision_throws — mismatched time throws for both Eval and JacobianInPlace; aligned inputs evaluate at their common precision.
  • Python (python/test/classes/system_test.py): the eval surface accepts any point precision, and the mixed time/space message reaches Python as a RuntimeError naming both precisions and the word "align".

Both doc-lint passes clean (C++ and Python).

🤖 Generated with Claude Code

…isions throw

Closes bertiniteam#377.  System evaluation is stateless (blocks are value-in, the
SLP is the evaluator), so the INPUT defines the working precision:
SetVariables now changes the system's internal precision to match the
incoming point instead of throwing on mismatch.  Callers evaluating at
precision p get the evaluation at precision p; the system's previous
precision is not their concern.  Precision-managing callers (the
trackers) always match already and take the fast path unchanged.

The time-and-variables case is different in kind: both are supplied in
the SAME call, so a precision mismatch between them is caller
incoherence, not internal-state drift -- silently promoting either one
would guess intent and mask exactly the ambient-precision-drift bugs
this exposes.  EvalInPlace and JacobianInPlace (the funnels for every
point+time evaluation) throw with a message naming both precisions and
instructing the caller to align them.  Previously SetPathVariable
checked nothing at all, so mixed time slipped in silently.

Tests: C++ (system_evaluate_mpfr_any_point_precision -- the system
follows the input up to 50 and down to 20 digits, values and result
precisions checked; system_evaluate_mixed_time_precision_throws) and
Python (the eval surface accepts any precision; the mismatch message
reaches Python naming both precisions and the word 'align').

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

Precision alignment is a pervasive footgun: evaluation should not throw when precisions differ

1 participant