Skip to content

test(search): compare cubic values across search policies with a ULP budget - #212

Merged
mgyoo86 merged 1 commit into
masterfrom
fix/search-crosspath-ulps
Oct 7, 2026
Merged

mgyoo86 merged 1 commit into
masterfrom
fix/search-crosspath-ulps

Conversation

@mgyoo86

@mgyoo86 mgyoo86 commented Oct 7, 2026

Copy link
Copy Markdown
Member

Summary

Problem. Since #211 the Julia 1.x macos-latest [2/2] shard fails on most runs (master 969b26cb0, and #209 after its rebase): test/test_search.jl:671-674 reports cubic values 1-2 ULP apart between LinearBinarySearch{0,2,8} and the default BinarySearch.

Cause. The "Integrated test" pinned six search policies with == on an unseeded sort(rand(10)). All policies share the inlined cubic value kernel, but each specialization is optimized as its own unit: on Julia 1.13 under --check-bounds=yes (what Pkg.test passes) LLVM's SLP vectorizer packs the linear blend of the LinearBinarySearch specialization into a <2 x double> multiply/subtract plus a horizontal add, which cannot fuse, while the default and LinearSearch paths keep both FMAs. The old dL³/dR³ kernel happened to compile identically on every path, so the pin never flaked; the t-form kernel from #211 exposes it on ~17 % of queries, i.e. ~85 % of seeds for a 10-query vector. Vector-grid search code performs no float arithmetic, so this is optimizer context only; muladd is contraction-optional by definition.

Fix. The five cross-path value pins use the isclose(…; nulps = PATH_ULPS) budget from the Basic snippet, the policy the other search-policy tests already follow. Search/index pins in the file stay exact.

before after
macOS 1.x shard 2/2, --check-bounds=yes, 200 seeds 171 failing 0 failing
measured drift between paths 1-2 ULP budget 8 ULP
cubic kernel unchanged unchanged

Changes

  • test/test_search.jl: @testitem "Search Module" gains setup = [Basic]; the five == pins become isclose(…; nulps = PATH_ULPS).

Not covered

  • src/ is untouched. Kernel-only accuracy of the fix(cubic): exact node values from the cubic value kernel #211 kernel against a BigFloat reference of the same inputs (100k queries, y = x³ on 101 nodes) is better than the old kernel on both paths: mean abs error 0.0622 eps (default) / 0.0693 eps (LinearBinarySearch) vs 0.0716 eps before.
  • test_nd_autosearch_peraxis.jl:195/386 keep == across linear search paths; they have stayed green and are left as is.

Tests

  • cc-julia-test-runner . test_search.jl green locally (aarch64, Julia 1.13.0); runic --check clean.
  • Standalone repro of the testitem body under --check-bounds=yes: == fails 171/200 seeds, isclose(PATH_ULPS) 0/200, max drift 2 ULP.

…budget

The "Integrated test" pinned the cubic results of six search policies with `==`
on an unseeded `sort(rand(10))`. The policies share the inlined value kernel,
but each specialization is optimized as its own unit, and on Julia 1.13 under
`--check-bounds=yes` LLVM packs the linear blend of the LinearBinarySearch
specialization into a 2-wide vector with a horizontal add, which cannot fuse.
The default and LinearSearch paths keep both FMAs, so the values drift by
1-2 ULP on ~17 % of queries and the pin failed on ~85 % of seeds (macOS 1.x
shard 2/2) since the t-form cubic kernel landed.

Cross-path value pins use the `isclose(…; nulps = PATH_ULPS)` budget from
the `Basic` snippet, as the other search-policy tests already do.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused test-only change consistently applies the repository’s existing cross-path tolerance policy.

0 open findings

What changed in this PR

Updates search-policy parity tests to tolerate expected floating-point contraction differences.

Changes:

  • Imports shared Basic test helpers.
  • Compares cubic outputs using the established 8-ULP path budget.
File Description
test/​test_search.jl Replaces exact cross-policy value comparisons with isclose.

🧠 Review effort: Balanced


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

@mgyoo86
mgyoo86 merged commit 5901fbe into master Oct 7, 2026
24 checks passed
@mgyoo86
mgyoo86 deleted the fix/search-crosspath-ulps branch October 7, 2026 23:29
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.

2 participants