Repository navigation
Studio: download the HNSW prebuilts (usearch + numkong) only when a knowledge base needs them - #16799
Conversation
…hash-checked and probed
…mandatory requirements
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
…e whose pair lands mid-build
… inconclusive probes leave no marker
…oad, and run HNSW in the idempotency smoke
…ith a second run [skip ci]
…exact-cached waiting scopes to HNSW [skip ci]
… that lands mid-build [skip ci]
… passing probe [skip ci]
|
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…outs like the backend, and baseline the installer load
…ng them, and drop the venv's wheel cache once the pair is ready [skip ci]
…ver uninstall the half that was already there [skip ci]
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…update download it only with UNSLOTH_HNSW_PREFETCH=1 [skip ci]
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
# Conflicts: # tests/studio/install/test_windows_torch_flavor_invariant.py
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…only from PyPI (or UNSLOTH_HNSW_MIRROR) through the checked installer [skip ci]
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…hashes --only-binary), debug info is stripped in place, and the hand-written wheel selection, downloader and JSON catalog go [skip ci]
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
… and pip (#18358) ## Summary On a runner whose own `certifi` or `pip` is below the CA trust floor and has no `uv` on PATH, 59 cases in `tests/studio/install/test_mlx_install.py` fail: ``` studio/install_python_stack.py:8272: in _ensure_trust_floor studio/install_python_stack.py:9653: in pip_install_try FileNotFoundError: [Errno 2] No such file or directory: 'uv' ``` This showed up on the macOS leg of the cross-platform staging run for #16799 (runner certifi 2026.7.22, below the `certifi>=2026.10.19` floor). ## Cause `install_python_stack()` calls `_ensure_trust_floor()` on every setup and update (#14887). That raises certifi, and pip on 3.10+, through `pip_install_try` whenever the running interpreter does not already meet the floor. The `_run_to_extras` helper stubs `pip_install`, `run`, `_bootstrap_uv` and the torch steps, but not this path. So whether these tests spawn a real installer depended on the runner image's certifi and pip versions. On hosts that already meet the floor, nothing runs and the tests pass. The installer behaviour is correct. The test was not hermetic. ## Fix Stub `_trust_floor_specs` to return `[]` in the helper, next to the `_no_torch_pair` stub from #18354. The floor logic keeps its own coverage in `tests/studio/install/test_ca_trust_floor.py`. ## Verification Reproduced by raising the certifi floor above any installed version and running with `uv` removed from PATH: | Tree | floor unmet, no `uv` | normal | |---|---|---| | main | 59 failed, 15 passed | 74 passed | | this branch | 74 passed | 74 passed | `test_ca_trust_floor.py` passes unchanged, and ruff is clean.
# Conflicts: # tests/studio/test_rag_upload_requirements_cover_ci_imports.py [skip ci]
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Studio's HNSW tier (#16145) depends on usearch + numkong native wheels. Today they are plain lines in
studio.txt/no-torch-runtime.txt, so:This PR makes the pair an optional prebuilt that Studio and Desktop download themselves, only when a knowledge base is large enough to use it.
What it adds
RAG_VEC_ANN_MIN_ROWS(100k) and the pair is missing, the backend starts one background install (never inside a SQLite transaction or the cache lock; search keeps answering from the exact cache / vec0), then rebuilds the waiting scopes as HNSW without a restart.UNSLOTH_HNSW_PREFETCH=1installs it during install / update instead, for a machine that will be offline later.studio/install_hnsw_prebuilt.py+studio/hnsw_prebuilt.txt, a hash-pinned requirements file with every usearch 2.26.6 / numkong 7.8.6 wheel for cp311 to cp314 (scripts/hnsw_catalog.py [--check]regenerates it from PyPI).--require-hashes --only-binary :all: --no-deps --no-config: uv picks the wheel for the interpreter, only the pinned bytes are accepted, nothing is ever built from source, and a user's uv config orUV_CONSTRAINTcannot interfere. Proxies,UV_INDEX_URL/PIP_INDEX_URLand the OS trust store (macOS, Windows, Desktop, as Studio's other downloads) are honoured. A platform with no wheel reportsunsupportedand backs off.unverifiedmarker before touching the venv and probes the pair in a child interpreter (import, insert, search, save, memory-mapped restore) before Studio imports it. A failed probe uninstalls only what this run installed and writesfailed(retried after 7 days or with--force); a hung probe staysunverified.vec_ann.usearch()never imports a failed, unverified or still-installing pair, so a bad native build cannot crash the backend.RAG_VEC_ANN_AUTO_INSTALL=0orRAG_VEC_ANN=0), offline, unsupported, failed, busy. Exit 0 for all of them;--strictexits 1 unless the pair is ready.studio.txt,no-torch-runtime.txtand thestudioextra and is in no pip requirement at all (a test enforces it), so no install can fail over it;known_unmet_indexignores it.Testing
test_hnsw_prebuilt.py: the hash file pins both packages; install flags and child env (constraints and secrets dropped, index / proxy / TLS kept); offline, opt-out, check-only; probe failure, unverified marker, an install killed halfway, no wheel for the platform, half a pair already installed; ELF debug stripping (synthetic ELF with a patchelf-style tail segment, unsafe layouts left alone) and in-place RECORD rewrite that leaves a hardlinked cache copy alone; and a real hash-pinned install, strip and probe of the pair that fails above 15 MB installed or with any debug section left.test_rag_hnsw_runtime.py: one request per missing scope, switch to HNSW after the install without a write, backoff per status, markers and the install lock skipping the import, a module still initialising on another thread.test_hnsw_prebuilt_step.py: installs and thesetup.sh/setup.ps1fast paths download nothing by default; withUNSLOTH_HNSW_PREFETCH=1the step never raises and the fast paths stay local when nothing is owed (bash and pwsh).readyand the tests passed on ubuntu x64 / arm64, macOS arm64 / x86_64 and Windows x64 / arm64; on AMD Strix Halo (gfx1151) Linux with ROCm and Windows 11 the pair installed and loaded and the HNSW suites passed (126 / 126).Follow-ups: pre-stripped wheels to shrink the Linux download for the users who fetch it (12.9 MB today), manylinux2014 builds for glibc 2.17 to 2.27, and signed Windows
.pydfiles.