-
Notifications
You must be signed in to change notification settings - Fork 664
feat: allow Triton model config specification in TensorModelConfig #3874
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
6e14de4
feat: add Triton model config specification in TensorModelConfig
GuanLuo 5eef909
test: add unit test for using Triton model config
GuanLuo a4b0fdd
fix: fix message format for passing Triton model config
GuanLuo 67d14e6
fix: where to import model config
GuanLuo bd6eedb
Merge branch 'main' into gluo/model-config
GuanLuo 8b9f4e6
style: style
GuanLuo efb015d
chore: address comment
GuanLuo 1a77c6a
Merge branch 'main' into gluo/model-config
GuanLuo 3d54ce7
chore: address comment
GuanLuo 06677f4
chore: address comment
GuanLuo 3ac01a4
Merge branch 'main' into gluo/model-config
GuanLuo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,8 @@ use crate::http::service::Metrics; | |
| use crate::http::service::metrics; | ||
|
|
||
| use crate::discovery::ModelManager; | ||
| use crate::local_model::runtime_config::ModelRuntimeConfig; | ||
| use crate::protocols::tensor::TensorModelConfig; | ||
| use crate::protocols::tensor::{NvCreateTensorRequest, NvCreateTensorResponse}; | ||
| use crate::request_template::RequestTemplate; | ||
| use anyhow::Result; | ||
|
|
@@ -38,6 +40,8 @@ use inference::{ | |
| ModelMetadataRequest, ModelMetadataResponse, ModelStreamInferResponse, | ||
| }; | ||
|
|
||
| use prost::Message; | ||
|
|
||
| /// [gluo TODO] 'metrics' are for HTTP service and there is HTTP endpoint | ||
| /// for it as part of HTTP service. Should we always start HTTP service up | ||
| /// for non-inference? | ||
|
|
@@ -157,6 +161,27 @@ impl KserveServiceConfigBuilder { | |
| } | ||
| } | ||
|
|
||
| #[allow(clippy::large_enum_variant)] | ||
| enum Config { | ||
| Dynamo(TensorModelConfig), | ||
| Triton(ModelConfig), | ||
| } | ||
rmccorm4 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| impl Config { | ||
| fn from_runtime_config(runtime_config: &ModelRuntimeConfig) -> Result<Config, anyhow::Error> { | ||
| if let Some(tensor_model_config) = runtime_config.tensor_model_config.as_ref() { | ||
| if let Some(triton_model_config) = tensor_model_config.triton_model_config.as_ref() { | ||
| let model_config = ModelConfig::decode(triton_model_config.as_slice())?; | ||
| Ok(Config::Triton(model_config)) | ||
| } else { | ||
| Ok(Config::Dynamo(tensor_model_config.clone())) | ||
| } | ||
| } else { | ||
| Err(anyhow::anyhow!("no model config is provided")) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #[tonic::async_trait] | ||
| impl GrpcInferenceService for KserveService { | ||
| async fn model_infer( | ||
|
|
@@ -390,38 +415,76 @@ impl GrpcInferenceService for KserveService { | |
| .find(|card| request_model_name == &card.display_name) | ||
| { | ||
| if card.model_type.supports_tensor() { | ||
| if let Some(tensor_model_config) = card.runtime_config.tensor_model_config.as_ref() | ||
| { | ||
| return Ok(Response::new(ModelMetadataResponse { | ||
| name: tensor_model_config.name.clone(), | ||
| versions: vec!["1".to_string()], | ||
| platform: "dynamo".to_string(), | ||
| inputs: tensor_model_config | ||
| .inputs | ||
| .iter() | ||
| .map(|input| inference::model_metadata_response::TensorMetadata { | ||
| name: input.name.clone(), | ||
| datatype: input.data_type.to_string(), | ||
| shape: input.shape.clone(), | ||
| }) | ||
| .collect(), | ||
| outputs: tensor_model_config | ||
| .outputs | ||
| .iter() | ||
| .map( | ||
| |output| inference::model_metadata_response::TensorMetadata { | ||
| name: output.name.clone(), | ||
| datatype: output.data_type.to_string(), | ||
| shape: output.shape.clone(), | ||
| }, | ||
| ) | ||
| .collect(), | ||
| })); | ||
| let config = Config::from_runtime_config(&card.runtime_config).map_err(|e| { | ||
| Status::invalid_argument(format!( | ||
| "Model '{}' has type Tensor but: {}", | ||
| request_model_name, e | ||
| )) | ||
| })?; | ||
| match config { | ||
| Config::Triton(model_config) => { | ||
| return Ok(Response::new(ModelMetadataResponse { | ||
| name: model_config.name, | ||
| versions: vec!["1".to_string()], | ||
| platform: model_config.platform, | ||
| inputs: model_config | ||
| .input | ||
| .iter() | ||
| .map(|input| inference::model_metadata_response::TensorMetadata { | ||
| name: input.name.clone(), | ||
| datatype: match inference::DataType::try_from(input.data_type) { | ||
| Ok(dt) => dt.as_str_name().to_string(), | ||
| Err(_) => "TYPE_INVALID".to_string(), | ||
| }, | ||
| shape: input.dims.clone(), | ||
| }) | ||
| .collect(), | ||
| outputs: model_config | ||
| .output | ||
| .iter() | ||
| .map( | ||
| |output| inference::model_metadata_response::TensorMetadata { | ||
| name: output.name.clone(), | ||
| datatype: match inference::DataType::try_from( | ||
| output.data_type, | ||
| ) { | ||
| Ok(dt) => dt.as_str_name().to_string(), | ||
| Err(_) => "TYPE_INVALID".to_string(), | ||
| }, | ||
| shape: output.dims.clone(), | ||
| }, | ||
| ) | ||
| .collect(), | ||
| })); | ||
| } | ||
| Config::Dynamo(model_config) => { | ||
| return Ok(Response::new(ModelMetadataResponse { | ||
| name: model_config.name.clone(), | ||
| versions: vec!["1".to_string()], | ||
| platform: "dynamo".to_string(), | ||
| inputs: model_config | ||
| .inputs | ||
| .iter() | ||
| .map(|input| inference::model_metadata_response::TensorMetadata { | ||
| name: input.name.clone(), | ||
| datatype: input.data_type.to_string(), | ||
| shape: input.shape.clone(), | ||
| }) | ||
| .collect(), | ||
| outputs: model_config | ||
| .outputs | ||
| .iter() | ||
| .map( | ||
| |output| inference::model_metadata_response::TensorMetadata { | ||
| name: output.name.clone(), | ||
| datatype: output.data_type.to_string(), | ||
| shape: output.shape.clone(), | ||
| }, | ||
| ) | ||
| .collect(), | ||
| })); | ||
| } | ||
| } | ||
| Err(Status::invalid_argument(format!( | ||
| "Model '{}' has type Tensor but no model config is provided", | ||
| request_model_name | ||
| )))? | ||
| } else if card.model_type.supports_completions() { | ||
| return Ok(Response::new(ModelMetadataResponse { | ||
| name: card.display_name, | ||
|
|
@@ -471,42 +534,50 @@ impl GrpcInferenceService for KserveService { | |
| .find(|card| request_model_name == &card.display_name) | ||
| { | ||
| if card.model_type.supports_tensor() { | ||
| if let Some(tensor_model_config) = card.runtime_config.tensor_model_config.as_ref() | ||
| { | ||
| let model_config = ModelConfig { | ||
| name: tensor_model_config.name.clone(), | ||
| platform: "dynamo".to_string(), | ||
| backend: "dynamo".to_string(), | ||
| input: tensor_model_config | ||
| .inputs | ||
| .iter() | ||
| .map(|input| ModelInput { | ||
| name: input.name.clone(), | ||
| data_type: input.data_type.to_kserve(), | ||
| dims: input.shape.clone(), | ||
| ..Default::default() | ||
| }) | ||
| .collect(), | ||
| output: tensor_model_config | ||
| .outputs | ||
| .iter() | ||
| .map(|output| ModelOutput { | ||
| name: output.name.clone(), | ||
| data_type: output.data_type.to_kserve(), | ||
| dims: output.shape.clone(), | ||
| ..Default::default() | ||
| }) | ||
| .collect(), | ||
| ..Default::default() | ||
| }; | ||
| return Ok(Response::new(ModelConfigResponse { | ||
| config: Some(model_config.clone()), | ||
| })); | ||
| let config = Config::from_runtime_config(&card.runtime_config).map_err(|e| { | ||
| Status::invalid_argument(format!( | ||
| "Model '{}' has type Tensor but: {}", | ||
| request_model_name, e | ||
| )) | ||
| })?; | ||
| match config { | ||
| Config::Triton(model_config) => { | ||
| return Ok(Response::new(ModelConfigResponse { | ||
| config: Some(model_config), | ||
| })); | ||
| } | ||
| Config::Dynamo(tensor_model_config) => { | ||
| let model_config = ModelConfig { | ||
| name: tensor_model_config.name.clone(), | ||
| platform: "dynamo".to_string(), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you writeup some documentation on the kserve frontend before you go on PTO? Separate PR is OK. High level things I'd want to see in something like
|
||
| backend: "dynamo".to_string(), | ||
| input: tensor_model_config | ||
| .inputs | ||
| .iter() | ||
| .map(|input| ModelInput { | ||
| name: input.name.clone(), | ||
| data_type: input.data_type.to_kserve(), | ||
| dims: input.shape.clone(), | ||
| ..Default::default() | ||
| }) | ||
| .collect(), | ||
| output: tensor_model_config | ||
| .outputs | ||
| .iter() | ||
| .map(|output| ModelOutput { | ||
| name: output.name.clone(), | ||
| data_type: output.data_type.to_kserve(), | ||
| dims: output.shape.clone(), | ||
| ..Default::default() | ||
| }) | ||
| .collect(), | ||
| ..Default::default() | ||
| }; | ||
| return Ok(Response::new(ModelConfigResponse { | ||
| config: Some(model_config.clone()), | ||
| })); | ||
| } | ||
| } | ||
| Err(Status::invalid_argument(format!( | ||
| "Model '{}' has type Tensor but no model config is provided", | ||
| request_model_name | ||
| )))? | ||
| } else if card.model_type.supports_completions() { | ||
| let config = ModelConfig { | ||
| name: card.display_name, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.