======================================== TLA+ Model for SCG Curvature-Mode Policy ======================================== This note captures the control-flow policy for choosing the SCG curvature oracle. It is intentionally narrow: it models configuration parsing and the exact-versus-finite-difference selection rule, not the numerical optimizer. Files: - `scg\_curvature\_mode.tla `_ - `scg\_curvature\_mode.cfg `_ The model encodes these rules: - missing config defaults to ``exact`` - ``finite_difference`` is only requested by explicit opt-in - unknown values are invalid and must error - requested ``exact`` may fall back to ``finite_difference`` only when the kernel/backend cannot provide the exact oracle This matches the intended branch policy: - cut over to exact by default - retain finite differences as an explicit compatibility mode - reject unknown ``curvature_mode`` values instead of silently choosing exact What the model does not cover: - the opt-in ``nlml_hessian_vector`` mode, which takes the ``finite_difference`` path, logged, for an objective without the exact NLML Hessian-vector product or when that product fails - correctness of the exact-curvature algebra itself - floating-point behavior - performance claims; the one measured cost of ``nlml_hessian_vector`` is stated at the end of this note, as a single example - full SCG convergence Those are covered elsewhere: - symbolic derivation and tests in `python/tests/test\_sympy\_scg\_exact\_curvature.py `_ - implementation note "Exact SCG Curvature for Distributed GP Training" (``docs/verification/scg_exact_curvature.org``) The model was checked locally with Apalache 0.56.1 using Java 26 and deadlock checking disabled for the terminal ``done`` states. Repository task: .. code:: bash pixi run apalache-scg-curvature Equivalent direct invocation. ``JAVA_HOME`` must name the selected JDK; the Apalache package path below is the system-wide default: .. code:: bash "${JAVA_HOME}/bin/java" -Xmx4096m -XX:+UseG1GC \ -jar /usr/share/java/apalache/apalache.jar \ check --no-deadlock \ --config=docs/verification/scg_curvature_mode.cfg \ docs/verification/scg_curvature_mode.tla Apalache currently ignores the fairness annotation in the spec, so the useful checked results here are the typed model plus the listed safety invariants. One measured cost of ``nlml_hessian_vector`` -------------------------------------------- This is one measured example, not a benchmark claim. On the case the gate measured, the ``bench_scg_curvature`` fixture (the ``SCGTest`` case: 14 training rows, a magnitude and two length scales), the gate reported about 103 µs for one ``evaluateNlmlHessianVector`` call against about 16 µs for one ``evaluateDirectionalCurvature`` call, and an SCG fit of 5.7 ms with ``curvature_mode`` ``nlml_hessian_vector`` against 2.2 ms with the exact directional curvature. A call of the product assembles the directional kernel derivative for the direction and the derivatives for each coordinate and contracts them with the cached inverse, so it does more work than the scalar curvature, and on this case a fit costs more with it. The mode is opt-in for that reason. The figures come from one run on one case; they say nothing about other kernels, training sizes, machines or compilers. ``bench/scg-curvature-spec.md`` describes how the benchmark runner measures the arms.