fix(utils): download tokenizer models locally via HTTP to avoid TF GCS C++ segfault on macOS#661
Open
prince-shakyaa wants to merge 1 commit into
Conversation
…S C++ segfault on macOS
Author
|
While testing locally on macOS Apple Silicon, Let me know if you need me to make any changes. |
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.
Description
Fixes #660
Fixes an issue where
gemmafails to download/cachegs://tokenizer paths efficiently, which triggers the TensorFlow C++ GCS client and results in alibc++abi: terminating due to uncaught exception of type std::__1::system_error: mutex lock failedcrash on macOS Apple Silicon at Python interpreter exit.By explicitly intercepting
gs://paths and downloading them via standard HTTP (urllib.request) directly into the local~/.gemma/tokenizer/cache, we completely bypass the C++ GCS client bug.Additionally, this adds true local caching for tokenizer models (previously the code was checking the cache, but never actually saving to it if the file was missing, leading to the full model being fetched over the network on every run).
Changes
gemma/gm/utils/_file_cache.py::maybe_get_from_cacheto translategs://paths tohttps://storage.googleapis.com/and download them natively to the cache directory before returning the local path.