fleet-memory/hindsight-api/hindsight_api/engine
Nicolò Boschi 0bf85a3435
fix: improve pytorch model initialization to prevent meta tensor issues (#180)
* fix: prevent meta tensor issues when accelerate is installed without GPU

When accelerate is installed but no GPU is available, transformers can
incorrectly use lazy loading (meta tensors) which fails when
sentence-transformers tries to move the model to a device.

The fix checks hardware and installed packages to determine the right
loading strategy:
- GPU available: device=None, device_map=None (auto-detect GPU)
- No GPU + accelerate: device='cpu', device_map='cpu' (force CPU loading)
- No GPU + no accelerate: device='cpu', device_map=None (normal CPU)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

* fix: add filelock for model initialization in parallel tests

When pytest-xdist runs multiple workers in parallel, they all try to
load models from the HuggingFace cache simultaneously, causing race
conditions and intermittent meta tensor errors.

Added filelock around embeddings and cross_encoder initialization in
conftest.py, similar to how pg0 database setup is serialized. Models
are now pre-initialized in the fixture before being passed to tests.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

* fix: add MPS support for macOS Apple Silicon

Extend GPU detection to include Apple MPS backend in addition to CUDA.
This ensures macOS users with Apple Silicon use MPS acceleration
instead of being incorrectly routed to the CPU fallback path.
2026-01-20 14:15:51 +01:00
..
mental_models feat: improve mental model refresh and add directives (#166) 2026-01-19 11:38:35 +01:00
reflect feat: improve mental model refresh and add directives (#166) 2026-01-19 11:38:35 +01:00
retain chore: drop unused access_count column (#178) 2026-01-20 10:36:02 +01:00
search chore: drop unused access_count column (#178) 2026-01-20 10:36:02 +01:00
__init__.py feat: extensions (#54) 2025-12-22 11:05:23 +01:00
cross_encoder.py fix: improve pytorch model initialization to prevent meta tensor issues (#180) 2026-01-20 14:15:51 +01:00
db_budget.py fix: batch queries on recall (#149) 2026-01-13 13:20:22 +01:00
db_utils.py misc: performance improvements (#140) 2026-01-09 14:47:20 +01:00
embeddings.py fix: improve pytorch model initialization to prevent meta tensor issues (#180) 2026-01-20 14:15:51 +01:00
entity_resolver.py fix: misc perf improvements (#133) 2026-01-08 22:49:04 +01:00
interface.py feat: introduce mental models (#132) 2026-01-16 11:16:41 +01:00
llm_wrapper.py feat: introduce mental models (#132) 2026-01-16 11:16:41 +01:00
memory_engine.py chore: drop unused access_count column (#178) 2026-01-20 10:36:02 +01:00
query_analyzer.py fix: improve mpfp retrieval (#146) 2026-01-12 18:58:05 +01:00
response_models.py feat: improve mental model refresh and add directives (#166) 2026-01-19 11:38:35 +01:00
task_backend.py feat: new 'worker' service (#176) 2026-01-20 10:17:56 +01:00
utils.py chore: drop unused access_count column (#178) 2026-01-20 10:36:02 +01:00