Skip to content

fix(model): replace a dangling model_uri cache link for image, audio, video and world models - #5915

Merged
qinxuye merged 1 commit into
xorbitsai:mainfrom
NgoQuocViet2001:fix-dangling-model-uri-link
Oct 30, 2026
Merged

qinxuye merged 1 commit into
xorbitsai:mainfrom
NgoQuocViet2001:fix-dangling-model-uri-link

Conversation

@NgoQuocViet2001

Copy link
Copy Markdown
Contributor

Image, audio, video and world models with a local model_uri are linked into ~/.xinference/cache/v2/<name>. If the weights are moved and the model is registered again with the new path, the old link is left dangling. CacheManager._cache_from_uri only checks os.path.exists, which follows the link and returns False, so the launch goes on to os.symlink and fails every time until the link is deleted by hand:

FileExistsError: [Errno 17] File exists: '/models/new/my-sd' -> '~/.xinference/cache/v2/my-sd'

LLM, embedding and rerank models already handle this in LLMCacheManager.cache_uri (#5097). This adds the same step to the generic cache manager: once the new URI resolves, a leftover symlink at the cache path is removed and recreated. A valid link still returns early, and a bad new URI still raises before anything is removed.

  • Ran: pytest xinference/model/tests/test_utils.py -k dangling on Linux: fails on main with the FileExistsError above, passes with this change.
  • Ran: pytest xinference/model/tests/test_utils.py xinference/model/tests/test_oci_utils.py: 97 passed; test_download_modelscope and test_cancel need modelscope, which was not installed, and fail the same way on main.
  • Ran: image registry, video engine, audio engine and cosyvoice security tests: 99 passed.
  • Checked: pre-commit run --files on both changed files passes.

… video and world models

CacheManager._cache_from_uri only checked os.path.exists, which follows
the link. When the directory a model_uri pointed to was moved, the old
cache symlink stayed behind and os.symlink raised FileExistsError on
every later launch. Remove the stale link before relinking, as
LLMCacheManager.cache_uri already does.
@XprobeBot XprobeBot added the bug Something isn't working label Oct 29, 2026
@XprobeBot XprobeBot added this to the v4.x milestone Oct 29, 2026

@qinxuye qinxuye left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The stale symlink is removed only after the new URI resolves, while valid cache entries retain their existing behavior. Validation: 96 related tests and pre-commit passed, plus 24 cache-entry checks across image, video, audio, and world paths; the new regression fails with the base implementation. Three network-download tests were excluded. The remaining macOS 3.14 CI failure is a Realtime WebSocket handshake returning 503 in a FakeModel test that does not use this cache path.

@qinxuye
qinxuye merged commit 60165ca into xorbitsai:main Oct 30, 2026
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants