Interrupted split GGUF download is treated as a complete cache and retry skips missing shards
System Info
Windows, OS build 26100. Reproduced with Python 3.14.6 and 3.10.20, pytest 9.1.1, huggingface-hub 1.16.1, ModelScope 1.40.2, and pydantic 2.14.1. The optional pycsghub SDK is not installed; its import/download boundary is stubbed in the test. The reproduction runs offline with small placeholder files and does not load a model.
Running Xinference with Docker?
- [ ] docker
- [ ] pip install
- [x] installation from source
Version info
Source checkout of main at
3e21084805ce26a3c5ed2ed6712abdb1bd775de0.
The command used to start Xinference
No server process is needed. The test calls the real cache manager, worker listing helper, version-info method, and launch artifact-construction path directly. The launch check stops at a mocked llama.cpp engine constructor.
From an installed source checkout, save the test below as
xinference/model/llm/tests/test_split_gguf_partial_cache.py and run this
PowerShell script from the checkout root once with each Python version selected
as python:
$env:PYTHONPATH = "."
$env:HF_HUB_OFFLINE = "1"
$env:TRANSFORMERS_OFFLINE = "1"
$env:PYTHONDONTWRITEBYTECODE = "1"
$env:PYTHONIOENCODING = "utf-8"
$runRoot = Join-Path ([System.IO.Path]::GetTempPath()) ("splitggufcache-" + [guid]::NewGuid().ToString("N"))
New-Item -ItemType Directory -Path $runRoot | Out-Null
$env:XINFERENCE_HOME = Join-Path $runRoot "xinference"
$env:TEMP = $runRoot
$env:TMP = $runRoot
$env:TMPDIR = $runRoot
python -m pytest -p no:cacheprovider -o 'addopts=' -q -s --tb=short --show-capture=no --disable-warnings -W ignore::FutureWarning xinference/model/llm/tests/test_split_gguf_partial_cache.py
exit $LASTEXITCODE
Reproduction
The built-in qwen3.8 27B BF16 GGUF spec
declares two shards:
BF16/Qwen3.8-27B-BF16-00001-of-00002.gguf
BF16/Qwen3.8-27B-BF16-00002-of-00002.gguf
The test patches the per-file downloader to store a placeholder for the first
shard and raise an OSError on every attempt to download the second. After
cache() raises, the test restores the downloader and retries through a new
LLMCacheManager.
That retry returns the cache directory without requesting the missing second
shard. The worker listing helper and model version-info method both report
cache_status=True. The complete-download control fetches both shards and
creates the final alias; its retry correctly makes no download requests.
This reproduces with both bundled Hugging Face and ModelScope specs. A
synthetic CSGHub case uses the copied Hugging Face spec with only model_hub
changed and the optional SDK boundary stubbed. There is no bundled split
CSGHub spec, so that case checks Xinference's downloader path, not a registered
CSGHub model or a live CSGHub service.
The cache check at
LLMCacheManager.get_cache_status, lines 196-212
requires the path from
resolve_gguf_model_path, lines 23-36.
For this split spec, that is only the first shard. Its presence triggers the
Hugging Face early return at lines 493-495
before the remaining files are downloaded. The ModelScope
early return at lines 564-566
and CSGHub early return at lines 666-668
use the same check.
The output also lists Qwen3.8-27B-BF16.gguf as missing.
merge_cached_files, lines 3020-3028
creates that alias to the first shard; it does not concatenate weights.
The missing second shard is the incomplete download demonstrated here.
The listing helper at
worker.py:1744
and LLMFamilyV2.to_version_info:321
both use the same status check. For Hugging Face and ModelScope, the test also
exercises the real
launch cache call at core.py:753-754:
the incomplete directory reaches the mocked engine constructor without further
download requests. Source inspection shows that the llama.cpp loader uses the
same path resolver at
llama_cpp/core.py:408.
Actual engine loading and inference are outside this reproduction.
Related work: #5471 added resumable download-task management; this report concerns the underlying artifact cache returning early during a retry. #5974 added the selected-GGUF-file existence check while correcting the GLM-4-32B-0414 spec. That check rejects a cache directory without the selected file; this case already has the first shard and lacks the second.
The three complete-download controls pass. The three interrupted-download cases fail at the assertion requiring the retry to request the missing shard, as shown in the captured outputs below.
Offline reproduction test
# Copyright 2022-2026 Xinference Holdings Pte. Ltd
# Licensed under the Apache License, Version 2.0.
# CI: linux
import importlib
import sys
from pathlib import Path
from types import ModuleType
import huggingface_hub
import pytest
from xinference import constants
from xinference.core.worker import WorkerActor
from xinference.model.cache_manager import CacheManager
from xinference.model.llm import llm_family
from xinference.model.llm.cache_manager import LLMCacheManager
from xinference.model.llm.core import create_llm_model_instance
from xinference.model.llm.gguf_model_metadata import resolve_gguf_model_path
from xinference.model.llm.llama_cpp.core import XllamaCppModel
@pytest.fixture(params=["huggingface", "modelscope", "csghub"])
def split_cache(request, tmp_path, monkeypatch):
hub = request.param
family = llm_family.get_llm_family_by_name("qwen3.8").copy(deep=True)
source_hub = "huggingface" if hub == "csghub" else hub
family.model_specs = [
spec
for spec in family.model_specs
if spec.model_format == "ggufv2"
and spec.model_size_in_billions == 27
and spec.quantization == "BF16"
and spec.model_hub == source_hub
]
assert len(family.model_specs) == 1
# No built-in split CSGHub spec: exercise its downloader with the unchanged
# built-in shard layout, changing only the hub used for dispatch.
family.model_specs[0].model_hub = hub
monkeypatch.setattr(constants, "XINFERENCE_CACHE_DIR", str(tmp_path / "cache"))
monkeypatch.setattr(constants, "XINFERENCE_MODEL_DIR", str(tmp_path / "models"))
monkeypatch.setattr(CacheManager, "is_initialized", False)
manager = LLMCacheManager(family)
shards, alias, need_merge = manager._gguf_file_names()
assert len(shards) == 2 and need_merge
calls = []
interrupt = {"enabled": False}
def download(model_id, filename=None, *, file_name=None, **kwargs):
assert model_id == family.model_specs[0].model_id
name = filename if filename is not None else file_name
assert name in shards
calls.append(name)
if interrupt["enabled"] and name == shards[1]:
raise OSError("simulated second-shard interruption")
blob = tmp_path / "hub" / name
blob.parent.mkdir(parents=True, exist_ok=True)
blob.write_bytes(b"placeholder")
# Older HF clients place the file directly in local_dir.
if kwargs.get("local_dir"):
local = Path(kwargs["local_dir"]) / name
local.parent.mkdir(parents=True, exist_ok=True)
local.write_bytes(blob.read_bytes())
return str(blob)
def unexpected_snapshot(*args, **kwargs):
pytest.fail("a split GGUF must use the patched per-file downloader")
monkeypatch.setattr(huggingface_hub, "hf_hub_download", download)
monkeypatch.setattr(huggingface_hub, "snapshot_download", unexpected_snapshot)
if hub == "modelscope":
module = importlib.import_module("modelscope.hub.file_download")
monkeypatch.setattr(module, "model_file_download", download)
module = importlib.import_module("modelscope.hub.snapshot_download")
monkeypatch.setattr(module, "snapshot_download", unexpected_snapshot)
elif hub == "csghub":
# The optional SDK is absent locally; stub only its import/download edge.
package = ModuleType("pycsghub")
package.__path__ = []
monkeypatch.setitem(sys.modules, "pycsghub", package)
for module_name, attribute, function in [
("file_download", "file_download", download),
("snapshot_download", "snapshot_download", unexpected_snapshot),
]:
module = ModuleType(f"pycsghub.{module_name}")
setattr(module, attribute, function)
monkeypatch.setitem(sys.modules, module.__name__, module)
return hub, family, manager, shards, alias, calls, interrupt
def listing_status(family) -> bool:
specs, _ = WorkerActor._get_spec_dicts_with_cache_status(
None, family, LLMCacheManager
)
status = specs[0]["cache_status"]
assert status == family.to_version_info()["cache_status"]
return status
def test_complete_download_then_retry_is_a_cache_hit(split_cache):
hub, family, manager, shards, alias, calls, _ = split_cache
cache_dir = Path(manager.cache())
assert calls == shards
assert all((cache_dir / name).is_file() for name in shards + [alias])
calls.clear()
assert LLMCacheManager(family).cache() == str(cache_dir)
assert calls == []
assert listing_status(family) is True
print(f"CONTROL {hub}: shards=2 alias=True cache_status=True retry_requests={calls}")
def test_interrupted_download_retry_fetches_missing_shard(split_cache, monkeypatch):
hub, family, manager, shards, alias, calls, interrupt = split_cache
interrupt["enabled"] = True
with pytest.raises(RuntimeError, match="after multiple retries") as error:
manager.cache()
assert isinstance(error.value.__cause__, OSError)
assert str(error.value.__cause__) == "simulated second-shard interruption"
cache_dir = Path(manager.get_cache_dir())
assert (cache_dir / shards[0]).is_file()
assert not (cache_dir / shards[1]).exists()
assert not (cache_dir / alias).exists()
calls.clear()
interrupt["enabled"] = False
assert LLMCacheManager(family).cache() == str(cache_dir)
retry_calls = calls.copy()
missing = [name for name in shards + [alias] if not (cache_dir / name).exists()]
status = listing_status(family)
runtime_path = Path(resolve_gguf_model_path(str(cache_dir), family.model_specs[0]))
print(f"PARTIAL {hub}: retry_requests={retry_calls} cache_status={status}")
print(f" missing={missing}")
print(f" runtime_path={runtime_path.relative_to(cache_dir).as_posix()}")
if hub != "csghub":
# Exercise the real launch/cache path, stopping at the engine constructor.
class Engine(XllamaCppModel):
def __init__(self, uid, selected_family, path, config):
self.path = path
monkeypatch.setattr(
llm_family, "check_engine_by_spec_parameters", lambda *args: Engine
)
model = create_llm_model_instance(
"partial-cache-0",
"qwen3.8",
"llama.cpp",
model_format="ggufv2",
model_size_in_billions=27,
quantization="BF16",
download_hub=hub,
enable_virtual_env=False,
)
assert model.path == str(cache_dir)
print(f" launch_constructor_received_cache=True launch_requests={calls}")
assert shards[1] in retry_calls, f"{hub}: retry did not request the missing shard"
assert missing == []
Exact pytest output: Python 3.14.6 (exit code 1)
CONTROL huggingface: shards=2 alias=True cache_status=True retry_requests=[]
.CONTROL modelscope: shards=2 alias=True cache_status=True retry_requests=[]
.CONTROL csghub: shards=2 alias=True cache_status=True retry_requests=[]
.PARTIAL huggingface: retry_requests=[] cache_status=True
missing=['BF16/Qwen3.8-27B-BF16-00002-of-00002.gguf', 'Qwen3.8-27B-BF16.gguf']
runtime_path=BF16/Qwen3.8-27B-BF16-00001-of-00002.gguf
launch_constructor_received_cache=True launch_requests=[]
FPARTIAL modelscope: retry_requests=[] cache_status=True
missing=['BF16/Qwen3.8-27B-BF16-00002-of-00002.gguf', 'Qwen3.8-27B-BF16.gguf']
runtime_path=BF16/Qwen3.8-27B-BF16-00001-of-00002.gguf
launch_constructor_received_cache=True launch_requests=[]
FPARTIAL csghub: retry_requests=[] cache_status=True
missing=['BF16/Qwen3.8-27B-BF16-00002-of-00002.gguf', 'Qwen3.8-27B-BF16.gguf']
runtime_path=BF16/Qwen3.8-27B-BF16-00001-of-00002.gguf
F
================================== FAILURES ===================================
_____ test_interrupted_download_retry_fetches_missing_shard[huggingface] ______
xinference\model\llm\tests\test_split_gguf_partial_cache.py:156: in test_interrupted_download_retry_fetches_missing_shard
assert shards[1] in retry_calls, f"{hub}: retry did not request the missing shard"
E AssertionError: huggingface: retry did not request the missing shard
E assert 'BF16/Qwen3.8-27B-BF16-00002-of-00002.gguf' in []
______ test_interrupted_download_retry_fetches_missing_shard[modelscope] ______
xinference\model\llm\tests\test_split_gguf_partial_cache.py:156: in test_interrupted_download_retry_fetches_missing_shard
assert shards[1] in retry_calls, f"{hub}: retry did not request the missing shard"
E AssertionError: modelscope: retry did not request the missing shard
E assert 'BF16/Qwen3.8-27B-BF16-00002-of-00002.gguf' in []
________ test_interrupted_download_retry_fetches_missing_shard[csghub] ________
xinference\model\llm\tests\test_split_gguf_partial_cache.py:156: in test_interrupted_download_retry_fetches_missing_shard
assert shards[1] in retry_calls, f"{hub}: retry did not request the missing shard"
E AssertionError: csghub: retry did not request the missing shard
E assert 'BF16/Qwen3.8-27B-BF16-00002-of-00002.gguf' in []
=========================== short test summary info ===========================
FAILED xinference/model/llm/tests/test_split_gguf_partial_cache.py::test_interrupted_download_retry_fetches_missing_shard[huggingface]
FAILED xinference/model/llm/tests/test_split_gguf_partial_cache.py::test_interrupted_download_retry_fetches_missing_shard[modelscope]
FAILED xinference/model/llm/tests/test_split_gguf_partial_cache.py::test_interrupted_download_retry_fetches_missing_shard[csghub]
3 failed, 3 passed, 20 warnings in 0.83s
Exact pytest output: Python 3.10.20 (exit code 1)
CONTROL huggingface: shards=2 alias=True cache_status=True retry_requests=[]
.CONTROL modelscope: shards=2 alias=True cache_status=True retry_requests=[]
.CONTROL csghub: shards=2 alias=True cache_status=True retry_requests=[]
.PARTIAL huggingface: retry_requests=[] cache_status=True
missing=['BF16/Qwen3.8-27B-BF16-00002-of-00002.gguf', 'Qwen3.8-27B-BF16.gguf']
runtime_path=BF16/Qwen3.8-27B-BF16-00001-of-00002.gguf
launch_constructor_received_cache=True launch_requests=[]
FPARTIAL modelscope: retry_requests=[] cache_status=True
missing=['BF16/Qwen3.8-27B-BF16-00002-of-00002.gguf', 'Qwen3.8-27B-BF16.gguf']
runtime_path=BF16/Qwen3.8-27B-BF16-00001-of-00002.gguf
launch_constructor_received_cache=True launch_requests=[]
FPARTIAL csghub: retry_requests=[] cache_status=True
missing=['BF16/Qwen3.8-27B-BF16-00002-of-00002.gguf', 'Qwen3.8-27B-BF16.gguf']
runtime_path=BF16/Qwen3.8-27B-BF16-00001-of-00002.gguf
F
================================== FAILURES ===================================
_____ test_interrupted_download_retry_fetches_missing_shard[huggingface] ______
xinference\model\llm\tests\test_split_gguf_partial_cache.py:156: in test_interrupted_download_retry_fetches_missing_shard
assert shards[1] in retry_calls, f"{hub}: retry did not request the missing shard"
E AssertionError: huggingface: retry did not request the missing shard
E assert 'BF16/Qwen3.8-27B-BF16-00002-of-00002.gguf' in []
______ test_interrupted_download_retry_fetches_missing_shard[modelscope] ______
xinference\model\llm\tests\test_split_gguf_partial_cache.py:156: in test_interrupted_download_retry_fetches_missing_shard
assert shards[1] in retry_calls, f"{hub}: retry did not request the missing shard"
E AssertionError: modelscope: retry did not request the missing shard
E assert 'BF16/Qwen3.8-27B-BF16-00002-of-00002.gguf' in []
________ test_interrupted_download_retry_fetches_missing_shard[csghub] ________
xinference\model\llm\tests\test_split_gguf_partial_cache.py:156: in test_interrupted_download_retry_fetches_missing_shard
assert shards[1] in retry_calls, f"{hub}: retry did not request the missing shard"
E AssertionError: csghub: retry did not request the missing shard
E assert 'BF16/Qwen3.8-27B-BF16-00002-of-00002.gguf' in []
=========================== short test summary info ===========================
FAILED xinference/model/llm/tests/test_split_gguf_partial_cache.py::test_interrupted_download_retry_fetches_missing_shard[huggingface]
FAILED xinference/model/llm/tests/test_split_gguf_partial_cache.py::test_interrupted_download_retry_fetches_missing_shard[modelscope]
FAILED xinference/model/llm/tests/test_split_gguf_partial_cache.py::test_interrupted_download_retry_fetches_missing_shard[csghub]
3 failed, 3 passed, 9 warnings in 0.91s
Expected behavior
A retry should fetch the missing declared shard. The cache listing should report that the download is incomplete until both shards are present. A complete download should remain a cache hit.
The cache-only download documentation describes pausing and resuming cache-only tasks, including unfinished tasks marked interrupted after a supervisor or worker restart. It states:
Resume reuses files already present in the model hub cache. Byte-range continuation of a partially written file depends on the selected hub client; otherwise that incomplete file is downloaded again.
Here an entire declared shard is absent, but the artifact-cache retry returns without calling the hub client. The test demonstrates that retry behavior; it does not exercise task persistence or the HTTP resume endpoint.
We do not currently plan to submit a fix.
AI disclosure: this was prepared with AI assistance (Claude Opus 5.5 and Claude Sonnet 5.5).