Skip to content

Preserve explicit MKL reproducibility settings and NumPy exclusions - #11

Draft
leej3 wants to merge 1 commit into
ReproNim:claude/ecstatic-brahmagupta-jsqg3pfrom
leej3:preserve-cpu-reproducibility
Draft

leej3 wants to merge 1 commit into
ReproNim:claude/ecstatic-brahmagupta-jsqg3pfrom
leej3:preserve-cpu-reproducibility

Conversation

@leej3

@leej3 leej3 commented Oct 3, 2026 •

Copy link
Copy Markdown

AI draft - not reviewed by John

PR 11 targets PR 9's branch. Under PR 9's x86-64-v3 profile, an explicit MKL_CBWR=AVX2,STRICT or COMPATIBLE is replaced with AVX2. On an AVX512 host, PR 9 also replaces existing NumPy exclusions such as NPY_DISABLE_CPU_FEATURES=X86_V3.

PR 11 preserves explicit MKL_CBWR values, warns for unverified/out-of-profile values, and appends missing NumPy exclusions without duplicate growth. PR 11 retains AVX2 as the default when MKL_CBWR is unset; it does not make COMPATIBLE the default. The documentation changes describe these exceptions, qualify the scope as configuring supported libraries, and link MKL reproducibility conditions and oneDNN's build dependency.

Recorded experiments use a pinned Pixi environment, DataLad run/rerun, and published arrays on Typhon and Smaug (Intel) and Unity cpu053 (AMD EPYC 7763). The recorded candidate-reproseed.sh is byte-for-byte identical to reproseed.sh at PR 11 commit 51d4c3578fe3bb43aeae87a29c5768a2cc53c4fd (Git blob d12fc032648e047d19e225cc32c32a9b44eba9fd).

  • Explicit AVX2,STRICT: On Typhon, direct MKL execution keeps four tested GEMMs identical across 1, 2, and 4 threads. PR 9 replaces this setting with AVX2 and introduces thread-count differences in three GEMMs. PR 11's strict_fixed benchmark preserves AVX2,STRICT and restores the direct results.
  • Existing NumPy exclusions: PR 11's numpy_fixed benchmark matches manually supplying the combined exclusion list. On Typhon, PR 9's replacement and PR 11's merge produce different float32 exp/log/sin outputs; runtime metadata confirms that only the merge retains the X86_V3 exclusion.
  • Default AVX2 versus explicit COMPATIBLE: With PR 9's default AVX2 request (pr benchmark), all ten tested arrays match between Typhon and Smaug at each fixed thread count (1, 2, or 4). Comparing either Intel host with Unity at the same thread count, the four MKL products differ and the six NumPy/OpenBLAS arrays match. With an explicit MKL_CBWR=COMPATIBLE preserved by PR 11 (compatible_fixed benchmark), all ten arrays match across the three hosts at each fixed thread count. This supports preserving the user's explicit COMPATIBLE choice. It does not establish agreement across different thread counts or untested workflows, and no performance tradeoff was measured.

Validation: ShellCheck passes; all 21 Bats tests pass on Linux. Added tests cover STRICT/COMPATIBLE preservation, a warning for AVX512, NumPy merge idempotence, and native preservation. No numerical-library dependencies are added to reproseed's shell tests.

@yarikoptic-gitmate

Copy link
Copy Markdown
Collaborator

PR 11 targets PR 9's branch.

why your beast does not use #ISSUE format my "boss" wonders...?

Comment thread docs/cpu-features.md
disable the others. It is not set if `/proc/cpuinfo` shows no
disable the others. Existing exclusions are retained and missing profile
targets appended, so wrapping a command does not re-enable excluded paths.
It is not set if `/proc/cpuinfo` shows no

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to KISS -- shouldn't we just skip setting them at all if already defined (even if totally empty) by the caller?!

yarikoptic-gitmate pushed a commit that referenced this pull request Oct 5, 2026
…hmagupta-jsqg3p

Conflict in tests/test_basic.sh "source check output": master switched
to $(...) with quoted "$out", this branch added 2>&1 since messages now
go to stderr; kept both.  Merged rather than rebased, since
#11 is based on this branch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0142mrYgtL7zA9zCpBtEgcxn
yarikoptic-gitmate pushed a commit that referenced this pull request Oct 5, 2026
Previously a different preset value was overridden with a warning,
which e.g. replaced an explicit MKL_CBWR=COMPATIBLE or AVX2,STRICT, or
NumPy exclusions such as NPY_DISABLE_CPU_FEATURES=X86_V3 (found by
@leej3 in #11).  Now any of these variables already
set, even to an empty value, is left as is, silently, as is
NPY_DISABLE_CPU_FEATURES when NPY_ENABLE_CPU_FEATURES is set.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0142mrYgtL7zA9zCpBtEgcxn

@yarikoptic-gitmate yarikoptic-gitmate left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This review checks this PR against #9, whose branch is now at da85ebd. I fetched the head of this PR: its 21 bats tests and shellcheck pass.

Confirmed. Intel's Specifying Code Branches states that "Settings other than AUTO or COMPATIBLE are available only for Intel processors", and that unsupported values silently fall back to AUTO. That matches your measurement on Unity (AMD). #9 now documents this and points to MKL_CBWR=COMPATIBLE for mixed Intel/AMD use (da85ebd). Whether the default should change to COMPATIBLE (consistent across vendors, but slower) is for @yarikoptic to decide.

Superseded by #9 (216b22d). Following @yarikoptic's KISS suggestion, reproseed now leaves any of its CPU variables alone if the caller has already set it, even to an empty value. That preserves MKL_CBWR=AVX2,STRICT or COMPATIBLE, and the caller's NumPy exclusions such as X86_V3. It needs no allow-list, no warning, and no merging into NPY_DISABLE_CPU_FEATURES; merging also changed the caller's value. The reproseed.sh and test changes here are therefore no longer needed, and they now conflict.

Worth keeping, as a docs-only change rebased onto #9:

  • The MKL reproducibility conditions: MKL_DYNAMIC=FALSE / OMP_DYNAMIC=FALSE, and strict CNR. Both match Intel's Reproducibility Conditions.
  • The oneDNN ONEDNN_ENABLE_MAX_CPU_ISA note. It defaults to ON, so "takes effect only when built with ONEDNN_ENABLE_MAX_CPU_ISA=ON" reads as if it were opt-in. Something like "unless built with ONEDNN_ENABLE_MAX_CPU_ISA=OFF" would be clearer.
  • The scope wording ("does not guarantee identical results …").

Style nits for that rebase:

  • In docs/cpu-features.md, the "Except for the NumPy exclusions …" paragraph is a single long line; please wrap it to about 72 columns like the rest of the file.
  • [mkl-cnr] should go into the sorted block of link definitions, without a blank line before it.
  • New tests should use tabs, as tests/test_basic.sh does.

Generated by Claude Code

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.

3 participants