Skip to content

perf: evaluate algebraic floating point for selected f64 functions #250

Closed

Description

@acgetchell

Summary

Evaluate Rust 1.99 algebraic floating-point operations for one or two promising existing f64 kernels, targeting v0.5.0. Produce a retained numerical/performance study and a per-function adopt, retain-strict, or defer decision. Adoption is conditional on the evidence; a documented negative result is a valid completion outcome.

Existing APIs remain strict. Any accepted algebraic implementation must have a distinct, explicitly opt-in public contract and preserve the crate's scientific invariants. The release number does not relax the correctness threshold.

Current state and prerequisites

The evaluation no longer waits for v0.5.0 publication. It belongs to the v0.5.0 milestone; unresolved broader investigation or adoption must not delay that release.

Bounded scope

Select at most two kernels from dot products/reductions, matrix multiplication, matrix-vector multiplication, or squared norms, using existing cost evidence and code inspection to justify the selection. This issue does not promise an exhaustive survey of every operation.

Exclude predicates, interval/certified arithmetic, exact fallbacks, convergence/branch decisions, and error-bound construction. Preserve deliberate mul_add semantics wherever single-rounding FMA is part of the numerical contract. Exact continues to mean exact arithmetic.

Prototype in isolated disposable harnesses outside repository-owned Rust. Existing AGENTS.md and Semgrep prohibitions remain in force; retaining an opt-in implementation requires a reviewed, narrowly scoped policy/rule change.

Evaluation method

  1. Capture the strict implementation and experimental source, dependency locks, rustc -Vv/LLVM version, target, features, profile, fixtures, and sampling settings.
  2. Assess candidate numerical contracts against Rust's documented algebraic-operator semantics. These permit unspecified precision, nondeterministic results, and unexpected special-value behavior. Passing observed tests cannot establish a portable numerical guarantee that the documented semantics do not provide.
  3. Compare with the strict implementation and independent exact/rational or analytical references. Cover cancellation, mixed/extreme magnitudes, signed zero, subnormals, overflow/underflow, and relevant non-finite input/intermediate behavior. Exercise D=2 through D=5 and each selected API's supported dimension boundaries.
  4. Check relevant downstream Delaunay scientific/property/regression workloads. A changed geometric classification, predicate, topology decision, or validation outcome is a correctness failure.
  5. Benchmark equivalent workloads on the same machine/toolchain/profile/features with correctness checks outside timing and no overlapping benchmark or validation jobs. Report absolute timings, uncertainty, and relative changes; inspect generated code where it explains the result.
  6. Validate relevant numerical behavior on supported Linux, macOS, and Windows targets. State the limits of measured performance claims; empirical platform coverage supplements contract analysis.
  7. Retain a study under docs/archive/performance/studies/, including raw evidence and source provenance, candidate selection, numerical findings, performance costs, limitations, and adopt/retain-strict/defer decisions. Preserve negative results. Incorporate accepted release results into the generated performance record through its owning workflow.

Adoption and release decision

  • Adopt in v0.5.0 only when a candidate demonstrates a repeatable material benefit and a useful numerical contract supported by the documented semantics and correctness analysis. Specify its domain, accuracy guarantees or limitations, special-value/range behavior, and typed failures. A large speedup or absence of observed test failures is insufficient.
  • Adoption uses a distinct, explicitly opt-in API. Feature gating may control its availability but must not change existing methods' semantics. Preserve strict defaults, exact/certified guarantees, and existing error provenance.
  • Before adoption lands, review the API and scoped guidance/Semgrep changes, retain independent regressions, and complete required repository CI and downstream validation. Refresh the release performance record after the implementation is final.
  • Defer adoption if the contract, evidence, API review, or release readiness remains unresolved. Record what was established and link a bounded follow-up issue. Compatible additions may target v0.5.1; changes incompatible with a published v0.5 API require an appropriate later minor release.
  • Retain strict arithmetic when no candidate meets the threshold. Record that decision and close the completed evaluation; adopting algebraic operations is not required to close this issue.
  • If the bounded evaluation itself cannot finish in the release window, explicitly transfer remaining scope and evidence to follow-up planning. Do not claim an unfinished evaluation or unverified adoption is complete.

Acceptance criteria

  • Select and justify at most two candidates, retaining the exclusions above.
  • Use the completed chore: upgrade to Rust 1.99 and audit numerical/codegen impact #251 baseline and capture the final strict candidate's source/environment identity.
  • Retain independent adversarial numerical checks, relevant native-platform validation, and downstream scientific evidence.
  • Retain comparable strict-versus-algebraic timings and a durable per-function findings/decision table.
  • Assess whether the proposed contract is supportable under documented compiler semantics; distinguish guarantees from empirical observations.
  • If adopting, satisfy the opt-in contract, API/policy review, independent regressions, final CI, and release-evidence requirements before shipping.
  • Record a justified adopt, retain-strict, or defer disposition and link any transferred unfinished work. Do not hold v0.5.0 for an unbounded optimization effort.

Non-goals

  • Globally enabling fast-math-like semantics or changing existing APIs to algebraic arithmetic.
  • Weakening exactness, outward bounds, typed errors, or downstream scientific correctness for benchmark results.
  • Duplicating every public operation into strict/algebraic variants.
  • Replacing intentional FMA merely to use the algebraic API.

Activity

  1. added this to the v0.4.7 milestone on Sep 12, 2026
  2. changed the title [-]perf: evaluate Rust algebraic floating-point operations in selected f64 kernels[/-] [+]perf: evaluate algebraic floating point for selected f64 functions[/+] on Sep 12, 2026
  3. modified the milestones: v0.4.7, v0.4.8, v0.5.0 on Oct 10, 2026
  4. acgetchell commented on Oct 15, 2026

    @acgetchell
    OwnerAuthor

    Decision: retain strict arithmetic; reject algebraic floating point

    On 2026-10-15 the maintainer accepted the negative result and requested closure of this evaluation. We will not add algebraic floating-point APIs or features, and no adoption follow-up is planned. Existing ordinary f64 operations, deliberate mul_add, exact arithmetic, certified bounds, and typed failures remain unchanged.

    The selected reduction was Matrix::norm_inf. The isolated algebraic_add prototype was faster on the Apple M4 Max at D=4/5 (about 22–25%) and D=8 (about 39–40%), with both measurement orders confirming those directions; D=2/3 regressed. This is diagnostic timing of an ineligible prototype, not evidence of a correctness-preserving optimization.

    The decisive counterexample is the finite D=4 row [2^969, 2^969, f64::MAX, 0]. Strict accumulation returns LaError::NonFinite with ArithmeticOperation::MatrixInfinityNorm and MatrixCell { row: 0, col: 2 }; the algebraic prototype returns the finite value f64::MAX. Appending zero reproduces the failure at D=5. A final is_finite check cannot catch overflow hidden by reassociation. Rust's documented algebraic semantics also do not provide a portable accuracy or repeatability guarantee.

    Retained evidence uses la-stack commit d1f85bb606735d5213a2fa5bd2692e5685a9adc4 (including PR #278), Rust 1.99.0 / LLVM 23.1.1, macOS 27.0.1, aarch64-apple-darwin, release optimization, fat LTO, and one codegen unit:

    • Independent exact-rational checks and adversarial cases at D=0, 1, 2, 3, 4, 5, 8, 16, plus 1,000 deterministic random matrices per dimension.
    • 18 focused upstream unit tests and 5 matrix property tests passed for the retained strict implementation.
    • 728 geometry unit tests, 26 geometry property tests, and 18 predicate property tests passed in isolated Delaunay commit bde38f4826cc248b425c4300cadd233417f7646c patched to strict la-stack. The rejected prototype was not installed downstream.
    • 40 saved Criterion measurements, 100 samples each, with strict/algebraic forward and reverse ordering. Raw samples, means, confidence intervals, medians, experimental sources, dependency locks, and compiler output are retained.
    • Linux and Windows probes cross-compiled. Native Linux/Windows prototype runs were not performed. The maintainer explicitly ended the investigation with rejection, discontinuing that remaining experimental scope. This does not mark the original native-platform criterion as passed; normal validation of the strict library continues independently.

    Documentation prepared in the working tree (not yet committed or pushed):

    • docs/archive/performance/studies/algebraic-float.md and algebraic-float/: full numerical/performance study, raw evidence archive, CSV, and provenance.
    • docs/validation/algebraic-floating-point.md: final decision, executed checks, and explicit closure of unperformed prototype work.
    • docs/validation/README.md: map of strict f64, certified/interval, exact binary64/rational, and strict/rounded conversion contracts to independent tests.
    • docs/mathematical_basis.md: clarification that strict floating-point arithmetic still rounds and is distinct from exact computation and strict exact conversion.
    • README, code-organization map, and roadmap navigation updated; deferred algebraic adoption removed from the roadmap.

    Evidence archive SHA-256: 5d03f40ecf6df8d73733e79b69d44dbbbb7bec599dac6a566637573942c5cce0.

    Closing as completed with a retain-strict decision, as permitted by this issue's negative-outcome provision and the maintainer's scope decision. No library behavior or arithmetic-policy exception is being shipped.

  5. added a commit that references this issue on Oct 15, 2026
    a275ddf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions