Summary
All tests in gemma/gm/ crash at collection time with:
AttributeError: module 'numpy' has no attribute 'float128'. Did you mean: 'float16'?
This causes 162 errors during pytest collection and blocks virtually every unit test from running on macOS (Apple Silicon) and Windows.
Root Cause
np.float128 is a platform-specific alias for the C long double type. It is only available on Linux x86-64. It does not exist on:
- macOS Apple Silicon (ARM64) — where
long double == double (64-bit)
- Windows — where
long double == double (64-bit)
NumPy 2.x made this even stricter: np.float128 is no longer silently created on platforms where it isn't available — it simply raises AttributeError.
The issue originates in kauldron/ktyping/dtypes.py (line 136), which unconditionally accesses np.float128 at module load time:
# Current (broken on macOS ARM / Windows):
float128 = NpDType(np.float128)
Since every test in gemma/gm/ transitively imports from kauldron.ktyping, this causes all of them to fail immediately during pytest collection — before any test body is executed.
Reproduction
# On macOS Apple Silicon or Windows:
pip install -e '.[dev]'
pytest -vv -n auto --ignore=gemma/gm/tests/ --ignore=gemma/peft/_interceptors_test.py --ignore=gemma/sampler_test.py
# => 162 errors: AttributeError: module 'numpy' has no attribute 'float128'
Suggested Fix (in kauldron/ktyping/dtypes.py)
# Before:
float128 = NpDType(np.float128)
# After:
float128 = NpDType(np.float128) if hasattr(np, 'float128') else NpDType(np.float64)
This guards the import and gracefully falls back to float64 on platforms that do not have 128-bit long doubles.
Impact
- Severity: High — blocks 162 test cases from running on macOS ARM and Windows.
- Platforms affected: macOS Apple Silicon, Windows.
- Platforms not affected: Linux x86-64.
Environment
|
|
| Python |
3.12.13 |
| Platform |
macOS Apple Silicon (arm64) |
| NumPy |
2.x |
| gemma |
4.0.1 (editable install from HEAD) |
| kauldron |
HEAD from GitHub |
Summary
All tests in
gemma/gm/crash at collection time with:This causes 162 errors during
pytestcollection and blocks virtually every unit test from running on macOS (Apple Silicon) and Windows.Root Cause
np.float128is a platform-specific alias for the Clong doubletype. It is only available on Linux x86-64. It does not exist on:long double == double(64-bit)long double == double(64-bit)NumPy 2.x made this even stricter:
np.float128is no longer silently created on platforms where it isn't available — it simply raisesAttributeError.The issue originates in
kauldron/ktyping/dtypes.py(line 136), which unconditionally accessesnp.float128at module load time:Since every test in
gemma/gm/transitively imports fromkauldron.ktyping, this causes all of them to fail immediately during pytest collection — before any test body is executed.Reproduction
Suggested Fix (in
kauldron/ktyping/dtypes.py)This guards the import and gracefully falls back to
float64on platforms that do not have 128-bit long doubles.Impact
Environment