Skip to content

fix: guard np.float128 for macOS ARM64 compatibility#1417

Open
ac12644 wants to merge 1 commit into
google-research:mainfrom
ac12644:fix/float128-macos-arm
Open

fix: guard np.float128 for macOS ARM64 compatibility#1417
ac12644 wants to merge 1 commit into
google-research:mainfrom
ac12644:fix/float128-macos-arm

Conversation

@ac12644

@ac12644 ac12644 commented Apr 5, 2026

Copy link
Copy Markdown

Summary

  • Guard np.float128 with hasattr check in kauldron/ktyping/dtypes.py to prevent AttributeError on macOS ARM64 (Apple Silicon) and Windows
  • Falls back to np.longdouble (the platform's native C long double) when np.float128 is unavailable
  • Preserves original behavior on x86-64 Linux where np.float128 exists

Context

np.float128 does not exist on platforms where C long double is 64-bit (macOS ARM64, Windows). This crashes from kauldron import ktyping at import time, blocking all downstream users including google-deepmind/gemma.

Why not np.longdouble unconditionally?

PR #1363 replaces np.float128 with np.longdouble unconditionally. On x86-64 Linux, np.float128 and np.longdouble can differ in some numpy versions — the hasattr guard preserves the original dtype where available while fixing the crash elsewhere.

Test plan

  • Verified from kauldron import ktyping succeeds on macOS ARM64 (M-series) with this patch
  • Confirmed np.longdouble is float64 on ARM Mac (expected — matches hardware)
  • No other references to np.float128 exist in kauldron

Fixes #1416

np.float128 does not exist on platforms where C long double is 64-bit
(macOS ARM64/Apple Silicon, Windows). This causes an AttributeError
when importing kauldron.ktyping, blocking all downstream users
including google-deepmind/gemma.

Fall back to np.longdouble when np.float128 is unavailable. This
preserves the original behavior on x86-64 Linux where np.float128
exists, while allowing import on ARM Mac and Windows.

Fixes google-research#1416
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.

Bug: np.float128 in ktyping/dtypes.py crashes on macOS ARM (Apple Silicon)

1 participant