fix: guard np.float128 for macOS ARM64 compatibility#1417
Open
ac12644 wants to merge 1 commit into
Open
Conversation
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
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
np.float128withhasattrcheck inkauldron/ktyping/dtypes.pyto preventAttributeErroron macOS ARM64 (Apple Silicon) and Windowsnp.longdouble(the platform's native Clong double) whennp.float128is unavailablenp.float128existsContext
np.float128does not exist on platforms where Clong doubleis 64-bit (macOS ARM64, Windows). This crashesfrom kauldron import ktypingat import time, blocking all downstream users includinggoogle-deepmind/gemma.Why not
np.longdoubleunconditionally?PR #1363 replaces
np.float128withnp.longdoubleunconditionally. On x86-64 Linux,np.float128andnp.longdoublecan differ in some numpy versions — thehasattrguard preserves the original dtype where available while fixing the crash elsewhere.Test plan
from kauldron import ktypingsucceeds on macOS ARM64 (M-series) with this patchnp.longdoubleisfloat64on ARM Mac (expected — matches hardware)np.float128exist in kauldronFixes #1416