fix: np.float128 platform crash on macOS/Windows & missing f-string in error message#659
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
I signed it! |
The error message was a plain string, causing {token!r} to be printed
literally instead of interpolating the actual token value. This makes
debugging stop_tokens / forbidden_tokens misconfigurations impossible.
Fixes google-deepmind#658
3be3cdb to
7c369a6
Compare
|
Note: The recent force-push on this branch was just an empty amend to re-trigger the Google CLA bot checks after signing the agreement, as the webhook seemed to be stuck. The code changes remain exactly the same! |
|
While testing locally, I noticed the Let me know if you need me to make any changes. |
Fix:
np.float128platform crash & missing f-string in error messageCloses #657
Closes #658
What this PR does
This PR fixes two backend bugs found during local development on macOS Apple Silicon (ARM64).
Fix 1 : Guard
np.float128for platform compatibility (Closes #657)File:
gemma/gm/utils/_dtype_params.py(viakauldrondependency)np.float128is not available on macOS Apple Silicon or Windows — it onlyexists on Linux x86-64 as a
long doublealias. Becausekauldron/ktyping/dtypes.pyunconditionally accesses
np.float128at module import time, every testthat transitively imports from
kauldron.ktypingfails immediately duringpytestcollection with:This caused 162 test collection errors on Apple Silicon in the CI-equivalent
local run. The fix guards the attribute access with
hasattr:Fix 2 : Add missing
f-prefix in_normalize_token()error message (Closes #658)File:
gemma/gm/text/_sampler.py, line 579The error raised when a multi-token
stop_tokenorforbidden_tokenstring issupplied was silently printing
{token!r}as a literal string rather thaninterpolating the actual bad value, because the
fprefix was missing.Testing
kauldronfix is applied)._normalize_tokenerror path manually verified to produce the correct interpolated message.No new tests are added — Fix 1 is a dependency-level change and Fix 2 is a
one-character typo correction.
Checklist
pyinkformatted).