google-deepmind / google-deepmind/gemma
Bug: Test suite fails on macOS Apple Silicon & Windows — does not exist
- Dominant language
- Python
- Stars
- 5.7k
- Forks
- 1k
- Avg merge
- 10h 33m
- Merged PRs (30d)
- 2
Description
## 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**:
```python
# 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
```bash
# 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`)
```python
# 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 |
Contributor guide
Assessment
This issue has not been assessed yet.