Skip to content

Commit 99472d4

Browse files
committed
init
1 parent a0f1a41 commit 99472d4

11 files changed

Lines changed: 68 additions & 37 deletions

File tree

demos/common/export_models/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ Some of the exceptions include:
5555

5656
### Text Generation Models
5757

58-
#### Text Generation CPU Deployment
58+
When `--target_device` is omitted, no device field is written to the graph configuration and OVMS auto-detects the best available device at startup. Pass `--target_device` explicitly to pin execution to a specific device.
59+
60+
#### Text Generation (Auto-detected Device)
5961
```console
6062
python export_model.py text_generation --source_model meta-llama/Meta-Llama-3-8B-Instruct --weight-format fp16 --kv_cache_precision u8 --config_file_path models/config_all.json --model_repository_path models
6163
```

demos/common/export_models/export_model.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def add_common_arguments(parser):
3030
parser.add_argument('--weight-format', default='int8', help='precision of the exported model', dest='precision')
3131
parser.add_argument('--config_file_path', default='config.json', help='path to the config file', dest='config_file_path')
3232
parser.add_argument('--overwrite_models', default=False, action='store_true', help='Overwrite the model if it already exists in the models repository', dest='overwrite_models')
33-
parser.add_argument('--target_device', default="CPU", help='CPU, GPU, NPU or HETERO, default is CPU', dest='target_device')
33+
parser.add_argument('--target_device', default=None, help='CPU, GPU, NPU or HETERO. When not specified the server will auto-detect the best available device at startup.', dest='target_device')
3434
parser.add_argument('--ov_cache_dir', default=None, help='Folder path for compilation cache to speedup initialization time', dest='ov_cache_dir')
3535
parser.add_argument('--extra_quantization_params', required=False, help='Add advanced quantization parameters. Check optimum-intel documentation. Example: "--sym --group-size -1 --ratio 1.0 --awq --scale-estimation --dataset wikitext2"', dest='extra_quantization_params')
3636

@@ -240,12 +240,14 @@ def add_common_arguments(parser):
240240
max_num_batched_tokens: {{max_num_batched_tokens}},{% endif %}
241241
{%- if not dynamic_split_fuse %}
242242
dynamic_split_fuse: false, {% endif %}
243-
max_num_seqs: {% if draft_eagle3_mode %}1{% else %}{{max_num_seqs|default("256", true)}}{% endif %},
244-
device: "{{target_device|default("CPU", true)}}",
243+
max_num_seqs: {{max_num_seqs|default("256", true)}},
244+
{%- if target_device %}
245+
device: "{{target_device}}",{% endif %}
245246
{%- if draft_model_dir_name %}
246247
# Speculative decoding configuration
247248
draft_models_path: "./{{draft_model_dir_name}}",
248-
draft_device: "{{target_device|default("CPU", true)}}",
249+
{%- if target_device %}
250+
draft_device: "{{target_device}}",{% endif %}
249251
draft_eagle3_mode: {{draft_eagle3_mode|default(false)}},{% endif %}
250252
{%- if reasoning_parser %}
251253
reasoning_parser: "{{reasoning_parser}}",{% endif %}
@@ -458,7 +460,7 @@ def export_text_generation_model(model_repository_path, source_model, model_name
458460
plugin_config['prompt_lookup'] = True
459461

460462
# Additional plugin properties for HETERO
461-
if "HETERO" in task_parameters['target_device']:
463+
if task_parameters['target_device'] and "HETERO" in task_parameters['target_device']:
462464
plugin_config['MODEL_DISTRIBUTION_POLICY'] = 'PIPELINE_PARALLEL'
463465

464466
if task_parameters['target_device'] == 'NPU':

demos/continuous_batching/accuracy/README.md

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ Example of LLM and VLM models deployment is documented in other demos like
2525
## Running the tests for LLM models
2626

2727
```text
28-
lm-eval --model local-chat-completions --tasks gsm8k --model_args model=meta-llama/Meta-Llama-3.1-8B-Instruct,base_url=http://localhost:8000/v3/chat/completions,num_concurrent=1,max_retries=3,tokenized_requests=False --verbosity DEBUG --log_samples --output_path test/ --seed 1 --apply_chat_template --limit 100
28+
lm-eval --model local-chat-completions --tasks gsm8k --model_args model=meta-llama/Meta-Llama-3.1-8B-Instruct,base_url=http://localhost:8000/v1/chat/completions,num_concurrent=1,max_retries=3,tokenized_requests=False --verbosity DEBUG --log_samples --output_path test/ --seed 1 --apply_chat_template --limit 100
2929
30-
local-chat-completions ({'model': 'meta-llama/Meta-Llama-3.1-8B-Instruct', 'base_url': 'http://localhost:8000/v3/chat/completions', 'num_concurrent': 10, 'max_retries': 3, 'tokenized_requests': False}), gen_kwargs: ({}), limit: 100.0, num_fewshot: None, batch_size: 1
30+
local-chat-completions ({'model': 'meta-llama/Meta-Llama-3.1-8B-Instruct', 'base_url': 'http://localhost:8000/v1/chat/completions', 'num_concurrent': 10, 'max_retries': 3, 'tokenized_requests': False}), gen_kwargs: ({}), limit: 100.0, num_fewshot: None, batch_size: 1
3131
|Tasks|Version| Filter |n-shot| Metric | |Value| |Stderr|
3232
|-----|------:|----------------|-----:|-----------|---|----:|---|-----:|
3333
|gsm8k| 3|flexible-extract| 5|exact_match|↑ | 0.62|± |0.0488|
@@ -37,9 +37,9 @@ local-chat-completions ({'model': 'meta-llama/Meta-Llama-3.1-8B-Instruct', 'base
3737
While testing the non chat model and `completion` endpoint, the command would look like this:
3838

3939
```text
40-
lm-eval --model local-completions --tasks gsm8k --model_args model=meta-llama/Meta-Llama-3.1-8B,base_url=http://localhost:8000/v3/completions,num_concurrent=1,max_retries=3,tokenized_requests=False --verbosity DEBUG --log_samples --output_path results/ --seed 1 --limit 100
40+
lm-eval --model local-completions --tasks gsm8k --model_args model=meta-llama/Meta-Llama-3.1-8B,base_url=http://localhost:8000/v1/completions,num_concurrent=1,max_retries=3,tokenized_requests=False --verbosity DEBUG --log_samples --output_path results/ --seed 1 --limit 100
4141
42-
local-completions ({'model': 'meta-llama/Meta-Llama-3.1-8B', 'base_url': 'http://localhost:8000/v3/completions', 'num_concurrent': 10, 'max_retries': 3, 'tokenized_requests': False}), gen_kwargs: ({}), limit: 100.0, num_fewshot: None, batch_size: 1
42+
local-completions ({'model': 'meta-llama/Meta-Llama-3.1-8B', 'base_url': 'http://localhost:8000/v1/completions', 'num_concurrent': 10, 'max_retries': 3, 'tokenized_requests': False}), gen_kwargs: ({}), limit: 100.0, num_fewshot: None, batch_size: 1
4343
|Tasks|Version| Filter |n-shot| Metric | |Value| |Stderr|
4444
|-----|------:|----------------|-----:|-----------|---|----:|---|-----:|
4545
|gsm8k| 3|flexible-extract| 5|exact_match|↑ | 0.43|± |0.0498|
@@ -49,19 +49,19 @@ local-completions ({'model': 'meta-llama/Meta-Llama-3.1-8B', 'base_url': 'http:/
4949
Other examples are below:
5050

5151
```text
52-
lm-eval --model local-chat-completions --tasks leaderboard_ifeval --model_args model=meta-llama/Meta-Llama-3.1-8B-Instruct,base_url=http://localhost:8000/v3/chat/completions,num_concurrent=10,max_retries=3,tokenized_requests=False --verbosity DEBUG --log_samples --output_path test/ --seed 1 --limit 100 --apply_chat_template
52+
lm-eval --model local-chat-completions --tasks leaderboard_ifeval --model_args model=meta-llama/Meta-Llama-3.1-8B-Instruct,base_url=http://localhost:8000/v1/chat/completions,num_concurrent=10,max_retries=3,tokenized_requests=False --verbosity DEBUG --log_samples --output_path test/ --seed 1 --limit 100 --apply_chat_template
5353
```
5454

5555
```text
56-
lm-eval --model local-completions --tasks wikitext --model_args model=meta-llama/Meta-Llama-3.1-8B,base_url=http://localhost:8000/v3/completions,num_concurrent=10,max_retries=3,tokenized_requests=False --verbosity DEBUG --log_samples --output_path test/ --seed 1 --limit 100
56+
lm-eval --model local-completions --tasks wikitext --model_args model=meta-llama/Meta-Llama-3.1-8B,base_url=http://localhost:8000/v1/completions,num_concurrent=10,max_retries=3,tokenized_requests=False --verbosity DEBUG --log_samples --output_path test/ --seed 1 --limit 100
5757
```
5858

5959
## Running the tests for VLM models
6060

6161
Use [lmms-eval project](https://github.com/EvolvingLMMs-Lab/lmms-eval) - mme and mmmu_val tasks.
6262

6363
```text
64-
export OPENAI_BASE_URL=http://localhost:8000/v3
64+
export OPENAI_BASE_URL=http://localhost:8000/v1
6565
export OPENAI_API_KEY="unused"
6666
git clone https://github.com/EvolvingLMMs-Lab/lmms-eval
6767
cd lmms-eval
@@ -103,7 +103,7 @@ pip install -e . --extra-index-url "https://download.pytorch.org/whl/cpu"
103103
```
104104
The commands below assumes the models is deployed with the name `ovms-model`. It must match the name set in the `bfcl_eval/constants/model_config.py`.
105105
```text
106-
export OPENAI_BASE_URL=http://localhost:8000/v3
106+
export OPENAI_BASE_URL=http://localhost:8000/v1
107107
export CHAT_TEMPLATE_KWARGS='{"enable_thinking":false, "reasoning_effort":"low", "preserve_reasoning":false}'
108108
109109
bfcl generate --model ovms-model --test-category simple_python,multiple,multi_turn_base --temperature 0.0 --num-threads 10 -o --result-dir model_name_dir
@@ -112,7 +112,7 @@ bfcl evaluate --model ovms-model --result-dir model_name_dir
112112

113113
Alternatively, use the model name `ovms-model-stream` to run the tests with stream requests. The results should be the same.
114114
```text
115-
export OPENAI_BASE_URL=http://localhost:8000/v3
115+
export OPENAI_BASE_URL=http://localhost:8000/v1
116116
bfcl generate --model ovms-model-stream --test-category simple_python,multiple,multi_turn_base --temperature 0.0 --num-threads 10 -o --result-dir model_name_dir
117117
bfcl evaluate --model ovms-model-stream --result-dir model_name_dir
118118
```
@@ -127,8 +127,3 @@ cat score/openvino-qwen3-8b-int4-FC/BFCL_v4_simple_python_score.json | head -1
127127
Those results can be compared with the reference from the [berkeley leaderbaord](https://gorilla.cs.berkeley.edu/leaderboard.html#leaderboard).
128128

129129
---
130-
131-
> **Note:** The same procedure can be used to validate vLLM component. The only needed change would be updating base_url including replacing `/v3/` with `/v1/`.
132-
133-
134-

demos/continuous_batching/speculative_decoding/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,12 @@ models
9090

9191
:::{dropdown} **Deploying with Docker**
9292
```bash
93-
docker run -d --rm -p 8000:8000 -v $(pwd)/models:/workspace:ro openvino/model_server:weekly --rest_port 8000 --config_path /workspace/config.json
93+
docker run -d --rm $(test -d /dev/dri && echo "--device /dev/dri --group-add $(stat -c '%g' /dev/dri/render* | head -n1)") \
94+
-p 8000:8000 -v $(pwd)/models:/workspace:ro openvino/model_server:weekly \
95+
--rest_port 8000 --config_path /workspace/config.json
9496
```
9597

96-
Running above command starts the container with no accelerators support.
97-
To deploy on devices other than CPU, change `target_device` parameter in `export_model.py` call and follow [AI accelerators guide](../../../docs/accelerators.md) for additionally required docker parameters.
98+
OVMS auto-detects the best available device at startup. To target a specific device explicitly, pass `--target_device GPU` (or `NPU`, `HETERO:GPU,CPU`, etc.) to `export_model.py` and follow the [AI accelerators guide](../../../docs/accelerators.md) for additionally required docker parameters.
9899
:::
99100

100101
:::{dropdown} **Deploying on Bare Metal**
@@ -119,7 +120,7 @@ Let's check how the deployed model is doing by running performance test. For tha
119120

120121
Install vLLM and download sonnet dataset:
121122
```bash
122-
pip install vllm --extra-index-url https://wheels.vllm.ai/nightly/cpu
123+
pip install vllm --index-url https://wheels.vllm.ai/nightly/cpu --extra-index-url https://pypi.org/simple
123124
curl https://raw.githubusercontent.com/vllm-project/vllm/refs/heads/main/benchmarks/sonnet.txt -o sonnet.txt
124125
```
125126

@@ -287,8 +288,7 @@ models
287288
docker run -d --rm -p 8000:8000 -v $(pwd)/models:/workspace:ro openvino/model_server:latest --rest_port 8000 --config_path /workspace/config.json
288289
```
289290

290-
Running above command starts the container with no accelerators support.
291-
To deploy on devices other than CPU, change `target_device` parameter in `export_model.py` call and follow [AI accelerators guide](../../../docs/accelerators.md) for additionally required docker parameters.
291+
OVMS auto-detects the best available device at startup. To target a specific device explicitly, pass `--target_device GPU` (or `NPU`, `HETERO:GPU,CPU`, etc.) to `export_model.py` and follow the [AI accelerators guide](../../../docs/accelerators.md) for additionally required docker parameters.
292292
:::
293293

294294
:::{dropdown} **Deploying on Bare Metal**

docs/parameters.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,10 @@ Task specific parameters for different tasks (text generation/image generation/e
147147
| `--enable_prefix_caching` | `bool` | Enables algorithm to cache the prompt tokens. Default: true. |
148148
| `--max_num_batched_tokens` | `integer` | The maximum number of tokens that can be batched together. |
149149
| `--cache_size` | `integer` | KV Cache size in GB. Default: 0 which is a dynamic allocation. |
150-
| `--draft_source_model` | `string` | HF model name or path to the local folder with PyTorch or OpenVINO draft model. |
150+
| `--draft_source_model` | `string` | HF model name or path to the local folder with PyTorch or OpenVINO draft model. Mutually exclusive with `--draft_model_path`. |
151+
| `--draft_model_path` | `string` | Absolute path to an already-exported OpenVINO draft model directory. Use for local models instead of `--draft_source_model`. |
152+
| `--draft_eagle3_mode` | `bool` | Enable EAGLE3 speculative decoding for the draft model. Default: false. |
153+
| `--draft_device` | `string` | Device to run the draft model on. Defaults to the same device as the main model. |
151154
| `--dynamic_split_fuse` | `bool` | Enables dynamic split fuse algorithm. Default: true. |
152155
| `--max_prompt_len` | `integer` | Sets NPU specific property for maximum number of tokens in the prompt. |
153156
| `--kv_cache_precision` | `string` | Reduced kv cache precision to `u8` lowers the cache size consumption. Accepted values: `u8` or empty (default). |

src/capi_frontend/server_settings.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ struct TextGenGraphSettingsImpl {
122122
std::optional<uint32_t> maxNumBatchedTokens;
123123
std::optional<std::string> draftModelDirName;
124124
bool draftEagle3Mode = false;
125+
std::optional<std::string> draftDevice;
126+
std::optional<std::string> draftModelPath;
125127
std::optional<std::string> pipelineType;
126128
std::optional<std::string> reasoningParser;
127129
std::optional<std::string> toolParser;

src/graph_export/graph_cli_parser.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,18 @@ void GraphCLIParser::createOptions() {
6565
"HF model name or path to the local folder with PyTorch or OpenVINO draft model.",
6666
cxxopts::value<std::string>(),
6767
"DRAFT_SOURCE_MODEL")
68+
("draft_model_path",
69+
"Absolute path to an already-exported OpenVINO draft model directory (use instead of --draft_source_model for local models).",
70+
cxxopts::value<std::string>(),
71+
"DRAFT_MODEL_PATH")
6872
("draft_eagle3_mode",
6973
"Enable EAGLE3 speculative decoding mode for the draft model.",
7074
cxxopts::value<bool>()->default_value("false")->implicit_value("true"),
7175
"DRAFT_EAGLE3_MODE")
76+
("draft_device",
77+
"Device to run the draft model on. Defaults to the same device as the main model.",
78+
cxxopts::value<std::string>(),
79+
"DRAFT_DEVICE")
7280
("dynamic_split_fuse",
7381
"Dynamic split fuse algorithm enabled. Default true.",
7482
cxxopts::value<std::string>()->default_value("true"),
@@ -152,9 +160,17 @@ void GraphCLIParser::prepare(OvmsServerMode serverMode, HFSettingsImpl& hfSettin
152160
if (result->count("draft_source_model")) {
153161
graphSettings.draftModelDirName = result->operator[]("draft_source_model").as<std::string>();
154162
}
163+
if (result->count("draft_model_path")) {
164+
if (result->count("draft_source_model"))
165+
throw std::invalid_argument("--draft_model_path and --draft_source_model are mutually exclusive");
166+
graphSettings.draftModelPath = result->operator[]("draft_model_path").as<std::string>();
167+
}
155168
if (result->count("draft_eagle3_mode")) {
156169
graphSettings.draftEagle3Mode = result->operator[]("draft_eagle3_mode").as<bool>();
157170
}
171+
if (result->count("draft_device")) {
172+
graphSettings.draftDevice = result->operator[]("draft_device").as<std::string>();
173+
}
158174
if (result->count("pipeline_type")) {
159175
graphSettings.pipelineType = result->operator[]("pipeline_type").as<std::string>();
160176
}

src/graph_export/graph_export.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,20 @@ static Status createTextGenerationGraphTemplate(const std::string& directoryPath
217217
oss << R"(
218218
dynamic_split_fuse: false,)";
219219
}
220-
if (graphSettings.draftModelDirName.has_value()) {
220+
if (graphSettings.draftModelDirName.has_value() || graphSettings.draftModelPath.has_value()) {
221221
oss << R"(
222222
# Speculative decoding configuration)";
223-
oss << R"(
223+
if (graphSettings.draftModelPath.has_value()) {
224+
oss << R"(
225+
draft_models_path: ")" << graphSettings.draftModelPath.value() << R"(",)";
226+
} else {
227+
oss << R"(
224228
draft_models_path: ")" << GraphExport::getDraftModelDirectoryName(graphSettings.draftModelDirName.value()) << R"(",)";
229+
}
230+
if (graphSettings.draftDevice.has_value()) {
231+
oss << R"(
232+
draft_device: ")" << graphSettings.draftDevice.value() << R"(",)";
233+
}
225234
if (graphSettings.draftEagle3Mode) {
226235
oss << R"(
227236
draft_eagle3_mode: true,)";

0 commit comments

Comments
 (0)