xinference 0.10.3__py3-none-any.whl → 0.11.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of xinference might be problematic. Click here for more details.
- xinference/_version.py +3 -3
- xinference/api/oauth2/auth_service.py +1 -1
- xinference/api/restful_api.py +53 -61
- xinference/client/restful/restful_client.py +52 -57
- xinference/conftest.py +1 -1
- xinference/core/cache_tracker.py +1 -1
- xinference/core/event.py +1 -1
- xinference/core/model.py +15 -4
- xinference/core/status_guard.py +1 -1
- xinference/core/supervisor.py +58 -72
- xinference/core/worker.py +68 -101
- xinference/deploy/cmdline.py +166 -1
- xinference/deploy/test/test_cmdline.py +2 -0
- xinference/deploy/utils.py +1 -1
- xinference/device_utils.py +29 -3
- xinference/fields.py +5 -1
- xinference/model/audio/whisper.py +88 -12
- xinference/model/core.py +2 -2
- xinference/model/image/__init__.py +29 -0
- xinference/model/image/core.py +6 -0
- xinference/model/image/custom.py +109 -0
- xinference/model/llm/__init__.py +92 -32
- xinference/model/llm/core.py +57 -102
- xinference/model/llm/ggml/tools/convert_ggml_to_gguf.py +2 -2
- xinference/model/llm/llm_family.json +306 -4
- xinference/model/llm/llm_family.py +45 -41
- xinference/model/llm/llm_family_modelscope.json +119 -2
- xinference/model/llm/pytorch/deepseek_vl.py +89 -33
- xinference/model/llm/pytorch/qwen_vl.py +67 -12
- xinference/model/llm/pytorch/yi_vl.py +62 -45
- xinference/model/llm/utils.py +29 -15
- xinference/model/llm/vllm/core.py +19 -4
- xinference/thirdparty/omnilmm/chat.py +2 -1
- xinference/thirdparty/omnilmm/model/omnilmm.py +2 -1
- xinference/types.py +2 -0
- xinference/web/ui/build/asset-manifest.json +6 -3
- xinference/web/ui/build/index.html +1 -1
- xinference/web/ui/build/static/css/main.54bca460.css +2 -0
- xinference/web/ui/build/static/css/main.54bca460.css.map +1 -0
- xinference/web/ui/build/static/js/main.8e44da4b.js +3 -0
- xinference/web/ui/build/static/js/{main.26fdbfbe.js.LICENSE.txt → main.8e44da4b.js.LICENSE.txt} +7 -0
- xinference/web/ui/build/static/js/main.8e44da4b.js.map +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/0b11a5339468c13b2d31ac085e7effe4303259b2071abd46a0a8eb8529233a5e.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/29dda700ab913cf7f2cfabe450ddabfb283e96adfa3ec9d315b2fa6c63cd375c.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/2c63e940b945fd5817157e08a42b889b30d668ea4c91332f48ef2b1b9d26f520.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/4135fe8745434cbce6438d1ebfa47422e0c77d884db4edc75c8bf32ea1d50621.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/46b6dd1f6d1109cd0e2455a0ea0be3e9bda1097cd4ebec9c4040070372671cfc.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/4de0a71074f9cbe1e7862750dcdd08cbc1bae7d9d9849a78b1783ca670017b3c.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/53f6c0c0afb51265cd8fb940daeb65523501879ac2a8c03a1ead22b9793c5041.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/8ccbb839002bc5bc03e0a0e7612362bf92f6ae64f87e094f8682d6a6fe4619bb.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/97ed30d6e22cf76f0733651e2c18364689a01665d0b5fe811c1b7ca3eb713c82.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/9c0c70f1838913aaa792a0d2260f17f90fd177b95698ed46b7bc3050eb712c1c.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/9cfd33238ca43e5bf9fc7e442690e8cc6027c73553db36de87e3597ed524ee4b.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/ada71518a429f821a9b1dea38bc951447f03c8db509887e0980b893acac938f3.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/b6c9558d28b5972bb8b2691c5a76a2c8814a815eb3443126da9f49f7d6a0c118.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/bb0f721c084a4d85c09201c984f02ee8437d3b6c5c38a57cb4a101f653daef1b.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/ddaec68b88e5eff792df1e39a4b4b8b737bfc832293c015660c3c69334e3cf5c.json +1 -0
- xinference/web/ui/node_modules/.package-lock.json +33 -0
- xinference/web/ui/node_modules/clipboard/.babelrc.json +11 -0
- xinference/web/ui/node_modules/clipboard/.eslintrc.json +24 -0
- xinference/web/ui/node_modules/clipboard/.prettierrc.json +9 -0
- xinference/web/ui/node_modules/clipboard/bower.json +18 -0
- xinference/web/ui/node_modules/clipboard/composer.json +25 -0
- xinference/web/ui/node_modules/clipboard/package.json +63 -0
- xinference/web/ui/node_modules/delegate/package.json +31 -0
- xinference/web/ui/node_modules/good-listener/bower.json +11 -0
- xinference/web/ui/node_modules/good-listener/package.json +35 -0
- xinference/web/ui/node_modules/select/bower.json +13 -0
- xinference/web/ui/node_modules/select/package.json +29 -0
- xinference/web/ui/node_modules/tiny-emitter/package.json +53 -0
- xinference/web/ui/package-lock.json +34 -0
- xinference/web/ui/package.json +1 -0
- {xinference-0.10.3.dist-info → xinference-0.11.0.dist-info}/METADATA +11 -11
- {xinference-0.10.3.dist-info → xinference-0.11.0.dist-info}/RECORD +78 -57
- xinference/client/oscar/__init__.py +0 -13
- xinference/client/oscar/actor_client.py +0 -611
- xinference/model/llm/pytorch/spec_decoding_utils.py +0 -531
- xinference/model/llm/pytorch/spec_model.py +0 -186
- xinference/web/ui/build/static/js/main.26fdbfbe.js +0 -3
- xinference/web/ui/build/static/js/main.26fdbfbe.js.map +0 -1
- xinference/web/ui/node_modules/.cache/babel-loader/63a4c48f0326d071c7772c46598215c006ae41fd3d4ff3577fe717de66ad6e89.json +0 -1
- xinference/web/ui/node_modules/.cache/babel-loader/de0299226173b0662b573f49e3992220f6611947073bd66ac079728a8bc8837d.json +0 -1
- xinference/web/ui/node_modules/.cache/babel-loader/e9b52d171223bb59fb918316297a051cdfd42dd453e8260fd918e90bc0a4ebdf.json +0 -1
- xinference/web/ui/node_modules/.cache/babel-loader/f4d5d1a41892a754c1ee0237450d804b20612d1b657945b59e564161ea47aa7a.json +0 -1
- xinference/web/ui/node_modules/.cache/babel-loader/fad4cd70de36ef6e6d5f8fd74a10ded58d964a8a91ef7681693fbb8376552da7.json +0 -1
- {xinference-0.10.3.dist-info → xinference-0.11.0.dist-info}/LICENSE +0 -0
- {xinference-0.10.3.dist-info → xinference-0.11.0.dist-info}/WHEEL +0 -0
- {xinference-0.10.3.dist-info → xinference-0.11.0.dist-info}/entry_points.txt +0 -0
- {xinference-0.10.3.dist-info → xinference-0.11.0.dist-info}/top_level.txt +0 -0
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
# Copyright 2022-2023 XProbe Inc.
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
14
|
-
|
|
15
|
-
import logging
|
|
16
|
-
from typing import Iterator, List, Optional, Union
|
|
17
|
-
|
|
18
|
-
from ....device_utils import (
|
|
19
|
-
get_device_preferred_dtype,
|
|
20
|
-
gpu_count,
|
|
21
|
-
is_hf_accelerate_supported,
|
|
22
|
-
)
|
|
23
|
-
from ....types import Completion, CompletionChunk, Embedding
|
|
24
|
-
from ...utils import select_device
|
|
25
|
-
from .. import LLMFamilyV1, LLMSpecV1
|
|
26
|
-
from .core import PytorchChatModel, PytorchGenerateConfig, PytorchModelConfig
|
|
27
|
-
|
|
28
|
-
logger = logging.getLogger(__name__)
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
class SpeculativeModel(PytorchChatModel):
|
|
32
|
-
def __init__(
|
|
33
|
-
self,
|
|
34
|
-
model_uid: str,
|
|
35
|
-
model_family: "LLMFamilyV1",
|
|
36
|
-
model_spec: "LLMSpecV1",
|
|
37
|
-
quantization: str,
|
|
38
|
-
model_path: str,
|
|
39
|
-
draft_model_family: "LLMFamilyV1",
|
|
40
|
-
draft_model_spec: "LLMSpecV1",
|
|
41
|
-
draft_quantization: str,
|
|
42
|
-
draft_model_path: str,
|
|
43
|
-
):
|
|
44
|
-
super().__init__(model_uid, model_family, model_spec, quantization, model_path)
|
|
45
|
-
self._pytorch_model_config: PytorchModelConfig = self._sanitize_model_config(
|
|
46
|
-
PytorchModelConfig()
|
|
47
|
-
)
|
|
48
|
-
self._draft_model_family = draft_model_family
|
|
49
|
-
self._draft_model_spec = draft_model_spec
|
|
50
|
-
self._draft_quantization = draft_quantization
|
|
51
|
-
self._draft_model_path = draft_model_path
|
|
52
|
-
|
|
53
|
-
def _load_model(self, model_path, **kwargs):
|
|
54
|
-
try:
|
|
55
|
-
from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
56
|
-
except ImportError:
|
|
57
|
-
error_message = "Failed to import module 'transformers'"
|
|
58
|
-
installation_guide = [
|
|
59
|
-
"Please make sure 'transformers' is installed. ",
|
|
60
|
-
"You can install it by `pip install transformers`\n",
|
|
61
|
-
]
|
|
62
|
-
|
|
63
|
-
raise ImportError(f"{error_message}\n\n{''.join(installation_guide)}")
|
|
64
|
-
|
|
65
|
-
tokenizer = AutoTokenizer.from_pretrained(
|
|
66
|
-
model_path,
|
|
67
|
-
use_fast=self._use_fast_tokenizer,
|
|
68
|
-
trust_remote_code=kwargs["trust_remote_code"],
|
|
69
|
-
revision=kwargs["revision"],
|
|
70
|
-
)
|
|
71
|
-
model = AutoModelForCausalLM.from_pretrained(
|
|
72
|
-
model_path,
|
|
73
|
-
low_cpu_mem_usage=True,
|
|
74
|
-
**kwargs,
|
|
75
|
-
)
|
|
76
|
-
return model, tokenizer
|
|
77
|
-
|
|
78
|
-
def load(self):
|
|
79
|
-
try:
|
|
80
|
-
import torch # noqa: F401
|
|
81
|
-
except ImportError:
|
|
82
|
-
raise ImportError(
|
|
83
|
-
f"Failed to import module 'torch'. Please make sure 'torch' is installed.\n\n"
|
|
84
|
-
)
|
|
85
|
-
|
|
86
|
-
num_gpus = gpu_count()
|
|
87
|
-
device = self._pytorch_model_config.get("device", "auto")
|
|
88
|
-
self._pytorch_model_config["device"] = select_device(device)
|
|
89
|
-
self._device = self._pytorch_model_config["device"]
|
|
90
|
-
|
|
91
|
-
kwargs = {}
|
|
92
|
-
|
|
93
|
-
dtype = get_device_preferred_dtype(self._device)
|
|
94
|
-
|
|
95
|
-
if dtype is not None:
|
|
96
|
-
kwargs["torch_dtype"] = dtype
|
|
97
|
-
else:
|
|
98
|
-
raise ValueError(f"Device {self._device} is not supported in temporary")
|
|
99
|
-
|
|
100
|
-
kwargs["trust_remote_code"] = self._pytorch_model_config.get(
|
|
101
|
-
"trust_remote_code"
|
|
102
|
-
)
|
|
103
|
-
|
|
104
|
-
if self.quantization != "none":
|
|
105
|
-
raise ValueError(
|
|
106
|
-
"Quantization is not supported by speculative decoding yet"
|
|
107
|
-
)
|
|
108
|
-
|
|
109
|
-
is_device_map_auto = False
|
|
110
|
-
|
|
111
|
-
if num_gpus > 0 and is_hf_accelerate_supported(self._device):
|
|
112
|
-
kwargs.update({"device_map": "auto"})
|
|
113
|
-
is_device_map_auto = True
|
|
114
|
-
|
|
115
|
-
self._model, self._tokenizer = self._load_model(
|
|
116
|
-
model_path=self.model_path,
|
|
117
|
-
revision=self.model_spec.model_revision,
|
|
118
|
-
**kwargs,
|
|
119
|
-
)
|
|
120
|
-
if not is_device_map_auto:
|
|
121
|
-
self._model.to(self._device)
|
|
122
|
-
logger.debug(
|
|
123
|
-
f"Model {self.model_uid} memory footprint: {self._model.get_memory_footprint()}"
|
|
124
|
-
)
|
|
125
|
-
|
|
126
|
-
self._draft_model, _ = self._load_model(
|
|
127
|
-
model_path=self._draft_model_path,
|
|
128
|
-
revision=self._draft_model_spec.model_revision,
|
|
129
|
-
**kwargs,
|
|
130
|
-
)
|
|
131
|
-
if not is_device_map_auto:
|
|
132
|
-
self._model.to(self._device)
|
|
133
|
-
logger.debug(
|
|
134
|
-
f"Draft model {self.model_uid} memory footprint: {self._model.get_memory_footprint()}"
|
|
135
|
-
)
|
|
136
|
-
|
|
137
|
-
def generate(
|
|
138
|
-
self, prompt: str, generate_config: Optional[PytorchGenerateConfig] = None
|
|
139
|
-
) -> Union[Completion, Iterator[CompletionChunk]]:
|
|
140
|
-
def generator_wrapper(
|
|
141
|
-
_prompt: str, _generate_config: PytorchGenerateConfig
|
|
142
|
-
) -> Iterator[CompletionChunk]:
|
|
143
|
-
for _completion_chunk, _completion_usage in speculative_generate_stream(
|
|
144
|
-
model_uid=self.model_uid,
|
|
145
|
-
draft_model=self._draft_model,
|
|
146
|
-
model=self._model,
|
|
147
|
-
tokenizer=self._tokenizer,
|
|
148
|
-
prompt=_prompt,
|
|
149
|
-
generate_config=_generate_config,
|
|
150
|
-
):
|
|
151
|
-
yield _completion_chunk
|
|
152
|
-
|
|
153
|
-
from .spec_decoding_utils import speculative_generate_stream
|
|
154
|
-
|
|
155
|
-
generate_config = self._sanitize_generate_config(generate_config)
|
|
156
|
-
|
|
157
|
-
assert self._draft_model is not None
|
|
158
|
-
assert self._model is not None
|
|
159
|
-
assert self._tokenizer is not None
|
|
160
|
-
|
|
161
|
-
stream = generate_config.get("stream", False)
|
|
162
|
-
if not stream:
|
|
163
|
-
for completion_chunk, completion_usage in speculative_generate_stream(
|
|
164
|
-
model_uid=self.model_uid,
|
|
165
|
-
draft_model=self._draft_model,
|
|
166
|
-
model=self._model,
|
|
167
|
-
tokenizer=self._tokenizer,
|
|
168
|
-
prompt=prompt,
|
|
169
|
-
generate_config=generate_config,
|
|
170
|
-
):
|
|
171
|
-
pass
|
|
172
|
-
|
|
173
|
-
completion = Completion(
|
|
174
|
-
id=completion_chunk["id"],
|
|
175
|
-
object=completion_chunk["object"],
|
|
176
|
-
created=completion_chunk["created"],
|
|
177
|
-
model=completion_chunk["model"],
|
|
178
|
-
choices=completion_chunk["choices"],
|
|
179
|
-
usage=completion_usage,
|
|
180
|
-
)
|
|
181
|
-
return completion
|
|
182
|
-
else:
|
|
183
|
-
return generator_wrapper(prompt, generate_config)
|
|
184
|
-
|
|
185
|
-
def create_embedding(self, input: Union[str, List[str]]) -> Embedding:
|
|
186
|
-
raise NotImplementedError
|