fix(simd): take the ssimulacra2 edge-diff difference in double, and gate ISA invariance - #1367
Draft
lusoris wants to merge 3 commits into
Draft
fix(simd): take the ssimulacra2 edge-diff difference in double, and gate ISA invariance#1367lusoris wants to merge 3 commits into
lusoris wants to merge 3 commits into
Conversation
lusoris
pushed a commit
that referenced
this pull request
Sep 6, 2026
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
lusoris
pushed a commit
that referenced
this pull request
Sep 7, 2026
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
lusoris
force-pushed
the
test/feature-isa-invariance
branch
from
September 7, 2026 06:53
d42e491 to
ec5d61e
Compare
lusoris
pushed a commit
that referenced
this pull request
Sep 7, 2026
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
lusoris
force-pushed
the
test/feature-isa-invariance
branch
from
September 7, 2026 09:14
ec5d61e to
e4c2e39
Compare
lusoris
pushed a commit
that referenced
this pull request
Sep 7, 2026
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
lusoris
force-pushed
the
test/feature-isa-invariance
branch
from
September 7, 2026 09:16
e4c2e39 to
e3fd1f0
Compare
6 tasks
lusoris
pushed a commit
that referenced
this pull request
Sep 7, 2026
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
lusoris
force-pushed
the
test/feature-isa-invariance
branch
from
September 7, 2026 10:18
e3fd1f0 to
e4d7d0d
Compare
…ate ISA invariance The fork's contract is that a score does not depend on the host instruction set. Ten `test_<feature>_simd.c` files assert bit-exactness and all pass, yet `ssimulacra2` scored differently with and without SIMD — twice (ADR-1205, and now this). The structural reason is that those tests do not compare the two things that ship. The shipped scalar functions are `static`, so each test defines its own scalar reference and compares the kernel against that; when only one of the shipped copies drifts, both halves of the test's comparison still agree and it passes. ADR-1207 adds `core/test/test_feature_isa_invariance.c`, which drives the public API twice over one fixture — once with the host ISA, once with `VmafConfiguration.cpumask` disabling every SIMD flag — and asserts bit-identical scores across ten features. It touches no internal symbol, so there is nothing to keep in sync. ADR-1208 is what it found on its first run. All four `edge_diff_map` kernels computed the per-pixel `|img - blur(img)|` with a float subtract and promoted afterwards, while the scalar reference and each kernel's own scalar tail promote first and subtract in double — exact for two floats. One call could mix both conventions depending on where a pixel fell relative to the vector width. `test_edge` passes before and after: it compares against its private reference at 33x21, where the float subtraction happens to be exact. Localised by dumping every scale-0 intermediate under both dispatch modes: lin, xyb, dxyb, mu1, mu2, s11, s22 and s12 were all bit-identical and only the edge accumulators differed, which named the function outright. Fixed by folding the subtraction into the per-lane loop in double — that loop was already scalar, so the vector subtract contributed nothing but rounding. Verified: test_feature_isa_invariance passes for all ten features with no skips (it fails on the parent commit), test_ssimulacra2_simd 13/13, libvmaf suite 133/133, and the fork-added python/test/ssimulacra2_test.py snapshot is byte-identical to six decimals on all six assertions, so no snapshot was regenerated. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
lusoris
force-pushed
the
test/feature-isa-invariance
branch
from
September 7, 2026 12:16
e4d7d0d to
a97949b
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.
Summary
Follows #1363 (now merged). Rebased onto
master; supersedes the auto-closed #1364.The fork's contract is that a score does not depend on the host instruction set. Ten
test_<feature>_simd.cfiles assert bit-exactness and all pass — yetssimulacra2scored differently with and without SIMD, twice (#1363/ADR-1205, and again here).The structural reason is that those tests do not compare the two things that ship. The shipped scalar functions are
static, so each test defines its own scalar reference and compares the kernel against that. It assertskernel == test's idea of the referencewhen the property that matters isshipped SIMD path == shipped scalar path. Those coincide only while someone keeps the private reference in sync by hand — and when only one shipped copy drifts, both halves of the test's comparison still agree and it passes.ADR-1207 adds
core/test/test_feature_isa_invariance.c: it drives the public API twice over one fixture — once with the host ISA, once withVmafConfiguration.cpumaskdisabling every SIMD flag (the--cpumaskswitch) — and asserts bit-identical scores across ten features. It touches no internal symbol, so there is nothing to keep in sync.ADR-1208 is what it found on its first run. All four
edge_diff_mapkernels computed the per-pixel|img - blur(img)|with a float subtract and promoted afterwards:while the scalar reference — and each kernel's own scalar tail — promote first and subtract in double, which is exact for two floats. One call could mix both conventions depending on where a pixel fell relative to the vector width.
Nine of the ten features already passed the new gate, which is useful evidence in itself: the contract was real and one implementation was violating it.
Type
fix— bug fixtest— test-onlysycl/cuda/simd— backend-specificChecklist
make format && make lintis green locally (pre-commit run --filesclean;assertion-density,check-copyright,check-state-md-rows,check-dispatch-registrypass).meson test -C build— 133/133 in a CPU-only container build./cross-backend-diffand the worst ULP is ≤ 2 — the equivalent is this PR's own gate: SIMD vs scalar is now bit-identical (delta exactly 0) for all ten features..c/.h, it has the appropriate license header —test_feature_isa_invariance.ccarries theCopyright 2026 Lusorisheader.docs/adr/_index_fragments/—concat-adr-index.sh --checkis in sync.Bug-status hygiene (ADR-0165)
docs/state.mdupdated in this PR with a row —T-SSIMULACRA2-EDGE-DIFF-FLOAT-SUBTRACT-2026-09-06, closed.Netflix golden-data gate (ADR-0024)
assertAlmostEqual(...)score in the Netflix golden Python tests.ssimulacra2is fork-added; its snapshot inpython/test/ssimulacra2_test.pywas measured byte-identical to six decimals on all six assertions after the fix (mean 24.614428, min 13.816386, max 49.968184, harmonic_mean 22.904302, frame0 49.968184, frame47 37.415193), so nothing was regenerated.Cross-backend numerical results
SIMD vs scalar, same fixture, via
cpumask:The AVX-512 and AVX2 paths agreed with each other throughout; the split was SIMD vs scalar.
Deep-dive deliverables (ADR-0108)
docs/research/2033-isa-invariance-as-a-gate.md, on testing the property instead of a proxy for it.## Alternatives consideredin ADR-1207 (four options, including un-static-ing the scalars and#include-ing the .c) and ADR-1208 (including the double-vector variant and why it was not worth it).AGENTS.mdinvariant note — added tocore/src/feature/AGENTS.md.changelog.d/fixed/ssimulacra2-edge-diff-double-subtract.md.docs/rebase-notes.md, "ADR-1207 / ADR-1208 — ISA invariance and the edge-diff subtraction".Reproducer
meson setup build -Denable_cuda=false -Denable_sycl=false ninja -C build meson test -C build test_feature_isa_invarianceOn the parent commit this fails with
ISA invariance FAIL ssimulacra2 (ssimulacra2): host-isa=-37.499049494926254 scalar=-37.499049496527277 delta=1.601e-09; on this branch it passes with no skips. Needs a host with AVX2 or better — on a scalar-only host both runs take the same path and the test is a tautology that still passes.Known follow-ups
*_simd.ctests remain the tool for pinpointing which kernel. Worth revisiting whether those should compare against the shipped functions rather than private copies.test_ssimulacra2_simd::test_edgestill passes at 33x21 both before and after the fix, so it remains unable to catch this class on its own.🤖 Generated with Claude Code