Skip to content

BUG: xinference 3.2.0 wheel is unimportable - KeyError: 'model_specs' (an audio model entry is packaged into llm_family.json) #5347

Description

@sfwani

System Info / 系統信息

Any. Reproduced on python:3.12-slim with a clean pip install xinference==3.2.0.

Running Xinference with Docker? / 是否使用 Docker 运行 Xinfernece?

  • docker / docker
  • pip install / 通过 pip install 安装
  • installation from source / 从源码安装

Version info / 版本信息

xinference 3.2.0 (from PyPI)

The command used to start Xinference / 用以启动 xinference 的命令

xinference-local -H 0.0.0.0 -p 9997

Any entrypoint fails identically, because the error happens at import time.

Reproduction / 复现过程

pip install xinference==3.2.0
xinference-local -H 0.0.0.0 -p 9997
File ".../xinference/model/__init__.py", line 25, in _install
    llm_install()
File ".../xinference/model/llm/__init__.py", line 273, in _install
    load_model_family_from_json("llm_family.json", BUILTIN_LLM_FAMILIES)
File ".../xinference/model/llm/__init__.py", line 187, in load_model_family_from_json
    for spec in json_obj["model_specs"]:
                ~~~~~~~~^^^^^^^^^^^^^^^
KeyError: 'model_specs'

Cause

The published wheel's xinference/model/llm/llm_family.json contains one entry that is not an LLM
family and has no model_specs key:

import json
d = json.load(open('.../site-packages/xinference/model/llm/llm_family.json'))
print(len(d))
print([e['model_name'] for e in d if 'model_specs' not in e])
167
['speech_campplus_sv_zh-cn_16k-common']

That entry is an audio model. It is byte-for-byte identical to the entry of the same name in
xinference/model/audio/model_spec.json, where it also correctly appears.

This looks like a release-pipeline problem rather than a source problem. The v3.2.0 git tag is
clean:

Artifact entries in llm_family.json entries missing model_specs
v3.2.0 git tag 166 none
xinference-3.2.0-py3-none-any.whl from PyPI 167 1 (speech_campplus_sv_zh-cn_16k-common)

So the audio entry is being appended to the LLM family JSON somewhere between tagging and
publishing, most likely by whatever merges the model JSON updates at build time.

Expected behavior / 期待表现

pip install xinference==3.2.0 should produce a working install. Right now every xinference-*
entrypoint raises KeyError: 'model_specs' on import, so the release is unusable without editing
the packaged JSON by hand.

Workaround

import json
p = '<site-packages>/xinference/model/llm/llm_family.json'
json.dump([x for x in json.load(open(p)) if 'model_specs' in x], open(p, 'w'))

Suggested fix

Two things, independent of each other:

  1. Fix whatever appends non-LLM entries to llm_family.json during the release build.
  2. Make load_model_family_from_json fail loudly with the offending model name rather than a bare
    KeyError, and consider skipping entries that do not match the expected shape, so one bad entry
    cannot make the whole package unimportable:
for json_obj in json.load(codecs.open(json_path, "r", encoding="utf-8")):
    if "model_specs" not in json_obj:
        raise ValueError(
            f"{json_filename}: entry {json_obj.get('model_name')!r} has no 'model_specs'"
        )

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstale

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions