2021-07-27 00:49:37 +08:00
|
|
|
[role="xpack"]
|
|
|
|
[[start-trained-model-deployment]]
|
|
|
|
= Start trained model deployment API
|
|
|
|
[subs="attributes"]
|
|
|
|
++++
|
|
|
|
<titleabbrev>Start trained model deployment</titleabbrev>
|
|
|
|
++++
|
|
|
|
|
2021-09-28 00:46:13 +08:00
|
|
|
Starts a new trained model deployment.
|
|
|
|
|
2022-05-06 04:49:02 +08:00
|
|
|
preview::[]
|
|
|
|
|
2021-07-27 00:49:37 +08:00
|
|
|
[[start-trained-model-deployment-request]]
|
|
|
|
== {api-request-title}
|
|
|
|
|
2021-11-05 05:23:03 +08:00
|
|
|
`POST _ml/trained_models/<model_id>/deployment/_start`
|
2021-09-28 00:46:13 +08:00
|
|
|
|
2021-07-27 00:49:37 +08:00
|
|
|
[[start-trained-model-deployment-prereq]]
|
|
|
|
== {api-prereq-title}
|
2021-09-28 00:46:13 +08:00
|
|
|
Requires the `manage_ml` cluster privilege. This privilege is included in the
|
|
|
|
`machine_learning_admin` built-in role.
|
2021-07-27 00:49:37 +08:00
|
|
|
|
|
|
|
[[start-trained-model-deployment-desc]]
|
|
|
|
== {api-description-title}
|
|
|
|
|
2021-09-28 00:46:13 +08:00
|
|
|
Currently only `pytorch` models are supported for deployment. When deployed,
|
2022-01-11 16:50:45 +08:00
|
|
|
the model attempts allocation to every machine learning node. Once deployed
|
|
|
|
the model can be used by the <<inference-processor,{infer-cap} processor>>
|
2022-05-06 02:58:59 +08:00
|
|
|
in an ingest pipeline or directly in the <<infer-trained-model>> API.
|
2021-07-27 00:49:37 +08:00
|
|
|
|
|
|
|
[[start-trained-model-deployment-path-params]]
|
|
|
|
== {api-path-parms-title}
|
|
|
|
|
|
|
|
`<model_id>`::
|
|
|
|
(Required, string)
|
|
|
|
include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=model-id]
|
|
|
|
|
|
|
|
[[start-trained-model-deployment-query-params]]
|
|
|
|
== {api-query-parms-title}
|
|
|
|
|
2022-05-10 22:41:00 +08:00
|
|
|
`number_of_allocations`::
|
2021-10-28 23:23:25 +08:00
|
|
|
(Optional, integer)
|
2022-05-10 22:41:00 +08:00
|
|
|
The number of model allocations on each node where the model is deployed.
|
|
|
|
All allocations on a node share the same copy of the model in memory but use
|
|
|
|
a separate set of threads to evaluate the model.
|
2021-12-14 21:07:34 +08:00
|
|
|
Increasing this value generally increases the throughput.
|
|
|
|
If this setting is greater than the number of hardware threads
|
|
|
|
it will automatically be changed to a value less than the number of hardware threads.
|
|
|
|
Defaults to 1.
|
|
|
|
|
|
|
|
[NOTE]
|
|
|
|
=============================================
|
2022-05-10 22:41:00 +08:00
|
|
|
If the sum of `threads_per_allocation` and `number_of_allocations` is greater than the number of
|
2022-03-18 15:41:27 +08:00
|
|
|
hardware threads then the number of `inference_threads` will be reduced.
|
2021-12-14 21:07:34 +08:00
|
|
|
=============================================
|
2021-11-25 02:09:45 +08:00
|
|
|
|
2021-10-28 23:23:25 +08:00
|
|
|
`queue_capacity`::
|
|
|
|
(Optional, integer)
|
2022-01-11 16:50:45 +08:00
|
|
|
Controls how many inference requests are allowed in the queue at a time.
|
|
|
|
Every machine learning node in the cluster where the model can be allocated
|
|
|
|
has a queue of this size; when the number of requests exceeds the total value,
|
|
|
|
new requests are rejected with a 429 error. Defaults to 1024.
|
2021-10-28 23:23:25 +08:00
|
|
|
|
2022-05-10 22:41:00 +08:00
|
|
|
`threads_per_allocation`::
|
|
|
|
(Optional, integer)
|
|
|
|
Sets the number of threads used by each model allocation during inference. This generally increases
|
|
|
|
the inference speed. The inference process is a compute-bound process; any number
|
|
|
|
greater than the number of available hardware threads on the machine does not increase the
|
|
|
|
inference speed. If this setting is greater than the number of hardware threads
|
|
|
|
it will automatically be changed to a value less than the number of hardware threads.
|
|
|
|
Defaults to 1.
|
|
|
|
|
2021-11-25 02:09:45 +08:00
|
|
|
`timeout`::
|
|
|
|
(Optional, time)
|
|
|
|
Controls the amount of time to wait for the model to deploy. Defaults
|
|
|
|
to 20 seconds.
|
|
|
|
|
|
|
|
`wait_for`::
|
|
|
|
(Optional, string)
|
|
|
|
Specifies the allocation status to wait for before returning. Defaults to
|
|
|
|
`started`. The value `starting` indicates deployment is starting but not yet on
|
|
|
|
any node. The value `started` indicates the model has started on at least one
|
|
|
|
node. The value `fully_allocated` indicates the deployment has started on all
|
|
|
|
valid nodes.
|
|
|
|
|
2021-07-27 00:49:37 +08:00
|
|
|
[[start-trained-model-deployment-example]]
|
|
|
|
== {api-examples-title}
|
2021-09-08 03:23:13 +08:00
|
|
|
|
2021-09-28 00:46:13 +08:00
|
|
|
The following example starts a new deployment for a
|
2021-10-28 23:23:25 +08:00
|
|
|
`elastic__distilbert-base-uncased-finetuned-conll03-english` trained model:
|
2021-09-28 00:46:13 +08:00
|
|
|
|
|
|
|
[source,console]
|
|
|
|
--------------------------------------------------
|
|
|
|
POST _ml/trained_models/elastic__distilbert-base-uncased-finetuned-conll03-english/deployment/_start?wait_for=started&timeout=1m
|
|
|
|
--------------------------------------------------
|
|
|
|
// TEST[skip:TBD]
|
|
|
|
|
|
|
|
The API returns the following results:
|
|
|
|
|
|
|
|
[source,console-result]
|
|
|
|
----
|
|
|
|
{
|
2022-04-18 23:35:10 +08:00
|
|
|
"assignment": {
|
2021-09-28 00:46:13 +08:00
|
|
|
"task_parameters": {
|
|
|
|
"model_id": "elastic__distilbert-base-uncased-finetuned-conll03-english",
|
|
|
|
"model_bytes": 265632637
|
|
|
|
},
|
|
|
|
"routing_table": {
|
|
|
|
"uckeG3R8TLe2MMNBQ6AGrw": {
|
|
|
|
"routing_state": "started",
|
|
|
|
"reason": ""
|
|
|
|
}
|
|
|
|
},
|
2022-04-18 23:35:10 +08:00
|
|
|
"assignment_state": "started",
|
2021-11-02 23:12:46 +08:00
|
|
|
"start_time": "2021-11-02T11:50:34.766591Z"
|
2021-09-28 00:46:13 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
----
|