Skip to content

Golden tests: pin CPU maths paths so results match on every runner CPU - #830

Merged
Hananel-Hazan merged 2 commits into
masterfrom
golden-cpu-independent
Oct 29, 2026
Merged

Hananel-Hazan merged 2 commits into
masterfrom
golden-cpu-independent

Conversation

@Hananel-Hazan

@Hananel-Hazan Hananel-Hazan commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

What this changes and why

The golden-output tests from #828 failed on test (3.11) in #829 (CI run 40800432540). #829 changes only a README comment, and the same code passed on #828. The difference is the GitHub runner's CPU. MKL (used for matrix products) and PyTorch's own kernels each pick the fastest code path for the processor. Some runners have AVX-512; the golden files were made on an AVX2-only CPU. The rounding moved voltages by up to 1.5e-5, and the Izhikevich neuron amplified this to 0.23 mV. The tolerance stays at 1e-6.

The fix pins the libraries to one code path on every CPU (test/regression/cpu_pins.py):

  • ATEN_CPU_CAPABILITY=avx2: PyTorch's kernels use AVX2 even on AVX-512 machines.
  • MKL_CBWR=COMPATIBLE: MKL's mode that gives the same results on all x86 processors.
  • oneDNN (used for convolutions) is off in the golden runs. Its blocking depends on cache sizes, and it ignores MKL_CBWR.

test/conftest.py and regen.py apply the pins before torch starts. networks.deterministic() raises an error if the PyTorch pin came too late.

The evidence that MKL's path matters, measured on one AVX2 machine: changing only MKL_CBWR changed 1 to 4 of the 16 goldens. Changing only ATEN_CPU_CAPABILITY changed none of them on that machine.

The goldens were regenerated with that reason; there is no library change. Spikes are identical in all 16 files. Float values moved by at most 2.3e-5, in 4 files: dc2015_b16, conn_postpre_b8, csrm_window and conv2d_if_izh. The other 12 are bit-identical. CI now prints each runner's CPU model and whether it has AVX-512.

Verified on both CPU kinds (CI run 40803279232, two rounds, six jobs): five jobs ran on AMD EPYC 7763 without AVX-512 and one (test (3.12), round 2) on AMD EPYC 9V45 with AVX-512. Every job passed: 512 passed, 4 skipped (the CUDA test), 40 xfailed. Only one AVX-512 sample has run so far.

Checklist

  • Full suite locally: 513 passed, 3 skipped, 40 xfailed.
  • Simulated results: unchanged (no library change). Only the reference rounding moved.
  • Golden files regenerated with --reason. The weakened-tests check will list them.
  • AI tool: Claude Code (Claude Opus 5.5).

🤖 Generated with Claude Code

Hananel-Hazan and others added 2 commits October 28, 2026 21:54
GitHub runners differ in CPU (some have AVX-512); MKL and PyTorch kernels pick
per-CPU code paths, which moved golden voltages by up to 1.5e-5 (Izhikevich
0.23 mV) on CI run 40800432540. Pin ATEN_CPU_CAPABILITY=avx2 and
MKL_CBWR=COMPATIBLE before torch starts (test/conftest.py, regen.py), switch
oneDNN off in the golden runs, and regenerate the goldens with that reason.
Spikes unchanged in all 16; floats moved at most 2.3e-5 in 4 files. CI prints
the runner CPU.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Hananel-Hazan Hananel-Hazan added the tests-changed-ok Maintainer reviewed every item the weakened-tests check listed label Oct 29, 2026
@Hananel-Hazan
Hananel-Hazan merged commit 33913c7 into master Oct 29, 2026
15 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests-changed-ok Maintainer reviewed every item the weakened-tests check listed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant