WASM PR 3: test the invariants the WASM kernels rely on, and run CI against relaxed-simd - #2565
Open
czoli1976 wants to merge 2 commits into
Open
WASM PR 3: test the invariants the WASM kernels rely on, and run CI against relaxed-simd#2565czoli1976 wants to merge 2 commits into
czoli1976 wants to merge 2 commits into
Conversation
… target Three timing modules lived in src behind #[cfg(test)] + #[ignore], which no other backend does. benches/wasm.rs already supersedes two of them — its own header records that looping four kernels back-to-back biased the in-src version — so those are dropped, and the activation bench moves across. The numerical-consistency check between 16x1 and 32x1 is an assertion rather than a timer, so it stays in src alongside the dispatch tests. The four copies of the kernel-lookup helper in the bench collapse to one; the timing loops keep their own warmup and repetition counts, which differ on purpose. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
… against relaxed-simd The backend picks its multiply-add form, its int8 packing and its sigmoid/tanh kernels at compile time on +relaxed-simd, so the single +simd128 CI leg left half of it untested; add a second leg. AddRowColProducts and AddMatMul with k=1 compute the same product and so must agree on whether that multiply-add is fused, which nothing checked — the existing coverage uses operands whose products are exact, where fused and separate agree trivially. Also record why wasm_f32_4x4 sits at TargetOptimized and is unreachable through dispatch, and assert that it stays that way. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Collaborator
|
|
kali
force-pushed
the
test/wasm-invariants-and-relaxed-ci
branch
from
August 3, 2026 19:36
253fc1c to
aecba60
Compare
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.
Stacked on #2564.
Two gaps in how the wasm backend is covered, both of which matter before anything touches the kernels.
CI only builds one of the two configurations. The backend chooses its multiply-add form, its int8 packing and its sigmoid/tanh kernels at compile time on
+relaxed-simd, so the single+simd128leg in.travis/cross.shleaves roughly half of it never executed. This adds a second leg. I ran it:tract-linalg2208,tract-core816 + 267,test-unit-core9 + 1, all green. It does cost a second wasm build and about 2.5 minutes of test time per run — the one thing in this series that costs you something, so say if you would rather not.Nothing checked that
AddRowColProductsandAddMatMulagree on fusion. Withk = 1they compute the samec[i][j] += a[i] * b[j], so within a kernel they have to make the same choice about the fused multiply-add — and today they do, in both directions: 32x1 and 8x8 fuse both arms, the other four fuse neither. Nothing held that in place. The existingmmm_kernel_fuse_tests!cannot: it uses small integers whose products are exact, where fused and separate agree trivially. The new test picksa = b = 1 + 2^-12againstc = -1, so the product needs 25 significand bits and the two forms differ by one ulp, then compares the two arms bit-for-bit. Under+simd128it is vacuous but still true; under+relaxed-simdit bites. I confirmed it bites by flipping 32x1'sAddRowColProductsto the non-fused macro — it fails on exactly that kernel.Also records why
wasm_f32_4x4sits atTargetOptimized. It is the only kernel not atManuallyOptimized, sostrategize'sretain()drops it and neithermmm_f32normmv_f32names it — it is unreachable through dispatch and reached only by name from its generated tests. It is worth keeping there as the second f32 kernel with a genuinely two-dimensional C tile, which is what gives the generated store and packing tests a second layout to cover, so this documents the arrangement and asserts dispatch never returns it rather than changing anything.🍍