feat(encoders): platform-aware default encoder for new albums#307
Open
lstein wants to merge 1 commit into
Open
feat(encoders): platform-aware default encoder for new albums#307lstein wants to merge 1 commit into
lstein wants to merge 1 commit into
Conversation
OpenCLIP ViT-L-14 is impractically slow to index/search on CPU-only Linux/Windows hosts. New albums on those hosts now default to the lightweight OpenAI CLIP ViT-B/32 instead, while CUDA hosts and macOS (untested for the lighter path) keep the high-quality ViT-L-14 default. - encoders.py: add CPU_FALLBACK_ENCODER_SPEC + default_encoder_spec() resolver (CUDA/macOS -> ViT-L-14, CPU Linux/Windows -> ViT-B/32) - config.py: Album.encoder_spec uses default_factory=default_encoder_spec - routers/album.py: GET /default_encoder/ exposes the host-resolved default - album-manager.js: new-album dropdown pre-selects the server default (cached fetch, falls back to recommended option on failure) Existing albums keep their stored encoder_spec; only the default for newly created albums changes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Problem
OpenCLIP ViT-L-14 (the default encoder for new albums) is impractically slow to index and search on a CPU-only host. Testing on a Windows machine without GPU acceleration confirmed this.
Change
New albums now pick their default encoder based on the host:
The dropdown still offers all three encoders for manual override; this only changes which one is pre-selected for a new album.
Implementation
encoders.py—CPU_FALLBACK_ENCODER_SPEC+default_encoder_spec()resolver.DEFAULT_ENCODER_SPEC/LEGACY_ENCODER_SPECunchanged.config.py—Album.encoder_specnow usesdefault_factory=default_encoder_spec.routers/album.py—GET /default_encoder/exposes the host-resolved default so the frontend doesn't have to guess the server's GPU/OS.album-manager.js— new-album dropdown pre-selects the server default (cached fetch; falls back to the recommended option if the request fails).Scope notes
encoder_specand would need re-indexing to switch.index_imagesCLI path already defaulted to the light ViT-B/32 (Embeddings.encoder_spec = LEGACY_ENCODER_SPEC), so only frontend-created albums hit the slow path. That's what this fixes.Tests
test_encoders.py—default_encoder_spec()across CUDA / macOS / CPU-Linux / CPU-Windows (monkeypatched), plus the new constant.test_albums.py— the/default_encoder/endpoint.ruff check, frontendnpm run lint+format:check, Jest 349/349.🤖 Generated with Claude Code