Skip to content

[Performance #727] Vectorize transcendental math and RBF-style elementwise kernels across C/MLIR backends #751

Closed

Description

@godofecht

Parent: #727. Related: #734 #739 #665.

Many ML/scientific loops are not only multiply/add: they contain exp/log/sqrt/trig used in RBF kernels, likelihoods and transforms. Scalar libm calls can cap SIMD throughput even after loop vectorization.

Audit target/compiler vector-math capabilities and lower eligible bulk operations through vectorizable forms/libraries/intrinsics while preserving documented IEEE/accuracy semantics. Provide strict and relaxed policies only if the semantic difference is explicit.

Acceptance: RBF distance->exp, GaussianNB likelihood and representative scientific elementwise kernels show vector-math evidence; error bounds are tested; strict mode never silently changes NaN/Inf/rounding semantics; performance is tracked on x86-64 and arm64.

Activity

  1. godofecht commented on Aug 27, 2026

    @godofecht
    ContributorAuthor

    Worked through the strict-semantics boundary for RBF SVC vector transcendental lowering and archived the full derivation + Flow semantic witness in godofecht/OpenProjects as ml/decision-certified-vector-exp-for-rbf-svc.{md,flow}.

    Key result: a generic approximate vector exp cannot silently replace scalar exp in strict mode merely because its error is small. For an RBF binary decision f = b + Σ β_i k_i, if a vector exp provides |k̃_i/k_i - 1| <= ε < 1, then

    |f - f̃| <= [ε/(1-ε)] Σ |β_i| k̃_i = B.

    So abs(f̃) > B certifies that the approximate vector path has exactly the same decision sign as the strict scalar implementation. Low-margin queries can selectively recompute exact scalar exponentials; after recomputing subset E, remove their uncertainty contributions and stop once the corrected score exceeds the remaining bound. Recomputing terms in descending |β_i| * ε/(1-ε) * k̃_i order is optimal for minimizing the remaining bound after any fixed number of exact refinements.

    The concrete 6-support witness certifies a large-margin query with 0 scalar fallbacks and a deliberately tiny-margin (+0.002 strict score) query after exactly 3/6 exact exp recomputations. An independent local oracle tested 100,000 randomized decisions with no certified sign flips and exhaustively verified the greedy uncertainty-removal rule on randomized 6-term systems.

    This suggests a useful split for #751: keep generic strict exp bit-semantics unchanged; add target vector-math providers with explicit error envelopes; allow domain-aware kernels such as RBF SVC to use speculative vector transcendental evaluation plus decision certificates/fallback. Apple’s current SIMD docs describe precise variants as accurate to a few ULPs, which reinforces that the vector provider needs an explicit numerical contract rather than being assumed bit-identical.

    No hosted workflow/CI work was used.

  2. added a commit that references this issue on Sep 9, 2026
  3. added a commit that references this issue on Oct 3, 2026
    7674ac3
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

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions