← Back to Pull requests

fix(llm): validate recorded custom LLM cache sources #6006

Closed
unknown closed this pull request without merging on Nov 05, 2026 11:23 UTC
View on GitHub
unknown unknown commented on Nov 03, 2026 22:29 UTC
Author

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_uri over 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_uri links remain excluded; explicit model_path launches 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:

  • The final ten factory cases against 362a3238 give 4 failed, 6 passed; with the fix, 10 passed.

  • The focused suite plus repository-lock test gives 60 passed; with a persisted my-llm, 59 passed, on each interpreter.

  • The whole family file plus lock test changes from 10 failed, 199 passed, 3 skipped to 6 failed, 203 passed, 3 skipped. The same six environment failures remain: offline downloads, Windows symlink creation and a missing llama.cpp engine.

  • Removing source-set validation, restoring the old destination key, or releasing the lock before downloading causes the corresponding regressions to fail on both interpreters.
  • Pre-commit on the changed files plus xinference/types.py passed.

    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, plus test_engine_discovery_paths_agree_on_draft_support on the pin) also fail at 362a3238. 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

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: Jackmeson1 Review duration: 2214m
    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
    0.57
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 57% (MEDIUM) · Higher = larger blast radius
    57%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 22.5% · Safe to merge
    22.5%