EmbeddingGemma fails to load with onnxruntime 1.30 + huggingface_hub 1.32: "External data path escapes model directory"
What happened?
Every mempalace mine fails when EmbeddingGemma loads with onnxruntime 1.30 and huggingface_hub 1.32:
onnxruntime.capi.onnxruntime_pybind11_state.Fail: [ONNXRuntimeError] : 1 : FAIL :
External data path validation failed for initializer: model.embed_tokens.weight_quantized.
Error: External data path escapes model directory.
External data path: "model_quantized.onnx_data"
resolved path: "~/.cache/huggingface/hub/blobs/2d/2dd111280ebe…"
allowed directory: "~/.cache/huggingface/hub/blobs/6a"Two changes combine to cause it:
- huggingface_hub 1.32 keeps blobs in a shared, sharded store. The snapshot files
onnx/model_quantized.onnxandonnx/model_quantized.onnx_dataare symlinks that end up in different directories (hub/blobs/6a/<sha>andhub/blobs/2d/<sha>). - onnxruntime 1.30 validates external data against the model's resolved directory. The directory it allows is the realpath of the
.onnx(blobs/6a), and the.onnx_dataresolves toblobs/2d, so it is rejected.
EmbeddinggemmaONNX._lazy_load (mempalace/embedding.py) passes the path returned by hf_hub_download(..., subfolder="onnx", filename="model_quantized.onnx") straight to ort.InferenceSession, so it hits this every time.
What did you expect?
The model loads and mining/search work, as they did with older onnxruntime/huggingface_hub.
How to reproduce:
- Install
mempalace==3.10.0withonnxruntime==1.30.0andhuggingface_hub==1.32.0on Linux. - Let EmbeddingGemma download (
onnx-community/embeddinggemma-300m-ONNX), then runmempalace mine <dir>. - Or, directly:
from mempalace.embedding import EmbeddinggemmaONNX; EmbeddinggemmaONNX()(["hola"]), which raises the error above.
Workaround (verified): in snapshots/<rev>/onnx/, replace the two symlinks with hardlinks to their targets (ln -f "$(readlink -f f)" f.tmp && mv f.tmp f). After that the model loads, mine indexes and search returns results.
Suggested fix: keep the .onnx and .onnx_data in the same real directory before creating the session. For example, hf_hub_download(..., local_dir=<mempalace cache>) writes real files side by side. Another option is to hardlink (or copy) both into a private dir, or pass the model as bytes with the external-data folder set explicitly.
Environment:
- OS: Ubuntu 24.04 (Linux 7.0.0-34, x86_64)
- Python version: 3.12.3 (uv tool install)
- MemPal version: 3.10.0 (onnxruntime 1.30.0, huggingface_hub 1.32.0, chromadb 1.5.9)
Source: MemPalace/mempalace