Skip to content

chore(scripts): probe-fft-platform.py — root-cause aid for #560#607

Merged
ruvnet merged 1 commit into
mainfrom
chore/probe-fft-platform-560
May 17, 2026
Merged

chore(scripts): probe-fft-platform.py — root-cause aid for #560#607
ruvnet merged 1 commit into
mainfrom
chore/probe-fft-platform-560

Conversation

@ruvnet
Copy link
Copy Markdown
Owner

@ruvnet ruvnet commented May 17, 2026

Summary

Adds scripts/probe-fft-platform.py, a single-file diagnostic that reproduces verify.py's hash-relevant FFT steps in isolation on a deterministic synthetic input, without pulling in src.app / pydantic Settings. Used to empirically locate the source of the platform-specific hash divergence reported in #560.

The script:

  • Runs the same scipy.fft.fft + scipy.signal.windows.hamming calls that verify.py hashes
  • Prints uname, python, numpy/scipy versions, SHA-256 of the output buffer, the first 8 Doppler bytes, the first 4 PSD floats, and the SciPy BLAS backend metadata
  • One JSON object on stdout per run — easy to diff across machines

Why

The docstring at archive/v1/data/proof/verify.py:172 ("platform-independent for IEEE 754 compliant systems") is incorrect. SciPy's pocketfft uses SIMD vector kernels — AVX2/AVX-512 on x86_64, NEON on Apple Silicon — that reorder FP operations differently across builds. IEEE 754 guarantees per-operation determinism, not associativity under reordering. The SHA-256 of the production pipeline diverges at ULP precision per platform, which is what bug report #560 caught on macOS arm64.

Empirical evidence (across three machines via Tailscale)

Platform numpy/scipy first 4 PSD floats sha256
Windows (Intel AVX-512) 2.4.2 / 1.17.1 ..., 94.40426770856882, ..., 51.677496924642476 78b3fb…
ruvultra (Linux x86_64) 1.26.4 / 1.14.1 ..., 94.40426770856882, ..., 51.677496924642476 41dc56…
ruv-mac-mini (Apple Silicon NEON) 2.4.4 / 1.17.1 ..., 94.4042677085688, ..., 51.67749692464246 9b5e19…
  • Win + Linux agree on first PSD values but produce different SHA-256s → divergence is in later FFT bins (different scipy pocketfft SIMD paths).
  • Mac arm64 differs from x86_64 at the first bins at ~1 ULP precision (~2e-14 on a value of ~94).

What this PR does NOT do

The architectural fix for #560 is quantize-before-hash in features_to_bytes() — round float64 to a fixed precision well above SIMD-ULP (e.g. 1e-9) before packing — then regenerate expected_features.sha256 on a canonical CI platform. That changes a published trust-anchor artifact (the witness chain) and merits a deliberate maintainer call. This PR ships only the diagnostic, so the empirical evidence is in-repo when that decision happens.

Relation to #577

PR #577 bundled the verify path fix for #559 + this probe script for #560. The verify path fix already shipped via PR #590 (merged earlier this session), so #577's diff against current main is now mostly empty for the verify portion. This PR extracts only the still-useful probe script; #577 can be closed.

Test plan

  • python3 scripts/probe-fft-platform.py runs cleanly on Windows (verified locally on ruvzen — output matches the Windows row of the table above)
  • (Maintainer) Run on macOS / Linux hosts to confirm the divergence pattern is reproducible
  • (Future) Use the output to validate that any chosen features_to_bytes() quantization actually collapses the per-platform hash to a single value

🤖 Generated with claude-flow

…for #560

The verify.py "platform-independent for IEEE 754 compliant systems"
docstring at archive/v1/data/proof/verify.py:172 is incorrect — scipy's
pocketfft uses SIMD vector kernels (AVX2/AVX-512 on x86_64, NEON on
Apple Silicon) that reorder FP operations differently across builds, so
the SHA-256 of the production pipeline diverges at ULP precision per
platform. That divergence is what bug report #560 caught on macOS arm64.

This script reproduces verify.py's hash-relevant scipy.fft.fft + Hamming-
window calls in isolation on a deterministic synthetic input, without
dragging in src.app / pydantic Settings. Run on each platform and diff
the JSON output:

  python3 scripts/probe-fft-platform.py

- If two machines print the same first8_doppler_bytes_hex and the same
  first4_psd_floats but different sha256, the divergence is in later FFT
  bins (SIMD reordering).
- If even the first values differ, it's true ULP-level divergence at
  every bin (NEON vs x86_64, or different scipy pocketfft builds).

Captured empirical evidence across Windows (Intel AVX-512), Linux x86_64
(ruvultra), and Apple Silicon (ruv-mac-mini) — Win + Linux agree on first
PSD values but produce different SHA-256s; Mac arm64 differs at the first
bins at ~1 ULP precision (~2e-14 on a value of ~94).

This commit ships only the diagnostic. The architectural fix for #560
(quantize-before-hash in features_to_bytes(), then regenerate
expected_features.sha256 on a canonical CI platform) is left as a
separate maintainer decision because it changes a published trust-anchor
artifact and merits a deliberate call.

Supersedes the probe portion of PR #577 (the verify path fix from #577
already shipped via PR #590).

Co-Authored-By: claude-flow <ruv@ruv.net>
@ruvnet ruvnet merged commit 88da304 into main May 17, 2026
20 checks passed
@ruvnet ruvnet deleted the chore/probe-fft-platform-560 branch May 17, 2026 21:34
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.

1 participant