deps: upgrade wide/thiserror/criterion + once_cell→std; fast_max/min recovers ~2.2x AVX2 - #56
Merged
Merged
Conversation
…x on AVX2) wide 1.x's `f32xN::max`/`min` are NaN-aware: on x86 AVX they compile to `max_m256` + `is_nan()` + `vblendvps` (1 -> 3 ops plus a max->isnan->blend dependency chain in the inner loop); on aarch64 NEON they emit the NaN-aware `vmaxnmq_f32`/`vminnmq_f32` instead of plain `vmaxq`/`vminq`. Tropical GEMM never produces NaN -- MaxPlus inputs are finite or -inf, MinPlus finite or +inf, MaxMul finite (zero = 0.0) -- so the only NaN source (+inf + -inf) never occurs and the NaN handling is dead work. Switch all 7 microkernels (avx2 x4, neon x3) to `.fast_max()`/`.fast_min()`, which lower to a single `maxps`/`minps`/`vmaxq`/`vminq`. Hardware-measured A/B (fast_* vs default max/min, same wide 1.4.0): - x86 AVX2 (HKUST-GZ): -51% to -55%, i.e. ~2.2x faster across all sizes and semirings. (So the wide 0.7->1.x bump had silently ~halved AVX2 throughput.) - ARM NEON (Apple M-series): -3% to -4% on MinPlus/MaxMul; MaxPlus ~flat. Correctness verified on both paths: 279 unit + 24 doctests on x86 AVX2 and on ARM NEON, 0 failures. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #56 +/- ##
=======================================
Coverage 96.29% 96.29%
=======================================
Files 19 19
Lines 918 918
=======================================
Hits 884 884
Misses 34 34 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two connected changes — a dependency refresh, and the SIMD fix that the refresh turned out to need.
1. Dependency upgrades
wide0.7 → 1 (SIMD)thiserror1.0 → 2.0criterion0.5 → 0.8 (dev/bench only;criterion::black_box→std::hint::black_box)once_cell→ stdOnceLock(external dep removed fromtropical-gemm-cuda)2. fast_max/fast_min — recovering performance the
widebump silently costwide1.x'sf32xN::max/minare NaN-aware, and that handling is not free:.max()/.min()(wide 1.x default).fast_max()/.fast_min()max_m256+is_nan()+vblendvps(3 ops + amax→isnan→blenddependency chain in the hot loop)max_m256vmaxnmq_f32/vminnmq_f32vmaxq_f32/vminq_f32Tropical GEMM never produces NaN — MaxPlus inputs are finite or −∞, MinPlus finite or +∞, MaxMul finite (zero = 0.0) — so the only NaN source (
+∞ + −∞) cannot occur and the NaN handling is dead work. Switching all 7 microkernels (avx2 ×4, neon ×3) tofast_max/fast_minlowers each to a singlemaxps/minps/vmaxq/vminq.Without this, the
wide0.7→1.x bump alone silently ~halves AVX2 throughput.Benchmarks (A/B:
fast_*vs defaultmax/min, same wide 1.4.0, criterion, p < 0.05)x86 AVX2 (HKUST-GZ HPC,
f32):(MaxPlus / MinPlus / MaxMul all ≈ −54%.)
ARM NEON (Apple M-series,
f32): −3% to −4% on MinPlus/MaxMul; MaxPlus ≈ flat.Correctness
cargo test -p tropical-gemmwithfast_*in place: 279 unit + 24 doctests, 0 failures on both x86 AVX2 (HPC) and ARM NEON (local). Includes the assertion-based AVX2 kernel unit tests.cargo auditclean. CUDA crate (thiserror 2.0 + once_cell→std + cudarc) builds and its 56 GPU tests pass on A40/CUDA 12.8.🤖 Generated with Claude Code