fix(llm): validate recorded custom LLM cache sources #6006
All Vouch review confidence checks passed
Residual risk 0.23 = Change Risk (0.57) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.57 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #6006"
general
weight: 0.35
Jackmeson1
What happens
Unregistering a custom LLM leaves its downloaded directory behind. Registering the same name for another repository or revision can then return the old cached files without downloading the new source.
A registration declaring multiple sources can also reuse recorded GGUF weights and a projector, or split shards, from different sources in one launch. Concurrent case aliases can race over the same destination on a case-insensitive filesystem.
Cause
The cache directory name does not identify its repository or revision. GGUF cache hits depend on the selected files: an existing directory can still need another download, and one registration can download different files from different hubs into it.
Checking each file against the declared sources independently does not establish that the files used together share one source. Path-based destination locks also depend on spelling;
normcase()preserves case on macOS even when the filesystem does not.Change
Record custom LLM download sources outside model directories, in
v2/.model-sources/<directory name>.json, before downloading. GGUF records cover newly added files, including split shards, their generated alias and projectors. Snapshot formats use one whole-directory entry.Check the files a launch reuses against the registration's declared sources, including filesystem aliases and case-only filename variants. On cache hits as well as downloads, recorded weights, shards and projectors used together must agree on one declared source. Compute resolved GGUF cache-hit filenames relative to the cache directory directly, including with a relative
XINFERENCE_HOME.Refuse conflicting recorded files before a download. When completing a split GGUF download, also reject existing selected files without source records; matching records must name the selected source. Use the same filename and filesystem-identity matching for both checks. Preserve retained files and their existing records without assigning provenance to unknown legacy files. A
model_uriover a downloaded directory checks its recorded files.Missing records and unrecorded files retain legacy compatibility, except when completing a split GGUF download. Removed directories do not carry their records into subsequent downloads. Built-ins, drafters and root
model_urilinks remain excluded; explicitmodel_pathlaunches bypass the cache manager. Listings remain presence-based.Keep repository and destination locks around source checks, record updates and downloads. Derive destination locks from filesystem parent identity and filename case behavior so case aliases share a lock before the destination exists. Preserve distinct destination names on case-sensitive parents. The cache layout remains unchanged.
Compare hub, repository ID and revision strings, including templated IDs and PyTorch's implicit
"none"expansion. This does not verify content identity or multipart-download completeness.From the API code, source-check failures map to HTTP 400 for waiting launches, while record-write failures map to 500. Asynchronous launches can fail in the background; these mappings were not exercised through a cluster.
Tests
The regressions use
create_model_instance()with stubbed hub downloaders and a disposable LLM registry, family list and engine table. They cover mixed-source projectors and fully cached shards, concurrent case aliases with missing and empty destinations, coherent reuse from another declared hub, and retained unknown legacy files. Existing incomplete-cache, split-completion, re-registration, alias, damaged-record and persisted-registration cases remain.The concurrent case-alias regression lives in
test_cache_download_lock.py, which the macOS/Windows CI jobs already run. On a case-sensitive filesystem it checks that the two distinct destinations can download independently.On Windows with Python 3.10.20 and 3.14.6, Transformers 5.17.0, huggingface-hub 1.16.1, offline flags and a temporary
XINFERENCE_HOME:362a3238give 4 failed, 6 passed; with the fix, 10 passed.my-llm, 59 passed, on each interpreter.Pre-commit on the changed files plus
xinference/types.pypassed.On Ubuntu 24.04.5 (a case-sensitive filesystem) with Python 3.12.3 and 3.10.22, the changed test file gave 207 passed, 3 skipped (205 passed with the CI pin Transformers 4.57.6); its failures (
test_query_engine_general, plustest_engine_discovery_paths_agree_on_draft_supporton the pin) also fail at362a3238. Changed-file pre-commit passed there too.Windows exercised case-insensitive NTFS with native and POSIX-style
normcase. Native macOS and native case-sensitive filesystem execution remain unverified. GPU, real-model and live-cluster checks were not run.AI disclosure: this was prepared with AI assistance (Claude Opus 5.5, Claude Sonnet 5.5 and OpenAI Codex).
🤖 Generated with Claude Code
https://claude.ai/code/session_01JfvcPZyKcKQUG9fQGYfRMw